Honor CONFIG_FS_POSIX_ACL kernel option

The required Posix ACL interfaces are only available for kernels
with CONFIG_FS_POSIX_ACL defined.  Therefore, only enable Posix
ACL support for these kernels.  All major distribution kernels
enable CONFIG_FS_POSIX_ACL by default.

If your kernel does not support Posix ACLs the following warning
will be printed at ZFS module load time.

  "ZFS: Posix ACLs disabled by kernel"

Signed-off-by: Massimo Maggi <me@massimo-maggi.eu>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1825
This commit is contained in:
Massimo Maggi 2013-11-03 00:40:26 +01:00 committed by Brian Behlendorf
parent 78e2739d3c
commit b695c34ea4
7 changed files with 38 additions and 0 deletions

View File

@ -174,6 +174,7 @@ lseek_execute(struct file *filp, struct inode *inode,
} }
#endif /* SEEK_HOLE && SEEK_DATA && !HAVE_LSEEK_EXECUTE */ #endif /* SEEK_HOLE && SEEK_DATA && !HAVE_LSEEK_EXECUTE */
#if defined(CONFIG_FS_POSIX_ACL)
/* /*
* These functions safely approximates the behavior of posix_acl_release() * These functions safely approximates the behavior of posix_acl_release()
* which cannot be used because it calls the GPL-only symbol kfree_rcu(). * which cannot be used because it calls the GPL-only symbol kfree_rcu().
@ -315,5 +316,6 @@ typedef umode_t zpl_equivmode_t;
#else #else
typedef mode_t zpl_equivmode_t; typedef mode_t zpl_equivmode_t;
#endif /* HAVE_POSIX_ACL_EQUIV_MODE_UMODE_T */ #endif /* HAVE_POSIX_ACL_EQUIV_MODE_UMODE_T */
#endif /* CONFIG_FS_POSIX_ACL */
#endif /* _ZFS_VFS_H */ #endif /* _ZFS_VFS_H */

View File

@ -71,6 +71,7 @@ extern struct file_system_type zpl_fs_type;
extern ssize_t zpl_xattr_list(struct dentry *dentry, char *buf, size_t size); extern ssize_t zpl_xattr_list(struct dentry *dentry, char *buf, size_t size);
extern int zpl_xattr_security_init(struct inode *ip, struct inode *dip, extern int zpl_xattr_security_init(struct inode *ip, struct inode *dip,
const struct qstr *qstr); const struct qstr *qstr);
#if defined(CONFIG_FS_POSIX_ACL)
extern int zpl_set_acl(struct inode *ip, int type, struct posix_acl *acl); extern int zpl_set_acl(struct inode *ip, int type, struct posix_acl *acl);
extern struct posix_acl *zpl_get_acl(struct inode *ip, int type); extern struct posix_acl *zpl_get_acl(struct inode *ip, int type);
#if !defined(HAVE_GET_ACL) #if !defined(HAVE_GET_ACL)
@ -87,6 +88,19 @@ extern int zpl_permission(struct inode *ip, int mask);
extern int zpl_init_acl(struct inode *ip, struct inode *dir); extern int zpl_init_acl(struct inode *ip, struct inode *dir);
extern int zpl_chmod_acl(struct inode *ip); extern int zpl_chmod_acl(struct inode *ip);
#else
static inline int
zpl_init_acl(struct inode *ip, struct inode *dir)
{
return (0);
}
static inline int
zpl_chmod_acl(struct inode *ip)
{
return (0);
}
#endif /* CONFIG_FS_POSIX_ACL */
extern xattr_handler_t *zpl_xattr_handlers[]; extern xattr_handler_t *zpl_xattr_handlers[];

View File

@ -5814,6 +5814,9 @@ _init(void)
"ZFS pool version %s, ZFS filesystem version %s\n", "ZFS pool version %s, ZFS filesystem version %s\n",
ZFS_META_VERSION, ZFS_META_RELEASE, ZFS_DEBUG_STR, ZFS_META_VERSION, ZFS_META_RELEASE, ZFS_DEBUG_STR,
SPA_VERSION_STRING, ZPL_VERSION_STRING); SPA_VERSION_STRING, ZPL_VERSION_STRING);
#ifndef CONFIG_FS_POSIX_ACL
printk(KERN_NOTICE "ZFS: Posix ACLs disabled by kernel\n");
#endif /* CONFIG_FS_POSIX_ACL */
return (0); return (0);

View File

@ -165,8 +165,13 @@ acltype_changed_cb(void *arg, uint64_t newval)
zsb->z_sb->s_flags &= ~MS_POSIXACL; zsb->z_sb->s_flags &= ~MS_POSIXACL;
break; break;
case ZFS_ACLTYPE_POSIXACL: case ZFS_ACLTYPE_POSIXACL:
#ifdef CONFIG_FS_POSIX_ACL
zsb->z_acl_type = ZFS_ACLTYPE_POSIXACL; zsb->z_acl_type = ZFS_ACLTYPE_POSIXACL;
zsb->z_sb->s_flags |= MS_POSIXACL; zsb->z_sb->s_flags |= MS_POSIXACL;
#else
zsb->z_acl_type = ZFS_ACLTYPE_OFF;
zsb->z_sb->s_flags &= ~MS_POSIXACL;
#endif /* CONFIG_FS_POSIX_ACL */
break; break;
default: default:
break; break;

View File

@ -462,6 +462,7 @@ const struct inode_operations zpl_inode_operations = {
#ifdef HAVE_INODE_FALLOCATE #ifdef HAVE_INODE_FALLOCATE
.fallocate = zpl_fallocate, .fallocate = zpl_fallocate,
#endif /* HAVE_INODE_FALLOCATE */ #endif /* HAVE_INODE_FALLOCATE */
#if defined(CONFIG_FS_POSIX_ACL)
#if defined(HAVE_GET_ACL) #if defined(HAVE_GET_ACL)
.get_acl = zpl_get_acl, .get_acl = zpl_get_acl,
#elif defined(HAVE_CHECK_ACL) #elif defined(HAVE_CHECK_ACL)
@ -469,6 +470,7 @@ const struct inode_operations zpl_inode_operations = {
#elif defined(HAVE_PERMISSION) #elif defined(HAVE_PERMISSION)
.permission = zpl_permission, .permission = zpl_permission,
#endif /* HAVE_GET_ACL | HAVE_CHECK_ACL | HAVE_PERMISSION */ #endif /* HAVE_GET_ACL | HAVE_CHECK_ACL | HAVE_PERMISSION */
#endif /* CONFIG_FS_POSIX_ACL */
}; };
const struct inode_operations zpl_dir_inode_operations = { const struct inode_operations zpl_dir_inode_operations = {
@ -487,6 +489,7 @@ const struct inode_operations zpl_dir_inode_operations = {
.getxattr = generic_getxattr, .getxattr = generic_getxattr,
.removexattr = generic_removexattr, .removexattr = generic_removexattr,
.listxattr = zpl_xattr_list, .listxattr = zpl_xattr_list,
#if defined(CONFIG_FS_POSIX_ACL)
#if defined(HAVE_GET_ACL) #if defined(HAVE_GET_ACL)
.get_acl = zpl_get_acl, .get_acl = zpl_get_acl,
#elif defined(HAVE_CHECK_ACL) #elif defined(HAVE_CHECK_ACL)
@ -494,6 +497,7 @@ const struct inode_operations zpl_dir_inode_operations = {
#elif defined(HAVE_PERMISSION) #elif defined(HAVE_PERMISSION)
.permission = zpl_permission, .permission = zpl_permission,
#endif /* HAVE_GET_ACL | HAVE_CHECK_ACL | HAVE_PERMISSION */ #endif /* HAVE_GET_ACL | HAVE_CHECK_ACL | HAVE_PERMISSION */
#endif /* CONFIG_FS_POSIX_ACL */
}; };
const struct inode_operations zpl_symlink_inode_operations = { const struct inode_operations zpl_symlink_inode_operations = {
@ -515,6 +519,7 @@ const struct inode_operations zpl_special_inode_operations = {
.getxattr = generic_getxattr, .getxattr = generic_getxattr,
.removexattr = generic_removexattr, .removexattr = generic_removexattr,
.listxattr = zpl_xattr_list, .listxattr = zpl_xattr_list,
#if defined(CONFIG_FS_POSIX_ACL)
#if defined(HAVE_GET_ACL) #if defined(HAVE_GET_ACL)
.get_acl = zpl_get_acl, .get_acl = zpl_get_acl,
#elif defined(HAVE_CHECK_ACL) #elif defined(HAVE_CHECK_ACL)
@ -522,6 +527,7 @@ const struct inode_operations zpl_special_inode_operations = {
#elif defined(HAVE_PERMISSION) #elif defined(HAVE_PERMISSION)
.permission = zpl_permission, .permission = zpl_permission,
#endif /* HAVE_GET_ACL | HAVE_CHECK_ACL | HAVE_PERMISSION */ #endif /* HAVE_GET_ACL | HAVE_CHECK_ACL | HAVE_PERMISSION */
#endif /* CONFIG_FS_POSIX_ACL */
}; };
dentry_operations_t zpl_dentry_operations = { dentry_operations_t zpl_dentry_operations = {

View File

@ -198,6 +198,7 @@ __zpl_show_options(struct seq_file *seq, zfs_sb_t *zsb)
{ {
seq_printf(seq, ",%s", zsb->z_flags & ZSB_XATTR ? "xattr" : "noxattr"); seq_printf(seq, ",%s", zsb->z_flags & ZSB_XATTR ? "xattr" : "noxattr");
#ifdef CONFIG_FS_POSIX_ACL
switch (zsb->z_acl_type) { switch (zsb->z_acl_type) {
case ZFS_ACLTYPE_POSIXACL: case ZFS_ACLTYPE_POSIXACL:
seq_puts(seq, ",posixacl"); seq_puts(seq, ",posixacl");
@ -206,6 +207,7 @@ __zpl_show_options(struct seq_file *seq, zfs_sb_t *zsb)
seq_puts(seq, ",noacl"); seq_puts(seq, ",noacl");
break; break;
} }
#endif /* CONFIG_FS_POSIX_ACL */
return (0); return (0);
} }

View File

@ -722,6 +722,8 @@ xattr_handler_t zpl_xattr_security_handler = {
.set = zpl_xattr_security_set, .set = zpl_xattr_security_set,
}; };
#ifdef CONFIG_FS_POSIX_ACL
int int
zpl_set_acl(struct inode *ip, int type, struct posix_acl *acl) zpl_set_acl(struct inode *ip, int type, struct posix_acl *acl)
{ {
@ -1187,11 +1189,15 @@ struct xattr_handler zpl_xattr_acl_default_handler =
#endif /* HAVE_DENTRY_XATTR_LIST */ #endif /* HAVE_DENTRY_XATTR_LIST */
}; };
#endif /* CONFIG_FS_POSIX_ACL */
xattr_handler_t *zpl_xattr_handlers[] = { xattr_handler_t *zpl_xattr_handlers[] = {
&zpl_xattr_security_handler, &zpl_xattr_security_handler,
&zpl_xattr_trusted_handler, &zpl_xattr_trusted_handler,
&zpl_xattr_user_handler, &zpl_xattr_user_handler,
#ifdef CONFIG_FS_POSIX_ACL
&zpl_xattr_acl_access_handler, &zpl_xattr_acl_access_handler,
&zpl_xattr_acl_default_handler, &zpl_xattr_acl_default_handler,
#endif /* CONFIG_FS_POSIX_ACL */
NULL NULL
}; };