diff options
Diffstat (limited to 'fs/ext')
-rw-r--r-- | fs/ext/dir.c | 38 | ||||
-rw-r--r-- | fs/ext/inode.c | 26 | ||||
-rw-r--r-- | fs/ext/namei.c | 4 |
3 files changed, 26 insertions, 42 deletions
diff --git a/fs/ext/dir.c b/fs/ext/dir.c index 10e30fafa..f4ae51d91 100644 --- a/fs/ext/dir.c +++ b/fs/ext/dir.c @@ -20,15 +20,12 @@ #include <linux/ext_fs.h> #include <linux/stat.h> -#define NAME_OFFSET(de) ((int) ((de)->d_name - (char *) (de))) -#define ROUND_UP(x) (((x)+3) & ~3) - static int ext_dir_read(struct inode * inode, struct file * filp, char * buf, int count) { return -EISDIR; } -static int ext_readdir(struct inode *, struct file *, struct dirent *, int); +static int ext_readdir(struct inode *, struct file *, void *, filldir_t); static struct file_operations ext_dir_operations = { NULL, /* lseek - default */ @@ -65,12 +62,11 @@ struct inode_operations ext_dir_inode_operations = { }; static int ext_readdir(struct inode * inode, struct file * filp, - struct dirent * dirent, int count) + void * dirent, filldir_t filldir) { + int error; unsigned int i; - unsigned int ret; off_t offset; - char c; struct buffer_head * bh; struct ext_dir_entry * de; @@ -78,8 +74,8 @@ static int ext_readdir(struct inode * inode, struct file * filp, return -EBADF; if ((filp->f_pos & 7) != 0) return -EBADF; - ret = 0; - while (!ret && filp->f_pos < inode->i_size) { + error = 0; + while (!error && filp->f_pos < inode->i_size) { offset = filp->f_pos & 1023; bh = ext_bread(inode,(filp->f_pos)>>BLOCK_SIZE_BITS,0); if (!bh) { @@ -94,7 +90,7 @@ static int ext_readdir(struct inode * inode, struct file * filp, } offset = i; de = (struct ext_dir_entry *) (offset + bh->b_data); - while (!ret && offset < 1024 && filp->f_pos < inode->i_size) { + while (offset < 1024 && filp->f_pos < inode->i_size) { if (de->rec_len < 8 || de->rec_len % 8 != 0 || de->rec_len < de->name_len + 8 || (de->rec_len + (off_t) filp->f_pos - 1) / 1024 > ((off_t) filp->f_pos / 1024)) { @@ -106,26 +102,16 @@ static int ext_readdir(struct inode * inode, struct file * filp, filp->f_pos = inode->i_size; continue; } - offset += de->rec_len; - filp->f_pos += de->rec_len; if (de->inode) { - for (i = 0; i < de->name_len; i++) - if ((c = de->name[i]) != 0) - put_fs_byte(c,i+dirent->d_name); - else - break; - if (i) { - put_fs_long(de->inode,&dirent->d_ino); - put_fs_byte(0,i+dirent->d_name); - put_fs_word(i,&dirent->d_reclen); - ret = ROUND_UP(NAME_OFFSET(dirent)+i+1); + error = filldir(dirent, de->name, de->name_len, filp->f_pos, de->inode); + if (error) break; - } } - de = (struct ext_dir_entry *) ((char *) de - + de->rec_len); + offset += de->rec_len; + filp->f_pos += de->rec_len; + ((char *) de) += de->rec_len; } brelse(bh); } - return ret; + return 0; } diff --git a/fs/ext/inode.c b/fs/ext/inode.c index b3ca2e2cf..5601becb7 100644 --- a/fs/ext/inode.c +++ b/fs/ext/inode.c @@ -144,21 +144,19 @@ void ext_write_super (struct super_block *sb) sb->s_dirt = 0; } -void ext_statfs (struct super_block *sb, struct statfs *buf) +void ext_statfs (struct super_block *sb, struct statfs *buf, int bufsiz) { - long tmp; - - put_fs_long(EXT_SUPER_MAGIC, &buf->f_type); - put_fs_long(1024, &buf->f_bsize); - put_fs_long(sb->u.ext_sb.s_nzones << sb->u.ext_sb.s_log_zone_size, - &buf->f_blocks); - tmp = ext_count_free_blocks(sb); - put_fs_long(tmp, &buf->f_bfree); - put_fs_long(tmp, &buf->f_bavail); - put_fs_long(sb->u.ext_sb.s_ninodes, &buf->f_files); - put_fs_long(ext_count_free_inodes(sb), &buf->f_ffree); - put_fs_long(EXT_NAME_LEN, &buf->f_namelen); - /* Don't know what value to put in buf->f_fsid */ + struct statfs tmp; + + tmp.f_type = EXT_SUPER_MAGIC; + tmp.f_bsize = 1024; + tmp.f_blocks = sb->u.ext_sb.s_nzones << sb->u.ext_sb.s_log_zone_size; + tmp.f_bfree = ext_count_free_blocks(sb); + tmp.f_bavail = tmp.f_bfree; + tmp.f_files = sb->u.ext_sb.s_ninodes; + tmp.f_ffree = ext_count_free_inodes(sb); + tmp.f_namelen = EXT_NAME_LEN; + memcpy_tofs(buf, &tmp, bufsiz); } #define inode_bmap(inode,nr) ((inode)->u.ext_i.i_data[(nr)]) diff --git a/fs/ext/namei.c b/fs/ext/namei.c index 85a411e94..f9e4b8499 100644 --- a/fs/ext/namei.c +++ b/fs/ext/namei.c @@ -285,6 +285,7 @@ printk ("ext_add_entry : creating next block\n"); de->rec_len = rec_len; } dir->i_mtime = dir->i_ctime = CURRENT_TIME; + dir->i_dirt = 1; de->name_len = namelen; for (i=0; i < namelen ; i++) de->name[i] = name[i]; @@ -810,8 +811,7 @@ start_up: retval = -EEXIST; if (new_bh) goto end_rename; - retval = -EACCES; - if (!permission(old_inode, MAY_WRITE)) + if ((retval = permission(old_inode, MAY_WRITE)) != 0) goto end_rename; retval = -EINVAL; if (subdir(new_dir, old_inode)) |