if (acl) {
if (S_ISDIR(mode))
*dpacl = posix_acl_dup(acl);
- retval = posix_acl_create(&acl, GFP_NOFS, &mode);
+ retval = __posix_acl_create(&acl, GFP_NOFS, &mode);
if (retval < 0)
return retval;
if (retval > 0)
if (ret)
goto failed;
}
- ret = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
+ ret = __posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
if (ret < 0)
return ret;
if (error)
goto cleanup;
}
- error = posix_acl_create(&acl, GFP_KERNEL, &inode->i_mode);
+ error = __posix_acl_create(&acl, GFP_KERNEL, &inode->i_mode);
if (error < 0)
return error;
if (error > 0) {
if (error)
goto cleanup;
}
- error = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
+ error = __posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
if (error < 0)
return error;
if (error)
goto cleanup;
}
- error = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
+ error = __posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
if (error < 0)
return error;
if (error)
goto cleanup;
}
- error = posix_acl_create(&acl, GFP_KERNEL, &inode->i_mode);
+ error = __posix_acl_create(&acl, GFP_KERNEL, &inode->i_mode);
if (error < 0)
return error;
if (error > 0)
if (acl) {
if (S_ISDIR(inode->i_mode))
set_cached_acl(inode, ACL_TYPE_DEFAULT, acl);
- error = posix_acl_create(&acl, GFP_KERNEL, &inode->i_mode);
+ error = __posix_acl_create(&acl, GFP_KERNEL, &inode->i_mode);
if (error < 0)
return error;
if (error > 0)
goto out;
}
- error = posix_acl_create(&acl, GFP_NOFS, &mode);
+ error = __posix_acl_create(&acl, GFP_NOFS, &mode);
if (error < 0)
return error;
goto init_acl_cleanup;
}
- err = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
+ err = __posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
if (unlikely(err < 0))
return err;
if (S_ISDIR(*i_mode))
set_cached_acl(inode, ACL_TYPE_DEFAULT, acl);
- rc = posix_acl_create(&acl, GFP_KERNEL, i_mode);
+ rc = __posix_acl_create(&acl, GFP_KERNEL, i_mode);
if (rc < 0)
return rc;
if (rc > 0)
if (rc)
goto cleanup;
}
- rc = posix_acl_create(&acl, GFP_KERNEL, &inode->i_mode);
+ rc = __posix_acl_create(&acl, GFP_KERNEL, &inode->i_mode);
if (rc < 0)
goto cleanup; /* posix_acl_release(NULL) is no-op */
if (rc > 0)
if (!dfacl)
return 0;
acl = posix_acl_dup(dfacl);
- error = posix_acl_create(&acl, GFP_KERNEL, &mode);
+ error = __posix_acl_create(&acl, GFP_KERNEL, &mode);
if (error < 0)
goto out_release_dfacl;
error = nfs3_proc_setacls(inode, acl, S_ISDIR(inode->i_mode) ?
goto cleanup;
}
mode = inode->i_mode;
- ret = posix_acl_create(&acl, GFP_NOFS, &mode);
+ ret = __posix_acl_create(&acl, GFP_NOFS, &mode);
if (ret < 0)
return ret;
}
int
-posix_acl_create(struct posix_acl **acl, gfp_t gfp, umode_t *mode_p)
+__posix_acl_create(struct posix_acl **acl, gfp_t gfp, umode_t *mode_p)
{
struct posix_acl *clone = posix_acl_clone(*acl, gfp);
int err = -ENOMEM;
*acl = clone;
return err;
}
-EXPORT_SYMBOL(posix_acl_create);
+EXPORT_SYMBOL(__posix_acl_create);
int
__posix_acl_chmod(struct posix_acl **acl, gfp_t gfp, umode_t mode)
EXPORT_SYMBOL(__posix_acl_chmod);
int
-posix_acl_chmod(struct inode *inode)
+posix_acl_chmod(struct inode *inode, umode_t mode)
{
struct posix_acl *acl;
int ret = 0;
if (IS_ERR_OR_NULL(acl))
return PTR_ERR(acl);
- ret = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
+ ret = __posix_acl_chmod(&acl, GFP_KERNEL, mode);
if (ret)
return ret;
ret = inode->i_op->set_acl(inode, acl, ACL_TYPE_ACCESS);
}
EXPORT_SYMBOL(posix_acl_chmod);
+int
+posix_acl_create(struct inode *dir, umode_t *mode,
+ struct posix_acl **default_acl, struct posix_acl **acl)
+{
+ struct posix_acl *p;
+ int ret;
+
+ if (S_ISLNK(*mode) || !IS_POSIXACL(dir))
+ goto no_acl;
+
+ p = get_acl(dir, ACL_TYPE_DEFAULT);
+ if (IS_ERR(p))
+ return PTR_ERR(p);
+
+ if (!p) {
+ *mode &= ~current_umask();
+ goto no_acl;
+ }
+
+ *acl = posix_acl_clone(p, GFP_NOFS);
+ if (!*acl)
+ return -ENOMEM;
+
+ ret = posix_acl_create_masq(*acl, mode);
+ if (ret < 0) {
+ posix_acl_release(*acl);
+ return -ENOMEM;
+ }
+
+ if (ret == 0) {
+ posix_acl_release(*acl);
+ *acl = NULL;
+ }
+
+ if (!S_ISDIR(*mode)) {
+ posix_acl_release(p);
+ *default_acl = NULL;
+ } else {
+ *default_acl = p;
+ }
+ return 0;
+
+no_acl:
+ *default_acl = NULL;
+ *acl = NULL;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(posix_acl_create);
+
/*
* Fix up the uids and gids in posix acl extended attributes in place.
*/
/* Now we reconcile the new ACL and the mode,
potentially modifying both */
- err = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
+ err = __posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
if (err < 0)
return err;
goto out;
}
- error = posix_acl_create(&acl, GFP_KERNEL, &mode);
+ error = __posix_acl_create(&acl, GFP_KERNEL, &mode);
if (error < 0)
return error;
/*
- * If posix_acl_create returns a positive value we need to
+ * If __posix_acl_create returns a positive value we need to
* inherit a permission that can't be represented using the Unix
* mode bits and we actually need to set an ACL.
*/
extern int posix_acl_permission(struct inode *, const struct posix_acl *, int);
extern struct posix_acl *posix_acl_from_mode(umode_t, gfp_t);
extern int posix_acl_equiv_mode(const struct posix_acl *, umode_t *);
-extern int posix_acl_create(struct posix_acl **, gfp_t, umode_t *);
+extern int __posix_acl_create(struct posix_acl **, gfp_t, umode_t *);
extern int __posix_acl_chmod(struct posix_acl **, gfp_t, umode_t);
extern struct posix_acl *get_posix_acl(struct inode *, int);
extern int set_posix_acl(struct inode *, int, struct posix_acl *);
#ifdef CONFIG_FS_POSIX_ACL
-extern int posix_acl_chmod(struct inode *);
+extern int posix_acl_chmod(struct inode *, umode_t);
+extern int posix_acl_create(struct inode *, umode_t *, struct posix_acl **,
+ struct posix_acl **);
static inline struct posix_acl **acl_by_type(struct inode *inode, int type)
{
inode->i_default_acl = NULL;
}
#else
-static inline int posix_acl_chmod(struct inode *inode)
+static inline int posix_acl_chmod(struct inode *inode, umode_t mode)
{
return 0;
}
static inline void cache_no_acl(struct inode *inode)
{
}
+
+static inline int posix_acl_create(struct inode *inode, umode_t *mode,
+ struct posix_acl **default_acl, struct posix_acl **acl)
+{
+ *default_acl = *acl = NULL;
+ return 0;
+}
#endif /* CONFIG_FS_POSIX_ACL */
struct posix_acl *get_acl(struct inode *inode, int type);