This source file includes following definitions.
- ext2_ioctl
1
2
3
4
5
6
7
8
9
10 #include <asm/segment.h>
11
12 #include <linux/errno.h>
13 #include <linux/fs.h>
14 #include <linux/ext2_fs.h>
15 #include <linux/ioctl.h>
16 #include <linux/sched.h>
17 #include <linux/mm.h>
18
19 int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
20 unsigned long arg)
21 {
22 int err;
23 unsigned long flags;
24
25 ext2_debug ("cmd = %u, arg = %lu\n", cmd, arg);
26
27 switch (cmd) {
28 case EXT2_IOC_GETFLAGS:
29 if ((err = verify_area (VERIFY_WRITE, (long *) arg, sizeof(long))))
30 return err;
31 put_fs_long (inode->u.ext2_i.i_flags, (long *) arg);
32 return 0;
33 case EXT2_IOC_SETFLAGS:
34 flags = get_fs_long ((long *) arg);
35
36
37
38
39 if ((flags & EXT2_IMMUTABLE_FL) ^
40 (inode->u.ext2_i.i_flags & EXT2_IMMUTABLE_FL)) {
41
42 if (!fsuser() || securelevel > 0)
43 return -EPERM;
44 } else
45 if ((current->fsuid != inode->i_uid) && !fsuser())
46 return -EPERM;
47 if (IS_RDONLY(inode))
48 return -EROFS;
49 inode->u.ext2_i.i_flags = flags;
50 if (flags & EXT2_APPEND_FL)
51 inode->i_flags |= S_APPEND;
52 else
53 inode->i_flags &= ~S_APPEND;
54 if (flags & EXT2_IMMUTABLE_FL)
55 inode->i_flags |= S_IMMUTABLE;
56 else
57 inode->i_flags &= ~S_IMMUTABLE;
58 inode->i_ctime = CURRENT_TIME;
59 inode->i_dirt = 1;
60 return 0;
61 case EXT2_IOC_GETVERSION:
62 if ((err = verify_area (VERIFY_WRITE, (long *) arg, sizeof(long))))
63 return err;
64 put_fs_long (inode->u.ext2_i.i_version, (long *) arg);
65 return 0;
66 case EXT2_IOC_SETVERSION:
67 if ((current->fsuid != inode->i_uid) && !fsuser())
68 return -EPERM;
69 if (IS_RDONLY(inode))
70 return -EROFS;
71 inode->u.ext2_i.i_version = get_fs_long ((long *) arg);
72 inode->i_ctime = CURRENT_TIME;
73 inode->i_dirt = 1;
74 return 0;
75 default:
76 return -EINVAL;
77 }
78 }