acl.c (31d1b7710262fba12282b24083f20dc76e0efc93) acl.c (5222595d093ebe80329d38d255d14316257afb3e)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * fs/f2fs/acl.c
4 *
5 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 * http://www.samsung.com/
7 *
8 * Portions of this code from linux/fs/ext2/acl.c

--- 146 unchanged lines hidden (view full) ---

155 default:
156 goto fail;
157 }
158 }
159 *size = f2fs_acl_size(acl->a_count);
160 return (void *)f2fs_acl;
161
162fail:
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * fs/f2fs/acl.c
4 *
5 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 * http://www.samsung.com/
7 *
8 * Portions of this code from linux/fs/ext2/acl.c

--- 146 unchanged lines hidden (view full) ---

155 default:
156 goto fail;
157 }
158 }
159 *size = f2fs_acl_size(acl->a_count);
160 return (void *)f2fs_acl;
161
162fail:
163 kfree(f2fs_acl);
163 kvfree(f2fs_acl);
164 return ERR_PTR(-EINVAL);
165}
166
167static struct posix_acl *__f2fs_get_acl(struct inode *inode, int type,
168 struct page *dpage)
169{
170 int name_index = F2FS_XATTR_INDEX_POSIX_ACL_DEFAULT;
171 void *value = NULL;

--- 13 unchanged lines hidden (view full) ---

185 }
186
187 if (retval > 0)
188 acl = f2fs_acl_from_disk(value, retval);
189 else if (retval == -ENODATA)
190 acl = NULL;
191 else
192 acl = ERR_PTR(retval);
164 return ERR_PTR(-EINVAL);
165}
166
167static struct posix_acl *__f2fs_get_acl(struct inode *inode, int type,
168 struct page *dpage)
169{
170 int name_index = F2FS_XATTR_INDEX_POSIX_ACL_DEFAULT;
171 void *value = NULL;

--- 13 unchanged lines hidden (view full) ---

185 }
186
187 if (retval > 0)
188 acl = f2fs_acl_from_disk(value, retval);
189 else if (retval == -ENODATA)
190 acl = NULL;
191 else
192 acl = ERR_PTR(retval);
193 kfree(value);
193 kvfree(value);
194
195 return acl;
196}
197
198struct posix_acl *f2fs_get_acl(struct inode *inode, int type)
199{
200 return __f2fs_get_acl(inode, type, NULL);
201}

--- 33 unchanged lines hidden (view full) ---

235 if (IS_ERR(value)) {
236 clear_inode_flag(inode, FI_ACL_MODE);
237 return PTR_ERR(value);
238 }
239 }
240
241 error = f2fs_setxattr(inode, name_index, "", value, size, ipage, 0);
242
194
195 return acl;
196}
197
198struct posix_acl *f2fs_get_acl(struct inode *inode, int type)
199{
200 return __f2fs_get_acl(inode, type, NULL);
201}

--- 33 unchanged lines hidden (view full) ---

235 if (IS_ERR(value)) {
236 clear_inode_flag(inode, FI_ACL_MODE);
237 return PTR_ERR(value);
238 }
239 }
240
241 error = f2fs_setxattr(inode, name_index, "", value, size, ipage, 0);
242
243 kfree(value);
243 kvfree(value);
244 if (!error)
245 set_cached_acl(inode, type, acl);
246
247 clear_inode_flag(inode, FI_ACL_MODE);
248 return error;
249}
250
251int f2fs_set_acl(struct inode *inode, struct posix_acl *acl, int type)

--- 95 unchanged lines hidden (view full) ---

347 if (!p || p == ERR_PTR(-EOPNOTSUPP)) {
348 *mode &= ~current_umask();
349 return 0;
350 }
351 if (IS_ERR(p))
352 return PTR_ERR(p);
353
354 clone = f2fs_acl_clone(p, GFP_NOFS);
244 if (!error)
245 set_cached_acl(inode, type, acl);
246
247 clear_inode_flag(inode, FI_ACL_MODE);
248 return error;
249}
250
251int f2fs_set_acl(struct inode *inode, struct posix_acl *acl, int type)

--- 95 unchanged lines hidden (view full) ---

347 if (!p || p == ERR_PTR(-EOPNOTSUPP)) {
348 *mode &= ~current_umask();
349 return 0;
350 }
351 if (IS_ERR(p))
352 return PTR_ERR(p);
353
354 clone = f2fs_acl_clone(p, GFP_NOFS);
355 if (!clone)
356 goto no_mem;
355 if (!clone) {
356 ret = -ENOMEM;
357 goto release_acl;
358 }
357
358 ret = f2fs_acl_create_masq(clone, mode);
359 if (ret < 0)
359
360 ret = f2fs_acl_create_masq(clone, mode);
361 if (ret < 0)
360 goto no_mem_clone;
362 goto release_clone;
361
362 if (ret == 0)
363 posix_acl_release(clone);
364 else
365 *acl = clone;
366
367 if (!S_ISDIR(*mode))
368 posix_acl_release(p);
369 else
370 *default_acl = p;
371
372 return 0;
373
363
364 if (ret == 0)
365 posix_acl_release(clone);
366 else
367 *acl = clone;
368
369 if (!S_ISDIR(*mode))
370 posix_acl_release(p);
371 else
372 *default_acl = p;
373
374 return 0;
375
374no_mem_clone:
376release_clone:
375 posix_acl_release(clone);
377 posix_acl_release(clone);
376no_mem:
378release_acl:
377 posix_acl_release(p);
379 posix_acl_release(p);
378 return -ENOMEM;
380 return ret;
379}
380
381int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage,
382 struct page *dpage)
383{
384 struct posix_acl *default_acl = NULL, *acl = NULL;
385 int error = 0;
386

--- 24 unchanged lines hidden ---
381}
382
383int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage,
384 struct page *dpage)
385{
386 struct posix_acl *default_acl = NULL, *acl = NULL;
387 int error = 0;
388

--- 24 unchanged lines hidden ---