~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise-security

« back to all changes in this revision

Viewing changes to include/linux/posix_acl.h

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati
  • Date: 2011-12-06 15:56:07 UTC
  • Revision ID: package-import@ubuntu.com-20111206155607-pcf44kv5fmhk564f
Tags: 3.2.0-1401.1
[ Paolo Pisati ]

* Rebased on top of Ubuntu-3.2.0-3.8
* Tilt-tracking @ ef2487af4bb15bdd0689631774b5a5e3a59f74e2
* Delete debian.ti-omap4/control, it shoudln't be tracked
* Fix architecture spelling (s/armel/armhf/)
* [Config] Update configs following 3.2 import
* [Config] Fix compilation: disable CODA and ARCH_OMAP3
* [Config] Fix compilation: disable Ethernet Faraday
* Update series to precise

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
#define __LINUX_POSIX_ACL_H
10
10
 
11
11
#include <linux/slab.h>
 
12
#include <linux/rcupdate.h>
12
13
 
13
14
#define ACL_UNDEFINED_ID        (-1)
14
15
 
38
39
};
39
40
 
40
41
struct posix_acl {
41
 
        atomic_t                a_refcount;
 
42
        union {
 
43
                atomic_t                a_refcount;
 
44
                struct rcu_head         a_rcu;
 
45
        };
42
46
        unsigned int            a_count;
43
47
        struct posix_acl_entry  a_entries[0];
44
48
};
65
69
posix_acl_release(struct posix_acl *acl)
66
70
{
67
71
        if (acl && atomic_dec_and_test(&acl->a_refcount))
68
 
                kfree(acl);
 
72
                kfree_rcu(acl, a_rcu);
69
73
}
70
74
 
71
75
 
73
77
 
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);
83
86
 
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 *);
86
89
 
87
90
#ifdef CONFIG_FS_POSIX_ACL
 
91
static inline struct posix_acl **acl_by_type(struct inode *inode, int type)
 
92
{
 
93
        switch (type) {
 
94
        case ACL_TYPE_ACCESS:
 
95
                return &inode->i_acl;
 
96
        case ACL_TYPE_DEFAULT:
 
97
                return &inode->i_default_acl;
 
98
        default:
 
99
                BUG();
 
100
        }
 
101
}
 
102
 
88
103
static inline struct posix_acl *get_cached_acl(struct inode *inode, int type)
89
104
{
90
 
        struct posix_acl **p, *acl;
91
 
        switch (type) {
92
 
        case ACL_TYPE_ACCESS:
93
 
                p = &inode->i_acl;
94
 
                break;
95
 
        case ACL_TYPE_DEFAULT:
96
 
                p = &inode->i_default_acl;
97
 
                break;
98
 
        default:
99
 
                return ERR_PTR(-EINVAL);
100
 
        }
101
 
        acl = ACCESS_ONCE(*p);
 
105
        struct posix_acl **p = acl_by_type(inode, type);
 
106
        struct posix_acl *acl = ACCESS_ONCE(*p);
102
107
        if (acl) {
103
108
                spin_lock(&inode->i_lock);
104
109
                acl = *p;
109
114
        return acl;
110
115
}
111
116
 
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)
113
118
{
114
 
        struct posix_acl **p, *acl;
115
 
        switch (type) {
116
 
        case ACL_TYPE_ACCESS:
117
 
                p = &inode->i_acl;
118
 
                break;
119
 
        case ACL_TYPE_DEFAULT:
120
 
                p = &inode->i_default_acl;
121
 
                break;
122
 
        default:
123
 
                BUG();
124
 
        }
125
 
        acl = ACCESS_ONCE(*p);
126
 
        if (acl)
127
 
                return 0;
128
 
        return 1;
 
119
        return rcu_dereference(*acl_by_type(inode, type));
129
120
}
130
121
 
131
122
static inline void set_cached_acl(struct inode *inode,
132
123
                                  int type,
133
124
                                  struct posix_acl *acl)
134
125
{
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);
137
 
        switch (type) {
138
 
        case ACL_TYPE_ACCESS:
139
 
                old = inode->i_acl;
140
 
                inode->i_acl = posix_acl_dup(acl);
141
 
                break;
142
 
        case ACL_TYPE_DEFAULT:
143
 
                old = inode->i_default_acl;
144
 
                inode->i_default_acl = posix_acl_dup(acl);
145
 
                break;
146
 
        }
 
129
        old = *p;
 
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);
151
135
 
152
136
static inline void forget_cached_acl(struct inode *inode, int type)
153
137
{
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);
156
 
        switch (type) {
157
 
        case ACL_TYPE_ACCESS:
158
 
                old = inode->i_acl;
159
 
                inode->i_acl = ACL_NOT_CACHED;
160
 
                break;
161
 
        case ACL_TYPE_DEFAULT:
162
 
                old = inode->i_default_acl;
163
 
                inode->i_default_acl = ACL_NOT_CACHED;
164
 
                break;
165
 
        }
 
141
        old = *p;
 
142
        *p = ACL_NOT_CACHED;
166
143
        spin_unlock(&inode->i_lock);
167
144
        if (old != ACL_NOT_CACHED)
168
145
                posix_acl_release(old);