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 err = verify_area(VERIFY_WRITE, (int *) arg, sizeof(int));
30 if (err)
31 return err;
32 put_user(inode->u.ext2_i.i_flags, (int *) arg);
33 return 0;
34 case EXT2_IOC_SETFLAGS:
35 err = verify_area(VERIFY_READ, (int *) arg, sizeof(int));
36 if (err)
37 return err;
38 flags = get_user((int *) arg);
39
40
41
42
43 if ((flags & EXT2_IMMUTABLE_FL) ^
44 (inode->u.ext2_i.i_flags & EXT2_IMMUTABLE_FL)) {
45
46 if (!fsuser() || securelevel > 0)
47 return -EPERM;
48 } else
49 if ((current->fsuid != inode->i_uid) && !fsuser())
50 return -EPERM;
51 if (IS_RDONLY(inode))
52 return -EROFS;
53 inode->u.ext2_i.i_flags = flags;
54 if (flags & EXT2_APPEND_FL)
55 inode->i_flags |= S_APPEND;
56 else
57 inode->i_flags &= ~S_APPEND;
58 if (flags & EXT2_IMMUTABLE_FL)
59 inode->i_flags |= S_IMMUTABLE;
60 else
61 inode->i_flags &= ~S_IMMUTABLE;
62 inode->i_ctime = CURRENT_TIME;
63 inode->i_dirt = 1;
64 return 0;
65 case EXT2_IOC_GETVERSION:
66 err = verify_area(VERIFY_WRITE, (int *) arg, sizeof(int));
67 if (err)
68 return err;
69 put_user(inode->u.ext2_i.i_version, (int *) arg);
70 return 0;
71 case EXT2_IOC_SETVERSION:
72 if ((current->fsuid != inode->i_uid) && !fsuser())
73 return -EPERM;
74 if (IS_RDONLY(inode))
75 return -EROFS;
76 err = verify_area(VERIFY_READ, (int *) arg, sizeof(int));
77 if (err)
78 return err;
79 inode->u.ext2_i.i_version = get_user((int *) arg);
80 inode->i_ctime = CURRENT_TIME;
81 inode->i_dirt = 1;
82 return 0;
83 default:
84 return -EINVAL;
85 }
86 }