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, 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)
     /* [previous][next][first][last][top][bottom][index][help] */
  27 {
  28         unsigned short mode = inode->i_mode;
  29 
  30         /*
  31          * Nobody gets write access to an immutable file
  32          */
  33         if ((mask & S_IWOTH) && IS_IMMUTABLE(inode))
  34                 return -EACCES;
  35         /*
  36          * Special case, access is always granted for root
  37          */
  38         if (fsuser())
  39                 return 0;
  40         /*
  41          * If no ACL, checks using the file mode
  42          */
  43         else if (current->fsuid == inode->i_uid)
  44                 mode >>= 6;
  45         else if (in_group_p (inode->i_gid))
  46                 mode >>= 3;
  47         if (((mode & mask & S_IRWXO) == mask))
  48                 return 0;
  49         else
  50                 return -EACCES;
  51 }

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