--- fs/hpfs/dir.c | 25 +++++++++++++---- fs/hpfs/file.c | 26 ++++++++++++++---- fs/hpfs/hpfs_fn.h | 26 ++++-------------- fs/hpfs/inode.c | 78 +----------------------------------------------------- fs/hpfs/namei.c | 60 +++++++++++++++++++++++++++++------------ fs/hpfs/super.c | 1 6 files changed, 93 insertions(+), 123 deletions(-) diff -puN fs/hpfs/dir.c~HPFS6-hpfs_cleanup-RC4-rc1 fs/hpfs/dir.c --- 25/fs/hpfs/dir.c~HPFS6-hpfs_cleanup-RC4-rc1 2004-02-29 12:49:44.000000000 -0800 +++ 25-akpm/fs/hpfs/dir.c 2004-02-29 12:53:06.000000000 -0800 @@ -11,7 +11,7 @@ #include #include -int hpfs_dir_release(struct inode *inode, struct file *filp) +static int hpfs_dir_release(struct inode *inode, struct file *filp) { lock_kernel(); hpfs_del_pos(inode, &filp->f_pos); @@ -22,7 +22,7 @@ int hpfs_dir_release(struct inode *inode /* This is slow, but it's not used often */ -loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence) +static loff_t hpfs_dir_lseek(struct file *filp, loff_t off, int whence) { loff_t new_off = off + (whence == 1 ? filp->f_pos : 0); loff_t pos; @@ -53,7 +53,7 @@ fail: return -ESPIPE; } -int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) +static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) { struct inode *inode = filp->f_dentry->d_inode; struct hpfs_inode_info *hpfs_inode = hpfs_i(inode); @@ -230,12 +230,18 @@ struct dentry *hpfs_lookup(struct inode goto bail1; } if (result->i_state & I_NEW) { + hpfs_init_inode(result); if (de->directory) hpfs_read_inode(result); else if (de->ea_size && hpfs_sb(dir->i_sb)->sb_eas) hpfs_read_inode(result); - else - hpfs_read_inode_light(result); + else { + result->i_mode |= S_IFREG; + result->i_mode &= ~0111; + result->i_op = &hpfs_file_iops; + result->i_fop = &hpfs_file_ops; + result->i_nlink = 1; + } unlock_new_inode(result); } hpfs_result = hpfs_i(result); @@ -305,3 +311,12 @@ struct dentry *hpfs_lookup(struct inode unlock_kernel(); return ERR_PTR(-ENOENT); } + +struct file_operations hpfs_dir_ops = +{ + .llseek = hpfs_dir_lseek, + .read = generic_read_dir, + .readdir = hpfs_readdir, + .release = hpfs_dir_release, + .fsync = hpfs_file_fsync, +}; diff -puN fs/hpfs/file.c~HPFS6-hpfs_cleanup-RC4-rc1 fs/hpfs/file.c --- 25/fs/hpfs/file.c~HPFS6-hpfs_cleanup-RC4-rc1 2004-02-29 12:49:44.000000000 -0800 +++ 25-akpm/fs/hpfs/file.c 2004-02-29 12:53:06.000000000 -0800 @@ -15,7 +15,7 @@ #define BLOCKS(size) (((size) + 511) >> 9) -int hpfs_file_release(struct inode *inode, struct file *file) +static int hpfs_file_release(struct inode *inode, struct file *file) { lock_kernel(); hpfs_write_if_changed(inode); @@ -34,7 +34,7 @@ int hpfs_file_fsync(struct file *file, s * so we must ignore such errors. */ -secno hpfs_bmap(struct inode *inode, unsigned file_secno) +static secno hpfs_bmap(struct inode *inode, unsigned file_secno) { struct hpfs_inode_info *hpfs_inode = hpfs_i(inode); unsigned n, disk_secno; @@ -50,7 +50,7 @@ secno hpfs_bmap(struct inode *inode, uns return disk_secno; } -void hpfs_truncate(struct inode *i) +static void hpfs_truncate(struct inode *i) { if (IS_IMMUTABLE(i)) return /*-EPERM*/; lock_kernel(); @@ -63,7 +63,7 @@ void hpfs_truncate(struct inode *i) unlock_kernel(); } -int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create) +static int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create) { secno s; s = hpfs_bmap(inode, iblock); @@ -113,7 +113,7 @@ struct address_space_operations hpfs_aop .bmap = _hpfs_bmap }; -ssize_t hpfs_file_write(struct file *file, const char __user *buf, +static ssize_t hpfs_file_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { ssize_t retval; @@ -127,3 +127,19 @@ ssize_t hpfs_file_write(struct file *fil return retval; } +struct file_operations hpfs_file_ops = +{ + .llseek = generic_file_llseek, + .read = generic_file_read, + .write = hpfs_file_write, + .mmap = generic_file_mmap, + .release = hpfs_file_release, + .fsync = hpfs_file_fsync, + .sendfile = generic_file_sendfile, +}; + +struct inode_operations hpfs_file_iops = +{ + .truncate = hpfs_truncate, + .setattr = hpfs_notify_change, +}; diff -puN fs/hpfs/hpfs_fn.h~HPFS6-hpfs_cleanup-RC4-rc1 fs/hpfs/hpfs_fn.h --- 25/fs/hpfs/hpfs_fn.h~HPFS6-hpfs_cleanup-RC4-rc1 2004-02-29 12:49:44.000000000 -0800 +++ 25-akpm/fs/hpfs/hpfs_fn.h 2004-02-29 12:53:06.000000000 -0800 @@ -205,10 +205,8 @@ void hpfs_set_dentry_operations(struct d /* dir.c */ -int hpfs_dir_release(struct inode *, struct file *); -loff_t hpfs_dir_lseek(struct file *, loff_t, int); -int hpfs_readdir(struct file *, void *, filldir_t); struct dentry *hpfs_lookup(struct inode *, struct dentry *, struct nameidata *); +extern struct file_operations hpfs_dir_ops; /* dnode.c */ @@ -235,17 +233,15 @@ void hpfs_set_ea(struct inode *, struct /* file.c */ -int hpfs_file_release(struct inode *, struct file *); int hpfs_file_fsync(struct file *, struct dentry *, int); -secno hpfs_bmap(struct inode *, unsigned); -void hpfs_truncate(struct inode *); -int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_head *bh_result, int create); -ssize_t hpfs_file_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos); +extern struct file_operations hpfs_file_ops; +extern struct inode_operations hpfs_file_iops; +extern struct address_space_operations hpfs_aops; /* inode.c */ void hpfs_read_inode(struct inode *); -void hpfs_read_inode_light(struct inode *); +void hpfs_init_inode(struct inode *); void hpfs_write_inode_ea(struct inode *, struct fnode *); void hpfs_write_inode(struct inode *); void hpfs_write_inode_nolock(struct inode *); @@ -276,14 +272,8 @@ void hpfs_decide_conv(struct inode *, un /* namei.c */ -int hpfs_mkdir(struct inode *, struct dentry *, int); -int hpfs_create(struct inode *, struct dentry *, int, struct nameidata *); -int hpfs_mknod(struct inode *, struct dentry *, int, dev_t); -int hpfs_symlink(struct inode *, struct dentry *, const char *); -int hpfs_unlink(struct inode *, struct dentry *); -int hpfs_rmdir(struct inode *, struct dentry *); -int hpfs_symlink_readpage(struct file *, struct page *); -int hpfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); +extern struct inode_operations hpfs_dir_iops; +extern struct address_space_operations hpfs_symlink_aops; static inline struct hpfs_inode_info *hpfs_i(struct inode *inode) { @@ -304,8 +294,6 @@ void hpfs_put_super(struct super_block * unsigned hpfs_count_one_bitmap(struct super_block *, secno); int hpfs_statfs(struct super_block *, struct kstatfs *); -extern struct address_space_operations hpfs_aops; - /* * local time (HPFS) to GMT (Unix) */ diff -puN fs/hpfs/inode.c~HPFS6-hpfs_cleanup-RC4-rc1 fs/hpfs/inode.c --- 25/fs/hpfs/inode.c~HPFS6-hpfs_cleanup-RC4-rc1 2004-02-29 12:49:44.000000000 -0800 +++ 25-akpm/fs/hpfs/inode.c 2004-02-29 12:53:06.000000000 -0800 @@ -12,50 +12,7 @@ #include #include "hpfs_fn.h" -static struct file_operations hpfs_file_ops = -{ - .llseek = generic_file_llseek, - .read = generic_file_read, - .write = hpfs_file_write, - .mmap = generic_file_mmap, - .release = hpfs_file_release, - .fsync = hpfs_file_fsync, - .sendfile = generic_file_sendfile, -}; - -static struct inode_operations hpfs_file_iops = -{ - .truncate = hpfs_truncate, - .setattr = hpfs_notify_change, -}; - -static struct file_operations hpfs_dir_ops = -{ - .llseek = hpfs_dir_lseek, - .read = generic_read_dir, - .readdir = hpfs_readdir, - .release = hpfs_dir_release, - .fsync = hpfs_file_fsync, -}; - -static struct inode_operations hpfs_dir_iops = -{ - .create = hpfs_create, - .lookup = hpfs_lookup, - .unlink = hpfs_unlink, - .symlink = hpfs_symlink, - .mkdir = hpfs_mkdir, - .rmdir = hpfs_rmdir, - .mknod = hpfs_mknod, - .rename = hpfs_rename, - .setattr = hpfs_notify_change, -}; - -struct address_space_operations hpfs_symlink_aops = { - .readpage = hpfs_symlink_readpage -}; - -void hpfs_read_inode_light(struct inode *i) +void hpfs_init_inode(struct inode *i) { struct super_block *sb = i->i_sb; struct hpfs_inode_info *hpfs_inode = hpfs_i(i); @@ -85,12 +42,6 @@ void hpfs_read_inode_light(struct inode i->i_ctime.tv_sec = i->i_ctime.tv_nsec = 0; i->i_mtime.tv_sec = i->i_mtime.tv_nsec = 0; i->i_atime.tv_sec = i->i_atime.tv_nsec = 0; - - i->i_mode |= S_IFREG; - i->i_mode &= ~0111; - i->i_op = &hpfs_file_iops; - i->i_fop = &hpfs_file_ops; - i->i_nlink = 1; } void hpfs_read_inode(struct inode *i) @@ -102,32 +53,6 @@ void hpfs_read_inode(struct inode *i) unsigned char *ea; int ea_size; - i->i_uid = hpfs_sb(sb)->sb_uid; - i->i_gid = hpfs_sb(sb)->sb_gid; - i->i_mode = hpfs_sb(sb)->sb_mode; - hpfs_inode->i_conv = hpfs_sb(sb)->sb_conv; - i->i_blksize = 512; - i->i_size = -1; - i->i_blocks = -1; - - hpfs_inode->i_dno = 0; - hpfs_inode->i_n_secs = 0; - hpfs_inode->i_file_sec = 0; - hpfs_inode->i_disk_sec = 0; - hpfs_inode->i_dpos = 0; - hpfs_inode->i_dsubdno = 0; - hpfs_inode->i_ea_mode = 0; - hpfs_inode->i_ea_uid = 0; - hpfs_inode->i_ea_gid = 0; - hpfs_inode->i_ea_size = 0; - - hpfs_inode->i_rddir_off = NULL; - hpfs_inode->i_dirty = 0; - - i->i_ctime.tv_sec = i->i_ctime.tv_nsec = 0; - i->i_mtime.tv_sec = i->i_mtime.tv_nsec = 0; - i->i_atime.tv_sec = i->i_atime.tv_nsec = 0; - if (!(fnode = hpfs_map_fnode(sb, i->i_ino, &bh))) { /*i->i_mode |= S_IFREG; i->i_mode &= ~0111; @@ -274,6 +199,7 @@ void hpfs_write_inode(struct inode *i) parent = iget_locked(i->i_sb, hpfs_inode->i_parent_dir); if (parent) { if (parent->i_state & I_NEW) { + hpfs_init_inode(parent); hpfs_read_inode(parent); unlock_new_inode(parent); } diff -puN fs/hpfs/namei.c~HPFS6-hpfs_cleanup-RC4-rc1 fs/hpfs/namei.c --- 25/fs/hpfs/namei.c~HPFS6-hpfs_cleanup-RC4-rc1 2004-02-29 12:49:44.000000000 -0800 +++ 25-akpm/fs/hpfs/namei.c 2004-02-29 12:53:06.000000000 -0800 @@ -11,7 +11,7 @@ #include #include "hpfs_fn.h" -int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) +static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) { const char *name = dentry->d_name.name; unsigned len = dentry->d_name.len; @@ -77,15 +77,22 @@ int hpfs_mkdir(struct inode *dir, struct if (!result) goto out; - hpfs_read_inode(result); + hpfs_init_inode(result); unlock_new_inode(result); hpfs_i(result)->i_parent_dir = dir->i_ino; + hpfs_i(result)->i_dno = dno; result->i_ctime.tv_sec = result->i_mtime.tv_sec = result->i_atime.tv_sec = local_to_gmt(dir->i_sb, dee.creation_date); result->i_ctime.tv_nsec = 0; result->i_mtime.tv_nsec = 0; result->i_atime.tv_nsec = 0; hpfs_i(result)->i_ea_size = 0; + result->i_mode |= S_IFDIR; + result->i_op = &hpfs_dir_iops; + result->i_fop = &hpfs_dir_ops; + result->i_blocks = 4; + result->i_size = 2048; + result->i_nlink = 2; if (dee.read_only) result->i_mode &= ~0222; if (result->i_uid != current->fsuid || result->i_gid != current->fsgid || @@ -113,7 +120,7 @@ bail: return err; } -int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd) +static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd) { const char *name = dentry->d_name.name; unsigned len = dentry->d_name.len; @@ -155,8 +162,13 @@ int hpfs_create(struct inode *dir, struc if (!result) goto out; - hpfs_read_inode_light(result); + hpfs_init_inode(result); unlock_new_inode(result); + result->i_mode |= S_IFREG; + result->i_mode &= ~0111; + result->i_op = &hpfs_file_iops; + result->i_fop = &hpfs_file_ops; + result->i_nlink = 1; hpfs_decide_conv(result, (char *)name, len); hpfs_i(result)->i_parent_dir = dir->i_ino; @@ -194,7 +206,7 @@ bail: return err; } -int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) +static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) { const char *name = dentry->d_name.name; unsigned len = dentry->d_name.len; @@ -237,7 +249,7 @@ int hpfs_mknod(struct inode *dir, struct if (!result) goto out; - hpfs_read_inode_light(result); + hpfs_init_inode(result); unlock_new_inode(result); hpfs_i(result)->i_parent_dir = dir->i_ino; @@ -246,8 +258,6 @@ int hpfs_mknod(struct inode *dir, struct result->i_mtime.tv_nsec = 0; result->i_atime.tv_nsec = 0; hpfs_i(result)->i_ea_size = 0; - /*if (result->i_blocks == -1) result->i_blocks = 1; - if (result->i_size == -1) result->i_size = 0;*/ result->i_uid = current->fsuid; result->i_gid = current->fsgid; result->i_nlink = 1; @@ -271,9 +281,7 @@ bail: return err; } -extern struct address_space_operations hpfs_symlink_aops; - -int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *symlink) +static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *symlink) { const char *name = dentry->d_name.name; unsigned len = dentry->d_name.len; @@ -317,7 +325,7 @@ int hpfs_symlink(struct inode *dir, stru if (!result) goto out; - hpfs_read_inode_light(result); + hpfs_init_inode(result); unlock_new_inode(result); hpfs_i(result)->i_parent_dir = dir->i_ino; @@ -326,12 +334,11 @@ int hpfs_symlink(struct inode *dir, stru result->i_mtime.tv_nsec = 0; result->i_atime.tv_nsec = 0; hpfs_i(result)->i_ea_size = 0; - /*if (result->i_blocks == -1) result->i_blocks = 1; - if (result->i_size == -1) result->i_size = 0;*/ result->i_mode = S_IFLNK | 0777; result->i_uid = current->fsuid; result->i_gid = current->fsgid; result->i_blocks = 1; + result->i_nlink = 1; result->i_size = strlen(symlink); result->i_op = &page_symlink_inode_operations; result->i_data.a_ops = &hpfs_symlink_aops; @@ -356,7 +363,7 @@ bail: return err; } -int hpfs_unlink(struct inode *dir, struct dentry *dentry) +static int hpfs_unlink(struct inode *dir, struct dentry *dentry) { const char *name = dentry->d_name.name; unsigned len = dentry->d_name.len; @@ -438,7 +445,7 @@ out: return err; } -int hpfs_rmdir(struct inode *dir, struct dentry *dentry) +static int hpfs_rmdir(struct inode *dir, struct dentry *dentry) { const char *name = dentry->d_name.name; unsigned len = dentry->d_name.len; @@ -498,7 +505,7 @@ out: return err; } -int hpfs_symlink_readpage(struct file *file, struct page *page) +static int hpfs_symlink_readpage(struct file *file, struct page *page) { char *link = kmap(page); struct inode *i = page->mapping->host; @@ -527,8 +534,12 @@ fail: unlock_page(page); return err; } + +struct address_space_operations hpfs_symlink_aops = { + .readpage = hpfs_symlink_readpage +}; -int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, +static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry) { char *old_name = (char *)old_dentry->d_name.name; @@ -639,3 +650,16 @@ int hpfs_rename(struct inode *old_dir, s unlock_kernel(); return err; } + +struct inode_operations hpfs_dir_iops = +{ + .create = hpfs_create, + .lookup = hpfs_lookup, + .unlink = hpfs_unlink, + .symlink = hpfs_symlink, + .mkdir = hpfs_mkdir, + .rmdir = hpfs_rmdir, + .mknod = hpfs_mknod, + .rename = hpfs_rename, + .setattr = hpfs_notify_change, +}; diff -puN fs/hpfs/super.c~HPFS6-hpfs_cleanup-RC4-rc1 fs/hpfs/super.c --- 25/fs/hpfs/super.c~HPFS6-hpfs_cleanup-RC4-rc1 2004-02-29 12:49:44.000000000 -0800 +++ 25-akpm/fs/hpfs/super.c 2004-02-29 12:53:06.000000000 -0800 @@ -614,6 +614,7 @@ static int hpfs_fill_super(struct super_ root = iget_locked(s, sbi->sb_root); if (!root) goto bail0; + hpfs_init_inode(root); hpfs_read_inode(root); unlock_new_inode(root); s->s_root = d_alloc_root(root); _