Annotation of linux/fs/stat.c, revision 1.1.1.4

1.1.1.2   root        1: /*
                      2:  *  linux/fs/stat.c
                      3:  *
                      4:  *  (C) 1991  Linus Torvalds
                      5:  */
                      6: 
1.1       root        7: #include <errno.h>
                      8: #include <sys/stat.h>
                      9: 
                     10: #include <linux/fs.h>
                     11: #include <linux/sched.h>
                     12: #include <linux/kernel.h>
                     13: #include <asm/segment.h>
                     14: 
1.1.1.4 ! root       15: static void cp_stat(struct inode * inode, struct stat * statbuf)
1.1       root       16: {
                     17:        struct stat tmp;
                     18:        int i;
                     19: 
1.1.1.3   root       20:        verify_area(statbuf,sizeof (struct stat));
1.1       root       21:        tmp.st_dev = inode->i_dev;
1.1.1.4 ! root       22:        tmp.st_ino = inode->i_ino;
1.1       root       23:        tmp.st_mode = inode->i_mode;
1.1.1.4 ! root       24:        tmp.st_nlink = inode->i_nlink;
1.1       root       25:        tmp.st_uid = inode->i_uid;
                     26:        tmp.st_gid = inode->i_gid;
1.1.1.4 ! root       27:        tmp.st_rdev = inode->i_rdev;
1.1       root       28:        tmp.st_size = inode->i_size;
                     29:        tmp.st_atime = inode->i_atime;
                     30:        tmp.st_mtime = inode->i_mtime;
                     31:        tmp.st_ctime = inode->i_ctime;
                     32:        for (i=0 ; i<sizeof (tmp) ; i++)
1.1.1.3   root       33:                put_fs_byte(((char *) &tmp)[i],i + (char *) statbuf);
1.1       root       34: }
                     35: 
                     36: int sys_stat(char * filename, struct stat * statbuf)
                     37: {
1.1.1.4 ! root       38:        struct inode * inode;
1.1       root       39: 
                     40:        if (!(inode=namei(filename)))
                     41:                return -ENOENT;
1.1.1.2   root       42:        cp_stat(inode,statbuf);
1.1       root       43:        iput(inode);
1.1.1.2   root       44:        return 0;
1.1       root       45: }
                     46: 
1.1.1.3   root       47: int sys_lstat(char * filename, struct stat * statbuf)
                     48: {
1.1.1.4 ! root       49:        struct inode * inode;
1.1.1.3   root       50: 
                     51:        if (!(inode = lnamei(filename)))
                     52:                return -ENOENT;
                     53:        cp_stat(inode,statbuf);
                     54:        iput(inode);
                     55:        return 0;
                     56: }
                     57: 
1.1       root       58: int sys_fstat(unsigned int fd, struct stat * statbuf)
                     59: {
                     60:        struct file * f;
1.1.1.4 ! root       61:        struct inode * inode;
1.1       root       62: 
                     63:        if (fd >= NR_OPEN || !(f=current->filp[fd]) || !(inode=f->f_inode))
1.1.1.2   root       64:                return -EBADF;
                     65:        cp_stat(inode,statbuf);
                     66:        return 0;
1.1       root       67: }
1.1.1.3   root       68: 
                     69: int sys_readlink(const char * path, char * buf, int bufsiz)
                     70: {
1.1.1.4 ! root       71:        struct inode * inode;
1.1.1.3   root       72: 
                     73:        if (bufsiz <= 0)
1.1.1.4 ! root       74:                return -EINVAL;
1.1.1.3   root       75:        verify_area(buf,bufsiz);
                     76:        if (!(inode = lnamei(path)))
                     77:                return -ENOENT;
1.1.1.4 ! root       78:        if (!inode->i_op || !inode->i_op->readlink) {
        !            79:                iput(inode);
        !            80:                return -EINVAL;
1.1.1.3   root       81:        }
1.1.1.4 ! root       82:        return inode->i_op->readlink(inode,buf,bufsiz);
1.1.1.3   root       83: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.