.. | .. |
---|
60 | 60 | } |
---|
61 | 61 | oldflags = ei->i_flags; |
---|
62 | 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 | | - inode_unlock(inode); |
---|
72 | | - ret = -EPERM; |
---|
73 | | - goto setflags_out; |
---|
74 | | - } |
---|
| 63 | + ret = vfs_ioc_setflags_prepare(inode, oldflags, flags); |
---|
| 64 | + if (ret) { |
---|
| 65 | + inode_unlock(inode); |
---|
| 66 | + goto setflags_out; |
---|
75 | 67 | } |
---|
76 | 68 | |
---|
77 | 69 | flags = flags & EXT2_FL_USER_MODIFIABLE; |
---|
.. | .. |
---|
153 | 145 | if (ei->i_block_alloc_info){ |
---|
154 | 146 | struct ext2_reserve_window_node *rsv = &ei->i_block_alloc_info->rsv_window_node; |
---|
155 | 147 | rsv->rsv_goal_size = rsv_window_size; |
---|
| 148 | + } else { |
---|
| 149 | + ret = -ENOMEM; |
---|
156 | 150 | } |
---|
| 151 | + |
---|
157 | 152 | mutex_unlock(&ei->truncate_mutex); |
---|
158 | 153 | mnt_drop_write_file(filp); |
---|
159 | | - return 0; |
---|
| 154 | + return ret; |
---|
160 | 155 | } |
---|
161 | 156 | default: |
---|
162 | 157 | return -ENOTTY; |
---|