From 3919ceb8a38e8539d76b42e6b2682f50249c2e82 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 11 Aug 2008 00:27:59 +0200 Subject: [PATCH] --- yaml --- r: 117457 b: refs/heads/master c: ca30bc99527ab968707bafc09e38807de7e70c4a h: refs/heads/master i: 117455: 261d012fd24abd14aa0fc08d322d8fafa49534fa v: v3 --- [refs] | 2 +- trunk/fs/hpfs/file.c | 2 +- trunk/fs/hpfs/hpfs_fn.h | 2 +- trunk/fs/hpfs/inode.c | 29 +++++++++++++++++++---------- trunk/fs/hpfs/namei.c | 2 +- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/[refs] b/[refs] index 6a76fd9168b8..82331ac86763 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 72e8264eda02b6ba85a222b9620802ebf23c6a10 +refs/heads/master: ca30bc99527ab968707bafc09e38807de7e70c4a diff --git a/trunk/fs/hpfs/file.c b/trunk/fs/hpfs/file.c index be8be5040e07..64ab52259204 100644 --- a/trunk/fs/hpfs/file.c +++ b/trunk/fs/hpfs/file.c @@ -143,5 +143,5 @@ const struct file_operations hpfs_file_ops = const struct inode_operations hpfs_file_iops = { .truncate = hpfs_truncate, - .setattr = hpfs_notify_change, + .setattr = hpfs_setattr, }; diff --git a/trunk/fs/hpfs/hpfs_fn.h b/trunk/fs/hpfs/hpfs_fn.h index 42ff60ccf2a9..c2ea31bae313 100644 --- a/trunk/fs/hpfs/hpfs_fn.h +++ b/trunk/fs/hpfs/hpfs_fn.h @@ -275,7 +275,7 @@ void hpfs_init_inode(struct inode *); void hpfs_read_inode(struct inode *); void hpfs_write_inode(struct inode *); void hpfs_write_inode_nolock(struct inode *); -int hpfs_notify_change(struct dentry *, struct iattr *); +int hpfs_setattr(struct dentry *, struct iattr *); void hpfs_write_if_changed(struct inode *); void hpfs_delete_inode(struct inode *); diff --git a/trunk/fs/hpfs/inode.c b/trunk/fs/hpfs/inode.c index 85d3e1d9ac00..39a1bfbea312 100644 --- a/trunk/fs/hpfs/inode.c +++ b/trunk/fs/hpfs/inode.c @@ -260,19 +260,28 @@ void hpfs_write_inode_nolock(struct inode *i) brelse(bh); } -int hpfs_notify_change(struct dentry *dentry, struct iattr *attr) +int hpfs_setattr(struct dentry *dentry, struct iattr *attr) { struct inode *inode = dentry->d_inode; - int error=0; + int error = -EINVAL; + lock_kernel(); - if ( ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size) || - (hpfs_sb(inode->i_sb)->sb_root == inode->i_ino) ) { - error = -EINVAL; - } else if ((error = inode_change_ok(inode, attr))) { - } else if ((error = inode_setattr(inode, attr))) { - } else { - hpfs_write_inode(inode); - } + if (inode->i_ino == hpfs_sb(inode->i_sb)->sb_root) + goto out_unlock; + if ((attr->ia_valid & ATTR_SIZE) && attr->ia_size > inode->i_size) + goto out_unlock; + + error = inode_change_ok(inode, attr); + if (error) + goto out_unlock; + + error = inode_setattr(inode, attr); + if (error) + goto out_unlock; + + hpfs_write_inode(inode); + + out_unlock: unlock_kernel(); return error; } diff --git a/trunk/fs/hpfs/namei.c b/trunk/fs/hpfs/namei.c index d9c59a775449..10783f3d265a 100644 --- a/trunk/fs/hpfs/namei.c +++ b/trunk/fs/hpfs/namei.c @@ -669,5 +669,5 @@ const struct inode_operations hpfs_dir_iops = .rmdir = hpfs_rmdir, .mknod = hpfs_mknod, .rename = hpfs_rename, - .setattr = hpfs_notify_change, + .setattr = hpfs_setattr, };