blob: d92a1dc6ee70f66ea8f95838598a859365e5cf64 [file] [log] [blame]
Randy Dunlap16f7e0f2006-01-11 12:17:46 -08001#include <linux/capability.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#include <linux/fs.h>
3#include <linux/posix_acl.h>
Al Virof466c6f2012-03-17 01:16:43 -04004#include "reiserfs.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -07005#include <linux/errno.h>
6#include <linux/pagemap.h>
7#include <linux/xattr.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +09008#include <linux/slab.h>
Christoph Hellwig9a59f452005-06-23 00:10:19 -07009#include <linux/posix_acl_xattr.h>
Al Viroc45ac882012-03-17 00:59:06 -040010#include "xattr.h"
Al Viroa3063ab2012-03-17 01:03:10 -040011#include "acl.h"
Fabian Frederick170939912014-08-08 14:21:12 -070012#include <linux/uaccess.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Christoph Hellwig47f70d02013-12-20 05:16:49 -080014static int __reiserfs_set_acl(struct reiserfs_transaction_handle *th,
Jeff Mahoney0ab26212009-03-30 14:02:39 -040015 struct inode *inode, int type,
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070016 struct posix_acl *acl);
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
Christoph Hellwig47f70d02013-12-20 05:16:49 -080018
19int
20reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -070021{
Jeff Mahoney0ab26212009-03-30 14:02:39 -040022 int error, error2;
23 struct reiserfs_transaction_handle th;
24 size_t jcreate_blocks;
Christoph Hellwig47f70d02013-12-20 05:16:49 -080025 int size = acl ? posix_acl_xattr_size(acl->a_count) : 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
Jeff Mahoney098297b2014-04-23 10:00:36 -040028 /*
29 * Pessimism: We can't assume that anything from the xattr root up
30 * has been created.
31 */
Jeff Mahoney0ab26212009-03-30 14:02:39 -040032
33 jcreate_blocks = reiserfs_xattr_jcreate_nblocks(inode) +
34 reiserfs_xattr_nblocks(inode, size) * 2;
35
36 reiserfs_write_lock(inode->i_sb);
37 error = journal_begin(&th, inode->i_sb, jcreate_blocks);
Jeff Mahoney4c051412013-08-08 17:27:19 -040038 reiserfs_write_unlock(inode->i_sb);
Jeff Mahoney0ab26212009-03-30 14:02:39 -040039 if (error == 0) {
Jan Kara6883cd72017-06-22 09:32:49 +020040 if (type == ACL_TYPE_ACCESS && acl) {
41 error = posix_acl_update_mode(inode, &inode->i_mode,
42 &acl);
43 if (error)
44 goto unlock;
45 }
Christoph Hellwig47f70d02013-12-20 05:16:49 -080046 error = __reiserfs_set_acl(&th, inode, type, acl);
Jan Kara6883cd72017-06-22 09:32:49 +020047unlock:
Jeff Mahoney4c051412013-08-08 17:27:19 -040048 reiserfs_write_lock(inode->i_sb);
Jeff Mahoney58d85422014-04-23 10:00:38 -040049 error2 = journal_end(&th);
Jeff Mahoney4c051412013-08-08 17:27:19 -040050 reiserfs_write_unlock(inode->i_sb);
Jeff Mahoney0ab26212009-03-30 14:02:39 -040051 if (error2)
52 error = error2;
53 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 return error;
56}
57
Linus Torvalds1da177e2005-04-16 15:20:36 -070058/*
59 * Convert from filesystem to in-memory representation.
60 */
Christoph Hellwig9dad9432013-12-20 05:16:36 -080061static struct posix_acl *reiserfs_posix_acl_from_disk(const void *value, size_t size)
Linus Torvalds1da177e2005-04-16 15:20:36 -070062{
63 const char *end = (char *)value + size;
64 int n, count;
65 struct posix_acl *acl;
66
67 if (!value)
68 return NULL;
69 if (size < sizeof(reiserfs_acl_header))
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070070 return ERR_PTR(-EINVAL);
71 if (((reiserfs_acl_header *) value)->a_version !=
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 cpu_to_le32(REISERFS_ACL_VERSION))
73 return ERR_PTR(-EINVAL);
74 value = (char *)value + sizeof(reiserfs_acl_header);
75 count = reiserfs_acl_count(size);
76 if (count < 0)
77 return ERR_PTR(-EINVAL);
78 if (count == 0)
79 return NULL;
80 acl = posix_acl_alloc(count, GFP_NOFS);
81 if (!acl)
82 return ERR_PTR(-ENOMEM);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070083 for (n = 0; n < count; n++) {
84 reiserfs_acl_entry *entry = (reiserfs_acl_entry *) value;
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 if ((char *)value + sizeof(reiserfs_acl_entry_short) > end)
86 goto fail;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070087 acl->a_entries[n].e_tag = le16_to_cpu(entry->e_tag);
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 acl->a_entries[n].e_perm = le16_to_cpu(entry->e_perm);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070089 switch (acl->a_entries[n].e_tag) {
90 case ACL_USER_OBJ:
91 case ACL_GROUP_OBJ:
92 case ACL_MASK:
93 case ACL_OTHER:
94 value = (char *)value +
95 sizeof(reiserfs_acl_entry_short);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070096 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
Linus Torvaldsbd4c6252005-07-12 20:21:28 -070098 case ACL_USER:
Eric W. Biedermandf814652012-02-07 16:30:06 -080099 value = (char *)value + sizeof(reiserfs_acl_entry);
100 if ((char *)value > end)
101 goto fail;
102 acl->a_entries[n].e_uid =
103 make_kuid(&init_user_ns,
104 le32_to_cpu(entry->e_id));
105 break;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700106 case ACL_GROUP:
107 value = (char *)value + sizeof(reiserfs_acl_entry);
108 if ((char *)value > end)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 goto fail;
Eric W. Biedermandf814652012-02-07 16:30:06 -0800110 acl->a_entries[n].e_gid =
111 make_kgid(&init_user_ns,
112 le32_to_cpu(entry->e_id));
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700113 break;
114
115 default:
116 goto fail;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 }
118 }
119 if (value != end)
120 goto fail;
121 return acl;
122
Jeff Mahoneycf776a72014-04-23 10:00:41 -0400123fail:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 posix_acl_release(acl);
125 return ERR_PTR(-EINVAL);
126}
127
128/*
129 * Convert from in-memory to filesystem representation.
130 */
Christoph Hellwig9dad9432013-12-20 05:16:36 -0800131static void *reiserfs_posix_acl_to_disk(const struct posix_acl *acl, size_t * size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132{
133 reiserfs_acl_header *ext_acl;
134 char *e;
135 int n;
136
137 *size = reiserfs_acl_size(acl->a_count);
Robert P. J. Day5cbded52006-12-13 00:35:56 -0800138 ext_acl = kmalloc(sizeof(reiserfs_acl_header) +
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700139 acl->a_count *
140 sizeof(reiserfs_acl_entry),
141 GFP_NOFS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 if (!ext_acl)
143 return ERR_PTR(-ENOMEM);
144 ext_acl->a_version = cpu_to_le32(REISERFS_ACL_VERSION);
145 e = (char *)ext_acl + sizeof(reiserfs_acl_header);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700146 for (n = 0; n < acl->a_count; n++) {
Eric W. Biedermandf814652012-02-07 16:30:06 -0800147 const struct posix_acl_entry *acl_e = &acl->a_entries[n];
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700148 reiserfs_acl_entry *entry = (reiserfs_acl_entry *) e;
149 entry->e_tag = cpu_to_le16(acl->a_entries[n].e_tag);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 entry->e_perm = cpu_to_le16(acl->a_entries[n].e_perm);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700151 switch (acl->a_entries[n].e_tag) {
152 case ACL_USER:
Eric W. Biedermandf814652012-02-07 16:30:06 -0800153 entry->e_id = cpu_to_le32(
154 from_kuid(&init_user_ns, acl_e->e_uid));
155 e += sizeof(reiserfs_acl_entry);
156 break;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700157 case ACL_GROUP:
Eric W. Biedermandf814652012-02-07 16:30:06 -0800158 entry->e_id = cpu_to_le32(
159 from_kgid(&init_user_ns, acl_e->e_gid));
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700160 e += sizeof(reiserfs_acl_entry);
161 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700163 case ACL_USER_OBJ:
164 case ACL_GROUP_OBJ:
165 case ACL_MASK:
166 case ACL_OTHER:
167 e += sizeof(reiserfs_acl_entry_short);
168 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700170 default:
171 goto fail;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 }
173 }
174 return (char *)ext_acl;
175
Jeff Mahoneycf776a72014-04-23 10:00:41 -0400176fail:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 kfree(ext_acl);
178 return ERR_PTR(-EINVAL);
179}
180
181/*
182 * Inode operation get_posix_acl().
183 *
Jes Sorensen1b1dcc12006-01-09 15:59:24 -0800184 * inode->i_mutex: down
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 * BKL held [before 2.5.x]
186 */
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700187struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188{
189 char *name, *value;
Al Viro073aaa12009-06-09 12:11:54 -0400190 struct posix_acl *acl;
Adrian Bunk3cdc4092006-03-25 03:07:50 -0800191 int size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 int retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700194 switch (type) {
195 case ACL_TYPE_ACCESS:
Andreas Gruenbacher97d79292015-12-02 14:44:35 +0100196 name = XATTR_NAME_POSIX_ACL_ACCESS;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700197 break;
198 case ACL_TYPE_DEFAULT:
Andreas Gruenbacher97d79292015-12-02 14:44:35 +0100199 name = XATTR_NAME_POSIX_ACL_DEFAULT;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700200 break;
201 default:
Al Viro073aaa12009-06-09 12:11:54 -0400202 BUG();
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700203 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700205 size = reiserfs_xattr_get(inode, name, NULL, 0);
Adrian Bunk3cdc4092006-03-25 03:07:50 -0800206 if (size < 0) {
Andreas Gruenbacherb8a7a3a2016-03-24 14:38:37 +0100207 if (size == -ENODATA || size == -ENOSYS)
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700208 return NULL;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700209 return ERR_PTR(size);
210 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700212 value = kmalloc(size, GFP_NOFS);
213 if (!value)
214 return ERR_PTR(-ENOMEM);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215
216 retval = reiserfs_xattr_get(inode, name, value, size);
217 if (retval == -ENODATA || retval == -ENOSYS) {
Jeff Mahoney098297b2014-04-23 10:00:36 -0400218 /*
219 * This shouldn't actually happen as it should have
220 * been caught above.. but just in case
221 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 acl = NULL;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700223 } else if (retval < 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 acl = ERR_PTR(retval);
225 } else {
Christoph Hellwig9dad9432013-12-20 05:16:36 -0800226 acl = reiserfs_posix_acl_from_disk(value, retval);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700227 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228
229 kfree(value);
230 return acl;
231}
232
233/*
234 * Inode operation set_posix_acl().
235 *
Jes Sorensen1b1dcc12006-01-09 15:59:24 -0800236 * inode->i_mutex: down
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 * BKL held [before 2.5.x]
238 */
239static int
Christoph Hellwig47f70d02013-12-20 05:16:49 -0800240__reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
Jeff Mahoney0ab26212009-03-30 14:02:39 -0400241 int type, struct posix_acl *acl)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242{
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700243 char *name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 void *value = NULL;
Jeff Mahoney48b32a32009-03-30 14:02:38 -0400245 size_t size = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 int error;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700248 switch (type) {
249 case ACL_TYPE_ACCESS:
Andreas Gruenbacher97d79292015-12-02 14:44:35 +0100250 name = XATTR_NAME_POSIX_ACL_ACCESS;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700251 break;
252 case ACL_TYPE_DEFAULT:
Andreas Gruenbacher97d79292015-12-02 14:44:35 +0100253 name = XATTR_NAME_POSIX_ACL_DEFAULT;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700254 if (!S_ISDIR(inode->i_mode))
255 return acl ? -EACCES : 0;
256 break;
257 default:
258 return -EINVAL;
259 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700261 if (acl) {
Christoph Hellwig9dad9432013-12-20 05:16:36 -0800262 value = reiserfs_posix_acl_to_disk(acl, &size);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700263 if (IS_ERR(value))
264 return (int)PTR_ERR(value);
Jeff Mahoney48b32a32009-03-30 14:02:38 -0400265 }
266
Jeff Mahoney0ab26212009-03-30 14:02:39 -0400267 error = reiserfs_xattr_set_handle(th, inode, name, value, size, 0);
Jeff Mahoney48b32a32009-03-30 14:02:38 -0400268
269 /*
270 * Ensure that the inode gets dirtied if we're only using
271 * the mode bits and an old ACL didn't exist. We don't need
272 * to check if the inode is hashed here since we won't get
273 * called by reiserfs_inherit_default_acl().
274 */
275 if (error == -ENODATA) {
276 error = 0;
277 if (type == ACL_TYPE_ACCESS) {
Deepa Dinamani02027d42016-09-14 07:48:05 -0700278 inode->i_ctime = current_time(inode);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700279 mark_inode_dirty(inode);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700280 }
281 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282
James Lamanna833d3042005-10-30 15:00:16 -0800283 kfree(value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284
Jeff Mahoneyd9845612009-03-30 14:02:35 -0400285 if (!error)
Al Viro073aaa12009-06-09 12:11:54 -0400286 set_cached_acl(inode, type, acl);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287
288 return error;
289}
290
Jeff Mahoney098297b2014-04-23 10:00:36 -0400291/*
292 * dir->i_mutex: locked,
293 * inode is new and not released into the wild yet
294 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295int
Jeff Mahoney0ab26212009-03-30 14:02:39 -0400296reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
297 struct inode *dir, struct dentry *dentry,
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700298 struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299{
Christoph Hellwig47f70d02013-12-20 05:16:49 -0800300 struct posix_acl *default_acl, *acl;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700301 int err = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700303 /* ACLs only get applied to files and directories */
304 if (S_ISLNK(inode->i_mode))
305 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
Jeff Mahoney098297b2014-04-23 10:00:36 -0400307 /*
308 * ACLs can only be used on "new" objects, so if it's an old object
309 * there is nothing to inherit from
310 */
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700311 if (get_inode_sd_version(dir) == STAT_DATA_V1)
312 goto apply_umask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313
Jeff Mahoney098297b2014-04-23 10:00:36 -0400314 /*
315 * Don't apply ACLs to objects in the .reiserfs_priv tree.. This
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700316 * would be useless since permissions are ignored, and a pain because
Jeff Mahoney098297b2014-04-23 10:00:36 -0400317 * it introduces locking cycles
318 */
Jeff Mahoney6dfede692009-03-30 14:02:32 -0400319 if (IS_PRIVATE(dir)) {
320 inode->i_flags |= S_PRIVATE;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700321 goto apply_umask;
322 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323
Christoph Hellwig47f70d02013-12-20 05:16:49 -0800324 err = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
325 if (err)
326 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327
Christoph Hellwig47f70d02013-12-20 05:16:49 -0800328 if (default_acl) {
329 err = __reiserfs_set_acl(th, inode, ACL_TYPE_DEFAULT,
330 default_acl);
331 posix_acl_release(default_acl);
332 }
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700333 if (acl) {
Christoph Hellwig47f70d02013-12-20 05:16:49 -0800334 if (!err)
335 err = __reiserfs_set_acl(th, inode, ACL_TYPE_ACCESS,
336 acl);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700337 posix_acl_release(acl);
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700338 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700340 return err;
Christoph Hellwig47f70d02013-12-20 05:16:49 -0800341
Jeff Mahoneycf776a72014-04-23 10:00:41 -0400342apply_umask:
Christoph Hellwig47f70d02013-12-20 05:16:49 -0800343 /* no ACL, apply umask */
344 inode->i_mode &= ~current_umask();
345 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346}
347
Jeff Mahoney0ab26212009-03-30 14:02:39 -0400348/* This is used to cache the default acl before a new object is created.
349 * The biggest reason for this is to get an idea of how many blocks will
350 * actually be required for the create operation if we must inherit an ACL.
351 * An ACL write can add up to 3 object creations and an additional file write
352 * so we'd prefer not to reserve that many blocks in the journal if we can.
353 * It also has the advantage of not loading the ACL with a transaction open,
354 * this may seem silly, but if the owner of the directory is doing the
355 * creation, the ACL may not be loaded since the permissions wouldn't require
356 * it.
357 * We return the number of blocks required for the transaction.
358 */
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700359int reiserfs_cache_default_acl(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360{
Jeff Mahoney0ab26212009-03-30 14:02:39 -0400361 struct posix_acl *acl;
362 int nblocks = 0;
363
364 if (IS_PRIVATE(inode))
365 return 0;
366
Al Viro7dffc872016-03-18 13:25:43 -0400367 acl = get_acl(inode, ACL_TYPE_DEFAULT);
Jeff Mahoney0ab26212009-03-30 14:02:39 -0400368
369 if (acl && !IS_ERR(acl)) {
370 int size = reiserfs_acl_size(acl->a_count);
371
372 /* Other xattrs can be created during inode creation. We don't
373 * want to claim too many blocks, so we check to see if we
374 * we need to create the tree to the xattrs, and then we
375 * just want two files. */
376 nblocks = reiserfs_xattr_jcreate_nblocks(inode);
377 nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
378
379 REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
380
381 /* We need to account for writes + bitmaps for two files */
382 nblocks += reiserfs_xattr_nblocks(inode, size) * 4;
383 posix_acl_release(acl);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384 }
385
Jeff Mahoney0ab26212009-03-30 14:02:39 -0400386 return nblocks;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700387}
388
Jeff Mahoney4c051412013-08-08 17:27:19 -0400389/*
390 * Called under i_mutex
391 */
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700392int reiserfs_acl_chmod(struct inode *inode)
393{
Jeff Mahoney4a857012013-05-31 15:54:17 -0400394 if (IS_PRIVATE(inode))
395 return 0;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700396 if (get_inode_sd_version(inode) == STAT_DATA_V1 ||
Christoph Hellwig47f70d02013-12-20 05:16:49 -0800397 !reiserfs_posixacl(inode->i_sb))
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700398 return 0;
Linus Torvaldsbd4c6252005-07-12 20:21:28 -0700399
Christoph Hellwig47f70d02013-12-20 05:16:49 -0800400 return posix_acl_chmod(inode, inode->i_mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401}