@@ -640,3 +640,32 @@ richacl_inherit(const struct richacl *dir_acl, mode_t mode)
return acl;
}
EXPORT_SYMBOL_GPL(richacl_inherit);
+
+struct richacl *
+richacl_from_mode(mode_t mode)
+{
+ struct richacl *acl;
+ struct richace *ace;
+ int is_dir = S_ISDIR(mode);
+
+ acl = richacl_alloc(1);
+ if (!acl)
+ return NULL;
+ ace = acl->a_entries;
+
+ acl->a_owner_mask = richacl_mode_to_mask(mode >> 6, is_dir);
+ acl->a_group_mask = richacl_mode_to_mask(mode >> 3, is_dir);
+ acl->a_other_mask = richacl_mode_to_mask(mode, is_dir);
+
+ ace->e_type = ACE4_ACCESS_ALLOWED_ACE_TYPE;
+ ace->e_flags = ACE4_SPECIAL_WHO;
+ ace->e_mask = ACE4_VALID_MASK;
+ ace->u.e_who = richace_everyone_who;
+ if (richacl_apply_masks(&acl)) {
+ richacl_put(acl);
+ acl = NULL;
+ }
+ return acl;
+
+}
+EXPORT_SYMBOL_GPL(richacl_from_mode);
@@ -238,5 +238,6 @@ extern int richacl_apply_masks(struct richacl **acl);
extern int richacl_write_through(struct richacl **acl);
extern struct richacl *map_posix_to_richacl(struct inode *, struct posix_acl *,
struct posix_acl *);
+extern struct richacl *richacl_from_mode(mode_t);
#endif /* __RICHACL_H */
When we don't have richacl stored on disk for permission check we need to generate richacl from mode values. This patch adds a helper function for doing that. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> --- fs/richacl_base.c | 29 +++++++++++++++++++++++++++++ include/linux/richacl.h | 1 + 2 files changed, 30 insertions(+), 0 deletions(-)