]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/linux/posix_acl.h
arm/arm64: smccc: Implement SMCCC v1.1 inline primitive
[mirror_ubuntu-artful-kernel.git] / include / linux / posix_acl.h
CommitLineData
1da177e4
LT
1/*
2 File: linux/posix_acl.h
3
4 (C) 2002 Andreas Gruenbacher, <a.gruenbacher@computer.org>
5*/
6
7
8#ifndef __LINUX_POSIX_ACL_H
9#define __LINUX_POSIX_ACL_H
10
187f1882 11#include <linux/bug.h>
1da177e4 12#include <linux/slab.h>
3567866b 13#include <linux/rcupdate.h>
bc8bcf3b 14#include <uapi/linux/posix_acl.h>
1da177e4
LT
15
16struct posix_acl_entry {
17 short e_tag;
18 unsigned short e_perm;
2f6f0654
EB
19 union {
20 kuid_t e_uid;
21 kgid_t e_gid;
2f6f0654 22 };
1da177e4
LT
23};
24
25struct posix_acl {
6d4e56ce
JL
26 atomic_t a_refcount;
27 struct rcu_head a_rcu;
1da177e4
LT
28 unsigned int a_count;
29 struct posix_acl_entry a_entries[0];
30};
31
32#define FOREACH_ACL_ENTRY(pa, acl, pe) \
33 for(pa=(acl)->a_entries, pe=pa+(acl)->a_count; pa<pe; pa++)
34
35
36/*
37 * Duplicate an ACL handle.
38 */
39static inline struct posix_acl *
40posix_acl_dup(struct posix_acl *acl)
41{
42 if (acl)
43 atomic_inc(&acl->a_refcount);
44 return acl;
45}
46
47/*
48 * Free an ACL handle.
49 */
50static inline void
51posix_acl_release(struct posix_acl *acl)
52{
53 if (acl && atomic_dec_and_test(&acl->a_refcount))
3567866b 54 kfree_rcu(acl, a_rcu);
1da177e4
LT
55}
56
57
58/* posix_acl.c */
59
f61f6da0 60extern void posix_acl_init(struct posix_acl *, int);
dd0fc66f 61extern struct posix_acl *posix_acl_alloc(int, gfp_t);
0d4d717f 62extern int posix_acl_valid(struct user_namespace *, const struct posix_acl *);
1da177e4 63extern int posix_acl_permission(struct inode *, const struct posix_acl *, int);
3a5fba19 64extern struct posix_acl *posix_acl_from_mode(umode_t, gfp_t);
d6952123 65extern int posix_acl_equiv_mode(const struct posix_acl *, umode_t *);
37bc1539 66extern int __posix_acl_create(struct posix_acl **, gfp_t, umode_t *);
5bf3258f 67extern int __posix_acl_chmod(struct posix_acl **, gfp_t, umode_t);
1da177e4
LT
68
69extern struct posix_acl *get_posix_acl(struct inode *, int);
70extern int set_posix_acl(struct inode *, int, struct posix_acl *);
71
641cf4a6 72#ifdef CONFIG_FS_POSIX_ACL
37bc1539
CH
73extern int posix_acl_chmod(struct inode *, umode_t);
74extern int posix_acl_create(struct inode *, umode_t *, struct posix_acl **,
75 struct posix_acl **);
07393101 76extern int posix_acl_update_mode(struct inode *, umode_t *, struct posix_acl **);
5bf3258f 77
feda821e
CH
78extern int simple_set_acl(struct inode *, struct posix_acl *, int);
79extern int simple_acl_create(struct inode *, struct inode *);
80
0afaa120
AM
81struct posix_acl *get_cached_acl(struct inode *inode, int type);
82struct posix_acl *get_cached_acl_rcu(struct inode *inode, int type);
83void set_cached_acl(struct inode *inode, int type, struct posix_acl *acl);
84void forget_cached_acl(struct inode *inode, int type);
85void forget_all_cached_acls(struct inode *inode);
72c04902
AV
86
87static inline void cache_no_acl(struct inode *inode)
88{
72c04902
AV
89 inode->i_acl = NULL;
90 inode->i_default_acl = NULL;
72c04902 91}
5bf3258f 92#else
37bc1539 93static inline int posix_acl_chmod(struct inode *inode, umode_t mode)
5bf3258f
CH
94{
95 return 0;
96}
97
feda821e
CH
98#define simple_set_acl NULL
99
100static inline int simple_acl_create(struct inode *dir, struct inode *inode)
101{
102 return 0;
103}
5bf3258f
CH
104static inline void cache_no_acl(struct inode *inode)
105{
106}
37bc1539
CH
107
108static inline int posix_acl_create(struct inode *inode, umode_t *mode,
109 struct posix_acl **default_acl, struct posix_acl **acl)
110{
111 *default_acl = *acl = NULL;
112 return 0;
113}
013cdf10
CH
114
115static inline void forget_all_cached_acls(struct inode *inode)
116{
117}
5bf3258f 118#endif /* CONFIG_FS_POSIX_ACL */
72c04902 119
2982baa2 120struct posix_acl *get_acl(struct inode *inode, int type);
72c04902 121
1da177e4 122#endif /* __LINUX_POSIX_ACL_H */