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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [sw/] [uClinux/] [fs/] [ext2/] [ioctl.c] - Blame information for rev 1777

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1628 jcastillo
/*
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 <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
                 * The IMMUTABLE and APPEND_ONLY flags can only be changed by
41
                 * the super user when the security level is zero.
42
                 */
43
                if ((flags & (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL)) ^
44
                    (inode->u.ext2_i.i_flags &
45
                     (EXT2_APPEND_FL | EXT2_IMMUTABLE_FL))) {
46
                        /* This test looks nicer. Thanks to Pauline Middelink */
47
                        if (!fsuser() || securelevel > 0)
48
                                return -EPERM;
49
                } else
50
                        if ((current->fsuid != inode->i_uid) && !fsuser())
51
                                return -EPERM;
52
                if (IS_RDONLY(inode))
53
                        return -EROFS;
54
                inode->u.ext2_i.i_flags = flags;
55
                if (flags & EXT2_APPEND_FL)
56
                        inode->i_flags |= S_APPEND;
57
                else
58
                        inode->i_flags &= ~S_APPEND;
59
                if (flags & EXT2_IMMUTABLE_FL)
60
                        inode->i_flags |= S_IMMUTABLE;
61
                else
62
                        inode->i_flags &= ~S_IMMUTABLE;
63
                if (flags & EXT2_NOATIME_FL)
64
                        inode->i_flags |= MS_NOATIME;
65
                else
66
                        inode->i_flags &= ~MS_NOATIME;
67
                inode->i_ctime = CURRENT_TIME;
68
                inode->i_dirt = 1;
69
                return 0;
70
        case EXT2_IOC_GETVERSION:
71
                err = verify_area(VERIFY_WRITE, (int *) arg, sizeof(int));
72
                if (err)
73
                        return err;
74
                put_user(inode->u.ext2_i.i_version, (int *) arg);
75
                return 0;
76
        case EXT2_IOC_SETVERSION:
77
                if ((current->fsuid != inode->i_uid) && !fsuser())
78
                        return -EPERM;
79
                if (IS_RDONLY(inode))
80
                        return -EROFS;
81
                err = verify_area(VERIFY_READ, (int *) arg, sizeof(int));
82
                if (err)
83
                        return err;
84
                inode->u.ext2_i.i_version = get_user((int *) arg);
85
                inode->i_ctime = CURRENT_TIME;
86
                inode->i_dirt = 1;
87
                return 0;
88
        default:
89
                return -ENOTTY;
90
        }
91
}

powered by: WebSVN 2.1.0

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