blob: 373c1d153a990791ece4cd80ab970eca60c7a7e8 [file] [log] [blame]
Herbert Poetzlca4d1472006-07-03 17:27:12 -07001/*
2 * linux/fs/ocfs2/ioctl.c
3 *
4 * Copyright (C) 2006 Herbert Poetzl
5 * adapted from Remy Card's ext2/ioctl.c
6 */
7
8#include <linux/fs.h>
9#include <linux/mount.h>
Tao Ma34e6c592010-01-27 10:21:52 +080010#include <linux/compat.h>
Herbert Poetzlca4d1472006-07-03 17:27:12 -070011
Herbert Poetzlca4d1472006-07-03 17:27:12 -070012#include <cluster/masklog.h>
13
14#include "ocfs2.h"
15#include "alloc.h"
16#include "dlmglue.h"
Mark Fashehb2580102007-03-09 16:53:21 -080017#include "file.h"
Herbert Poetzlca4d1472006-07-03 17:27:12 -070018#include "inode.h"
19#include "journal.h"
20
21#include "ocfs2_fs.h"
Adrian Bunk2d562512006-07-10 01:32:51 +020022#include "ioctl.h"
Tao Mad6590722007-12-18 15:47:03 +080023#include "resize.h"
Tao Mabd508732009-09-21 11:25:14 +080024#include "refcounttree.h"
Adrian Bunk2d562512006-07-10 01:32:51 +020025
Herbert Poetzlca4d1472006-07-03 17:27:12 -070026#include <linux/ext2_fs.h>
27
Tristan Yeddee5cd2010-05-22 16:26:33 +080028#define o2info_from_user(a, b) \
29 copy_from_user(&(a), (b), sizeof(a))
30#define o2info_to_user(a, b) \
31 copy_to_user((typeof(a) __user *)b, &(a), sizeof(a))
32
33/*
34 * This call is void because we are already reporting an error that may
35 * be -EFAULT. The error will be returned from the ioctl(2) call. It's
36 * just a best-effort to tell userspace that this request caused the error.
37 */
Tristan Ye8aa1fa32011-05-24 15:22:59 +080038static inline void o2info_set_request_error(struct ocfs2_info_request *kreq,
Tristan Yeddee5cd2010-05-22 16:26:33 +080039 struct ocfs2_info_request __user *req)
40{
41 kreq->ir_flags |= OCFS2_INFO_FL_ERROR;
42 (void)put_user(kreq->ir_flags, (__u32 __user *)&(req->ir_flags));
43}
44
Tristan Ye8aa1fa32011-05-24 15:22:59 +080045static inline void o2info_set_request_filled(struct ocfs2_info_request *req)
Tristan Ye1936a262011-01-30 14:25:59 +080046{
47 req->ir_flags |= OCFS2_INFO_FL_FILLED;
48}
49
Tristan Ye8aa1fa32011-05-24 15:22:59 +080050static inline void o2info_clear_request_filled(struct ocfs2_info_request *req)
Tristan Ye1936a262011-01-30 14:25:59 +080051{
52 req->ir_flags &= ~OCFS2_INFO_FL_FILLED;
53}
54
Herbert Poetzlca4d1472006-07-03 17:27:12 -070055static int ocfs2_get_inode_attr(struct inode *inode, unsigned *flags)
56{
57 int status;
58
Mark Fashehe63aecb62007-10-18 15:30:42 -070059 status = ocfs2_inode_lock(inode, NULL, 0);
Herbert Poetzlca4d1472006-07-03 17:27:12 -070060 if (status < 0) {
61 mlog_errno(status);
62 return status;
63 }
Jan Kara6e4b0d52007-04-27 11:08:01 -070064 ocfs2_get_inode_flags(OCFS2_I(inode));
Herbert Poetzlca4d1472006-07-03 17:27:12 -070065 *flags = OCFS2_I(inode)->ip_attr;
Mark Fashehe63aecb62007-10-18 15:30:42 -070066 ocfs2_inode_unlock(inode, 0);
Herbert Poetzlca4d1472006-07-03 17:27:12 -070067
Herbert Poetzlca4d1472006-07-03 17:27:12 -070068 return status;
69}
70
71static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags,
72 unsigned mask)
73{
74 struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode);
75 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
Mark Fasheh1fabe142006-10-09 18:11:45 -070076 handle_t *handle = NULL;
Herbert Poetzlca4d1472006-07-03 17:27:12 -070077 struct buffer_head *bh = NULL;
78 unsigned oldflags;
79 int status;
80
81 mutex_lock(&inode->i_mutex);
82
Mark Fashehe63aecb62007-10-18 15:30:42 -070083 status = ocfs2_inode_lock(inode, &bh, 1);
Herbert Poetzlca4d1472006-07-03 17:27:12 -070084 if (status < 0) {
85 mlog_errno(status);
86 goto bail;
87 }
88
Herbert Poetzlca4d1472006-07-03 17:27:12 -070089 status = -EACCES;
Serge E. Hallyn2e149672011-03-23 16:43:26 -070090 if (!inode_owner_or_capable(inode))
Herbert Poetzlca4d1472006-07-03 17:27:12 -070091 goto bail_unlock;
92
93 if (!S_ISDIR(inode->i_mode))
94 flags &= ~OCFS2_DIRSYNC_FL;
95
Mark Fasheh65eff9c2006-10-09 17:26:22 -070096 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
Herbert Poetzlca4d1472006-07-03 17:27:12 -070097 if (IS_ERR(handle)) {
98 status = PTR_ERR(handle);
99 mlog_errno(status);
100 goto bail_unlock;
101 }
102
103 oldflags = ocfs2_inode->ip_attr;
104 flags = flags & mask;
105 flags |= oldflags & ~mask;
106
107 /*
108 * The IMMUTABLE and APPEND_ONLY flags can only be changed by
109 * the relevant capability.
110 */
111 status = -EPERM;
112 if ((oldflags & OCFS2_IMMUTABLE_FL) || ((flags ^ oldflags) &
113 (OCFS2_APPEND_FL | OCFS2_IMMUTABLE_FL))) {
114 if (!capable(CAP_LINUX_IMMUTABLE))
115 goto bail_unlock;
116 }
117
118 ocfs2_inode->ip_attr = flags;
119 ocfs2_set_inode_flags(inode);
120
121 status = ocfs2_mark_inode_dirty(handle, inode, bh);
122 if (status < 0)
123 mlog_errno(status);
124
Mark Fasheh02dc1af2006-10-09 16:48:10 -0700125 ocfs2_commit_trans(osb, handle);
Herbert Poetzlca4d1472006-07-03 17:27:12 -0700126bail_unlock:
Mark Fashehe63aecb62007-10-18 15:30:42 -0700127 ocfs2_inode_unlock(inode, 1);
Herbert Poetzlca4d1472006-07-03 17:27:12 -0700128bail:
129 mutex_unlock(&inode->i_mutex);
130
Mark Fasheha81cb882008-10-07 14:25:16 -0700131 brelse(bh);
Herbert Poetzlca4d1472006-07-03 17:27:12 -0700132
Herbert Poetzlca4d1472006-07-03 17:27:12 -0700133 return status;
134}
135
Tristan Yeddee5cd2010-05-22 16:26:33 +0800136int ocfs2_info_handle_blocksize(struct inode *inode,
137 struct ocfs2_info_request __user *req)
138{
139 int status = -EFAULT;
140 struct ocfs2_info_blocksize oib;
141
142 if (o2info_from_user(oib, req))
143 goto bail;
144
145 oib.ib_blocksize = inode->i_sb->s_blocksize;
Tristan Ye1936a262011-01-30 14:25:59 +0800146
Tristan Ye8aa1fa32011-05-24 15:22:59 +0800147 o2info_set_request_filled(&oib.ib_req);
Tristan Yeddee5cd2010-05-22 16:26:33 +0800148
149 if (o2info_to_user(oib, req))
150 goto bail;
151
152 status = 0;
153bail:
154 if (status)
Tristan Ye8aa1fa32011-05-24 15:22:59 +0800155 o2info_set_request_error(&oib.ib_req, req);
Tristan Yeddee5cd2010-05-22 16:26:33 +0800156
157 return status;
158}
159
160int ocfs2_info_handle_clustersize(struct inode *inode,
161 struct ocfs2_info_request __user *req)
162{
163 int status = -EFAULT;
164 struct ocfs2_info_clustersize oic;
165 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
166
167 if (o2info_from_user(oic, req))
168 goto bail;
169
170 oic.ic_clustersize = osb->s_clustersize;
Tristan Ye1936a262011-01-30 14:25:59 +0800171
Tristan Ye8aa1fa32011-05-24 15:22:59 +0800172 o2info_set_request_filled(&oic.ic_req);
Tristan Yeddee5cd2010-05-22 16:26:33 +0800173
174 if (o2info_to_user(oic, req))
175 goto bail;
176
177 status = 0;
178bail:
179 if (status)
Tristan Ye8aa1fa32011-05-24 15:22:59 +0800180 o2info_set_request_error(&oic.ic_req, req);
Tristan Yeddee5cd2010-05-22 16:26:33 +0800181
182 return status;
183}
184
185int ocfs2_info_handle_maxslots(struct inode *inode,
186 struct ocfs2_info_request __user *req)
187{
188 int status = -EFAULT;
189 struct ocfs2_info_maxslots oim;
190 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
191
192 if (o2info_from_user(oim, req))
193 goto bail;
194
195 oim.im_max_slots = osb->max_slots;
Tristan Ye1936a262011-01-30 14:25:59 +0800196
Tristan Ye8aa1fa32011-05-24 15:22:59 +0800197 o2info_set_request_filled(&oim.im_req);
Tristan Yeddee5cd2010-05-22 16:26:33 +0800198
199 if (o2info_to_user(oim, req))
200 goto bail;
201
202 status = 0;
203bail:
204 if (status)
Tristan Ye8aa1fa32011-05-24 15:22:59 +0800205 o2info_set_request_error(&oim.im_req, req);
Tristan Yeddee5cd2010-05-22 16:26:33 +0800206
207 return status;
208}
209
210int ocfs2_info_handle_label(struct inode *inode,
211 struct ocfs2_info_request __user *req)
212{
213 int status = -EFAULT;
214 struct ocfs2_info_label oil;
215 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
216
217 if (o2info_from_user(oil, req))
218 goto bail;
219
220 memcpy(oil.il_label, osb->vol_label, OCFS2_MAX_VOL_LABEL_LEN);
Tristan Ye1936a262011-01-30 14:25:59 +0800221
Tristan Ye8aa1fa32011-05-24 15:22:59 +0800222 o2info_set_request_filled(&oil.il_req);
Tristan Yeddee5cd2010-05-22 16:26:33 +0800223
224 if (o2info_to_user(oil, req))
225 goto bail;
226
227 status = 0;
228bail:
229 if (status)
Tristan Ye8aa1fa32011-05-24 15:22:59 +0800230 o2info_set_request_error(&oil.il_req, req);
Tristan Yeddee5cd2010-05-22 16:26:33 +0800231
232 return status;
233}
234
235int ocfs2_info_handle_uuid(struct inode *inode,
236 struct ocfs2_info_request __user *req)
237{
238 int status = -EFAULT;
239 struct ocfs2_info_uuid oiu;
240 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
241
242 if (o2info_from_user(oiu, req))
243 goto bail;
244
245 memcpy(oiu.iu_uuid_str, osb->uuid_str, OCFS2_TEXT_UUID_LEN + 1);
Tristan Ye1936a262011-01-30 14:25:59 +0800246
Tristan Ye8aa1fa32011-05-24 15:22:59 +0800247 o2info_set_request_filled(&oiu.iu_req);
Tristan Yeddee5cd2010-05-22 16:26:33 +0800248
249 if (o2info_to_user(oiu, req))
250 goto bail;
251
252 status = 0;
253bail:
254 if (status)
Tristan Ye8aa1fa32011-05-24 15:22:59 +0800255 o2info_set_request_error(&oiu.iu_req, req);
Tristan Yeddee5cd2010-05-22 16:26:33 +0800256
257 return status;
258}
259
260int ocfs2_info_handle_fs_features(struct inode *inode,
261 struct ocfs2_info_request __user *req)
262{
263 int status = -EFAULT;
264 struct ocfs2_info_fs_features oif;
265 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
266
267 if (o2info_from_user(oif, req))
268 goto bail;
269
270 oif.if_compat_features = osb->s_feature_compat;
271 oif.if_incompat_features = osb->s_feature_incompat;
272 oif.if_ro_compat_features = osb->s_feature_ro_compat;
Tristan Ye1936a262011-01-30 14:25:59 +0800273
Tristan Ye8aa1fa32011-05-24 15:22:59 +0800274 o2info_set_request_filled(&oif.if_req);
Tristan Yeddee5cd2010-05-22 16:26:33 +0800275
276 if (o2info_to_user(oif, req))
277 goto bail;
278
279 status = 0;
280bail:
281 if (status)
Tristan Ye8aa1fa32011-05-24 15:22:59 +0800282 o2info_set_request_error(&oif.if_req, req);
Tristan Yeddee5cd2010-05-22 16:26:33 +0800283
284 return status;
285}
286
287int ocfs2_info_handle_journal_size(struct inode *inode,
288 struct ocfs2_info_request __user *req)
289{
290 int status = -EFAULT;
291 struct ocfs2_info_journal_size oij;
292 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
293
294 if (o2info_from_user(oij, req))
295 goto bail;
296
297 oij.ij_journal_size = osb->journal->j_inode->i_size;
298
Tristan Ye8aa1fa32011-05-24 15:22:59 +0800299 o2info_set_request_filled(&oij.ij_req);
Tristan Yeddee5cd2010-05-22 16:26:33 +0800300
301 if (o2info_to_user(oij, req))
302 goto bail;
303
304 status = 0;
305bail:
306 if (status)
Tristan Ye8aa1fa32011-05-24 15:22:59 +0800307 o2info_set_request_error(&oij.ij_req, req);
Tristan Yeddee5cd2010-05-22 16:26:33 +0800308
309 return status;
310}
311
312int ocfs2_info_handle_unknown(struct inode *inode,
313 struct ocfs2_info_request __user *req)
314{
315 int status = -EFAULT;
316 struct ocfs2_info_request oir;
317
318 if (o2info_from_user(oir, req))
319 goto bail;
320
Tristan Ye8aa1fa32011-05-24 15:22:59 +0800321 o2info_clear_request_filled(&oir);
Tristan Yeddee5cd2010-05-22 16:26:33 +0800322
323 if (o2info_to_user(oir, req))
324 goto bail;
325
326 status = 0;
327bail:
328 if (status)
Tristan Ye8aa1fa32011-05-24 15:22:59 +0800329 o2info_set_request_error(&oir, req);
Tristan Yeddee5cd2010-05-22 16:26:33 +0800330
331 return status;
332}
333
334/*
335 * Validate and distinguish OCFS2_IOC_INFO requests.
336 *
337 * - validate the magic number.
338 * - distinguish different requests.
339 * - validate size of different requests.
340 */
341int ocfs2_info_handle_request(struct inode *inode,
342 struct ocfs2_info_request __user *req)
343{
344 int status = -EFAULT;
345 struct ocfs2_info_request oir;
346
347 if (o2info_from_user(oir, req))
348 goto bail;
349
350 status = -EINVAL;
351 if (oir.ir_magic != OCFS2_INFO_MAGIC)
352 goto bail;
353
354 switch (oir.ir_code) {
355 case OCFS2_INFO_BLOCKSIZE:
356 if (oir.ir_size == sizeof(struct ocfs2_info_blocksize))
357 status = ocfs2_info_handle_blocksize(inode, req);
358 break;
359 case OCFS2_INFO_CLUSTERSIZE:
360 if (oir.ir_size == sizeof(struct ocfs2_info_clustersize))
361 status = ocfs2_info_handle_clustersize(inode, req);
362 break;
363 case OCFS2_INFO_MAXSLOTS:
364 if (oir.ir_size == sizeof(struct ocfs2_info_maxslots))
365 status = ocfs2_info_handle_maxslots(inode, req);
366 break;
367 case OCFS2_INFO_LABEL:
368 if (oir.ir_size == sizeof(struct ocfs2_info_label))
369 status = ocfs2_info_handle_label(inode, req);
370 break;
371 case OCFS2_INFO_UUID:
372 if (oir.ir_size == sizeof(struct ocfs2_info_uuid))
373 status = ocfs2_info_handle_uuid(inode, req);
374 break;
375 case OCFS2_INFO_FS_FEATURES:
376 if (oir.ir_size == sizeof(struct ocfs2_info_fs_features))
377 status = ocfs2_info_handle_fs_features(inode, req);
378 break;
379 case OCFS2_INFO_JOURNAL_SIZE:
380 if (oir.ir_size == sizeof(struct ocfs2_info_journal_size))
381 status = ocfs2_info_handle_journal_size(inode, req);
382 break;
383 default:
384 status = ocfs2_info_handle_unknown(inode, req);
385 break;
386 }
387
388bail:
389 return status;
390}
391
392int ocfs2_get_request_ptr(struct ocfs2_info *info, int idx,
393 u64 *req_addr, int compat_flag)
394{
395 int status = -EFAULT;
396 u64 __user *bp = NULL;
397
398 if (compat_flag) {
399#ifdef CONFIG_COMPAT
400 /*
401 * pointer bp stores the base address of a pointers array,
402 * which collects all addresses of separate request.
403 */
404 bp = (u64 __user *)(unsigned long)compat_ptr(info->oi_requests);
405#else
406 BUG();
407#endif
408 } else
409 bp = (u64 __user *)(unsigned long)(info->oi_requests);
410
411 if (o2info_from_user(*req_addr, bp + idx))
412 goto bail;
413
414 status = 0;
415bail:
416 return status;
417}
418
419/*
420 * OCFS2_IOC_INFO handles an array of requests passed from userspace.
421 *
422 * ocfs2_info_handle() recevies a large info aggregation, grab and
423 * validate the request count from header, then break it into small
424 * pieces, later specific handlers can handle them one by one.
425 *
426 * Idea here is to make each separate request small enough to ensure
427 * a better backward&forward compatibility, since a small piece of
428 * request will be less likely to be broken if disk layout get changed.
429 */
430int ocfs2_info_handle(struct inode *inode, struct ocfs2_info *info,
431 int compat_flag)
432{
433 int i, status = 0;
434 u64 req_addr;
435 struct ocfs2_info_request __user *reqp;
436
437 if ((info->oi_count > OCFS2_INFO_MAX_REQUEST) ||
438 (!info->oi_requests)) {
439 status = -EINVAL;
440 goto bail;
441 }
442
443 for (i = 0; i < info->oi_count; i++) {
444
445 status = ocfs2_get_request_ptr(info, i, &req_addr, compat_flag);
446 if (status)
447 break;
448
449 reqp = (struct ocfs2_info_request *)(unsigned long)req_addr;
450 if (!reqp) {
451 status = -EINVAL;
452 goto bail;
453 }
454
455 status = ocfs2_info_handle_request(inode, reqp);
456 if (status)
457 break;
458 }
459
460bail:
461 return status;
462}
463
Andi Kleenc9ec1482008-01-27 03:17:17 +0100464long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
Herbert Poetzlca4d1472006-07-03 17:27:12 -0700465{
Andi Kleenc9ec1482008-01-27 03:17:17 +0100466 struct inode *inode = filp->f_path.dentry->d_inode;
Herbert Poetzlca4d1472006-07-03 17:27:12 -0700467 unsigned int flags;
Tao Mad6590722007-12-18 15:47:03 +0800468 int new_clusters;
Herbert Poetzlca4d1472006-07-03 17:27:12 -0700469 int status;
Mark Fashehb2580102007-03-09 16:53:21 -0800470 struct ocfs2_space_resv sr;
Tao Ma7909f2b2007-12-18 15:47:25 +0800471 struct ocfs2_new_group_input input;
Tao Mabd508732009-09-21 11:25:14 +0800472 struct reflink_arguments args;
473 const char *old_path, *new_path;
474 bool preserve;
Tristan Yeddee5cd2010-05-22 16:26:33 +0800475 struct ocfs2_info info;
Herbert Poetzlca4d1472006-07-03 17:27:12 -0700476
477 switch (cmd) {
478 case OCFS2_IOC_GETFLAGS:
479 status = ocfs2_get_inode_attr(inode, &flags);
480 if (status < 0)
481 return status;
482
483 flags &= OCFS2_FL_VISIBLE;
484 return put_user(flags, (int __user *) arg);
485 case OCFS2_IOC_SETFLAGS:
486 if (get_user(flags, (int __user *) arg))
487 return -EFAULT;
488
Dave Hansen42a74f22008-02-15 14:37:46 -0800489 status = mnt_want_write(filp->f_path.mnt);
490 if (status)
491 return status;
492 status = ocfs2_set_inode_attr(inode, flags,
Herbert Poetzlca4d1472006-07-03 17:27:12 -0700493 OCFS2_FL_MODIFIABLE);
Dave Hansen42a74f22008-02-15 14:37:46 -0800494 mnt_drop_write(filp->f_path.mnt);
495 return status;
Mark Fashehb2580102007-03-09 16:53:21 -0800496 case OCFS2_IOC_RESVSP:
497 case OCFS2_IOC_RESVSP64:
498 case OCFS2_IOC_UNRESVSP:
499 case OCFS2_IOC_UNRESVSP64:
500 if (copy_from_user(&sr, (int __user *) arg, sizeof(sr)))
501 return -EFAULT;
502
503 return ocfs2_change_file_space(filp, cmd, &sr);
Tao Mad6590722007-12-18 15:47:03 +0800504 case OCFS2_IOC_GROUP_EXTEND:
Mark Fasheh0957f002007-12-18 18:58:18 -0800505 if (!capable(CAP_SYS_RESOURCE))
506 return -EPERM;
507
Tao Mad6590722007-12-18 15:47:03 +0800508 if (get_user(new_clusters, (int __user *)arg))
509 return -EFAULT;
510
511 return ocfs2_group_extend(inode, new_clusters);
Tao Ma7909f2b2007-12-18 15:47:25 +0800512 case OCFS2_IOC_GROUP_ADD:
513 case OCFS2_IOC_GROUP_ADD64:
Mark Fasheh0957f002007-12-18 18:58:18 -0800514 if (!capable(CAP_SYS_RESOURCE))
515 return -EPERM;
516
Tao Ma7909f2b2007-12-18 15:47:25 +0800517 if (copy_from_user(&input, (int __user *) arg, sizeof(input)))
518 return -EFAULT;
519
520 return ocfs2_group_add(inode, &input);
Tao Mabd508732009-09-21 11:25:14 +0800521 case OCFS2_IOC_REFLINK:
522 if (copy_from_user(&args, (struct reflink_arguments *)arg,
523 sizeof(args)))
524 return -EFAULT;
525 old_path = (const char *)(unsigned long)args.old_path;
526 new_path = (const char *)(unsigned long)args.new_path;
527 preserve = (args.preserve != 0);
528
529 return ocfs2_reflink_ioctl(inode, old_path, new_path, preserve);
Tristan Yeddee5cd2010-05-22 16:26:33 +0800530 case OCFS2_IOC_INFO:
531 if (copy_from_user(&info, (struct ocfs2_info __user *)arg,
532 sizeof(struct ocfs2_info)))
533 return -EFAULT;
534
535 return ocfs2_info_handle(inode, &info, 0);
Herbert Poetzlca4d1472006-07-03 17:27:12 -0700536 default:
537 return -ENOTTY;
538 }
539}
540
Mark Fasheh586d2322007-03-09 15:56:28 -0800541#ifdef CONFIG_COMPAT
542long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg)
543{
Tao Ma34e6c592010-01-27 10:21:52 +0800544 bool preserve;
545 struct reflink_arguments args;
546 struct inode *inode = file->f_path.dentry->d_inode;
Tristan Yeddee5cd2010-05-22 16:26:33 +0800547 struct ocfs2_info info;
Tao Ma34e6c592010-01-27 10:21:52 +0800548
Mark Fasheh586d2322007-03-09 15:56:28 -0800549 switch (cmd) {
550 case OCFS2_IOC32_GETFLAGS:
551 cmd = OCFS2_IOC_GETFLAGS;
552 break;
553 case OCFS2_IOC32_SETFLAGS:
554 cmd = OCFS2_IOC_SETFLAGS;
555 break;
Mark Fashehb2580102007-03-09 16:53:21 -0800556 case OCFS2_IOC_RESVSP:
557 case OCFS2_IOC_RESVSP64:
558 case OCFS2_IOC_UNRESVSP:
559 case OCFS2_IOC_UNRESVSP64:
Tao Mad6590722007-12-18 15:47:03 +0800560 case OCFS2_IOC_GROUP_EXTEND:
Tao Ma7909f2b2007-12-18 15:47:25 +0800561 case OCFS2_IOC_GROUP_ADD:
562 case OCFS2_IOC_GROUP_ADD64:
Mark Fashehb2580102007-03-09 16:53:21 -0800563 break;
Tao Ma34e6c592010-01-27 10:21:52 +0800564 case OCFS2_IOC_REFLINK:
565 if (copy_from_user(&args, (struct reflink_arguments *)arg,
566 sizeof(args)))
567 return -EFAULT;
568 preserve = (args.preserve != 0);
569
570 return ocfs2_reflink_ioctl(inode, compat_ptr(args.old_path),
571 compat_ptr(args.new_path), preserve);
Tristan Yeddee5cd2010-05-22 16:26:33 +0800572 case OCFS2_IOC_INFO:
573 if (copy_from_user(&info, (struct ocfs2_info __user *)arg,
574 sizeof(struct ocfs2_info)))
575 return -EFAULT;
576
577 return ocfs2_info_handle(inode, &info, 1);
Mark Fasheh586d2322007-03-09 15:56:28 -0800578 default:
579 return -ENOIOCTLCMD;
580 }
581
Andi Kleenc9ec1482008-01-27 03:17:17 +0100582 return ocfs2_ioctl(file, cmd, arg);
Mark Fasheh586d2322007-03-09 15:56:28 -0800583}
584#endif