74
78
extern void posix_acl_init(struct posix_acl *, int);
75
79
extern struct posix_acl *posix_acl_alloc(int, gfp_t);
76
extern struct posix_acl *posix_acl_clone(const struct posix_acl *, gfp_t);
77
80
extern int posix_acl_valid(const struct posix_acl *);
78
81
extern int posix_acl_permission(struct inode *, const struct posix_acl *, int);
79
extern struct posix_acl *posix_acl_from_mode(mode_t, gfp_t);
80
extern int posix_acl_equiv_mode(const struct posix_acl *, mode_t *);
81
extern int posix_acl_create_masq(struct posix_acl *, mode_t *);
82
extern int posix_acl_chmod_masq(struct posix_acl *, mode_t);
82
extern struct posix_acl *posix_acl_from_mode(umode_t, gfp_t);
83
extern int posix_acl_equiv_mode(const struct posix_acl *, umode_t *);
84
extern int posix_acl_create(struct posix_acl **, gfp_t, umode_t *);
85
extern int posix_acl_chmod(struct posix_acl **, gfp_t, umode_t);
84
87
extern struct posix_acl *get_posix_acl(struct inode *, int);
85
88
extern int set_posix_acl(struct inode *, int, struct posix_acl *);
87
90
#ifdef CONFIG_FS_POSIX_ACL
91
static inline struct posix_acl **acl_by_type(struct inode *inode, int type)
96
case ACL_TYPE_DEFAULT:
97
return &inode->i_default_acl;
88
103
static inline struct posix_acl *get_cached_acl(struct inode *inode, int type)
90
struct posix_acl **p, *acl;
95
case ACL_TYPE_DEFAULT:
96
p = &inode->i_default_acl;
99
return ERR_PTR(-EINVAL);
101
acl = ACCESS_ONCE(*p);
105
struct posix_acl **p = acl_by_type(inode, type);
106
struct posix_acl *acl = ACCESS_ONCE(*p);
103
108
spin_lock(&inode->i_lock);
112
static inline int negative_cached_acl(struct inode *inode, int type)
117
static inline struct posix_acl *get_cached_acl_rcu(struct inode *inode, int type)
114
struct posix_acl **p, *acl;
116
case ACL_TYPE_ACCESS:
119
case ACL_TYPE_DEFAULT:
120
p = &inode->i_default_acl;
125
acl = ACCESS_ONCE(*p);
119
return rcu_dereference(*acl_by_type(inode, type));
131
122
static inline void set_cached_acl(struct inode *inode,
133
124
struct posix_acl *acl)
135
struct posix_acl *old = NULL;
126
struct posix_acl **p = acl_by_type(inode, type);
127
struct posix_acl *old;
136
128
spin_lock(&inode->i_lock);
138
case ACL_TYPE_ACCESS:
140
inode->i_acl = posix_acl_dup(acl);
142
case ACL_TYPE_DEFAULT:
143
old = inode->i_default_acl;
144
inode->i_default_acl = posix_acl_dup(acl);
130
rcu_assign_pointer(*p, posix_acl_dup(acl));
147
131
spin_unlock(&inode->i_lock);
148
132
if (old != ACL_NOT_CACHED)
149
133
posix_acl_release(old);
152
136
static inline void forget_cached_acl(struct inode *inode, int type)
154
struct posix_acl *old = NULL;
138
struct posix_acl **p = acl_by_type(inode, type);
139
struct posix_acl *old;
155
140
spin_lock(&inode->i_lock);
157
case ACL_TYPE_ACCESS:
159
inode->i_acl = ACL_NOT_CACHED;
161
case ACL_TYPE_DEFAULT:
162
old = inode->i_default_acl;
163
inode->i_default_acl = ACL_NOT_CACHED;
166
143
spin_unlock(&inode->i_lock);
167
144
if (old != ACL_NOT_CACHED)
168
145
posix_acl_release(old);