Merge branch 'topic/hda-acomp-base' into for-next
[linux-2.6-microblaze.git] / fs / hfsplus / ioctl.c
index 5e6502e..ce15b94 100644 (file)
@@ -57,9 +57,8 @@ static int hfsplus_ioctl_bless(struct file *file, int __user *user_flags)
        return 0;
 }
 
-static int hfsplus_ioctl_getflags(struct file *file, int __user *user_flags)
+static inline unsigned int hfsplus_getflags(struct inode *inode)
 {
-       struct inode *inode = file_inode(file);
        struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
        unsigned int flags = 0;
 
@@ -69,6 +68,13 @@ static int hfsplus_ioctl_getflags(struct file *file, int __user *user_flags)
                flags |= FS_APPEND_FL;
        if (hip->userflags & HFSPLUS_FLG_NODUMP)
                flags |= FS_NODUMP_FL;
+       return flags;
+}
+
+static int hfsplus_ioctl_getflags(struct file *file, int __user *user_flags)
+{
+       struct inode *inode = file_inode(file);
+       unsigned int flags = hfsplus_getflags(inode);
 
        return put_user(flags, user_flags);
 }
@@ -78,6 +84,7 @@ static int hfsplus_ioctl_setflags(struct file *file, int __user *user_flags)
        struct inode *inode = file_inode(file);
        struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
        unsigned int flags, new_fl = 0;
+       unsigned int oldflags = hfsplus_getflags(inode);
        int err = 0;
 
        err = mnt_want_write_file(file);
@@ -96,13 +103,9 @@ static int hfsplus_ioctl_setflags(struct file *file, int __user *user_flags)
 
        inode_lock(inode);
 
-       if ((flags & (FS_IMMUTABLE_FL|FS_APPEND_FL)) ||
-           inode->i_flags & (S_IMMUTABLE|S_APPEND)) {
-               if (!capable(CAP_LINUX_IMMUTABLE)) {
-                       err = -EPERM;
-                       goto out_unlock_inode;
-               }
-       }
+       err = vfs_ioc_setflags_prepare(inode, oldflags, flags);
+       if (err)
+               goto out_unlock_inode;
 
        /* don't silently ignore unsupported ext2 flags */
        if (flags & ~(FS_IMMUTABLE_FL|FS_APPEND_FL|FS_NODUMP_FL)) {