OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [fs/] [ext2/] [ioctl.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * linux/fs/ext2/ioctl.c
3
 *
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)
8
 */
9
 
10
#include <linux/fs.h>
11
#include <linux/ext2_fs.h>
12
#include <linux/sched.h>
13
#include <asm/uaccess.h>
14
 
15
 
16
int ext2_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
17
                unsigned long arg)
18
{
19
        unsigned int flags;
20
 
21
        ext2_debug ("cmd = %u, arg = %lu\n", cmd, arg);
22
 
23
        switch (cmd) {
24
        case EXT2_IOC_GETFLAGS:
25
                flags = inode->u.ext2_i.i_flags & EXT2_FL_USER_VISIBLE;
26
                return put_user(flags, (int *) arg);
27
        case EXT2_IOC_SETFLAGS: {
28
                unsigned int oldflags;
29
 
30
                if (IS_RDONLY(inode))
31
                        return -EROFS;
32
 
33
                if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
34
                        return -EACCES;
35
 
36
                if (get_user(flags, (int *) arg))
37
                        return -EFAULT;
38
 
39
                oldflags = inode->u.ext2_i.i_flags;
40
 
41
                /*
42
                 * The IMMUTABLE and APPEND_ONLY flags can only be changed by
43
                 * the relevant capability.
44
                 *
45
                 * This test looks nicer. Thanks to Pauline Middelink
46
                 */
47
                if ((flags ^ oldflags) & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) {
48
                        if (!capable(CAP_LINUX_IMMUTABLE))
49
                                return -EPERM;
50
                }
51
 
52
                flags = flags & EXT2_FL_USER_MODIFIABLE;
53
                flags |= oldflags & ~EXT2_FL_USER_MODIFIABLE;
54
                inode->u.ext2_i.i_flags = flags;
55
 
56
                ext2_set_inode_flags(inode);
57
                inode->i_ctime = CURRENT_TIME;
58
                mark_inode_dirty(inode);
59
                return 0;
60
        }
61
        case EXT2_IOC_GETVERSION:
62
                return put_user(inode->i_generation, (int *) arg);
63
        case EXT2_IOC_SETVERSION:
64
                if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
65
                        return -EPERM;
66
                if (IS_RDONLY(inode))
67
                        return -EROFS;
68
                if (get_user(inode->i_generation, (int *) arg))
69
                        return -EFAULT;
70
                inode->i_ctime = CURRENT_TIME;
71
                mark_inode_dirty(inode);
72
                return 0;
73
        default:
74
                return -ENOTTY;
75
        }
76
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.