Annotation of linux/fs/ext/dir.c, revision 1.1

1.1     ! root        1: /*
        !             2:  *  linux/fs/ext/dir.c
        !             3:  *
        !             4:  *  (C) 1992 Remy Card ([email protected])
        !             5:  *
        !             6:  *  from
        !             7:  *
        !             8:  *  linux/fs/minix/dir.c
        !             9:  *
        !            10:  *  (C) 1991 Linus Torvalds
        !            11:  *
        !            12:  *  ext directory handling functions
        !            13:  */
        !            14: 
        !            15: #include <errno.h>
        !            16: 
        !            17: #include <asm/segment.h>
        !            18: 
        !            19: #include <linux/fs.h>
        !            20: #include <linux/ext_fs.h>
        !            21: #include <linux/stat.h>
        !            22: 
        !            23: static int ext_readdir(struct inode *, struct file *, struct dirent *, int);
        !            24: 
        !            25: static struct file_operations ext_dir_operations = {
        !            26:        NULL,                   /* lseek - default */
        !            27:        NULL,                   /* read */
        !            28:        NULL,                   /* write - bad */
        !            29:        ext_readdir,            /* readdir */
        !            30:        NULL,                   /* select - default */
        !            31:        NULL,                   /* ioctl - default */
        !            32:        NULL,                   /* no special open code */
        !            33:        NULL                    /* no special release code */
        !            34: };
        !            35: 
        !            36: /*
        !            37:  * directories can handle most operations...
        !            38:  */
        !            39: struct inode_operations ext_dir_inode_operations = {
        !            40:        &ext_dir_operations,    /* default directory file-ops */
        !            41:        ext_create,             /* create */
        !            42:        ext_lookup,             /* lookup */
        !            43:        ext_link,               /* link */
        !            44:        ext_unlink,             /* unlink */
        !            45:        ext_symlink,            /* symlink */
        !            46:        ext_mkdir,              /* mkdir */
        !            47:        ext_rmdir,              /* rmdir */
        !            48:        ext_mknod,              /* mknod */
        !            49:        ext_rename,             /* rename */
        !            50:        NULL,                   /* readlink */
        !            51:        NULL,                   /* follow_link */
        !            52:        ext_bmap,               /* bmap */
        !            53:        ext_truncate            /* truncate */
        !            54: };
        !            55: 
        !            56: static int ext_readdir(struct inode * inode, struct file * filp,
        !            57:        struct dirent * dirent, int count)
        !            58: {
        !            59:        unsigned int block,offset,i;
        !            60:        char c;
        !            61:        struct buffer_head * bh;
        !            62:        struct ext_dir_entry * de;
        !            63: 
        !            64:        if (!inode || !S_ISDIR(inode->i_mode))
        !            65:                return -EBADF;
        !            66: /*     if (filp->f_pos & (sizeof (struct ext_dir_entry) - 1))
        !            67:                return -EBADF; */
        !            68:        while (filp->f_pos < inode->i_size) {
        !            69:                offset = filp->f_pos & 1023;
        !            70:                block = ext_bmap(inode,(filp->f_pos)>>BLOCK_SIZE_BITS);
        !            71:                if (!block || !(bh = bread(inode->i_dev,block))) {
        !            72:                        filp->f_pos += 1024-offset;
        !            73:                        continue;
        !            74:                }
        !            75:                de = (struct ext_dir_entry *) (offset + bh->b_data);
        !            76:                while (offset < 1024 && filp->f_pos < inode->i_size) {
        !            77:                        offset += de->rec_len;
        !            78:                        filp->f_pos += de->rec_len;
        !            79:                        if (de->inode) {
        !            80:                                for (i = 0; i < de->name_len; i++)
        !            81:                                        if (c = de->name[i])
        !            82:                                                put_fs_byte(c,i+dirent->d_name);
        !            83:                                        else
        !            84:                                                break;
        !            85:                                if (i) {
        !            86:                                        put_fs_long(de->inode,&dirent->d_ino);
        !            87:                                        put_fs_byte(0,i+dirent->d_name);
        !            88:                                        put_fs_word(i,&dirent->d_reclen);
        !            89:                                        brelse(bh);
        !            90:                                        return i;
        !            91:                                }
        !            92:                        }
        !            93: /*                     de++; */
        !            94:                        de = (struct ext_dir_entry *) ((char *) de + de->rec_len);
        !            95:                }
        !            96:                brelse(bh);
        !            97:        }
        !            98:        return 0;
        !            99: }

unix.superglobalmegacorp.com

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