]>
git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - fs/ext2/ioctl.c
2 * linux/fs/ext2/ioctl.c
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)
11 #include <linux/capability.h>
12 #include <linux/time.h>
13 #include <linux/sched.h>
14 #include <asm/current.h>
15 #include <asm/uaccess.h>
18 int ext2_ioctl (struct inode
* inode
, struct file
* filp
, unsigned int cmd
,
21 struct ext2_inode_info
*ei
= EXT2_I(inode
);
24 ext2_debug ("cmd = %u, arg = %lu\n", cmd
, arg
);
27 case EXT2_IOC_GETFLAGS
:
28 flags
= ei
->i_flags
& EXT2_FL_USER_VISIBLE
;
29 return put_user(flags
, (int __user
*) arg
);
30 case EXT2_IOC_SETFLAGS
: {
31 unsigned int oldflags
;
36 if ((current
->fsuid
!= inode
->i_uid
) && !capable(CAP_FOWNER
))
39 if (get_user(flags
, (int __user
*) arg
))
42 if (!S_ISDIR(inode
->i_mode
))
43 flags
&= ~EXT2_DIRSYNC_FL
;
45 oldflags
= ei
->i_flags
;
48 * The IMMUTABLE and APPEND_ONLY flags can only be changed by
49 * the relevant capability.
51 * This test looks nicer. Thanks to Pauline Middelink
53 if ((flags
^ oldflags
) & (EXT2_APPEND_FL
| EXT2_IMMUTABLE_FL
)) {
54 if (!capable(CAP_LINUX_IMMUTABLE
))
58 flags
= flags
& EXT2_FL_USER_MODIFIABLE
;
59 flags
|= oldflags
& ~EXT2_FL_USER_MODIFIABLE
;
62 ext2_set_inode_flags(inode
);
63 inode
->i_ctime
= CURRENT_TIME_SEC
;
64 mark_inode_dirty(inode
);
67 case EXT2_IOC_GETVERSION
:
68 return put_user(inode
->i_generation
, (int __user
*) arg
);
69 case EXT2_IOC_SETVERSION
:
70 if ((current
->fsuid
!= inode
->i_uid
) && !capable(CAP_FOWNER
))
74 if (get_user(inode
->i_generation
, (int __user
*) arg
))
76 inode
->i_ctime
= CURRENT_TIME_SEC
;
77 mark_inode_dirty(inode
);