]>
Commit | Line | Data |
---|---|---|
ac27a0ec | 1 | /* |
617ba13b | 2 | * linux/fs/ext4/ioctl.c |
ac27a0ec DK |
3 | * |
4 | * Copyright (C) 1993, 1994, 1995 | |
5 | * Remy Card ([email protected]) | |
6 | * Laboratoire MASI - Institut Blaise Pascal | |
7 | * Universite Pierre et Marie Curie (Paris VI) | |
8 | */ | |
9 | ||
10 | #include <linux/fs.h> | |
dab291af | 11 | #include <linux/jbd2.h> |
ac27a0ec | 12 | #include <linux/capability.h> |
ac27a0ec DK |
13 | #include <linux/time.h> |
14 | #include <linux/compat.h> | |
42a74f20 | 15 | #include <linux/mount.h> |
748de673 | 16 | #include <linux/file.h> |
ac27a0ec | 17 | #include <asm/uaccess.h> |
3dcf5451 CH |
18 | #include "ext4_jbd2.h" |
19 | #include "ext4.h" | |
ac27a0ec | 20 | |
19c5246d YY |
21 | #define MAX_32_NUM ((((unsigned long long) 1) << 32) - 1) |
22 | ||
5cdd7b2d | 23 | long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
ac27a0ec | 24 | { |
496ad9aa | 25 | struct inode *inode = file_inode(filp); |
bab08ab9 | 26 | struct super_block *sb = inode->i_sb; |
617ba13b | 27 | struct ext4_inode_info *ei = EXT4_I(inode); |
ac27a0ec | 28 | unsigned int flags; |
ac27a0ec | 29 | |
af5bc92d | 30 | ext4_debug("cmd = %u, arg = %lu\n", cmd, arg); |
ac27a0ec DK |
31 | |
32 | switch (cmd) { | |
617ba13b | 33 | case EXT4_IOC_GETFLAGS: |
ff9ddf7e | 34 | ext4_get_inode_flags(ei); |
617ba13b | 35 | flags = ei->i_flags & EXT4_FL_USER_VISIBLE; |
ac27a0ec | 36 | return put_user(flags, (int __user *) arg); |
617ba13b | 37 | case EXT4_IOC_SETFLAGS: { |
ac27a0ec | 38 | handle_t *handle = NULL; |
4db46fc2 | 39 | int err, migrate = 0; |
617ba13b | 40 | struct ext4_iloc iloc; |
79906964 | 41 | unsigned int oldflags, mask, i; |
ac27a0ec DK |
42 | unsigned int jflag; |
43 | ||
2e149670 | 44 | if (!inode_owner_or_capable(inode)) |
ac27a0ec DK |
45 | return -EACCES; |
46 | ||
47 | if (get_user(flags, (int __user *) arg)) | |
48 | return -EFAULT; | |
49 | ||
a561be71 | 50 | err = mnt_want_write_file(filp); |
42a74f20 DH |
51 | if (err) |
52 | return err; | |
53 | ||
2dc6b0d4 | 54 | flags = ext4_mask_flags(inode->i_mode, flags); |
ac27a0ec | 55 | |
42a74f20 | 56 | err = -EPERM; |
ac27a0ec | 57 | mutex_lock(&inode->i_mutex); |
e47776a0 | 58 | /* Is it quota file? Do not allow user to mess with it */ |
42a74f20 DH |
59 | if (IS_NOQUOTA(inode)) |
60 | goto flags_out; | |
61 | ||
ac27a0ec DK |
62 | oldflags = ei->i_flags; |
63 | ||
64 | /* The JOURNAL_DATA flag is modifiable only by root */ | |
617ba13b | 65 | jflag = flags & EXT4_JOURNAL_DATA_FL; |
ac27a0ec DK |
66 | |
67 | /* | |
68 | * The IMMUTABLE and APPEND_ONLY flags can only be changed by | |
69 | * the relevant capability. | |
70 | * | |
71 | * This test looks nicer. Thanks to Pauline Middelink | |
72 | */ | |
617ba13b | 73 | if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) { |
42a74f20 DH |
74 | if (!capable(CAP_LINUX_IMMUTABLE)) |
75 | goto flags_out; | |
ac27a0ec DK |
76 | } |
77 | ||
78 | /* | |
79 | * The JOURNAL_DATA flag can only be changed by | |
80 | * the relevant capability. | |
81 | */ | |
617ba13b | 82 | if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) { |
42a74f20 DH |
83 | if (!capable(CAP_SYS_RESOURCE)) |
84 | goto flags_out; | |
ac27a0ec | 85 | } |
4db46fc2 AK |
86 | if (oldflags & EXT4_EXTENTS_FL) { |
87 | /* We don't support clearning extent flags */ | |
88 | if (!(flags & EXT4_EXTENTS_FL)) { | |
89 | err = -EOPNOTSUPP; | |
90 | goto flags_out; | |
91 | } | |
92 | } else if (flags & EXT4_EXTENTS_FL) { | |
93 | /* migrate the file */ | |
94 | migrate = 1; | |
95 | flags &= ~EXT4_EXTENTS_FL; | |
96 | } | |
ac27a0ec | 97 | |
c8d46e41 JZ |
98 | if (flags & EXT4_EOFBLOCKS_FL) { |
99 | /* we don't support adding EOFBLOCKS flag */ | |
100 | if (!(oldflags & EXT4_EOFBLOCKS_FL)) { | |
101 | err = -EOPNOTSUPP; | |
102 | goto flags_out; | |
103 | } | |
104 | } else if (oldflags & EXT4_EOFBLOCKS_FL) | |
105 | ext4_truncate(inode); | |
106 | ||
9924a92a | 107 | handle = ext4_journal_start(inode, EXT4_HT_INODE, 1); |
ac27a0ec | 108 | if (IS_ERR(handle)) { |
42a74f20 DH |
109 | err = PTR_ERR(handle); |
110 | goto flags_out; | |
ac27a0ec DK |
111 | } |
112 | if (IS_SYNC(inode)) | |
0390131b | 113 | ext4_handle_sync(handle); |
617ba13b | 114 | err = ext4_reserve_inode_write(handle, inode, &iloc); |
ac27a0ec DK |
115 | if (err) |
116 | goto flags_err; | |
117 | ||
79906964 TT |
118 | for (i = 0, mask = 1; i < 32; i++, mask <<= 1) { |
119 | if (!(mask & EXT4_FL_USER_MODIFIABLE)) | |
120 | continue; | |
121 | if (mask & flags) | |
122 | ext4_set_inode_flag(inode, i); | |
123 | else | |
124 | ext4_clear_inode_flag(inode, i); | |
125 | } | |
ac27a0ec | 126 | |
617ba13b | 127 | ext4_set_inode_flags(inode); |
ef7f3835 | 128 | inode->i_ctime = ext4_current_time(inode); |
ac27a0ec | 129 | |
617ba13b | 130 | err = ext4_mark_iloc_dirty(handle, inode, &iloc); |
ac27a0ec | 131 | flags_err: |
617ba13b | 132 | ext4_journal_stop(handle); |
42a74f20 DH |
133 | if (err) |
134 | goto flags_out; | |
ac27a0ec | 135 | |
617ba13b MC |
136 | if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) |
137 | err = ext4_change_inode_journal_flag(inode, jflag); | |
4db46fc2 AK |
138 | if (err) |
139 | goto flags_out; | |
140 | if (migrate) | |
141 | err = ext4_ext_migrate(inode); | |
42a74f20 | 142 | flags_out: |
ac27a0ec | 143 | mutex_unlock(&inode->i_mutex); |
2a79f17e | 144 | mnt_drop_write_file(filp); |
ac27a0ec DK |
145 | return err; |
146 | } | |
617ba13b MC |
147 | case EXT4_IOC_GETVERSION: |
148 | case EXT4_IOC_GETVERSION_OLD: | |
ac27a0ec | 149 | return put_user(inode->i_generation, (int __user *) arg); |
617ba13b MC |
150 | case EXT4_IOC_SETVERSION: |
151 | case EXT4_IOC_SETVERSION_OLD: { | |
ac27a0ec | 152 | handle_t *handle; |
617ba13b | 153 | struct ext4_iloc iloc; |
ac27a0ec DK |
154 | __u32 generation; |
155 | int err; | |
156 | ||
2e149670 | 157 | if (!inode_owner_or_capable(inode)) |
ac27a0ec | 158 | return -EPERM; |
42a74f20 | 159 | |
814525f4 DW |
160 | if (EXT4_HAS_RO_COMPAT_FEATURE(inode->i_sb, |
161 | EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) { | |
162 | ext4_warning(sb, "Setting inode version is not " | |
163 | "supported with metadata_csum enabled."); | |
164 | return -ENOTTY; | |
165 | } | |
166 | ||
a561be71 | 167 | err = mnt_want_write_file(filp); |
42a74f20 DH |
168 | if (err) |
169 | return err; | |
170 | if (get_user(generation, (int __user *) arg)) { | |
171 | err = -EFAULT; | |
172 | goto setversion_out; | |
173 | } | |
ac27a0ec | 174 | |
6c2155b9 | 175 | mutex_lock(&inode->i_mutex); |
9924a92a | 176 | handle = ext4_journal_start(inode, EXT4_HT_INODE, 1); |
42a74f20 DH |
177 | if (IS_ERR(handle)) { |
178 | err = PTR_ERR(handle); | |
6c2155b9 | 179 | goto unlock_out; |
42a74f20 | 180 | } |
617ba13b | 181 | err = ext4_reserve_inode_write(handle, inode, &iloc); |
ac27a0ec | 182 | if (err == 0) { |
ef7f3835 | 183 | inode->i_ctime = ext4_current_time(inode); |
ac27a0ec | 184 | inode->i_generation = generation; |
617ba13b | 185 | err = ext4_mark_iloc_dirty(handle, inode, &iloc); |
ac27a0ec | 186 | } |
617ba13b | 187 | ext4_journal_stop(handle); |
6c2155b9 DH |
188 | |
189 | unlock_out: | |
190 | mutex_unlock(&inode->i_mutex); | |
42a74f20 | 191 | setversion_out: |
2a79f17e | 192 | mnt_drop_write_file(filp); |
ac27a0ec DK |
193 | return err; |
194 | } | |
617ba13b MC |
195 | case EXT4_IOC_GROUP_EXTEND: { |
196 | ext4_fsblk_t n_blocks_count; | |
ac046f1d | 197 | int err, err2=0; |
ac27a0ec | 198 | |
8f82f840 YY |
199 | err = ext4_resize_begin(sb); |
200 | if (err) | |
201 | return err; | |
ac27a0ec | 202 | |
014a1770 DH |
203 | if (get_user(n_blocks_count, (__u32 __user *)arg)) { |
204 | err = -EFAULT; | |
205 | goto group_extend_out; | |
206 | } | |
ac27a0ec | 207 | |
bab08ab9 TT |
208 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, |
209 | EXT4_FEATURE_RO_COMPAT_BIGALLOC)) { | |
210 | ext4_msg(sb, KERN_ERR, | |
211 | "Online resizing not supported with bigalloc"); | |
014a1770 DH |
212 | err = -EOPNOTSUPP; |
213 | goto group_extend_out; | |
bab08ab9 TT |
214 | } |
215 | ||
a561be71 | 216 | err = mnt_want_write_file(filp); |
42a74f20 | 217 | if (err) |
014a1770 | 218 | goto group_extend_out; |
42a74f20 | 219 | |
617ba13b | 220 | err = ext4_group_extend(sb, EXT4_SB(sb)->s_es, n_blocks_count); |
ac046f1d PT |
221 | if (EXT4_SB(sb)->s_journal) { |
222 | jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); | |
223 | err2 = jbd2_journal_flush(EXT4_SB(sb)->s_journal); | |
224 | jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); | |
225 | } | |
7ffe1ea8 HK |
226 | if (err == 0) |
227 | err = err2; | |
2a79f17e | 228 | mnt_drop_write_file(filp); |
014a1770 | 229 | group_extend_out: |
8f82f840 | 230 | ext4_resize_end(sb); |
ac27a0ec DK |
231 | return err; |
232 | } | |
748de673 AF |
233 | |
234 | case EXT4_IOC_MOVE_EXT: { | |
235 | struct move_extent me; | |
2903ff01 AV |
236 | struct fd donor; |
237 | int err; | |
748de673 | 238 | |
4a58579b AF |
239 | if (!(filp->f_mode & FMODE_READ) || |
240 | !(filp->f_mode & FMODE_WRITE)) | |
241 | return -EBADF; | |
242 | ||
748de673 AF |
243 | if (copy_from_user(&me, |
244 | (struct move_extent __user *)arg, sizeof(me))) | |
245 | return -EFAULT; | |
4a58579b | 246 | me.moved_len = 0; |
748de673 | 247 | |
2903ff01 AV |
248 | donor = fdget(me.donor_fd); |
249 | if (!donor.file) | |
748de673 AF |
250 | return -EBADF; |
251 | ||
2903ff01 | 252 | if (!(donor.file->f_mode & FMODE_WRITE)) { |
4a58579b AF |
253 | err = -EBADF; |
254 | goto mext_out; | |
748de673 AF |
255 | } |
256 | ||
bab08ab9 TT |
257 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, |
258 | EXT4_FEATURE_RO_COMPAT_BIGALLOC)) { | |
259 | ext4_msg(sb, KERN_ERR, | |
260 | "Online defrag not supported with bigalloc"); | |
399c9b86 AV |
261 | err = -EOPNOTSUPP; |
262 | goto mext_out; | |
bab08ab9 TT |
263 | } |
264 | ||
a561be71 | 265 | err = mnt_want_write_file(filp); |
4a58579b AF |
266 | if (err) |
267 | goto mext_out; | |
268 | ||
2903ff01 | 269 | err = ext4_move_extents(filp, donor.file, me.orig_start, |
748de673 | 270 | me.donor_start, me.len, &me.moved_len); |
2a79f17e | 271 | mnt_drop_write_file(filp); |
748de673 | 272 | |
60e6679e | 273 | if (copy_to_user((struct move_extent __user *)arg, |
c437b273 | 274 | &me, sizeof(me))) |
4a58579b AF |
275 | err = -EFAULT; |
276 | mext_out: | |
2903ff01 | 277 | fdput(donor); |
748de673 AF |
278 | return err; |
279 | } | |
280 | ||
617ba13b MC |
281 | case EXT4_IOC_GROUP_ADD: { |
282 | struct ext4_new_group_data input; | |
ac046f1d | 283 | int err, err2=0; |
ac27a0ec | 284 | |
8f82f840 YY |
285 | err = ext4_resize_begin(sb); |
286 | if (err) | |
287 | return err; | |
ac27a0ec | 288 | |
617ba13b | 289 | if (copy_from_user(&input, (struct ext4_new_group_input __user *)arg, |
014a1770 DH |
290 | sizeof(input))) { |
291 | err = -EFAULT; | |
292 | goto group_add_out; | |
293 | } | |
ac27a0ec | 294 | |
bab08ab9 TT |
295 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, |
296 | EXT4_FEATURE_RO_COMPAT_BIGALLOC)) { | |
297 | ext4_msg(sb, KERN_ERR, | |
298 | "Online resizing not supported with bigalloc"); | |
014a1770 DH |
299 | err = -EOPNOTSUPP; |
300 | goto group_add_out; | |
bab08ab9 TT |
301 | } |
302 | ||
a561be71 | 303 | err = mnt_want_write_file(filp); |
42a74f20 | 304 | if (err) |
014a1770 | 305 | goto group_add_out; |
42a74f20 | 306 | |
617ba13b | 307 | err = ext4_group_add(sb, &input); |
ac046f1d PT |
308 | if (EXT4_SB(sb)->s_journal) { |
309 | jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); | |
310 | err2 = jbd2_journal_flush(EXT4_SB(sb)->s_journal); | |
311 | jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); | |
312 | } | |
7ffe1ea8 HK |
313 | if (err == 0) |
314 | err = err2; | |
2a79f17e | 315 | mnt_drop_write_file(filp); |
7f511862 TT |
316 | if (!err && ext4_has_group_desc_csum(sb) && |
317 | test_opt(sb, INIT_INODE_TABLE)) | |
318 | err = ext4_register_li_request(sb, input.group); | |
014a1770 | 319 | group_add_out: |
8f82f840 | 320 | ext4_resize_end(sb); |
ac27a0ec DK |
321 | return err; |
322 | } | |
323 | ||
c14c6fd5 | 324 | case EXT4_IOC_MIGRATE: |
2a43a878 AK |
325 | { |
326 | int err; | |
2e149670 | 327 | if (!inode_owner_or_capable(inode)) |
2a43a878 AK |
328 | return -EACCES; |
329 | ||
a561be71 | 330 | err = mnt_want_write_file(filp); |
2a43a878 AK |
331 | if (err) |
332 | return err; | |
333 | /* | |
334 | * inode_mutex prevent write and truncate on the file. | |
335 | * Read still goes through. We take i_data_sem in | |
336 | * ext4_ext_swap_inode_data before we switch the | |
337 | * inode format to prevent read. | |
338 | */ | |
339 | mutex_lock(&(inode->i_mutex)); | |
340 | err = ext4_ext_migrate(inode); | |
341 | mutex_unlock(&(inode->i_mutex)); | |
2a79f17e | 342 | mnt_drop_write_file(filp); |
2a43a878 AK |
343 | return err; |
344 | } | |
c14c6fd5 | 345 | |
ccd2506b TT |
346 | case EXT4_IOC_ALLOC_DA_BLKS: |
347 | { | |
348 | int err; | |
2e149670 | 349 | if (!inode_owner_or_capable(inode)) |
ccd2506b TT |
350 | return -EACCES; |
351 | ||
a561be71 | 352 | err = mnt_want_write_file(filp); |
ccd2506b TT |
353 | if (err) |
354 | return err; | |
355 | err = ext4_alloc_da_blocks(inode); | |
2a79f17e | 356 | mnt_drop_write_file(filp); |
ccd2506b TT |
357 | return err; |
358 | } | |
359 | ||
19c5246d YY |
360 | case EXT4_IOC_RESIZE_FS: { |
361 | ext4_fsblk_t n_blocks_count; | |
362 | struct super_block *sb = inode->i_sb; | |
363 | int err = 0, err2 = 0; | |
7f511862 | 364 | ext4_group_t o_group = EXT4_SB(sb)->s_groups_count; |
19c5246d YY |
365 | |
366 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, | |
367 | EXT4_FEATURE_RO_COMPAT_BIGALLOC)) { | |
368 | ext4_msg(sb, KERN_ERR, | |
369 | "Online resizing not (yet) supported with bigalloc"); | |
370 | return -EOPNOTSUPP; | |
371 | } | |
372 | ||
19c5246d YY |
373 | if (copy_from_user(&n_blocks_count, (__u64 __user *)arg, |
374 | sizeof(__u64))) { | |
375 | return -EFAULT; | |
376 | } | |
377 | ||
19c5246d YY |
378 | err = ext4_resize_begin(sb); |
379 | if (err) | |
380 | return err; | |
381 | ||
8cae6f71 | 382 | err = mnt_want_write_file(filp); |
19c5246d YY |
383 | if (err) |
384 | goto resizefs_out; | |
385 | ||
386 | err = ext4_resize_fs(sb, n_blocks_count); | |
387 | if (EXT4_SB(sb)->s_journal) { | |
388 | jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal); | |
389 | err2 = jbd2_journal_flush(EXT4_SB(sb)->s_journal); | |
390 | jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal); | |
391 | } | |
392 | if (err == 0) | |
393 | err = err2; | |
8cae6f71 | 394 | mnt_drop_write_file(filp); |
7f511862 TT |
395 | if (!err && (o_group > EXT4_SB(sb)->s_groups_count) && |
396 | ext4_has_group_desc_csum(sb) && | |
397 | test_opt(sb, INIT_INODE_TABLE)) | |
398 | err = ext4_register_li_request(sb, o_group); | |
399 | ||
19c5246d YY |
400 | resizefs_out: |
401 | ext4_resize_end(sb); | |
402 | return err; | |
403 | } | |
404 | ||
e681c047 LC |
405 | case FITRIM: |
406 | { | |
41431792 | 407 | struct request_queue *q = bdev_get_queue(sb->s_bdev); |
e681c047 LC |
408 | struct fstrim_range range; |
409 | int ret = 0; | |
410 | ||
411 | if (!capable(CAP_SYS_ADMIN)) | |
412 | return -EPERM; | |
413 | ||
41431792 LC |
414 | if (!blk_queue_discard(q)) |
415 | return -EOPNOTSUPP; | |
416 | ||
e6705f7c | 417 | if (copy_from_user(&range, (struct fstrim_range __user *)arg, |
e681c047 LC |
418 | sizeof(range))) |
419 | return -EFAULT; | |
420 | ||
5c2ed62f LC |
421 | range.minlen = max((unsigned int)range.minlen, |
422 | q->limits.discard_granularity); | |
e681c047 LC |
423 | ret = ext4_trim_fs(sb, &range); |
424 | if (ret < 0) | |
425 | return ret; | |
426 | ||
e6705f7c | 427 | if (copy_to_user((struct fstrim_range __user *)arg, &range, |
e681c047 LC |
428 | sizeof(range))) |
429 | return -EFAULT; | |
430 | ||
431 | return 0; | |
432 | } | |
433 | ||
ac27a0ec DK |
434 | default: |
435 | return -ENOTTY; | |
436 | } | |
437 | } | |
438 | ||
439 | #ifdef CONFIG_COMPAT | |
617ba13b | 440 | long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
ac27a0ec | 441 | { |
ac27a0ec DK |
442 | /* These are just misnamed, they actually get/put from/to user an int */ |
443 | switch (cmd) { | |
617ba13b MC |
444 | case EXT4_IOC32_GETFLAGS: |
445 | cmd = EXT4_IOC_GETFLAGS; | |
ac27a0ec | 446 | break; |
617ba13b MC |
447 | case EXT4_IOC32_SETFLAGS: |
448 | cmd = EXT4_IOC_SETFLAGS; | |
ac27a0ec | 449 | break; |
617ba13b MC |
450 | case EXT4_IOC32_GETVERSION: |
451 | cmd = EXT4_IOC_GETVERSION; | |
ac27a0ec | 452 | break; |
617ba13b MC |
453 | case EXT4_IOC32_SETVERSION: |
454 | cmd = EXT4_IOC_SETVERSION; | |
ac27a0ec | 455 | break; |
617ba13b MC |
456 | case EXT4_IOC32_GROUP_EXTEND: |
457 | cmd = EXT4_IOC_GROUP_EXTEND; | |
ac27a0ec | 458 | break; |
617ba13b MC |
459 | case EXT4_IOC32_GETVERSION_OLD: |
460 | cmd = EXT4_IOC_GETVERSION_OLD; | |
ac27a0ec | 461 | break; |
617ba13b MC |
462 | case EXT4_IOC32_SETVERSION_OLD: |
463 | cmd = EXT4_IOC_SETVERSION_OLD; | |
ac27a0ec | 464 | break; |
617ba13b MC |
465 | case EXT4_IOC32_GETRSVSZ: |
466 | cmd = EXT4_IOC_GETRSVSZ; | |
ac27a0ec | 467 | break; |
617ba13b MC |
468 | case EXT4_IOC32_SETRSVSZ: |
469 | cmd = EXT4_IOC_SETRSVSZ; | |
ac27a0ec | 470 | break; |
4d92dc0f BH |
471 | case EXT4_IOC32_GROUP_ADD: { |
472 | struct compat_ext4_new_group_input __user *uinput; | |
473 | struct ext4_new_group_input input; | |
474 | mm_segment_t old_fs; | |
475 | int err; | |
476 | ||
477 | uinput = compat_ptr(arg); | |
478 | err = get_user(input.group, &uinput->group); | |
479 | err |= get_user(input.block_bitmap, &uinput->block_bitmap); | |
480 | err |= get_user(input.inode_bitmap, &uinput->inode_bitmap); | |
481 | err |= get_user(input.inode_table, &uinput->inode_table); | |
482 | err |= get_user(input.blocks_count, &uinput->blocks_count); | |
483 | err |= get_user(input.reserved_blocks, | |
484 | &uinput->reserved_blocks); | |
485 | if (err) | |
486 | return -EFAULT; | |
487 | old_fs = get_fs(); | |
488 | set_fs(KERNEL_DS); | |
489 | err = ext4_ioctl(file, EXT4_IOC_GROUP_ADD, | |
490 | (unsigned long) &input); | |
491 | set_fs(old_fs); | |
492 | return err; | |
493 | } | |
b684b2ee | 494 | case EXT4_IOC_MOVE_EXT: |
a56e69c2 | 495 | case FITRIM: |
19c5246d | 496 | case EXT4_IOC_RESIZE_FS: |
b684b2ee | 497 | break; |
ac27a0ec DK |
498 | default: |
499 | return -ENOIOCTLCMD; | |
500 | } | |
5cdd7b2d | 501 | return ext4_ioctl(file, cmd, (unsigned long) compat_ptr(arg)); |
ac27a0ec DK |
502 | } |
503 | #endif |