From b89ecd47b409ff5bc2d7d263deb62719a8de420f Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Fri, 26 May 2023 16:18:55 -0400 Subject: [PATCH] Use __posix_acl_create/_chmod and add backwards compatibility There are new interfaces available but the old one has been retained for us to use. In case of older kernels, we will need to fall back to the previous name of these functions. Signed-off-by: Auke Kok --- kmod/src/Makefile.kernelcompat | 10 ++++++++++ kmod/src/acl.c | 4 ++-- kmod/src/kernelcompat.h | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/kmod/src/Makefile.kernelcompat b/kmod/src/Makefile.kernelcompat index f1e0b8bb..fde9b31a 100644 --- a/kmod/src/Makefile.kernelcompat +++ b/kmod/src/Makefile.kernelcompat @@ -64,6 +64,16 @@ ifneq (,$(shell grep 'static inline bool RBNAME.*_compute_max' include/linux/rbt ccflags-y += -DKC_RB_TREE_AUGMENTED_COMPUTE_MAX endif +# +# v3.13-25-g37bc15392a23 +# +# Renames posix_acl_create to __posix_acl_create and provide some +# new interfaces for creating ACLs +# +ifneq (,$(shell grep '__posix_acl_create' include/linux/posix_acl.h)) +ccflags-y += -DKC___POSIX_ACL_CREATE +endif + # # v4.8-rc1-29-g31051c85b5e2 # diff --git a/kmod/src/acl.c b/kmod/src/acl.c index 11a83266..6b43d8cc 100644 --- a/kmod/src/acl.c +++ b/kmod/src/acl.c @@ -301,7 +301,7 @@ int scoutfs_init_acl_locked(struct inode *inode, struct inode *dir, if (ret) goto out; } - 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 (ret > 0) @@ -345,7 +345,7 @@ int scoutfs_acl_chmod_locked(struct inode *inode, struct iattr *attr, if (IS_ERR_OR_NULL(acl)) return PTR_ERR(acl); - ret = posix_acl_chmod(&acl, GFP_KERNEL, attr->ia_mode); + ret = __posix_acl_chmod(&acl, GFP_KERNEL, attr->ia_mode); if (ret) return ret; diff --git a/kmod/src/kernelcompat.h b/kmod/src/kernelcompat.h index 1f6072e3..7c831648 100644 --- a/kmod/src/kernelcompat.h +++ b/kmod/src/kernelcompat.h @@ -108,4 +108,9 @@ static inline int dir_emit_dots(struct file *file, void *dirent, #define setattr_prepare(dentry, attr) inode_change_ok(d_inode(dentry), attr) #endif +#ifndef KC___POSIX_ACL_CREATE +#define __posix_acl_create posix_acl_create +#define __posix_acl_chmod posix_acl_chmod +#endif + #endif