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 if ((flags & EXT2_IMMUTABLE_FL) ^
39 (inode->u.ext2_i.i_flags & EXT2_IMMUTABLE_FL)) {
40
41 if (!fsuser())
42 return -EPERM;
43 } else
44 if ((current->fsuid != inode->i_uid) && !fsuser())
45 return -EPERM;
46 if (IS_RDONLY(inode))
47 return -EROFS;
48 inode->u.ext2_i.i_flags = flags;
49 if (flags & EXT2_APPEND_FL)
50 inode->i_flags |= S_APPEND;
51 else
52 inode->i_flags &= ~S_APPEND;
53 if (flags & EXT2_IMMUTABLE_FL)
54 inode->i_flags |= S_IMMUTABLE;
55 else
56 inode->i_flags &= ~S_IMMUTABLE;
57 inode->i_ctime = CURRENT_TIME;
58 inode->i_dirt = 1;
59 return 0;
60 case EXT2_IOC_GETVERSION:
61 if ((err = verify_area (VERIFY_WRITE, (long *) arg, sizeof(long))))
62 return err;
63 put_fs_long (inode->u.ext2_i.i_version, (long *) arg);
64 return 0;
65 case EXT2_IOC_SETVERSION:
66 if ((current->fsuid != inode->i_uid) && !fsuser())
67 return -EPERM;
68 if (IS_RDONLY(inode))
69 return -EROFS;
70 inode->u.ext2_i.i_version = get_fs_long ((long *) arg);
71 inode->i_ctime = CURRENT_TIME;
72 inode->i_dirt = 1;
73 return 0;
74 default:
75 return -EINVAL;
76 }
77 }