blob: a57ff4e6d39a512f16b9be305a7499c53b5cdb33 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott7b718762005-11-02 14:58:39 +11002 * Copyright (c) 2001-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * 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 Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * 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 Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * 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 Torvalds1da177e2005-04-16 15:20:36 -070017 */
18#ifndef __XFS_ACL_H__
19#define __XFS_ACL_H__
20
21/*
22 * Access Control Lists
23 */
24typedef __uint16_t xfs_acl_perm_t;
25typedef __int32_t xfs_acl_type_t;
26typedef __int32_t xfs_acl_tag_t;
27typedef __int32_t xfs_acl_id_t;
28
29#define XFS_ACL_MAX_ENTRIES 25
30#define XFS_ACL_NOT_PRESENT (-1)
31
32typedef struct xfs_acl_entry {
33 xfs_acl_tag_t ae_tag;
34 xfs_acl_id_t ae_id;
35 xfs_acl_perm_t ae_perm;
36} xfs_acl_entry_t;
37
38typedef struct xfs_acl {
39 __int32_t acl_cnt;
40 xfs_acl_entry_t acl_entry[XFS_ACL_MAX_ENTRIES];
41} xfs_acl_t;
42
43/* On-disk XFS extended attribute names */
44#define SGI_ACL_FILE "SGI_ACL_FILE"
45#define SGI_ACL_DEFAULT "SGI_ACL_DEFAULT"
46#define SGI_ACL_FILE_SIZE (sizeof(SGI_ACL_FILE)-1)
47#define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1)
48
49
50#ifdef CONFIG_XFS_POSIX_ACL
51
52struct vattr;
Nathan Scott67fcaa72006-06-09 17:00:52 +100053struct bhv_vnode;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054struct xfs_inode;
55
56extern struct kmem_zone *xfs_acl_zone;
57#define xfs_acl_zone_init(zone, name) \
Nathan Scott3758dee2006-03-22 12:47:28 +110058 (zone) = kmem_zone_init(sizeof(xfs_acl_t), (name))
59#define xfs_acl_zone_destroy(zone) kmem_zone_destroy(zone)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Nathan Scott67fcaa72006-06-09 17:00:52 +100061extern int xfs_acl_inherit(struct bhv_vnode *, struct vattr *, xfs_acl_t *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062extern int xfs_acl_iaccess(struct xfs_inode *, mode_t, cred_t *);
Nathan Scott67fcaa72006-06-09 17:00:52 +100063extern int xfs_acl_vtoacl(struct bhv_vnode *, xfs_acl_t *, xfs_acl_t *);
64extern int xfs_acl_vhasacl_access(struct bhv_vnode *);
65extern int xfs_acl_vhasacl_default(struct bhv_vnode *);
66extern int xfs_acl_vset(struct bhv_vnode *, void *, size_t, int);
67extern int xfs_acl_vget(struct bhv_vnode *, void *, size_t, int);
68extern int xfs_acl_vremove(struct bhv_vnode *, int);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70#define _ACL_TYPE_ACCESS 1
71#define _ACL_TYPE_DEFAULT 2
72#define _ACL_PERM_INVALID(perm) ((perm) & ~(ACL_READ|ACL_WRITE|ACL_EXECUTE))
73
74#define _ACL_INHERIT(c,v,d) (xfs_acl_inherit(c,v,d))
75#define _ACL_GET_ACCESS(pv,pa) (xfs_acl_vtoacl(pv,pa,NULL) == 0)
76#define _ACL_GET_DEFAULT(pv,pd) (xfs_acl_vtoacl(pv,NULL,pd) == 0)
77#define _ACL_ACCESS_EXISTS xfs_acl_vhasacl_access
78#define _ACL_DEFAULT_EXISTS xfs_acl_vhasacl_default
79#define _ACL_XFS_IACCESS(i,m,c) (XFS_IFORK_Q(i) ? xfs_acl_iaccess(i,m,c) : -1)
80
81#define _ACL_ALLOC(a) ((a) = kmem_zone_alloc(xfs_acl_zone, KM_SLEEP))
82#define _ACL_FREE(a) ((a)? kmem_zone_free(xfs_acl_zone, (a)):(void)0)
83
84#else
85#define xfs_acl_zone_init(zone,name)
86#define xfs_acl_zone_destroy(zone)
87#define xfs_acl_vset(v,p,sz,t) (-EOPNOTSUPP)
88#define xfs_acl_vget(v,p,sz,t) (-EOPNOTSUPP)
89#define xfs_acl_vremove(v,t) (-EOPNOTSUPP)
90#define xfs_acl_vhasacl_access(v) (0)
91#define xfs_acl_vhasacl_default(v) (0)
92#define _ACL_ALLOC(a) (1) /* successfully allocate nothing */
93#define _ACL_FREE(a) ((void)0)
94#define _ACL_INHERIT(c,v,d) (0)
95#define _ACL_GET_ACCESS(pv,pa) (0)
96#define _ACL_GET_DEFAULT(pv,pd) (0)
97#define _ACL_ACCESS_EXISTS (NULL)
98#define _ACL_DEFAULT_EXISTS (NULL)
99#define _ACL_XFS_IACCESS(i,m,c) (-1)
100#endif
101
102#endif /* __XFS_ACL_H__ */