home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / KERNEL-S / V1.0 / LINUX-1.0 / LINUX-1 / linux / fs / ext2 / acl.c next >
Encoding:
C/C++ Source or Header  |  1993-12-31  |  940 b   |  46 lines

  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)
  26. {
  27.     unsigned short mode = inode->i_mode;
  28.  
  29.     /*
  30.      * Special case, access is always granted for root
  31.      */
  32.     if (suser ())
  33.         return 1;
  34.     /*
  35.      * If no ACL, checks using the file mode
  36.      */
  37.     else if (current->euid == inode->i_uid)
  38.         mode >>= 6;
  39.     else if (in_group_p (inode->i_gid))
  40.         mode >>= 3;
  41.     if (((mode & mask & S_IRWXO) == mask))
  42.         return 1;
  43.     else
  44.         return 0;
  45. }
  46.