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

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.2 ! root       15: static void cp_stat(struct m_inode * inode, struct stat * statbuf)
1.1       root       16: {
                     17:        struct stat tmp;
                     18:        int i;
                     19: 
                     20:        verify_area(statbuf,sizeof (* statbuf));
                     21:        tmp.st_dev = inode->i_dev;
                     22:        tmp.st_ino = inode->i_num;
                     23:        tmp.st_mode = inode->i_mode;
                     24:        tmp.st_nlink = inode->i_nlinks;
                     25:        tmp.st_uid = inode->i_uid;
                     26:        tmp.st_gid = inode->i_gid;
                     27:        tmp.st_rdev = inode->i_zone[0];
                     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++)
                     33:                put_fs_byte(((char *) &tmp)[i],&((char *) statbuf)[i]);
                     34: }
                     35: 
                     36: int sys_stat(char * filename, struct stat * statbuf)
                     37: {
                     38:        struct m_inode * inode;
                     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: 
                     47: int sys_fstat(unsigned int fd, struct stat * statbuf)
                     48: {
                     49:        struct file * f;
                     50:        struct m_inode * inode;
                     51: 
                     52:        if (fd >= NR_OPEN || !(f=current->filp[fd]) || !(inode=f->f_inode))
1.1.1.2 ! root       53:                return -EBADF;
        !            54:        cp_stat(inode,statbuf);
        !            55:        return 0;
1.1       root       56: }

unix.superglobalmegacorp.com

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