blob: eb3bc2fe647e710de889f04da3afaf5821e00556 [file] [log] [blame]
Dave Kleikampac27a0e2006-10-11 01:20:50 -07001/*
Mingming Cao617ba132006-10-11 01:20:53 -07002 * linux/fs/ext4/ioctl.c
Dave Kleikampac27a0e2006-10-11 01:20:50 -07003 *
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 */
9
10#include <linux/fs.h>
Mingming Caodab291a2006-10-11 01:21:01 -070011#include <linux/jbd2.h>
Dave Kleikampac27a0e2006-10-11 01:20:50 -070012#include <linux/capability.h>
Dave Kleikampac27a0e2006-10-11 01:20:50 -070013#include <linux/time.h>
14#include <linux/compat.h>
Dave Hansen42a74f22008-02-15 14:37:46 -080015#include <linux/mount.h>
Akira Fujita748de672009-06-17 19:24:03 -040016#include <linux/file.h>
Dave Kleikampac27a0e2006-10-11 01:20:50 -070017#include <asm/uaccess.h>
Christoph Hellwig3dcf5452008-04-29 18:13:32 -040018#include "ext4_jbd2.h"
19#include "ext4.h"
Dave Kleikampac27a0e2006-10-11 01:20:50 -070020
Andi Kleen5cdd7b22008-04-29 22:03:54 -040021long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
Dave Kleikampac27a0e2006-10-11 01:20:50 -070022{
Andi Kleen5cdd7b22008-04-29 22:03:54 -040023 struct inode *inode = filp->f_dentry->d_inode;
Mingming Cao617ba132006-10-11 01:20:53 -070024 struct ext4_inode_info *ei = EXT4_I(inode);
Dave Kleikampac27a0e2006-10-11 01:20:50 -070025 unsigned int flags;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070026
Theodore Ts'oaf5bc922008-09-08 22:25:24 -040027 ext4_debug("cmd = %u, arg = %lu\n", cmd, arg);
Dave Kleikampac27a0e2006-10-11 01:20:50 -070028
29 switch (cmd) {
Mingming Cao617ba132006-10-11 01:20:53 -070030 case EXT4_IOC_GETFLAGS:
Jan Karaff9ddf72007-07-18 09:24:20 -040031 ext4_get_inode_flags(ei);
Mingming Cao617ba132006-10-11 01:20:53 -070032 flags = ei->i_flags & EXT4_FL_USER_VISIBLE;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070033 return put_user(flags, (int __user *) arg);
Mingming Cao617ba132006-10-11 01:20:53 -070034 case EXT4_IOC_SETFLAGS: {
Dave Kleikampac27a0e2006-10-11 01:20:50 -070035 handle_t *handle = NULL;
Aneesh Kumar K.V4db46fc2008-10-08 23:34:06 -040036 int err, migrate = 0;
Mingming Cao617ba132006-10-11 01:20:53 -070037 struct ext4_iloc iloc;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070038 unsigned int oldflags;
39 unsigned int jflag;
40
Satyam Sharma3bd858a2007-07-17 15:00:08 +053041 if (!is_owner_or_cap(inode))
Dave Kleikampac27a0e2006-10-11 01:20:50 -070042 return -EACCES;
43
44 if (get_user(flags, (int __user *) arg))
45 return -EFAULT;
46
Dave Hansen42a74f22008-02-15 14:37:46 -080047 err = mnt_want_write(filp->f_path.mnt);
48 if (err)
49 return err;
50
Duane Griffin2dc6b0d2009-02-15 18:09:20 -050051 flags = ext4_mask_flags(inode->i_mode, flags);
Dave Kleikampac27a0e2006-10-11 01:20:50 -070052
Dave Hansen42a74f22008-02-15 14:37:46 -080053 err = -EPERM;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070054 mutex_lock(&inode->i_mutex);
Jan Karae47776a2007-11-14 16:58:56 -080055 /* Is it quota file? Do not allow user to mess with it */
Dave Hansen42a74f22008-02-15 14:37:46 -080056 if (IS_NOQUOTA(inode))
57 goto flags_out;
58
Dave Kleikampac27a0e2006-10-11 01:20:50 -070059 oldflags = ei->i_flags;
60
61 /* The JOURNAL_DATA flag is modifiable only by root */
Mingming Cao617ba132006-10-11 01:20:53 -070062 jflag = flags & EXT4_JOURNAL_DATA_FL;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070063
64 /*
65 * The IMMUTABLE and APPEND_ONLY flags can only be changed by
66 * the relevant capability.
67 *
68 * This test looks nicer. Thanks to Pauline Middelink
69 */
Mingming Cao617ba132006-10-11 01:20:53 -070070 if ((flags ^ oldflags) & (EXT4_APPEND_FL | EXT4_IMMUTABLE_FL)) {
Dave Hansen42a74f22008-02-15 14:37:46 -080071 if (!capable(CAP_LINUX_IMMUTABLE))
72 goto flags_out;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070073 }
74
75 /*
76 * The JOURNAL_DATA flag can only be changed by
77 * the relevant capability.
78 */
Mingming Cao617ba132006-10-11 01:20:53 -070079 if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL)) {
Dave Hansen42a74f22008-02-15 14:37:46 -080080 if (!capable(CAP_SYS_RESOURCE))
81 goto flags_out;
Dave Kleikampac27a0e2006-10-11 01:20:50 -070082 }
Aneesh Kumar K.V4db46fc2008-10-08 23:34:06 -040083 if (oldflags & EXT4_EXTENTS_FL) {
84 /* We don't support clearning extent flags */
85 if (!(flags & EXT4_EXTENTS_FL)) {
86 err = -EOPNOTSUPP;
87 goto flags_out;
88 }
89 } else if (flags & EXT4_EXTENTS_FL) {
90 /* migrate the file */
91 migrate = 1;
92 flags &= ~EXT4_EXTENTS_FL;
93 }
Dave Kleikampac27a0e2006-10-11 01:20:50 -070094
Jiaying Zhangc8d46e42010-02-24 09:52:53 -050095 if (flags & EXT4_EOFBLOCKS_FL) {
96 /* we don't support adding EOFBLOCKS flag */
97 if (!(oldflags & EXT4_EOFBLOCKS_FL)) {
98 err = -EOPNOTSUPP;
99 goto flags_out;
100 }
101 } else if (oldflags & EXT4_EOFBLOCKS_FL)
102 ext4_truncate(inode);
103
Mingming Cao617ba132006-10-11 01:20:53 -0700104 handle = ext4_journal_start(inode, 1);
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700105 if (IS_ERR(handle)) {
Dave Hansen42a74f22008-02-15 14:37:46 -0800106 err = PTR_ERR(handle);
107 goto flags_out;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700108 }
109 if (IS_SYNC(inode))
Frank Mayhar03901312009-01-07 00:06:22 -0500110 ext4_handle_sync(handle);
Mingming Cao617ba132006-10-11 01:20:53 -0700111 err = ext4_reserve_inode_write(handle, inode, &iloc);
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700112 if (err)
113 goto flags_err;
114
Mingming Cao617ba132006-10-11 01:20:53 -0700115 flags = flags & EXT4_FL_USER_MODIFIABLE;
116 flags |= oldflags & ~EXT4_FL_USER_MODIFIABLE;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700117 ei->i_flags = flags;
118
Mingming Cao617ba132006-10-11 01:20:53 -0700119 ext4_set_inode_flags(inode);
Kalpak Shahef7f3832007-07-18 09:15:20 -0400120 inode->i_ctime = ext4_current_time(inode);
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700121
Mingming Cao617ba132006-10-11 01:20:53 -0700122 err = ext4_mark_iloc_dirty(handle, inode, &iloc);
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700123flags_err:
Mingming Cao617ba132006-10-11 01:20:53 -0700124 ext4_journal_stop(handle);
Dave Hansen42a74f22008-02-15 14:37:46 -0800125 if (err)
126 goto flags_out;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700127
Mingming Cao617ba132006-10-11 01:20:53 -0700128 if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL))
129 err = ext4_change_inode_journal_flag(inode, jflag);
Aneesh Kumar K.V4db46fc2008-10-08 23:34:06 -0400130 if (err)
131 goto flags_out;
132 if (migrate)
133 err = ext4_ext_migrate(inode);
Dave Hansen42a74f22008-02-15 14:37:46 -0800134flags_out:
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700135 mutex_unlock(&inode->i_mutex);
Dave Hansen42a74f22008-02-15 14:37:46 -0800136 mnt_drop_write(filp->f_path.mnt);
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700137 return err;
138 }
Mingming Cao617ba132006-10-11 01:20:53 -0700139 case EXT4_IOC_GETVERSION:
140 case EXT4_IOC_GETVERSION_OLD:
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700141 return put_user(inode->i_generation, (int __user *) arg);
Mingming Cao617ba132006-10-11 01:20:53 -0700142 case EXT4_IOC_SETVERSION:
143 case EXT4_IOC_SETVERSION_OLD: {
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700144 handle_t *handle;
Mingming Cao617ba132006-10-11 01:20:53 -0700145 struct ext4_iloc iloc;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700146 __u32 generation;
147 int err;
148
Satyam Sharma3bd858a2007-07-17 15:00:08 +0530149 if (!is_owner_or_cap(inode))
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700150 return -EPERM;
Dave Hansen42a74f22008-02-15 14:37:46 -0800151
152 err = mnt_want_write(filp->f_path.mnt);
153 if (err)
154 return err;
155 if (get_user(generation, (int __user *) arg)) {
156 err = -EFAULT;
157 goto setversion_out;
158 }
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700159
Mingming Cao617ba132006-10-11 01:20:53 -0700160 handle = ext4_journal_start(inode, 1);
Dave Hansen42a74f22008-02-15 14:37:46 -0800161 if (IS_ERR(handle)) {
162 err = PTR_ERR(handle);
163 goto setversion_out;
164 }
Mingming Cao617ba132006-10-11 01:20:53 -0700165 err = ext4_reserve_inode_write(handle, inode, &iloc);
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700166 if (err == 0) {
Kalpak Shahef7f3832007-07-18 09:15:20 -0400167 inode->i_ctime = ext4_current_time(inode);
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700168 inode->i_generation = generation;
Mingming Cao617ba132006-10-11 01:20:53 -0700169 err = ext4_mark_iloc_dirty(handle, inode, &iloc);
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700170 }
Mingming Cao617ba132006-10-11 01:20:53 -0700171 ext4_journal_stop(handle);
Dave Hansen42a74f22008-02-15 14:37:46 -0800172setversion_out:
173 mnt_drop_write(filp->f_path.mnt);
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700174 return err;
175 }
Jose R. Santose23291b2007-07-18 08:57:06 -0400176#ifdef CONFIG_JBD2_DEBUG
Mingming Cao617ba132006-10-11 01:20:53 -0700177 case EXT4_IOC_WAIT_FOR_READONLY:
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700178 /*
179 * This is racy - by the time we're woken up and running,
180 * the superblock could be released. And the module could
181 * have been unloaded. So sue me.
182 *
183 * Returns 1 if it slept, else zero.
184 */
185 {
186 struct super_block *sb = inode->i_sb;
187 DECLARE_WAITQUEUE(wait, current);
188 int ret = 0;
189
190 set_current_state(TASK_INTERRUPTIBLE);
Mingming Cao617ba132006-10-11 01:20:53 -0700191 add_wait_queue(&EXT4_SB(sb)->ro_wait_queue, &wait);
192 if (timer_pending(&EXT4_SB(sb)->turn_ro_timer)) {
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700193 schedule();
194 ret = 1;
195 }
Mingming Cao617ba132006-10-11 01:20:53 -0700196 remove_wait_queue(&EXT4_SB(sb)->ro_wait_queue, &wait);
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700197 return ret;
198 }
199#endif
Mingming Cao617ba132006-10-11 01:20:53 -0700200 case EXT4_IOC_GROUP_EXTEND: {
201 ext4_fsblk_t n_blocks_count;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700202 struct super_block *sb = inode->i_sb;
Peng Taoac046f12009-07-13 09:30:17 -0400203 int err, err2=0;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700204
205 if (!capable(CAP_SYS_RESOURCE))
206 return -EPERM;
207
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700208 if (get_user(n_blocks_count, (__u32 __user *)arg))
209 return -EFAULT;
210
Dave Hansen42a74f22008-02-15 14:37:46 -0800211 err = mnt_want_write(filp->f_path.mnt);
212 if (err)
213 return err;
214
Mingming Cao617ba132006-10-11 01:20:53 -0700215 err = ext4_group_extend(sb, EXT4_SB(sb)->s_es, n_blocks_count);
Peng Taoac046f12009-07-13 09:30:17 -0400216 if (EXT4_SB(sb)->s_journal) {
217 jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal);
218 err2 = jbd2_journal_flush(EXT4_SB(sb)->s_journal);
219 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
220 }
Hidehiro Kawai7ffe1ea2008-10-10 20:29:21 -0400221 if (err == 0)
222 err = err2;
Dave Hansen42a74f22008-02-15 14:37:46 -0800223 mnt_drop_write(filp->f_path.mnt);
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700224
225 return err;
226 }
Akira Fujita748de672009-06-17 19:24:03 -0400227
228 case EXT4_IOC_MOVE_EXT: {
229 struct move_extent me;
230 struct file *donor_filp;
231 int err;
232
Akira Fujita4a585792009-12-06 23:38:31 -0500233 if (!(filp->f_mode & FMODE_READ) ||
234 !(filp->f_mode & FMODE_WRITE))
235 return -EBADF;
236
Akira Fujita748de672009-06-17 19:24:03 -0400237 if (copy_from_user(&me,
238 (struct move_extent __user *)arg, sizeof(me)))
239 return -EFAULT;
Akira Fujita4a585792009-12-06 23:38:31 -0500240 me.moved_len = 0;
Akira Fujita748de672009-06-17 19:24:03 -0400241
242 donor_filp = fget(me.donor_fd);
243 if (!donor_filp)
244 return -EBADF;
245
Akira Fujita4a585792009-12-06 23:38:31 -0500246 if (!(donor_filp->f_mode & FMODE_WRITE)) {
247 err = -EBADF;
248 goto mext_out;
Akira Fujita748de672009-06-17 19:24:03 -0400249 }
250
Akira Fujita4a585792009-12-06 23:38:31 -0500251 err = mnt_want_write(filp->f_path.mnt);
252 if (err)
253 goto mext_out;
254
Akira Fujita748de672009-06-17 19:24:03 -0400255 err = ext4_move_extents(filp, donor_filp, me.orig_start,
256 me.donor_start, me.len, &me.moved_len);
Akira Fujita4a585792009-12-06 23:38:31 -0500257 mnt_drop_write(filp->f_path.mnt);
258 if (me.moved_len > 0)
259 file_remove_suid(donor_filp);
Akira Fujita748de672009-06-17 19:24:03 -0400260
Theodore Ts'o60e66792010-05-17 07:00:00 -0400261 if (copy_to_user((struct move_extent __user *)arg,
Akira Fujitac437b272010-03-04 00:39:24 -0500262 &me, sizeof(me)))
Akira Fujita4a585792009-12-06 23:38:31 -0500263 err = -EFAULT;
264mext_out:
265 fput(donor_filp);
Akira Fujita748de672009-06-17 19:24:03 -0400266 return err;
267 }
268
Mingming Cao617ba132006-10-11 01:20:53 -0700269 case EXT4_IOC_GROUP_ADD: {
270 struct ext4_new_group_data input;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700271 struct super_block *sb = inode->i_sb;
Peng Taoac046f12009-07-13 09:30:17 -0400272 int err, err2=0;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700273
274 if (!capable(CAP_SYS_RESOURCE))
275 return -EPERM;
276
Mingming Cao617ba132006-10-11 01:20:53 -0700277 if (copy_from_user(&input, (struct ext4_new_group_input __user *)arg,
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700278 sizeof(input)))
279 return -EFAULT;
280
Dave Hansen42a74f22008-02-15 14:37:46 -0800281 err = mnt_want_write(filp->f_path.mnt);
282 if (err)
283 return err;
284
Mingming Cao617ba132006-10-11 01:20:53 -0700285 err = ext4_group_add(sb, &input);
Peng Taoac046f12009-07-13 09:30:17 -0400286 if (EXT4_SB(sb)->s_journal) {
287 jbd2_journal_lock_updates(EXT4_SB(sb)->s_journal);
288 err2 = jbd2_journal_flush(EXT4_SB(sb)->s_journal);
289 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
290 }
Hidehiro Kawai7ffe1ea2008-10-10 20:29:21 -0400291 if (err == 0)
292 err = err2;
Dave Hansen42a74f22008-02-15 14:37:46 -0800293 mnt_drop_write(filp->f_path.mnt);
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700294
295 return err;
296 }
297
Aneesh Kumar K.Vc14c6fd2008-01-28 23:58:26 -0500298 case EXT4_IOC_MIGRATE:
Aneesh Kumar K.V2a43a872008-09-13 12:52:26 -0400299 {
300 int err;
301 if (!is_owner_or_cap(inode))
302 return -EACCES;
303
304 err = mnt_want_write(filp->f_path.mnt);
305 if (err)
306 return err;
307 /*
308 * inode_mutex prevent write and truncate on the file.
309 * Read still goes through. We take i_data_sem in
310 * ext4_ext_swap_inode_data before we switch the
311 * inode format to prevent read.
312 */
313 mutex_lock(&(inode->i_mutex));
314 err = ext4_ext_migrate(inode);
315 mutex_unlock(&(inode->i_mutex));
316 mnt_drop_write(filp->f_path.mnt);
317 return err;
318 }
Aneesh Kumar K.Vc14c6fd2008-01-28 23:58:26 -0500319
Theodore Ts'occd25062009-02-26 01:04:07 -0500320 case EXT4_IOC_ALLOC_DA_BLKS:
321 {
322 int err;
323 if (!is_owner_or_cap(inode))
324 return -EACCES;
325
326 err = mnt_want_write(filp->f_path.mnt);
327 if (err)
328 return err;
329 err = ext4_alloc_da_blocks(inode);
330 mnt_drop_write(filp->f_path.mnt);
331 return err;
332 }
333
Lukas Czernere681c042010-11-19 21:47:07 -0500334 case FITRIM:
335 {
336 struct super_block *sb = inode->i_sb;
337 struct fstrim_range range;
338 int ret = 0;
339
340 if (!capable(CAP_SYS_ADMIN))
341 return -EPERM;
342
343 if (copy_from_user(&range, (struct fstrim_range *)arg,
344 sizeof(range)))
345 return -EFAULT;
346
347 ret = ext4_trim_fs(sb, &range);
348 if (ret < 0)
349 return ret;
350
351 if (copy_to_user((struct fstrim_range *)arg, &range,
352 sizeof(range)))
353 return -EFAULT;
354
355 return 0;
356 }
357
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700358 default:
359 return -ENOTTY;
360 }
361}
362
363#ifdef CONFIG_COMPAT
Mingming Cao617ba132006-10-11 01:20:53 -0700364long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700365{
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700366 /* These are just misnamed, they actually get/put from/to user an int */
367 switch (cmd) {
Mingming Cao617ba132006-10-11 01:20:53 -0700368 case EXT4_IOC32_GETFLAGS:
369 cmd = EXT4_IOC_GETFLAGS;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700370 break;
Mingming Cao617ba132006-10-11 01:20:53 -0700371 case EXT4_IOC32_SETFLAGS:
372 cmd = EXT4_IOC_SETFLAGS;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700373 break;
Mingming Cao617ba132006-10-11 01:20:53 -0700374 case EXT4_IOC32_GETVERSION:
375 cmd = EXT4_IOC_GETVERSION;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700376 break;
Mingming Cao617ba132006-10-11 01:20:53 -0700377 case EXT4_IOC32_SETVERSION:
378 cmd = EXT4_IOC_SETVERSION;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700379 break;
Mingming Cao617ba132006-10-11 01:20:53 -0700380 case EXT4_IOC32_GROUP_EXTEND:
381 cmd = EXT4_IOC_GROUP_EXTEND;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700382 break;
Mingming Cao617ba132006-10-11 01:20:53 -0700383 case EXT4_IOC32_GETVERSION_OLD:
384 cmd = EXT4_IOC_GETVERSION_OLD;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700385 break;
Mingming Cao617ba132006-10-11 01:20:53 -0700386 case EXT4_IOC32_SETVERSION_OLD:
387 cmd = EXT4_IOC_SETVERSION_OLD;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700388 break;
Jose R. Santose23291b2007-07-18 08:57:06 -0400389#ifdef CONFIG_JBD2_DEBUG
Mingming Cao617ba132006-10-11 01:20:53 -0700390 case EXT4_IOC32_WAIT_FOR_READONLY:
391 cmd = EXT4_IOC_WAIT_FOR_READONLY;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700392 break;
393#endif
Mingming Cao617ba132006-10-11 01:20:53 -0700394 case EXT4_IOC32_GETRSVSZ:
395 cmd = EXT4_IOC_GETRSVSZ;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700396 break;
Mingming Cao617ba132006-10-11 01:20:53 -0700397 case EXT4_IOC32_SETRSVSZ:
398 cmd = EXT4_IOC_SETRSVSZ;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700399 break;
Ben Hutchings4d92dc02010-05-17 06:00:00 -0400400 case EXT4_IOC32_GROUP_ADD: {
401 struct compat_ext4_new_group_input __user *uinput;
402 struct ext4_new_group_input input;
403 mm_segment_t old_fs;
404 int err;
405
406 uinput = compat_ptr(arg);
407 err = get_user(input.group, &uinput->group);
408 err |= get_user(input.block_bitmap, &uinput->block_bitmap);
409 err |= get_user(input.inode_bitmap, &uinput->inode_bitmap);
410 err |= get_user(input.inode_table, &uinput->inode_table);
411 err |= get_user(input.blocks_count, &uinput->blocks_count);
412 err |= get_user(input.reserved_blocks,
413 &uinput->reserved_blocks);
414 if (err)
415 return -EFAULT;
416 old_fs = get_fs();
417 set_fs(KERNEL_DS);
418 err = ext4_ioctl(file, EXT4_IOC_GROUP_ADD,
419 (unsigned long) &input);
420 set_fs(old_fs);
421 return err;
422 }
Christian Borntraegerb684b2e2010-05-15 00:00:00 -0400423 case EXT4_IOC_MOVE_EXT:
424 break;
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700425 default:
426 return -ENOIOCTLCMD;
427 }
Andi Kleen5cdd7b22008-04-29 22:03:54 -0400428 return ext4_ioctl(file, cmd, (unsigned long) compat_ptr(arg));
Dave Kleikampac27a0e2006-10-11 01:20:50 -0700429}
430#endif