ioctl.c (bf61c8840efe60fd8f91446860b63338fb424158) ioctl.c (5955102c9984fa081b2d570cfac75c97eecf8f3b)
1/*
2 * linux/fs/ext2/ioctl.c
3 *
4 * Copyright (C) 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 */

--- 37 unchanged lines hidden (view full) ---

46
47 if (get_user(flags, (int __user *) arg)) {
48 ret = -EFAULT;
49 goto setflags_out;
50 }
51
52 flags = ext2_mask_flags(inode->i_mode, flags);
53
1/*
2 * linux/fs/ext2/ioctl.c
3 *
4 * Copyright (C) 1993, 1994, 1995
5 * Remy Card (card@masi.ibp.fr)
6 * Laboratoire MASI - Institut Blaise Pascal
7 * Universite Pierre et Marie Curie (Paris VI)
8 */

--- 37 unchanged lines hidden (view full) ---

46
47 if (get_user(flags, (int __user *) arg)) {
48 ret = -EFAULT;
49 goto setflags_out;
50 }
51
52 flags = ext2_mask_flags(inode->i_mode, flags);
53
54 mutex_lock(&inode->i_mutex);
54 inode_lock(inode);
55 /* Is it quota file? Do not allow user to mess with it */
56 if (IS_NOQUOTA(inode)) {
55 /* Is it quota file? Do not allow user to mess with it */
56 if (IS_NOQUOTA(inode)) {
57 mutex_unlock(&inode->i_mutex);
57 inode_unlock(inode);
58 ret = -EPERM;
59 goto setflags_out;
60 }
61 oldflags = ei->i_flags;
62
63 /*
64 * The IMMUTABLE and APPEND_ONLY flags can only be changed by
65 * the relevant capability.
66 *
67 * This test looks nicer. Thanks to Pauline Middelink
68 */
69 if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
70 if (!capable(CAP_LINUX_IMMUTABLE)) {
58 ret = -EPERM;
59 goto setflags_out;
60 }
61 oldflags = ei->i_flags;
62
63 /*
64 * The IMMUTABLE and APPEND_ONLY flags can only be changed by
65 * the relevant capability.
66 *
67 * This test looks nicer. Thanks to Pauline Middelink
68 */
69 if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
70 if (!capable(CAP_LINUX_IMMUTABLE)) {
71 mutex_unlock(&inode->i_mutex);
71 inode_unlock(inode);
72 ret = -EPERM;
73 goto setflags_out;
74 }
75 }
76
77 flags = flags & EXT2_FL_USER_MODIFIABLE;
78 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
79 ei->i_flags = flags;
80
81 ext2_set_inode_flags(inode);
82 inode->i_ctime = CURRENT_TIME_SEC;
72 ret = -EPERM;
73 goto setflags_out;
74 }
75 }
76
77 flags = flags & EXT2_FL_USER_MODIFIABLE;
78 flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
79 ei->i_flags = flags;
80
81 ext2_set_inode_flags(inode);
82 inode->i_ctime = CURRENT_TIME_SEC;
83 mutex_unlock(&inode->i_mutex);
83 inode_unlock(inode);
84
85 mark_inode_dirty(inode);
86setflags_out:
87 mnt_drop_write_file(filp);
88 return ret;
89 }
90 case EXT2_IOC_GETVERSION:
91 return put_user(inode->i_generation, (int __user *) arg);

--- 5 unchanged lines hidden (view full) ---

97 ret = mnt_want_write_file(filp);
98 if (ret)
99 return ret;
100 if (get_user(generation, (int __user *) arg)) {
101 ret = -EFAULT;
102 goto setversion_out;
103 }
104
84
85 mark_inode_dirty(inode);
86setflags_out:
87 mnt_drop_write_file(filp);
88 return ret;
89 }
90 case EXT2_IOC_GETVERSION:
91 return put_user(inode->i_generation, (int __user *) arg);

--- 5 unchanged lines hidden (view full) ---

97 ret = mnt_want_write_file(filp);
98 if (ret)
99 return ret;
100 if (get_user(generation, (int __user *) arg)) {
101 ret = -EFAULT;
102 goto setversion_out;
103 }
104
105 mutex_lock(&inode->i_mutex);
105 inode_lock(inode);
106 inode->i_ctime = CURRENT_TIME_SEC;
107 inode->i_generation = generation;
106 inode->i_ctime = CURRENT_TIME_SEC;
107 inode->i_generation = generation;
108 mutex_unlock(&inode->i_mutex);
108 inode_unlock(inode);
109
110 mark_inode_dirty(inode);
111setversion_out:
112 mnt_drop_write_file(filp);
113 return ret;
114 }
115 case EXT2_IOC_GETRSVSZ:
116 if (test_opt(inode->i_sb, RESERVATION)

--- 72 unchanged lines hidden ---
109
110 mark_inode_dirty(inode);
111setversion_out:
112 mnt_drop_write_file(filp);
113 return ret;
114 }
115 case EXT2_IOC_GETRSVSZ:
116 if (test_opt(inode->i_sb, RESERVATION)

--- 72 unchanged lines hidden ---