~ubuntu-branches/ubuntu/lucid/linux-rt/lucid

« back to all changes in this revision

Viewing changes to fs/ext4/acl.c

  • Committer: Bazaar Package Importer
  • Author(s): Luke Yelavich
  • Date: 2009-08-05 23:00:52 UTC
  • Revision ID: james.westby@ubuntu.com-20090805230052-7xedvqcyk9dnnxb2
Tags: 2.6.31-1.1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
        return ERR_PTR(-EINVAL);
127
127
}
128
128
 
129
 
static inline struct posix_acl *
130
 
ext4_iget_acl(struct inode *inode, struct posix_acl **i_acl)
131
 
{
132
 
        struct posix_acl *acl = EXT4_ACL_NOT_CACHED;
133
 
 
134
 
        spin_lock(&inode->i_lock);
135
 
        if (*i_acl != EXT4_ACL_NOT_CACHED)
136
 
                acl = posix_acl_dup(*i_acl);
137
 
        spin_unlock(&inode->i_lock);
138
 
 
139
 
        return acl;
140
 
}
141
 
 
142
 
static inline void
143
 
ext4_iset_acl(struct inode *inode, struct posix_acl **i_acl,
144
 
                struct posix_acl *acl)
145
 
{
146
 
        spin_lock(&inode->i_lock);
147
 
        if (*i_acl != EXT4_ACL_NOT_CACHED)
148
 
                posix_acl_release(*i_acl);
149
 
        *i_acl = posix_acl_dup(acl);
150
 
        spin_unlock(&inode->i_lock);
151
 
}
152
 
 
153
129
/*
154
130
 * Inode operation get_posix_acl().
155
131
 *
158
134
static struct posix_acl *
159
135
ext4_get_acl(struct inode *inode, int type)
160
136
{
161
 
        struct ext4_inode_info *ei = EXT4_I(inode);
162
137
        int name_index;
163
138
        char *value = NULL;
164
139
        struct posix_acl *acl;
167
142
        if (!test_opt(inode->i_sb, POSIX_ACL))
168
143
                return NULL;
169
144
 
 
145
        acl = get_cached_acl(inode, type);
 
146
        if (acl != ACL_NOT_CACHED)
 
147
                return acl;
 
148
 
170
149
        switch (type) {
171
150
        case ACL_TYPE_ACCESS:
172
 
                acl = ext4_iget_acl(inode, &ei->i_acl);
173
 
                if (acl != EXT4_ACL_NOT_CACHED)
174
 
                        return acl;
175
151
                name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS;
176
152
                break;
177
 
 
178
153
        case ACL_TYPE_DEFAULT:
179
 
                acl = ext4_iget_acl(inode, &ei->i_default_acl);
180
 
                if (acl != EXT4_ACL_NOT_CACHED)
181
 
                        return acl;
182
154
                name_index = EXT4_XATTR_INDEX_POSIX_ACL_DEFAULT;
183
155
                break;
184
 
 
185
156
        default:
186
 
                return ERR_PTR(-EINVAL);
 
157
                BUG();
187
158
        }
188
159
        retval = ext4_xattr_get(inode, name_index, "", NULL, 0);
189
160
        if (retval > 0) {
200
171
                acl = ERR_PTR(retval);
201
172
        kfree(value);
202
173
 
203
 
        if (!IS_ERR(acl)) {
204
 
                switch (type) {
205
 
                case ACL_TYPE_ACCESS:
206
 
                        ext4_iset_acl(inode, &ei->i_acl, acl);
207
 
                        break;
 
174
        if (!IS_ERR(acl))
 
175
                set_cached_acl(inode, type, acl);
208
176
 
209
 
                case ACL_TYPE_DEFAULT:
210
 
                        ext4_iset_acl(inode, &ei->i_default_acl, acl);
211
 
                        break;
212
 
                }
213
 
        }
214
177
        return acl;
215
178
}
216
179
 
223
186
ext4_set_acl(handle_t *handle, struct inode *inode, int type,
224
187
             struct posix_acl *acl)
225
188
{
226
 
        struct ext4_inode_info *ei = EXT4_I(inode);
227
189
        int name_index;
228
190
        void *value = NULL;
229
191
        size_t size = 0;
268
230
                                      value, size, 0);
269
231
 
270
232
        kfree(value);
271
 
        if (!error) {
272
 
                switch (type) {
273
 
                case ACL_TYPE_ACCESS:
274
 
                        ext4_iset_acl(inode, &ei->i_acl, acl);
275
 
                        break;
 
233
        if (!error)
 
234
                set_cached_acl(inode, type, acl);
276
235
 
277
 
                case ACL_TYPE_DEFAULT:
278
 
                        ext4_iset_acl(inode, &ei->i_default_acl, acl);
279
 
                        break;
280
 
                }
281
 
        }
282
236
        return error;
283
237
}
284
238
 
323
277
                                return PTR_ERR(acl);
324
278
                }
325
279
                if (!acl)
326
 
                        inode->i_mode &= ~current->fs->umask;
 
280
                        inode->i_mode &= ~current_umask();
327
281
        }
328
282
        if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
329
283
                struct posix_acl *clone;