root/fs/ext2/acl.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ext2_permission

   1 /*
   2  * linux/fs/ext2/acl.c
   3  *
   4  * Copyright (C) 1993, 1994  Remy Card (card@masi.ibp.fr)
   5  *                           Laboratoire MASI - Institut Blaise Pascal
   6  *                           Universite Pierre et Marie Curie (Paris VI)
   7  */
   8 
   9 /*
  10  * This file will contain the Access Control Lists management for the
  11  * second extended file system.
  12  */
  13 
  14 #include <linux/errno.h>
  15 #include <linux/fs.h>
  16 #include <linux/ext2_fs.h>
  17 #include <linux/sched.h>
  18 #include <linux/stat.h>
  19 
  20 /*
  21  * ext2_permission ()
  22  *
  23  * Check for access rights
  24  */
  25 int ext2_permission (struct inode * inode, int mask)
     /* [previous][next][first][last][top][bottom][index][help] */
  26 {
  27         unsigned short mode = inode->i_mode;
  28 
  29         /*
  30          * Nobody gets write access to an immutable file
  31          */
  32         if ((mask & S_IWOTH) && IS_IMMUTABLE(inode))
  33                 return -EACCES;
  34         /*
  35          * Special case, access is always granted for root
  36          */
  37         if (fsuser())
  38                 return 0;
  39         /*
  40          * If no ACL, checks using the file mode
  41          */
  42         else if (current->fsuid == inode->i_uid)
  43                 mode >>= 6;
  44         else if (in_group_p (inode->i_gid))
  45                 mode >>= 3;
  46         if (((mode & mask & S_IRWXO) == mask))
  47                 return 0;
  48         else
  49                 return -EACCES;
  50 }

/* [previous][next][first][last][top][bottom][index][help] */