| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 2 | * Copyright (c) 2001-2005 Silicon Graphics, Inc. | 
|  | 3 | * All Rights Reserved. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 5 | * This program is free software; you can redistribute it and/or | 
|  | 6 | * modify it under the terms of the GNU General Public License as | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * published by the Free Software Foundation. | 
|  | 8 | * | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 9 | * This program is distributed in the hope that it would be useful, | 
|  | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 12 | * GNU General Public License for more details. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * | 
| Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 14 | * You should have received a copy of the GNU General Public License | 
|  | 15 | * along with this program; if not, write the Free Software Foundation, | 
|  | 16 | * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ | 
|  | 18 | #ifndef __XFS_ACL_H__ | 
|  | 19 | #define __XFS_ACL_H__ | 
|  | 20 |  | 
|  | 21 | /* | 
|  | 22 | * Access Control Lists | 
|  | 23 | */ | 
|  | 24 | typedef __uint16_t	xfs_acl_perm_t; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | typedef __int32_t	xfs_acl_tag_t; | 
|  | 26 | typedef __int32_t	xfs_acl_id_t; | 
|  | 27 |  | 
|  | 28 | #define XFS_ACL_MAX_ENTRIES 25 | 
|  | 29 | #define XFS_ACL_NOT_PRESENT (-1) | 
|  | 30 |  | 
|  | 31 | typedef struct xfs_acl_entry { | 
|  | 32 | xfs_acl_tag_t	ae_tag; | 
|  | 33 | xfs_acl_id_t	ae_id; | 
|  | 34 | xfs_acl_perm_t	ae_perm; | 
|  | 35 | } xfs_acl_entry_t; | 
|  | 36 |  | 
|  | 37 | typedef struct xfs_acl { | 
|  | 38 | __int32_t	acl_cnt; | 
|  | 39 | xfs_acl_entry_t	acl_entry[XFS_ACL_MAX_ENTRIES]; | 
|  | 40 | } xfs_acl_t; | 
|  | 41 |  | 
|  | 42 | /* On-disk XFS extended attribute names */ | 
|  | 43 | #define SGI_ACL_FILE	"SGI_ACL_FILE" | 
|  | 44 | #define SGI_ACL_DEFAULT	"SGI_ACL_DEFAULT" | 
|  | 45 | #define SGI_ACL_FILE_SIZE	(sizeof(SGI_ACL_FILE)-1) | 
|  | 46 | #define SGI_ACL_DEFAULT_SIZE	(sizeof(SGI_ACL_DEFAULT)-1) | 
|  | 47 |  | 
| Tim Shimmin | 136f8f2 | 2008-06-27 13:34:42 +1000 | [diff] [blame] | 48 | #define _ACL_TYPE_ACCESS	1 | 
|  | 49 | #define _ACL_TYPE_DEFAULT	2 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 |  | 
|  | 51 | #ifdef CONFIG_XFS_POSIX_ACL | 
|  | 52 |  | 
|  | 53 | struct vattr; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | struct xfs_inode; | 
|  | 55 |  | 
|  | 56 | extern struct kmem_zone *xfs_acl_zone; | 
|  | 57 | #define xfs_acl_zone_init(zone, name)	\ | 
| Nathan Scott | 3758dee | 2006-03-22 12:47:28 +1100 | [diff] [blame] | 58 | (zone) = kmem_zone_init(sizeof(xfs_acl_t), (name)) | 
|  | 59 | #define xfs_acl_zone_destroy(zone)	kmem_zone_destroy(zone) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 |  | 
| Christoph Hellwig | 5ec7f8c | 2008-08-13 16:22:40 +1000 | [diff] [blame] | 61 | extern int xfs_acl_inherit(struct inode *, mode_t mode, xfs_acl_t *); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | extern int xfs_acl_iaccess(struct xfs_inode *, mode_t, cred_t *); | 
| Christoph Hellwig | 5ec7f8c | 2008-08-13 16:22:40 +1000 | [diff] [blame] | 63 | extern int xfs_acl_vtoacl(struct inode *, xfs_acl_t *, xfs_acl_t *); | 
|  | 64 | extern int xfs_acl_vhasacl_access(struct inode *); | 
|  | 65 | extern int xfs_acl_vhasacl_default(struct inode *); | 
|  | 66 | extern int xfs_acl_vset(struct inode *, void *, size_t, int); | 
|  | 67 | extern int xfs_acl_vget(struct inode *, void *, size_t, int); | 
|  | 68 | extern int xfs_acl_vremove(struct inode *, int); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | #define _ACL_PERM_INVALID(perm)	((perm) & ~(ACL_READ|ACL_WRITE|ACL_EXECUTE)) | 
|  | 71 |  | 
| Christoph Hellwig | 3e5daf0 | 2007-10-11 18:09:12 +1000 | [diff] [blame] | 72 | #define _ACL_INHERIT(c,m,d)	(xfs_acl_inherit(c,m,d)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | #define _ACL_GET_ACCESS(pv,pa)	(xfs_acl_vtoacl(pv,pa,NULL) == 0) | 
|  | 74 | #define _ACL_GET_DEFAULT(pv,pd)	(xfs_acl_vtoacl(pv,NULL,pd) == 0) | 
|  | 75 | #define _ACL_ACCESS_EXISTS	xfs_acl_vhasacl_access | 
|  | 76 | #define _ACL_DEFAULT_EXISTS	xfs_acl_vhasacl_default | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 |  | 
|  | 78 | #define _ACL_ALLOC(a)		((a) = kmem_zone_alloc(xfs_acl_zone, KM_SLEEP)) | 
|  | 79 | #define _ACL_FREE(a)		((a)? kmem_zone_free(xfs_acl_zone, (a)):(void)0) | 
|  | 80 |  | 
|  | 81 | #else | 
|  | 82 | #define xfs_acl_zone_init(zone,name) | 
|  | 83 | #define xfs_acl_zone_destroy(zone) | 
|  | 84 | #define xfs_acl_vset(v,p,sz,t)	(-EOPNOTSUPP) | 
|  | 85 | #define xfs_acl_vget(v,p,sz,t)	(-EOPNOTSUPP) | 
|  | 86 | #define xfs_acl_vremove(v,t)	(-EOPNOTSUPP) | 
|  | 87 | #define xfs_acl_vhasacl_access(v)	(0) | 
|  | 88 | #define xfs_acl_vhasacl_default(v)	(0) | 
|  | 89 | #define _ACL_ALLOC(a)		(1)	/* successfully allocate nothing */ | 
|  | 90 | #define _ACL_FREE(a)		((void)0) | 
| Christoph Hellwig | 3e5daf0 | 2007-10-11 18:09:12 +1000 | [diff] [blame] | 91 | #define _ACL_INHERIT(c,m,d)	(0) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | #define _ACL_GET_ACCESS(pv,pa)	(0) | 
|  | 93 | #define _ACL_GET_DEFAULT(pv,pd)	(0) | 
|  | 94 | #define _ACL_ACCESS_EXISTS	(NULL) | 
|  | 95 | #define _ACL_DEFAULT_EXISTS	(NULL) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | #endif | 
|  | 97 |  | 
|  | 98 | #endif	/* __XFS_ACL_H__ */ |