Miklos recent patches got me looking at hpps_notify_change and
I couldn't resist making it a little more readable:
- rename it to hppfs_setattr, to match the method name
- use goto based unwinding instead of long if else clause with
function call in it
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: linux-2.6/fs/hpfs/file.c
===================================================================
--- linux-2.6.orig/fs/hpfs/file.c 2008-05-05 16:06:53.000000000 +0200
+++ linux-2.6/fs/hpfs/file.c 2008-05-05 16:06:58.000000000 +0200
@@ -143,5 +143,5 @@ const struct file_operations hpfs_file_o
const struct inode_operations hpfs_file_iops =
{
.truncate = hpfs_truncate,
- .setattr = hpfs_notify_change,
+ .setattr = hpfs_setattr,
};
Index: linux-2.6/fs/hpfs/hpfs_fn.h
===================================================================
--- linux-2.6.orig/fs/hpfs/hpfs_fn.h 2008-05-05 16:06:33.000000000 +0200
+++ linux-2.6/fs/hpfs/hpfs_fn.h 2008-05-05 16:06:39.000000000 +0200
@@ -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 *);
Index: linux-2.6/fs/hpfs/inode.c
===================================================================
--- linux-2.6.orig/fs/hpfs/inode.c 2008-05-05 16:07:01.000000000 +0200
+++ linux-2.6/fs/hpfs/inode.c 2008-05-05 16:09:12.000000000 +0200
@@ -260,19 +260,28 @@ void hpfs_write_inode_nolock(struct inod
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;
}
Index: linux-2.6/fs/hpfs/namei.c
===================================================================
--- linux-2.6.orig/fs/hpfs/namei.c 2008-05-05 16:06:43.000000000 +0200
+++ linux-2.6/fs/hpfs/namei.c 2008-05-05 16:06:50.000000000 +0200
@@ -669,5 +669,5 @@ const struct inode_operations hpfs_dir_i
.rmdir = hpfs_rmdir,
.mknod = hpfs_mknod,
.rename = hpfs_rename,
- .setattr = hpfs_notify_change,
+ .setattr = hpfs_setattr,
};
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
| Parag Warudkar | Re: soft lockup - CPU#1 stuck for 15s! [swapper:0] |
| Bryan Woods | Stardom SATA HSM violation |
| Bart Van Assche | Integration of SCST in the mainstream Linux kernel |
| Steven Rostedt | [PATCH 2/2] ftrace: support for PowerPC |
git: | |
| Abdelrazak Younes | Git-windows and git-svn? |
| Linus Torvalds | Re: On Tabs and Spaces |
| Shawn O. Pearce | Java Git (aka jgit) library switching license to BSD/EPL |
| Manu | Re: fatal: unable to create '.git/index': File exists |
| Brandon Lee | DELL PERC 5iR slow performance |
| Chris Jones | GRE over IPsec |
| Frank Bax | wine question |
| Jona Joachim | X11 very slow with SMP kernel |
| Jon Anhold | rawrite |
| Mark Tarrabain | Some thoughts on device drivers |
| Rik Faith | ATI VGA WONDER driver for x386 |
| Seng-Poh Lee, Speedy | Slight rlogind problem, 'Unable to determine your tty name' |
| SMDK2410 LCD Framebuffer driver | 4 hours ago | Linux kernel |
| Resetting the bios password for Toshiba Laptop | 4 hours ago | Hardware |
| Problem booting a barebone kernel in VMWare | 7 hours ago | Linux kernel |
| IP layer send packet | 12 hours ago | Linux kernel |
| PID to ELF image full path | 14 hours ago | Linux kernel |
| types of kernel | 1 day ago | Linux kernel |
| magical mounts | 2 days ago | Linux kernel |
| Problem in scim in Fedora 9 | 2 days ago | Linux general |
| The new Western Digital power saving drives | 2 days ago | Hardware |
| Battery Maximizer Software | 3 days ago | Linux kernel |
