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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [fs/] [ext2/] [acl.c] - Blame information for rev 199

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

Line No. Rev Author Line
1 199 simons
/*
2
 * linux/fs/ext2/acl.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
/*
11
 * This file will contain the Access Control Lists management for the
12
 * second extended file system.
13
 */
14
 
15
#include <linux/errno.h>
16
#include <linux/fs.h>
17
#include <linux/ext2_fs.h>
18
#include <linux/sched.h>
19
#include <linux/stat.h>
20
 
21
/*
22
 * ext2_permission ()
23
 *
24
 * Check for access rights
25
 */
26
int ext2_permission (struct inode * inode, int mask)
27
{
28
        unsigned short mode = inode->i_mode;
29
 
30
        /*
31
         * Nobody gets write access to a file on a readonly-fs
32
         */
33
        if ((mask & S_IWOTH) &&
34
            (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) &&
35
            IS_RDONLY(inode))
36
                return -EROFS;
37
        /*
38
         * Nobody gets write access to an immutable file
39
         */
40
        if ((mask & S_IWOTH) && IS_IMMUTABLE(inode))
41
                return -EACCES;
42
        /*
43
         * Special case, access is always granted for root
44
         */
45
        if (fsuser())
46
                return 0;
47
        /*
48
         * If no ACL, checks using the file mode
49
         */
50
        else if (current->fsuid == inode->i_uid)
51
                mode >>= 6;
52
        else if (in_group_p (inode->i_gid))
53
                mode >>= 3;
54
        if (((mode & mask & S_IRWXO) == mask))
55
                return 0;
56
        else
57
                return -EACCES;
58
}

powered by: WebSVN 2.1.0

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