From a7dc7e5d5a5c4a68266b3d9ce89c6c53c04b1741 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Tue, 7 Dec 2010 16:05:25 -0800 Subject: [PATCH 01/16] Enable rrwlock.c compilation With the addition of the thread specific data interfaces to the SPL it is safe to enable compilation of the re-enterant read reader/writer locks. --- module/zfs/rrwlock.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/module/zfs/rrwlock.c b/module/zfs/rrwlock.c index 8d05d93..4cef53f 100644 --- a/module/zfs/rrwlock.c +++ b/module/zfs/rrwlock.c @@ -23,8 +23,6 @@ * Use is subject to license terms. */ -#ifdef HAVE_ZPL - #include #include @@ -264,4 +262,3 @@ rrw_held(rrwlock_t *rrl, krw_t rw) return (held); } -#endif /* HAVE_ZPL */ -- 1.8.3.1 From 8d4e8140ef67fa9c8fa0b1d0f5b1d5d36c747969 Mon Sep 17 00:00:00 2001 From: "Ricardo M. Correia" Date: Tue, 14 Dec 2010 09:50:37 -0800 Subject: [PATCH 02/16] Fix block device-related issues in zdb. Specifically, this fixes the two following errors in zdb when a pool is composed of block devices: 1) 'Value too large for defined data type' when running 'zdb '. 2) 'character device required' when running 'zdb -l '. Signed-off-by: Ricardo M. Correia Signed-off-by: Brian Behlendorf --- cmd/zdb/zdb.c | 10 +------- lib/libspl/include/sys/Makefile.am | 1 + lib/libspl/include/sys/Makefile.in | 1 + lib/libspl/include/sys/stat.h | 50 ++++++++++++++++++++++++++++++++++++++ lib/libzpool/kernel.c | 19 ++++----------- 5 files changed, 58 insertions(+), 23 deletions(-) create mode 100644 lib/libspl/include/sys/stat.h diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index a5ad7fe..2f5f19e 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -1803,7 +1803,7 @@ dump_label(const char *dev) exit(1); } - if (fstat64(fd, &statbuf) != 0) { + if (fstat64_blk(fd, &statbuf) != 0) { (void) printf("failed to stat '%s': %s\n", path, strerror(errno)); free(path); @@ -1811,14 +1811,6 @@ dump_label(const char *dev) exit(1); } - if (S_ISBLK(statbuf.st_mode)) { - (void) printf("cannot use '%s': character device required\n", - path); - free(path); - (void) close(fd); - exit(1); - } - psize = statbuf.st_size; psize = P2ALIGN(psize, (uint64_t)sizeof (vdev_label_t)); diff --git a/lib/libspl/include/sys/Makefile.am b/lib/libspl/include/sys/Makefile.am index 5f5496f..c8ef297 100644 --- a/lib/libspl/include/sys/Makefile.am +++ b/lib/libspl/include/sys/Makefile.am @@ -36,6 +36,7 @@ libspl_HEADERS = \ $(top_srcdir)/lib/libspl/include/sys/processor.h \ $(top_srcdir)/lib/libspl/include/sys/sdt.h \ $(top_srcdir)/lib/libspl/include/sys/stack.h \ + $(top_srcdir)/lib/libspl/include/sys/stat.h \ $(top_srcdir)/lib/libspl/include/sys/stropts.h \ $(top_srcdir)/lib/libspl/include/sys/sunddi.h \ $(top_srcdir)/lib/libspl/include/sys/sysevent.h \ diff --git a/lib/libspl/include/sys/Makefile.in b/lib/libspl/include/sys/Makefile.in index cb930aa..20fdfca 100644 --- a/lib/libspl/include/sys/Makefile.in +++ b/lib/libspl/include/sys/Makefile.in @@ -349,6 +349,7 @@ libspl_HEADERS = \ $(top_srcdir)/lib/libspl/include/sys/processor.h \ $(top_srcdir)/lib/libspl/include/sys/sdt.h \ $(top_srcdir)/lib/libspl/include/sys/stack.h \ + $(top_srcdir)/lib/libspl/include/sys/stat.h \ $(top_srcdir)/lib/libspl/include/sys/stropts.h \ $(top_srcdir)/lib/libspl/include/sys/sunddi.h \ $(top_srcdir)/lib/libspl/include/sys/sysevent.h \ diff --git a/lib/libspl/include/sys/stat.h b/lib/libspl/include/sys/stat.h new file mode 100644 index 0000000..b9ad152 --- /dev/null +++ b/lib/libspl/include/sys/stat.h @@ -0,0 +1,50 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + */ + +#ifndef _LIBSPL_SYS_STAT_H +#define _LIBSPL_SYS_STAT_H + +#include_next + +#include /* for BLKGETSIZE64 */ + +/* + * Emulate Solaris' behavior of returning the block device size in fstat64(). + */ +static inline int +fstat64_blk(int fd, struct stat64 *st) +{ + if (fstat64(fd, st) == -1) + return -1; + + /* In Linux we need to use an ioctl to get the size of a block device */ + if (S_ISBLK(st->st_mode)) { + if (ioctl(fd, BLKGETSIZE64, &st->st_size) != 0) + return -1; + } + + return 0; +} +#endif /* _LIBSPL_SYS_STAT_H */ diff --git a/lib/libzpool/kernel.c b/lib/libzpool/kernel.c index 6f06f40..002276a 100644 --- a/lib/libzpool/kernel.c +++ b/lib/libzpool/kernel.c @@ -36,7 +36,6 @@ #include #include #include -#include /* for BLKGETSIZE64 */ #include /* @@ -592,22 +591,12 @@ vn_open(char *path, int x1, int flags, int mode, vnode_t **vpp, int x2, int x3) if (fd == -1) return (errno); - if (fstat64(fd, &st) == -1) { + if (fstat64_blk(fd, &st) == -1) { err = errno; close(fd); return (err); } -#ifdef __linux__ - /* In Linux, use an ioctl to get the size of a block device. */ - if (S_ISBLK(st.st_mode)) { - if (ioctl(fd, BLKGETSIZE64, &st.st_size) != 0) { - err = errno; - close(fd); - return (err); - } - } -#endif (void) fcntl(fd, F_SETFD, FD_CLOEXEC); *vpp = vp = umem_zalloc(sizeof (vnode_t), UMEM_NOFAIL); @@ -699,10 +688,12 @@ int fop_getattr(vnode_t *vp, vattr_t *vap) { struct stat64 st; + int err; - if (fstat64(vp->v_fd, &st) == -1) { + if (fstat64_blk(vp->v_fd, &st) == -1) { + err = errno; close(vp->v_fd); - return (errno); + return (err); } vap->va_size = st.st_size; -- 1.8.3.1 From 5b63b3eb6f42f3d9f6a19b22c3f10f72927eeacc Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 10 Dec 2010 12:00:00 -0800 Subject: [PATCH 03/16] Use cv_timedwait_interruptible in arc The issue is that cv_timedwait() sleeps uninterruptibly to block signals and avoid waking up early. Under Linux this counts against the load average keeping it artificially high. This change allows the arc to sleep interruptibly which mean it may be woken up early due to a signal. Normally this means some extra care must be taken to handle a potential signal. But for the arcs usage of cv_timedwait() there is no harm in waking up before the timeout expires so no extra handling is required. --- include/sys/zfs_context.h | 1 + module/zfs/arc.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h index c449903..44e3dd1 100644 --- a/include/sys/zfs_context.h +++ b/include/sys/zfs_context.h @@ -310,6 +310,7 @@ extern void cv_wait(kcondvar_t *cv, kmutex_t *mp); extern clock_t cv_timedwait(kcondvar_t *cv, kmutex_t *mp, clock_t abstime); extern void cv_signal(kcondvar_t *cv); extern void cv_broadcast(kcondvar_t *cv); +#define cv_timedwait_interruptible(cv, mp, at) cv_timedwait(cv, mp, at); /* * kstat creation, installation and deletion diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 32d99bf..808c8e8 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -2149,7 +2149,7 @@ arc_reclaim_thread(void) /* block until needed, or one second, whichever is shorter */ CALLB_CPR_SAFE_BEGIN(&cpr); - (void) cv_timedwait(&arc_reclaim_thr_cv, + (void) cv_timedwait_interruptible(&arc_reclaim_thr_cv, &arc_reclaim_thr_lock, (ddi_get_lbolt() + hz)); CALLB_CPR_SAFE_END(&cpr, &arc_reclaim_thr_lock); } @@ -4435,8 +4435,8 @@ l2arc_feed_thread(void) while (l2arc_thread_exit == 0) { CALLB_CPR_SAFE_BEGIN(&cpr); - (void) cv_timedwait(&l2arc_feed_thr_cv, &l2arc_feed_thr_lock, - next); + (void) cv_timedwait_interruptible(&l2arc_feed_thr_cv, + &l2arc_feed_thr_lock, next); CALLB_CPR_SAFE_END(&cpr, &l2arc_feed_thr_lock); next = ddi_get_lbolt() + hz; -- 1.8.3.1 From 683fe41fc718fd43f57aa9ca76457fe34e62057c Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 10 Dec 2010 12:54:30 -0800 Subject: [PATCH 04/16] Add missing mkdirp prototype For while now mkdirp has been built as part of libspl however the protoype was never added to libgen.h. This went unnoticed until enabling the mount support which uses mkdirp(). --- lib/libspl/include/libgen.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 lib/libspl/include/libgen.h diff --git a/lib/libspl/include/libgen.h b/lib/libspl/include/libgen.h new file mode 100644 index 0000000..29e5400 --- /dev/null +++ b/lib/libspl/include/libgen.h @@ -0,0 +1,34 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _LIBSPL_LIBGEN_H +#define _LIBSPL_LIBGEN_H + +#include + +extern int mkdirp(const char *, mode_t); + +#endif /* _LIBSPL_LIBGEN_H */ -- 1.8.3.1 From 149e873ab174ded1f632f2b2eb2267593517c7ca Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 16 Dec 2010 14:05:42 -0800 Subject: [PATCH 05/16] Fix minor compiler warnings These compiler warnings were introduced when code which was previously #ifdef'ed out by HAVE_ZPL was re-added for use by the posix layer. All of the following changes should be obviously correct and will cause no semantic changes. --- cmd/zfs/zfs_main.c | 12 +++++------ cmd/zinject/zinject.c | 2 +- lib/libzfs/libzfs_mount.c | 2 +- module/zfs/zfs_acl.c | 38 ++++++++++++++++----------------- module/zfs/zfs_dir.c | 6 +++--- module/zfs/zfs_vfsops.c | 18 +++++++++------- module/zfs/zfs_vnops.c | 53 ++++++++++++++++++++++++----------------------- module/zfs/zfs_znode.c | 2 +- 8 files changed, 68 insertions(+), 65 deletions(-) diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 5f22e43..e2c39a8 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -3153,11 +3153,11 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol, shared_nfs = zfs_is_shared_nfs(zhp, NULL); shared_smb = zfs_is_shared_smb(zhp, NULL); - if (shared_nfs && shared_smb || - (shared_nfs && strcmp(shareopts, "on") == 0 && - strcmp(smbshareopts, "off") == 0) || - (shared_smb && strcmp(smbshareopts, "on") == 0 && - strcmp(shareopts, "off") == 0)) { + if ((shared_nfs && shared_smb) || + ((shared_nfs && strcmp(shareopts, "on") == 0) && + (strcmp(smbshareopts, "off") == 0)) || + ((shared_smb && strcmp(smbshareopts, "on") == 0) && + (strcmp(shareopts, "off") == 0))) { if (!explicit) return (0); @@ -3622,7 +3622,7 @@ unshare_unmount(int op, int argc, char **argv) */ struct mnttab entry; uu_avl_pool_t *pool; - uu_avl_t *tree; + uu_avl_t *tree = NULL; unshare_unmount_node_t *node; uu_avl_index_t idx; uu_avl_walk_t *walk; diff --git a/cmd/zinject/zinject.c b/cmd/zinject/zinject.c index 3ad90e3..e76e626 100644 --- a/cmd/zinject/zinject.c +++ b/cmd/zinject/zinject.c @@ -566,7 +566,7 @@ main(int argc, char **argv) zinject_record_t record = { 0 }; char pool[MAXNAMELEN]; char dataset[MAXNAMELEN]; - zfs_handle_t *zhp; + zfs_handle_t *zhp = NULL; int nowrites = 0; int dur_txg = 0; int dur_secs = 0; diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index 4b9038d..88bd071 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -467,7 +467,7 @@ zfs_is_shared_proto(zfs_handle_t *zhp, char **where, zfs_share_proto_t proto) if (!zfs_is_mounted(zhp, &mountpoint)) return (SHARED_NOT_SHARED); - if (rc = is_shared(zhp->zfs_hdl, mountpoint, proto)) { + if ((rc = is_shared(zhp->zfs_hdl, mountpoint, proto))) { if (where != NULL) *where = mountpoint; else diff --git a/module/zfs/zfs_acl.c b/module/zfs/zfs_acl.c index f1ba9af..3efd4f8 100644 --- a/module/zfs/zfs_acl.c +++ b/module/zfs/zfs_acl.c @@ -494,7 +494,7 @@ zfs_acl_release_nodes(zfs_acl_t *aclp) { zfs_acl_node_t *aclnode; - while (aclnode = list_head(&aclp->z_acl)) { + while ((aclnode = list_head(&aclp->z_acl))) { list_remove(&aclp->z_acl, aclnode); zfs_acl_node_free(aclnode); } @@ -732,8 +732,8 @@ zfs_copy_fuid_2_ace(zfsvfs_t *zfsvfs, zfs_acl_t *aclp, cred_t *cr, size_t ace_size; uint16_t entry_type; - while (zacep = zfs_acl_next_ace(aclp, zacep, - &who, &access_mask, &iflags, &type)) { + while ((zacep = zfs_acl_next_ace(aclp, zacep, + &who, &access_mask, &iflags, &type))) { switch (type) { case ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE: @@ -823,8 +823,8 @@ zfs_acl_xform(znode_t *zp, zfs_acl_t *aclp, cred_t *cr) oldaclp = kmem_alloc(sizeof (zfs_oldace_t) * aclp->z_acl_count, KM_SLEEP); i = 0; - while (cookie = zfs_acl_next_ace(aclp, cookie, &who, - &access_mask, &iflags, &type)) { + while ((cookie = zfs_acl_next_ace(aclp, cookie, &who, + &access_mask, &iflags, &type))) { oldaclp[i].z_flags = iflags; oldaclp[i].z_type = type; oldaclp[i].z_fuid = who; @@ -904,8 +904,8 @@ zfs_mode_compute(uint64_t fmode, zfs_acl_t *aclp, mode = (fmode & (S_IFMT | S_ISUID | S_ISGID | S_ISVTX)); - while (acep = zfs_acl_next_ace(aclp, acep, &who, - &access_mask, &iflags, &type)) { + while ((acep = zfs_acl_next_ace(aclp, acep, &who, + &access_mask, &iflags, &type))) { if (!zfs_acl_valid_ace_type(type, iflags)) continue; @@ -1441,8 +1441,8 @@ zfs_acl_chmod(zfsvfs_t *zfsvfs, uint64_t mode, zfs_acl_t *aclp) new_bytes += abstract_size; } - while (acep = zfs_acl_next_ace(aclp, acep, &who, &access_mask, - &iflags, &type)) { + while ((acep = zfs_acl_next_ace(aclp, acep, &who, &access_mask, + &iflags, &type))) { uint16_t inherit_flags; entry_type = (iflags & ACE_TYPE_FLAGS); @@ -1584,8 +1584,8 @@ zfs_acl_inherit(zfsvfs_t *zfsvfs, vtype_t vtype, zfs_acl_t *paclp, aclp = zfs_acl_alloc(paclp->z_version); if (zfsvfs->z_acl_inherit == ZFS_ACL_DISCARD || vtype == VLNK) return (aclp); - while (pacep = zfs_acl_next_ace(paclp, pacep, &who, - &access_mask, &iflags, &type)) { + while ((pacep = zfs_acl_next_ace(paclp, pacep, &who, + &access_mask, &iflags, &type))) { /* * don't inherit bogus ACEs @@ -1837,7 +1837,7 @@ zfs_getacl(znode_t *zp, vsecattr_t *vsecp, boolean_t skipaclchk, cred_t *cr) if (mask == 0) return (ENOSYS); - if (error = zfs_zaccess(zp, ACE_READ_ACL, 0, skipaclchk, cr)) + if ((error = zfs_zaccess(zp, ACE_READ_ACL, 0, skipaclchk, cr))) return (error); mutex_enter(&zp->z_acl_lock); @@ -1857,8 +1857,8 @@ zfs_getacl(znode_t *zp, vsecattr_t *vsecp, boolean_t skipaclchk, cred_t *cr) uint32_t access_mask; uint16_t type, iflags; - while (zacep = zfs_acl_next_ace(aclp, zacep, - &who, &access_mask, &iflags, &type)) { + while ((zacep = zfs_acl_next_ace(aclp, zacep, + &who, &access_mask, &iflags, &type))) { switch (type) { case ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE: case ACE_ACCESS_DENIED_OBJECT_ACE_TYPE: @@ -1996,7 +1996,7 @@ zfs_setacl(znode_t *zp, vsecattr_t *vsecp, boolean_t skipaclchk, cred_t *cr) if (zp->z_pflags & ZFS_IMMUTABLE) return (EPERM); - if (error = zfs_zaccess(zp, ACE_WRITE_ACL, 0, skipaclchk, cr)) + if ((error = zfs_zaccess(zp, ACE_WRITE_ACL, 0, skipaclchk, cr))) return (error); error = zfs_vsec_2_aclp(zfsvfs, ZTOV(zp)->v_type, vsecp, cr, &fuidp, @@ -2173,8 +2173,8 @@ zfs_zaccess_aces_check(znode_t *zp, uint32_t *working_mode, ASSERT(zp->z_acl_cached); - while (acep = zfs_acl_next_ace(aclp, acep, &who, &access_mask, - &iflags, &type)) { + while ((acep = zfs_acl_next_ace(aclp, acep, &who, &access_mask, + &iflags, &type))) { uint32_t mask_matched; if (!zfs_acl_valid_ace_type(type, iflags)) @@ -2730,14 +2730,14 @@ zfs_zaccess_rename(znode_t *sdzp, znode_t *szp, znode_t *tdzp, * If that succeeds then check for add_file/add_subdir permissions */ - if (error = zfs_zaccess_delete(sdzp, szp, cr)) + if ((error = zfs_zaccess_delete(sdzp, szp, cr))) return (error); /* * If we have a tzp, see if we can delete it? */ if (tzp) { - if (error = zfs_zaccess_delete(tdzp, tzp, cr)) + if ((error = zfs_zaccess_delete(tdzp, tzp, cr))) return (error); } diff --git a/module/zfs/zfs_dir.c b/module/zfs/zfs_dir.c index f0084cd..a1f3df1 100644 --- a/module/zfs/zfs_dir.c +++ b/module/zfs/zfs_dir.c @@ -153,9 +153,9 @@ zfs_dirent_lock(zfs_dirlock_t **dlpp, znode_t *dzp, char *name, znode_t **zpp, /* * Verify that we are not trying to lock '.', '..', or '.zfs' */ - if (name[0] == '.' && - (name[1] == '\0' || (name[1] == '.' && name[2] == '\0')) || - zfs_has_ctldir(dzp) && strcmp(name, ZFS_CTLDIR_NAME) == 0) + if ((name[0] == '.' && + (name[1] == '\0' || (name[1] == '.' && name[2] == '\0'))) || + (zfs_has_ctldir(dzp) && strcmp(name, ZFS_CTLDIR_NAME) == 0)) return (EEXIST); /* diff --git a/module/zfs/zfs_vfsops.c b/module/zfs/zfs_vfsops.c index 77bef00..30bbccc 100644 --- a/module/zfs/zfs_vfsops.c +++ b/module/zfs/zfs_vfsops.c @@ -485,8 +485,8 @@ zfs_register_callbacks(vfs_t *vfsp) char osname[MAXNAMELEN]; dmu_objset_name(os, osname); - if (error = dsl_prop_get_integer(osname, "nbmand", &nbmand, - NULL)) { + if ((error = dsl_prop_get_integer(osname, "nbmand", &nbmand, + NULL))) { return (error); } } @@ -642,6 +642,8 @@ zfs_userquota_prop_to_obj(zfsvfs_t *zfsvfs, zfs_userquota_prop_t type) return (zfsvfs->z_userquota_obj); case ZFS_PROP_GROUPQUOTA: return (zfsvfs->z_groupquota_obj); + default: + return (ENOTSUP); } return (0); } @@ -873,7 +875,7 @@ zfsvfs_create(const char *osname, zfsvfs_t **zfvp) goto out; } else if (zfsvfs->z_version > zfs_zpl_version_map(spa_version(dmu_objset_spa(os)))) { - (void) printf("Can't mount a version %lld file system " + (void) printk("Can't mount a version %lld file system " "on a version %lld pool\n. Pool must be upgraded to mount " "this file system.", (u_longlong_t)zfsvfs->z_version, (u_longlong_t)spa_version(dmu_objset_spa(os))); @@ -1126,8 +1128,8 @@ zfs_domount(vfs_t *vfsp, char *osname) } ASSERT(vfs_devismounted(mount_dev) == 0); - if (error = dsl_prop_get_integer(osname, "recordsize", &recordsize, - NULL)) + if ((error = dsl_prop_get_integer(osname, "recordsize", + &recordsize, NULL))) goto out; vfsp->vfs_dev = mount_dev; @@ -1169,7 +1171,7 @@ zfs_domount(vfs_t *vfsp, char *osname) atime_changed_cb(zfsvfs, B_FALSE); readonly_changed_cb(zfsvfs, B_TRUE); - if (error = dsl_prop_get_integer(osname, "xattr", &pval, NULL)) + if ((error = dsl_prop_get_integer(osname,"xattr",&pval,NULL))) goto out; xattr_changed_cb(zfsvfs, pval); zfsvfs->z_issnap = B_TRUE; @@ -1565,7 +1567,7 @@ zfs_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr) /* * Get the objset name (the "special" mount argument). */ - if (error = pn_get(uap->spec, fromspace, &spn)) + if ((error = pn_get(uap->spec, fromspace, &spn))) return (error); osname = spn.pn_path; @@ -1968,7 +1970,7 @@ zfs_vget(vfs_t *vfsp, vnode_t **vpp, fid_t *fidp) gen_mask = -1ULL >> (64 - 8 * i); dprintf("getting %llu [%u mask %llx]\n", object, fid_gen, gen_mask); - if (err = zfs_zget(zfsvfs, object, &zp)) { + if ((err = zfs_zget(zfsvfs, object, &zp))) { ZFS_EXIT(zfsvfs); return (err); } diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index 5899c7f..44bae8e 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -450,7 +450,7 @@ zfs_read(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct) zfsvfs_t *zfsvfs = zp->z_zfsvfs; objset_t *os; ssize_t n, nbytes; - int error; + int error = 0; rl_t *rl; xuio_t *xuio = NULL; @@ -763,8 +763,8 @@ again: max_blksz); ASSERT(abuf != NULL); ASSERT(arc_buf_size(abuf) == max_blksz); - if (error = uiocopy(abuf->b_data, max_blksz, - UIO_WRITE, uio, &cbytes)) { + if ((error = uiocopy(abuf->b_data, max_blksz, + UIO_WRITE, uio, &cbytes))) { dmu_return_arcbuf(abuf); break; } @@ -1223,7 +1223,7 @@ zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct pathname *pnp, return (EINVAL); } - if (error = zfs_get_xattrdir(VTOZ(dvp), vpp, cr, flags)) { + if ((error = zfs_get_xattrdir(VTOZ(dvp), vpp, cr, flags))) { ZFS_EXIT(zfsvfs); return (error); } @@ -1232,8 +1232,8 @@ zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct pathname *pnp, * Do we have permission to get into attribute directory? */ - if (error = zfs_zaccess(VTOZ(*vpp), ACE_EXECUTE, 0, - B_FALSE, cr)) { + if ((error = zfs_zaccess(VTOZ(*vpp), ACE_EXECUTE, 0, + B_FALSE, cr))) { VN_RELE(*vpp); *vpp = NULL; } @@ -1251,7 +1251,7 @@ zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct pathname *pnp, * Check accessibility of directory. */ - if (error = zfs_zaccess(zdp, ACE_EXECUTE, 0, B_FALSE, cr)) { + if ((error = zfs_zaccess(zdp, ACE_EXECUTE, 0, B_FALSE, cr))) { ZFS_EXIT(zfsvfs); return (error); } @@ -1310,7 +1310,7 @@ zfs_create(vnode_t *dvp, char *name, vattr_t *vap, vcexcl_t excl, int error; ksid_t *ksid; uid_t uid; - gid_t gid = crgetgid(cr); + gid_t gid; zfs_acl_ids_t acl_ids; boolean_t fuid_dirtied; boolean_t have_acl = B_FALSE; @@ -1320,6 +1320,7 @@ zfs_create(vnode_t *dvp, char *name, vattr_t *vap, vcexcl_t excl, * make sure file system is at proper version */ + gid = crgetgid(cr); ksid = crgetsid(cr, KSID_OWNER); if (ksid) uid = ksid_getid(ksid); @@ -1389,7 +1390,7 @@ top: * Create a new file object and update the directory * to reference it. */ - if (error = zfs_zaccess(dzp, ACE_ADD_FILE, 0, B_FALSE, cr)) { + if ((error = zfs_zaccess(dzp, ACE_ADD_FILE, 0, B_FALSE, cr))) { if (have_acl) zfs_acl_ids_free(&acl_ids); goto out; @@ -1587,8 +1588,8 @@ top: /* * Attempt to lock directory; fail if entry doesn't exist. */ - if (error = zfs_dirent_lock(&dl, dzp, name, &zp, zflg, - NULL, realnmp)) { + if ((error = zfs_dirent_lock(&dl, dzp, name, &zp, zflg, + NULL, realnmp))) { if (realnmp) pn_free(realnmp); ZFS_EXIT(zfsvfs); @@ -1597,7 +1598,7 @@ top: vp = ZTOV(zp); - if (error = zfs_zaccess_delete(dzp, zp, cr)) { + if ((error = zfs_zaccess_delete(dzp, zp, cr))) { goto out; } @@ -1617,7 +1618,7 @@ top: dnlc_remove(dvp, name); mutex_enter(&vp->v_lock); - may_delete_now = vp->v_count == 1 && !vn_has_cached_data(vp); + may_delete_now = ((vp->v_count == 1) && (!vn_has_cached_data(vp))); mutex_exit(&vp->v_lock); /* @@ -1856,14 +1857,14 @@ zfs_mkdir(vnode_t *dvp, char *dirname, vattr_t *vap, vnode_t **vpp, cred_t *cr, top: *vpp = NULL; - if (error = zfs_dirent_lock(&dl, dzp, dirname, &zp, zf, - NULL, NULL)) { + if ((error = zfs_dirent_lock(&dl, dzp, dirname, &zp, zf, + NULL, NULL))) { zfs_acl_ids_free(&acl_ids); ZFS_EXIT(zfsvfs); return (error); } - if (error = zfs_zaccess(dzp, ACE_ADD_SUBDIRECTORY, 0, B_FALSE, cr)) { + if ((error = zfs_zaccess(dzp, ACE_ADD_SUBDIRECTORY, 0, B_FALSE, cr))) { zfs_acl_ids_free(&acl_ids); zfs_dirent_unlock(dl); ZFS_EXIT(zfsvfs); @@ -1987,15 +1988,15 @@ top: /* * Attempt to lock directory; fail if entry doesn't exist. */ - if (error = zfs_dirent_lock(&dl, dzp, name, &zp, zflg, - NULL, NULL)) { + if ((error = zfs_dirent_lock(&dl, dzp, name, &zp, zflg, + NULL, NULL))) { ZFS_EXIT(zfsvfs); return (error); } vp = ZTOV(zp); - if (error = zfs_zaccess_delete(dzp, zp, cr)) { + if ((error = zfs_zaccess_delete(dzp, zp, cr))) { goto out; } @@ -2442,8 +2443,8 @@ zfs_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr, */ if (!(zp->z_pflags & ZFS_ACL_TRIVIAL) && (vap->va_uid != crgetuid(cr))) { - if (error = zfs_zaccess(zp, ACE_READ_ATTRIBUTES, 0, - skipaclchk, cr)) { + if ((error = zfs_zaccess(zp, ACE_READ_ATTRIBUTES, 0, + skipaclchk, cr))) { ZFS_EXIT(zfsvfs); return (error); } @@ -3520,7 +3521,7 @@ top: * done in a single check. */ - if (error = zfs_zaccess_rename(sdzp, szp, tdzp, tzp, cr)) + if ((error = zfs_zaccess_rename(sdzp, szp, tdzp, tzp, cr))) goto out; if (ZTOV(szp)->v_type == VDIR) { @@ -3528,7 +3529,7 @@ top: * Check to make sure rename is valid. * Can't do a move like this: /usr/a/b to /usr/a/b/c/d */ - if (error = zfs_rename_lock(szp, tdzp, sdzp, &zl)) + if ((error = zfs_rename_lock(szp, tdzp, sdzp, &zl))) goto out; } @@ -3746,7 +3747,7 @@ top: return (error); } - if (error = zfs_zaccess(dzp, ACE_ADD_FILE, 0, B_FALSE, cr)) { + if ((error = zfs_zaccess(dzp, ACE_ADD_FILE, 0, B_FALSE, cr))) { zfs_acl_ids_free(&acl_ids); zfs_dirent_unlock(dl); ZFS_EXIT(zfsvfs); @@ -3969,7 +3970,7 @@ zfs_link(vnode_t *tdvp, vnode_t *svp, char *name, cred_t *cr, return (EPERM); } - if (error = zfs_zaccess(dzp, ACE_ADD_FILE, 0, B_FALSE, cr)) { + if ((error = zfs_zaccess(dzp, ACE_ADD_FILE, 0, B_FALSE, cr))) { ZFS_EXIT(zfsvfs); return (error); } @@ -4727,7 +4728,7 @@ zfs_space(vnode_t *vp, int cmd, flock64_t *bfp, int flag, return (EINVAL); } - if (error = convoff(vp, bfp, 0, offset)) { + if ((error = convoff(vp, bfp, 0, offset))) { ZFS_EXIT(zfsvfs); return (error); } diff --git a/module/zfs/zfs_znode.c b/module/zfs/zfs_znode.c index 4f6185f..93f2f02 100644 --- a/module/zfs/zfs_znode.c +++ b/module/zfs/zfs_znode.c @@ -1000,7 +1000,7 @@ zfs_mknode(znode_t *dzp, vattr_t *vap, dmu_tx_t *tx, cred_t *cr, if (obj_type == DMU_OT_ZNODE || acl_ids->z_aclp->z_version < ZFS_ACL_VERSION_FUID) { err = zfs_aclset_common(*zpp, acl_ids->z_aclp, cr, tx); - ASSERT3P(err, ==, 0); + ASSERT3S(err, ==, 0); } ZFS_OBJ_HOLD_EXIT(zfsvfs, obj); } -- 1.8.3.1 From 95c73795b001267d6b683b71e8abe51de4b0c938 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 7 Jan 2011 12:24:03 -0800 Subject: [PATCH 06/16] Fix ZVOL rename minor devices During a rename we need to be careful to destroy and create a new minor for the ZVOL _only_ if the rename succeeded. The previous code would both destroy you minor device unconditionally, it would also fail to create the new minor device on success. --- module/zfs/zfs_ioctl.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index 45e118e..6e8422b 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -3307,6 +3307,7 @@ static int zfs_ioc_rename(zfs_cmd_t *zc) { boolean_t recursive = zc->zc_cookie & 1; + int err; zc->zc_value[sizeof (zc->zc_value) - 1] = '\0'; if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0 || @@ -3320,13 +3321,18 @@ zfs_ioc_rename(zfs_cmd_t *zc) */ if (!recursive && strchr(zc->zc_name, '@') != NULL && zc->zc_objset_type == DMU_OST_ZFS) { - int err = zfs_unmount_snap(zc->zc_name, NULL); + err = zfs_unmount_snap(zc->zc_name, NULL); if (err) return (err); } - if (zc->zc_objset_type == DMU_OST_ZVOL) + + err = dmu_objset_rename(zc->zc_name, zc->zc_value, recursive); + if ((err == 0) && (zc->zc_objset_type == DMU_OST_ZVOL)) { (void) zvol_remove_minor(zc->zc_name); - return (dmu_objset_rename(zc->zc_name, zc->zc_value, recursive)); + (void) zvol_create_minor(zc->zc_value); + } + + return (err); } static int -- 1.8.3.1 From b3259b6a2ba29595dc5f2df0f6def8c7fc6bcb98 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 16 Dec 2010 14:26:08 -0800 Subject: [PATCH 07/16] Autoconf selinux support If libselinux is detected on your system at configure time link against it. This allows us to use a library call to detect if selinux is enabled and if it is to pass the mount option: "context=\"system_u:object_r:file_t:s0" For now this is required because none of the existing selinux policies are aware of the zfs filesystem type. Because of this they do not properly enable xattr based labeling even though zfs supports all of the required hooks. Until distro's add zfs as a known xattr friendly fs type we must use mntpoint labeling. Alternately, end users could modify their existing selinux policy with a little guidance. --- Makefile.in | 2 + cmd/Makefile.in | 2 + cmd/zdb/Makefile.in | 2 + cmd/zfs/Makefile.in | 2 + cmd/zinject/Makefile.in | 2 + cmd/zpios/Makefile.in | 2 + cmd/zpool/Makefile.in | 2 + cmd/zpool_id/Makefile.in | 2 + cmd/zpool_layout/Makefile.in | 2 + cmd/ztest/Makefile.in | 2 + config/user-selinux.m4 | 36 ++ config/user.m4 | 1 + configure | 555 +++++++++++++++++++++++++++- etc/Makefile.in | 2 + include/Makefile.in | 2 + include/sys/Makefile.in | 2 + include/sys/fm/Makefile.in | 2 + include/sys/fm/fs/Makefile.in | 2 + include/sys/fs/Makefile.in | 2 + lib/Makefile.in | 2 + lib/libavl/Makefile.in | 2 + lib/libefi/Makefile.in | 2 + lib/libnvpair/Makefile.in | 2 + lib/libspl/Makefile.in | 2 + lib/libspl/asm-generic/Makefile.in | 2 + lib/libspl/asm-i386/Makefile.in | 2 + lib/libspl/asm-x86_64/Makefile.in | 2 + lib/libspl/include/Makefile.in | 2 + lib/libspl/include/ia32/Makefile.in | 2 + lib/libspl/include/ia32/sys/Makefile.in | 2 + lib/libspl/include/rpc/Makefile.in | 2 + lib/libspl/include/sys/Makefile.in | 2 + lib/libspl/include/sys/dktp/Makefile.in | 2 + lib/libspl/include/sys/sysevent/Makefile.in | 2 + lib/libspl/include/util/Makefile.in | 2 + lib/libunicode/Makefile.in | 2 + lib/libuutil/Makefile.in | 2 + lib/libzfs/Makefile.am | 2 +- lib/libzfs/Makefile.in | 4 +- lib/libzfs/libzfs_mount.c | 9 + lib/libzpool/Makefile.in | 2 + man/Makefile.in | 2 + man/man8/Makefile.in | 2 + scripts/Makefile.in | 2 + scripts/zpios-profile/Makefile.in | 2 + scripts/zpios-test/Makefile.in | 2 + scripts/zpool-config/Makefile.in | 2 + scripts/zpool-layout/Makefile.in | 2 + zfs_config.h.in | 3 + 49 files changed, 678 insertions(+), 16 deletions(-) create mode 100644 config/user-selinux.m4 diff --git a/Makefile.in b/Makefile.in index 2502482..09708bf 100644 --- a/Makefile.in +++ b/Makefile.in @@ -80,6 +80,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -210,6 +211,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/cmd/Makefile.in b/cmd/Makefile.in index f8f5a76..bed2951 100644 --- a/cmd/Makefile.in +++ b/cmd/Makefile.in @@ -65,6 +65,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -178,6 +179,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/cmd/zdb/Makefile.in b/cmd/zdb/Makefile.in index 88152b8..b84eb2c 100644 --- a/cmd/zdb/Makefile.in +++ b/cmd/zdb/Makefile.in @@ -68,6 +68,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -180,6 +181,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/cmd/zfs/Makefile.in b/cmd/zfs/Makefile.in index dd44b26..6bd1f3f 100644 --- a/cmd/zfs/Makefile.in +++ b/cmd/zfs/Makefile.in @@ -68,6 +68,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -180,6 +181,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/cmd/zinject/Makefile.in b/cmd/zinject/Makefile.in index ddf61bc..c259867 100644 --- a/cmd/zinject/Makefile.in +++ b/cmd/zinject/Makefile.in @@ -68,6 +68,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -180,6 +181,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/cmd/zpios/Makefile.in b/cmd/zpios/Makefile.in index 911f9c3..c30a3e0 100644 --- a/cmd/zpios/Makefile.in +++ b/cmd/zpios/Makefile.in @@ -68,6 +68,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -170,6 +171,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/cmd/zpool/Makefile.in b/cmd/zpool/Makefile.in index 258de64..b628756 100644 --- a/cmd/zpool/Makefile.in +++ b/cmd/zpool/Makefile.in @@ -68,6 +68,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -181,6 +182,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/cmd/zpool_id/Makefile.in b/cmd/zpool_id/Makefile.in index 6d2fd50..932bc25 100644 --- a/cmd/zpool_id/Makefile.in +++ b/cmd/zpool_id/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -163,6 +164,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/cmd/zpool_layout/Makefile.in b/cmd/zpool_layout/Makefile.in index ea8947c..9b1b5eb 100644 --- a/cmd/zpool_layout/Makefile.in +++ b/cmd/zpool_layout/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -163,6 +164,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/cmd/ztest/Makefile.in b/cmd/ztest/Makefile.in index c102d02..3b4e7c4 100644 --- a/cmd/ztest/Makefile.in +++ b/cmd/ztest/Makefile.in @@ -68,6 +68,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -180,6 +181,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/config/user-selinux.m4 b/config/user-selinux.m4 new file mode 100644 index 0000000..84df6ce --- /dev/null +++ b/config/user-selinux.m4 @@ -0,0 +1,36 @@ +dnl # +dnl # Check to see if the selinux libraries are available. If they +dnl # are then they will be consulted during mount to determine if +dnl # selinux is enabled or disabled. +dnl # +AC_DEFUN([ZFS_AC_CONFIG_USER_LIBSELINUX], [ + AC_ARG_WITH([selinux], + [AS_HELP_STRING([--with-selinux], + [support selinux @<:@default=check@:>@])], + [], + [with_selinux=check]) + + LIBSELINUX= + AS_IF([test "x$with_selinux" != xno], [ + AC_CHECK_HEADER([selinux/selinux.h], [ + AC_CHECK_LIB([selinux], [is_selinux_enabled], [ + AC_SUBST([LIBSELINUX], ["-lselinux"]) + AC_DEFINE([HAVE_LIBSELINUX], 1, + [Define if you have selinux]) + ], [ + AS_IF([test "x$with_selinux" != xcheck], + [AC_MSG_FAILURE( + [--with-selinux given but unavailable]) + ]) + ]) + ], [ + AS_IF([test "x$with_selinux" != xcheck], + [AC_MSG_FAILURE( + [--with-selinux given but unavailable]) + ]) + ]) + ], [ + AC_MSG_CHECKING([for selinux support]) + AC_MSG_RESULT([no]) + ]) +]) diff --git a/config/user.m4 b/config/user.m4 index bc68808..6f02769 100644 --- a/config/user.m4 +++ b/config/user.m4 @@ -8,6 +8,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [ ZFS_AC_CONFIG_USER_ZLIB ZFS_AC_CONFIG_USER_LIBUUID ZFS_AC_CONFIG_USER_LIBBLKID + ZFS_AC_CONFIG_USER_LIBSELINUX ZFS_AC_CONFIG_USER_FRAME_LARGER_THAN ZFS_AC_CONFIG_USER_STACK_GUARD ]) diff --git a/configure b/configure index 8c4ce63..48bf4cb 100755 --- a/configure +++ b/configure @@ -794,6 +794,7 @@ CONFIG_KERNEL_TRUE CONFIG_USER_FALSE CONFIG_USER_TRUE FRAME_LARGER_THAN +LIBSELINUX LIBBLKID LIBUUID ZLIB @@ -972,6 +973,7 @@ with_linux_obj with_spl with_spl_obj with_blkid +with_selinux enable_debug ' ac_precious_vars='build_alias @@ -1639,6 +1641,7 @@ Optional Packages: --with-spl=PATH Path to spl source --with-spl-obj=PATH Path to spl build objects --with-blkid support blkid caching [default=check] + --with-selinux support selinux [default=check] Some influential environment variables: CC C compiler command @@ -4817,13 +4820,13 @@ if test "${lt_cv_nm_interface+set}" = set; then else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:4820: $ac_compile\"" >&5) + (eval echo "\"\$as_me:4823: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:4823: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:4826: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:4826: output\"" >&5) + (eval echo "\"\$as_me:4829: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -6029,7 +6032,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 6032 "configure"' > conftest.$ac_ext + echo '#line 6035 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -7882,11 +7885,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7885: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7888: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7889: \$? = $ac_status" >&5 + echo "$as_me:7892: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -8221,11 +8224,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8224: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8227: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8228: \$? = $ac_status" >&5 + echo "$as_me:8231: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -8326,11 +8329,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8329: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8332: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:8333: \$? = $ac_status" >&5 + echo "$as_me:8336: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -8381,11 +8384,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8384: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8387: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:8388: \$? = $ac_status" >&5 + echo "$as_me:8391: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -11184,7 +11187,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11187 "configure" +#line 11190 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11280,7 +11283,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11283 "configure" +#line 11286 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -14979,6 +14982,268 @@ fi + +# Check whether --with-selinux was given. +if test "${with_selinux+set}" = set; then + withval=$with_selinux; +else + with_selinux=check +fi + + + LIBSELINUX= + if test "x$with_selinux" != xno; then + + if test "${ac_cv_header_selinux_selinux_h+set}" = set; then + { $as_echo "$as_me:$LINENO: checking for selinux/selinux.h" >&5 +$as_echo_n "checking for selinux/selinux.h... " >&6; } +if test "${ac_cv_header_selinux_selinux_h+set}" = set; then + $as_echo_n "(cached) " >&6 +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_selinux_selinux_h" >&5 +$as_echo "$ac_cv_header_selinux_selinux_h" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking selinux/selinux.h usability" >&5 +$as_echo_n "checking selinux/selinux.h usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking selinux/selinux.h presence" >&5 +$as_echo_n "checking selinux/selinux.h presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: selinux/selinux.h: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: selinux/selinux.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: selinux/selinux.h: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: selinux/selinux.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: selinux/selinux.h: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: selinux/selinux.h: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: selinux/selinux.h: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: selinux/selinux.h: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: selinux/selinux.h: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: selinux/selinux.h: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: selinux/selinux.h: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: selinux/selinux.h: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: selinux/selinux.h: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: selinux/selinux.h: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: selinux/selinux.h: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: selinux/selinux.h: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for selinux/selinux.h" >&5 +$as_echo_n "checking for selinux/selinux.h... " >&6; } +if test "${ac_cv_header_selinux_selinux_h+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_cv_header_selinux_selinux_h=$ac_header_preproc +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_selinux_selinux_h" >&5 +$as_echo "$ac_cv_header_selinux_selinux_h" >&6; } + +fi +if test "x$ac_cv_header_selinux_selinux_h" = x""yes; then + + { $as_echo "$as_me:$LINENO: checking for is_selinux_enabled in -lselinux" >&5 +$as_echo_n "checking for is_selinux_enabled in -lselinux... " >&6; } +if test "${ac_cv_lib_selinux_is_selinux_enabled+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lselinux $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char is_selinux_enabled (); +int +main () +{ +return is_selinux_enabled (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_selinux_is_selinux_enabled=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_selinux_is_selinux_enabled=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_selinux_is_selinux_enabled" >&5 +$as_echo "$ac_cv_lib_selinux_is_selinux_enabled" >&6; } +if test "x$ac_cv_lib_selinux_is_selinux_enabled" = x""yes; then + + LIBSELINUX="-lselinux" + + +cat >>confdefs.h <<\_ACEOF +#define HAVE_LIBSELINUX 1 +_ACEOF + + +else + + if test "x$with_selinux" != xcheck; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: --with-selinux given but unavailable +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: --with-selinux given but unavailable +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } + +fi + + +fi + + +else + + if test "x$with_selinux" != xcheck; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: --with-selinux given but unavailable +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: --with-selinux given but unavailable +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } + +fi + + +fi + + + +else + + { $as_echo "$as_me:$LINENO: checking for selinux support" >&5 +$as_echo_n "checking for selinux support... " >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + +fi + + + { $as_echo "$as_me:$LINENO: checking for -Wframe-larger-than= support" >&5 $as_echo_n "checking for -Wframe-larger-than= support... " >&6; } @@ -18314,6 +18579,268 @@ fi + +# Check whether --with-selinux was given. +if test "${with_selinux+set}" = set; then + withval=$with_selinux; +else + with_selinux=check +fi + + + LIBSELINUX= + if test "x$with_selinux" != xno; then + + if test "${ac_cv_header_selinux_selinux_h+set}" = set; then + { $as_echo "$as_me:$LINENO: checking for selinux/selinux.h" >&5 +$as_echo_n "checking for selinux/selinux.h... " >&6; } +if test "${ac_cv_header_selinux_selinux_h+set}" = set; then + $as_echo_n "(cached) " >&6 +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_selinux_selinux_h" >&5 +$as_echo "$ac_cv_header_selinux_selinux_h" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:$LINENO: checking selinux/selinux.h usability" >&5 +$as_echo_n "checking selinux/selinux.h usability... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:$LINENO: checking selinux/selinux.h presence" >&5 +$as_echo_n "checking selinux/selinux.h presence... " >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { $as_echo "$as_me:$LINENO: WARNING: selinux/selinux.h: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: selinux/selinux.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: selinux/selinux.h: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: selinux/selinux.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { $as_echo "$as_me:$LINENO: WARNING: selinux/selinux.h: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: selinux/selinux.h: present but cannot be compiled" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: selinux/selinux.h: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: selinux/selinux.h: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: selinux/selinux.h: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: selinux/selinux.h: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: selinux/selinux.h: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: selinux/selinux.h: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: selinux/selinux.h: proceeding with the preprocessor's result" >&5 +$as_echo "$as_me: WARNING: selinux/selinux.h: proceeding with the preprocessor's result" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: selinux/selinux.h: in the future, the compiler will take precedence" >&5 +$as_echo "$as_me: WARNING: selinux/selinux.h: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ $as_echo "$as_me:$LINENO: checking for selinux/selinux.h" >&5 +$as_echo_n "checking for selinux/selinux.h... " >&6; } +if test "${ac_cv_header_selinux_selinux_h+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_cv_header_selinux_selinux_h=$ac_header_preproc +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_selinux_selinux_h" >&5 +$as_echo "$ac_cv_header_selinux_selinux_h" >&6; } + +fi +if test "x$ac_cv_header_selinux_selinux_h" = x""yes; then + + { $as_echo "$as_me:$LINENO: checking for is_selinux_enabled in -lselinux" >&5 +$as_echo_n "checking for is_selinux_enabled in -lselinux... " >&6; } +if test "${ac_cv_lib_selinux_is_selinux_enabled+set}" = set; then + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lselinux $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char is_selinux_enabled (); +int +main () +{ +return is_selinux_enabled (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" +$as_echo "$ac_try_echo") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then + ac_cv_lib_selinux_is_selinux_enabled=yes +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_selinux_is_selinux_enabled=no +fi + +rm -rf conftest.dSYM +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_selinux_is_selinux_enabled" >&5 +$as_echo "$ac_cv_lib_selinux_is_selinux_enabled" >&6; } +if test "x$ac_cv_lib_selinux_is_selinux_enabled" = x""yes; then + + LIBSELINUX="-lselinux" + + +cat >>confdefs.h <<\_ACEOF +#define HAVE_LIBSELINUX 1 +_ACEOF + + +else + + if test "x$with_selinux" != xcheck; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: --with-selinux given but unavailable +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: --with-selinux given but unavailable +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } + +fi + + +fi + + +else + + if test "x$with_selinux" != xcheck; then + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +{ { $as_echo "$as_me:$LINENO: error: --with-selinux given but unavailable +See \`config.log' for more details." >&5 +$as_echo "$as_me: error: --with-selinux given but unavailable +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; }; } + +fi + + +fi + + + +else + + { $as_echo "$as_me:$LINENO: checking for selinux support" >&5 +$as_echo_n "checking for selinux support... " >&6; } + { $as_echo "$as_me:$LINENO: result: no" >&5 +$as_echo "no" >&6; } + +fi + + + { $as_echo "$as_me:$LINENO: checking for -Wframe-larger-than= support" >&5 $as_echo_n "checking for -Wframe-larger-than= support... " >&6; } diff --git a/etc/Makefile.in b/etc/Makefile.in index 5eb5551..eb8ad95 100644 --- a/etc/Makefile.in +++ b/etc/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -163,6 +164,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/include/Makefile.in b/include/Makefile.in index 6821a67..7a1f40a 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -222,6 +223,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/include/sys/Makefile.in b/include/sys/Makefile.in index 8964aae..d3985cc 100644 --- a/include/sys/Makefile.in +++ b/include/sys/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -343,6 +344,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/include/sys/fm/Makefile.in b/include/sys/fm/Makefile.in index 5e1f4b8..b275659 100644 --- a/include/sys/fm/Makefile.in +++ b/include/sys/fm/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -207,6 +208,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/include/sys/fm/fs/Makefile.in b/include/sys/fm/fs/Makefile.in index ed828eb..e8d289a 100644 --- a/include/sys/fm/fs/Makefile.in +++ b/include/sys/fm/fs/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -167,6 +168,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/include/sys/fs/Makefile.in b/include/sys/fs/Makefile.in index 3103ffa..d1ee3b2 100644 --- a/include/sys/fs/Makefile.in +++ b/include/sys/fs/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -167,6 +168,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/Makefile.in b/lib/Makefile.in index 9749b77..18ff052 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -65,6 +65,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -178,6 +179,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/libavl/Makefile.in b/lib/libavl/Makefile.in index 930f8e5..500846a 100644 --- a/lib/libavl/Makefile.in +++ b/lib/libavl/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -190,6 +191,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/libefi/Makefile.in b/lib/libefi/Makefile.in index 294cac0..1f44090 100644 --- a/lib/libefi/Makefile.in +++ b/lib/libefi/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -190,6 +191,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/libnvpair/Makefile.in b/lib/libnvpair/Makefile.in index 8f689d4..e1027d5 100644 --- a/lib/libnvpair/Makefile.in +++ b/lib/libnvpair/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -191,6 +192,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/libspl/Makefile.in b/lib/libspl/Makefile.in index 6bf1478..385a567 100644 --- a/lib/libspl/Makefile.in +++ b/lib/libspl/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -241,6 +242,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/libspl/asm-generic/Makefile.in b/lib/libspl/asm-generic/Makefile.in index 8b87c31..162c386 100644 --- a/lib/libspl/asm-generic/Makefile.in +++ b/lib/libspl/asm-generic/Makefile.in @@ -66,6 +66,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -139,6 +140,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/libspl/asm-i386/Makefile.in b/lib/libspl/asm-i386/Makefile.in index fe9d9cb..9a26bb4 100644 --- a/lib/libspl/asm-i386/Makefile.in +++ b/lib/libspl/asm-i386/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -143,6 +144,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/libspl/asm-x86_64/Makefile.in b/lib/libspl/asm-x86_64/Makefile.in index 7506903..a00f235 100644 --- a/lib/libspl/asm-x86_64/Makefile.in +++ b/lib/libspl/asm-x86_64/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -143,6 +144,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/libspl/include/Makefile.in b/lib/libspl/include/Makefile.in index 1a0a7f8..3605600 100644 --- a/lib/libspl/include/Makefile.in +++ b/lib/libspl/include/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -203,6 +204,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/libspl/include/ia32/Makefile.in b/lib/libspl/include/ia32/Makefile.in index 4b97ee1..a9f80cd 100644 --- a/lib/libspl/include/ia32/Makefile.in +++ b/lib/libspl/include/ia32/Makefile.in @@ -65,6 +65,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -178,6 +179,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/libspl/include/ia32/sys/Makefile.in b/lib/libspl/include/ia32/sys/Makefile.in index 1b2fb35..fb0fe3f 100644 --- a/lib/libspl/include/ia32/sys/Makefile.in +++ b/lib/libspl/include/ia32/sys/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -165,6 +166,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/libspl/include/rpc/Makefile.in b/lib/libspl/include/rpc/Makefile.in index f5385d9..1fd162a 100644 --- a/lib/libspl/include/rpc/Makefile.in +++ b/lib/libspl/include/rpc/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -165,6 +166,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/libspl/include/sys/Makefile.in b/lib/libspl/include/sys/Makefile.in index 20fdfca..0746ded 100644 --- a/lib/libspl/include/sys/Makefile.in +++ b/lib/libspl/include/sys/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -203,6 +204,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/libspl/include/sys/dktp/Makefile.in b/lib/libspl/include/sys/dktp/Makefile.in index 713aa88..499081a 100644 --- a/lib/libspl/include/sys/dktp/Makefile.in +++ b/lib/libspl/include/sys/dktp/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -165,6 +166,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/libspl/include/sys/sysevent/Makefile.in b/lib/libspl/include/sys/sysevent/Makefile.in index 858e388..0a9c6d1 100644 --- a/lib/libspl/include/sys/sysevent/Makefile.in +++ b/lib/libspl/include/sys/sysevent/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -165,6 +166,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/libspl/include/util/Makefile.in b/lib/libspl/include/util/Makefile.in index 1cdbb57..27aa363 100644 --- a/lib/libspl/include/util/Makefile.in +++ b/lib/libspl/include/util/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -165,6 +166,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/libunicode/Makefile.in b/lib/libunicode/Makefile.in index 1f431da..5daee2b 100644 --- a/lib/libunicode/Makefile.in +++ b/lib/libunicode/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -190,6 +191,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/libuutil/Makefile.in b/lib/libuutil/Makefile.in index e600ba4..1a28249 100644 --- a/lib/libuutil/Makefile.in +++ b/lib/libuutil/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -192,6 +193,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/lib/libzfs/Makefile.am b/lib/libzfs/Makefile.am index 70210c3..de52122 100644 --- a/lib/libzfs/Makefile.am +++ b/lib/libzfs/Makefile.am @@ -6,7 +6,7 @@ DEFAULT_INCLUDES += \ lib_LTLIBRARIES = libzfs.la -libzfs_la_LDFLAGS = -lm +libzfs_la_LDFLAGS = -lm $(LIBSELINUX) libzfs_la_LIBADD = \ $(top_builddir)/lib/libefi/libefi.la \ diff --git a/lib/libzfs/Makefile.in b/lib/libzfs/Makefile.in index 741f39d..c8b5004 100644 --- a/lib/libzfs/Makefile.in +++ b/lib/libzfs/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -197,6 +198,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ @@ -314,7 +316,7 @@ AM_CFLAGS = -Wall -Wstrict-prototypes -fno-strict-aliasing \ -D_POSIX_PTHREAD_SEMANTICS -D_FILE_OFFSET_BITS=64 \ -D_LARGEFILE64_SOURCE -DTEXT_DOMAIN=\"zfs-linux-user\" lib_LTLIBRARIES = libzfs.la -libzfs_la_LDFLAGS = -lm +libzfs_la_LDFLAGS = -lm $(LIBSELINUX) libzfs_la_LIBADD = \ $(top_builddir)/lib/libefi/libefi.la \ $(top_builddir)/lib/libuutil/libuutil.la diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index 88bd071..9950bf9 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -72,6 +72,9 @@ #include #include #include +#ifdef HAVE_LIBSELINUX +#include +#endif /* HAVE_LIBSELINUX */ #include @@ -277,6 +280,12 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags) if (zpool_get_prop_int(zhp->zpool_hdl, ZPOOL_PROP_READONLY, NULL)) flags |= MS_RDONLY; +#ifdef HAVE_LIBSELINUX + if (is_selinux_enabled()) + (void) strlcat(mntopts, ",context=\"system_u:" + "object_r:file_t:s0\"", sizeof (mntopts)); +#endif /* HAVE_LIBSELINUX */ + if (!zfs_is_mountable(zhp, mountpoint, sizeof (mountpoint), NULL)) return (0); diff --git a/lib/libzpool/Makefile.in b/lib/libzpool/Makefile.in index 99ad719..421e55c 100644 --- a/lib/libzpool/Makefile.in +++ b/lib/libzpool/Makefile.in @@ -67,6 +67,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -211,6 +212,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/man/Makefile.in b/man/Makefile.in index c18b275..47a16fe 100644 --- a/man/Makefile.in +++ b/man/Makefile.in @@ -65,6 +65,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -178,6 +179,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/man/man8/Makefile.in b/man/man8/Makefile.in index 8cace2c..0a96d97 100644 --- a/man/man8/Makefile.in +++ b/man/man8/Makefile.in @@ -65,6 +65,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -163,6 +164,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/scripts/Makefile.in b/scripts/Makefile.in index 3e68eda..076fc6c 100644 --- a/scripts/Makefile.in +++ b/scripts/Makefile.in @@ -66,6 +66,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -203,6 +204,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/scripts/zpios-profile/Makefile.in b/scripts/zpios-profile/Makefile.in index 1aa1306..fe89e1d 100644 --- a/scripts/zpios-profile/Makefile.in +++ b/scripts/zpios-profile/Makefile.in @@ -66,6 +66,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -163,6 +164,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/scripts/zpios-test/Makefile.in b/scripts/zpios-test/Makefile.in index dcd0fca..09f0503 100644 --- a/scripts/zpios-test/Makefile.in +++ b/scripts/zpios-test/Makefile.in @@ -66,6 +66,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -163,6 +164,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/scripts/zpool-config/Makefile.in b/scripts/zpool-config/Makefile.in index 56a5630..71ef3c5 100644 --- a/scripts/zpool-config/Makefile.in +++ b/scripts/zpool-config/Makefile.in @@ -66,6 +66,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -163,6 +164,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/scripts/zpool-layout/Makefile.in b/scripts/zpool-layout/Makefile.in index baa2088..d270230 100644 --- a/scripts/zpool-layout/Makefile.in +++ b/scripts/zpool-layout/Makefile.in @@ -66,6 +66,7 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ + $(top_srcdir)/config/user-selinux.m4 \ $(top_srcdir)/config/user-zlib.m4 $(top_srcdir)/config/user.m4 \ $(top_srcdir)/config/zfs-build.m4 \ $(top_srcdir)/config/zfs-meta.m4 $(top_srcdir)/configure.ac @@ -163,6 +164,7 @@ LDFLAGS = @LDFLAGS@ LIBBLKID = @LIBBLKID@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LIBSELINUX = @LIBSELINUX@ LIBTOOL = @LIBTOOL@ LIBUUID = @LIBUUID@ LINUX = @LINUX@ diff --git a/zfs_config.h.in b/zfs_config.h.in index 6e0e623..e1532f6 100644 --- a/zfs_config.h.in +++ b/zfs_config.h.in @@ -84,6 +84,9 @@ /* Define if you have libblkid */ #undef HAVE_LIBBLKID +/* Define if you have selinux */ +#undef HAVE_LIBSELINUX + /* Define to 1 if 'libshare' library available */ #undef HAVE_LIBSHARE -- 1.8.3.1 From 3b8cfee8af1d966eea75389e2a2e53a5a8dca600 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Wed, 8 Dec 2010 16:40:11 -0800 Subject: [PATCH 08/16] Enable mount.zfs helper While not strictly required to mount a zfs filesystem using a mount helper has certain advantages. First, we need it if we want to honor the mount behavior as found on Solaris. As part of the mount we need to validate that the dataset has the legacy mount property set if we are using 'mount' instead of 'zfs mount'. Secondly, by using a mount helper we can automatically load the zpl kernel module. This way you can just issue a 'mount' or 'zfs mount' and it will just work. Finally, it gives us common hook in user space to add any zfs specific mount options we might want. At the moment we don't have any but now the infrastructure is at least in place. --- cmd/zfs/zfs_main.c | 220 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 188 insertions(+), 32 deletions(-) diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index e2c39a8..2aa3e2e 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -3864,45 +3864,208 @@ zfs_do_python(int argc, char **argv) return (-1); } +typedef struct option_map { + const char *name; + int mask; +} option_map_t; + +static const option_map_t option_map[] = { + /* Canonicalized filesystem independent options from mount(8) */ + { MNTOPT_NOAUTO, MS_COMMENT }, + { MNTOPT_DEFAULTS, MS_COMMENT }, + { MNTOPT_NODEVICES, MS_NODEV }, + { MNTOPT_DIRSYNC, MS_DIRSYNC }, + { MNTOPT_NOEXEC, MS_NOEXEC }, + { MNTOPT_GROUP, MS_GROUP }, + { MNTOPT_NETDEV, MS_COMMENT }, + { MNTOPT_NOFAIL, MS_COMMENT }, + { MNTOPT_NOSUID, MS_NOSUID }, + { MNTOPT_OWNER, MS_OWNER }, + { MNTOPT_REMOUNT, MS_REMOUNT }, + { MNTOPT_RO, MS_RDONLY }, + { MNTOPT_SYNC, MS_SYNCHRONOUS }, + { MNTOPT_USER, MS_USERS }, + { MNTOPT_USERS, MS_USERS }, +#ifdef MS_NOATIME + { MNTOPT_NOATIME, MS_NOATIME }, +#endif +#ifdef MS_NODIRATIME + { MNTOPT_NODIRATIME, MS_NODIRATIME }, +#endif +#ifdef MS_RELATIME + { MNTOPT_RELATIME, MS_RELATIME }, +#endif +#ifdef MS_STRICTATIME + { MNTOPT_DFRATIME, MS_STRICTATIME }, +#endif +#ifdef HAVE_SELINUX + { MNTOPT_CONTEXT, MS_COMMENT }, + { MNTOPT_FSCONTEXT, MS_COMMENT }, + { MNTOPT_DEFCONTEXT, MS_COMMENT }, + { MNTOPT_ROOTCONTEXT, MS_COMMENT }, +#endif +#ifdef MS_I_VERSION + { MNTOPT_IVERSION, MS_I_VERSION }, +#endif +#ifdef MS_MANDLOCK + { MNTOPT_NBMAND, MS_MANDLOCK }, +#endif + /* Valid options not found in mount(8) */ + { MNTOPT_BIND, MS_BIND }, + { MNTOPT_RBIND, MS_BIND|MS_REC }, + { MNTOPT_COMMENT, MS_COMMENT }, + { MNTOPT_BOOTWAIT, MS_COMMENT }, + { MNTOPT_NOBOOTWAIT, MS_COMMENT }, + { MNTOPT_OPTIONAL, MS_COMMENT }, + { MNTOPT_SHOWTHROUGH, MS_COMMENT }, +#ifdef MS_NOSUB + { MNTOPT_NOSUB, MS_NOSUB }, +#endif +#ifdef MS_SILENT + { MNTOPT_QUIET, MS_SILENT }, +#endif + /* Custom zfs options */ + { MNTOPT_NOXATTR, MS_COMMENT }, + { NULL, 0 } }; + /* - * Called when invoked as /etc/fs/zfs/mount. Do the mount if the mountpoint is - * 'legacy'. Otherwise, complain that use should be using 'zfs mount'. + * Break the mount option in to a name/value pair. The name is + * validated against the option map and mount flags set accordingly. + */ +static int +parse_option(char *mntopt, unsigned long *mntflags, int sloppy) +{ + const option_map_t *opt; + char *ptr, *name, *value = NULL; + int rc; + + name = strdup(mntopt); + if (name == NULL) + return (ENOMEM); + + for (ptr = name; ptr && *ptr; ptr++) { + if (*ptr == '=') { + *ptr = '\0'; + value = ptr+1; + break; + } + } + + for (opt = option_map; opt->name != NULL; opt++) { + if (strncmp(name, opt->name, strlen(name)) == 0) { + *mntflags |= opt->mask; + + /* MS_USERS implies default user options */ + if (opt->mask & (MS_USERS)) + *mntflags |= (MS_NOEXEC|MS_NOSUID|MS_NODEV); + + /* MS_OWNER|MS_GROUP imply default owner options */ + if (opt->mask & (MS_OWNER | MS_GROUP)) + *mntflags |= (MS_NOSUID|MS_NODEV); + + rc = 0; + goto out; + } + } + + if (!sloppy) + rc = ENOENT; +out: + /* If required further process on the value may be done here */ + free(name); + return (rc); +} + +/* + * Translate the mount option string in to MS_* mount flags for the + * kernel vfs. When sloppy is non-zero unknown options will be ignored + * otherwise they are considered fatal are copied in to badopt. + */ +static int +parse_options(char *mntopts, unsigned long *mntflags, int sloppy, char *badopt) +{ + int rc = 0, quote = 0; + char *ptr, *opt, *opts; + + opts = strdup(mntopts); + if (opts == NULL) + return (ENOMEM); + + *mntflags = 0; + opt = NULL; + + /* + * Scan through all mount options which must be comma delimited. + * We must be careful to notice regions which are double quoted + * and skip commas in these regions. Each option is then checked + * to determine if it is a known option. + */ + for (ptr = opts; ptr && *ptr; ptr++) { + if (opt == NULL) + opt = ptr; + + if (*ptr == '"') + quote = !quote; + + if (quote) + continue; + + if ((*ptr == ',') || (*ptr == '\0')) { + *ptr = '\0'; + rc = parse_option(opt, mntflags, sloppy); + if (rc) { + strcpy(badopt, opt); + goto out; + } + + opt = NULL; + } + } +out: + free(opts); + return (rc); +} + +/* + * Called when invoked as /sbin/mount.zfs, mount helper for mount(8). */ -#ifdef HAVE_ZPL static int manual_mount(int argc, char **argv) { zfs_handle_t *zhp; - char mountpoint[ZFS_MAXPROPLEN]; + char legacy[ZFS_MAXPROPLEN]; char mntopts[MNT_LINE_MAX] = { '\0' }; - int ret; - int c; - int flags = 0; - char *dataset, *path; + char badopt[MNT_LINE_MAX] = { '\0' }; + char *dataset, *mntpoint; + unsigned long mntflags; + int sloppy = 0, fake = 0, verbose = 0; + int rc, c; /* check options */ - while ((c = getopt(argc, argv, ":mo:O")) != -1) { + while ((c = getopt(argc, argv, "sfnvo:h?")) != -1) { switch (c) { - case 'o': - (void) strlcpy(mntopts, optarg, sizeof (mntopts)); + case 's': + sloppy = 1; break; - case 'O': - flags |= MS_OVERLAY; + case 'f': + fake = 1; break; - case 'm': - flags |= MS_NOMNTTAB; + case 'n': + /* Ignored, handled by mount(8) */ break; - case ':': - (void) fprintf(stderr, gettext("missing argument for " - "'%c' option\n"), optopt); - usage(B_FALSE); + case 'v': + verbose++; + break; + case 'o': + (void) strlcpy(mntopts, optarg, sizeof (mntopts)); break; + case 'h': case '?': - (void) fprintf(stderr, gettext("invalid option '%c'\n"), + (void) fprintf(stderr, gettext("Invalid option '%c'\n"), optopt); - (void) fprintf(stderr, gettext("usage: mount [-o opts] " - "\n")); - return (2); + (void) fprintf(stderr, gettext("Usage: mount.zfs " + "[-sfnv] [-o options] \n")); + return (MOUNT_USAGE); } } @@ -3999,7 +4162,6 @@ manual_unmount(int argc, char **argv) return (unshare_unmount_path(OP_MOUNT, argv[0], flags, B_TRUE)); } -#endif /* HAVE_ZPL */ static int find_command_idx(char *command, int *idx) @@ -4098,9 +4260,7 @@ main(int argc, char **argv) { int ret; int i = 0; -#ifdef HAVE_ZPL char *progname; -#endif char *cmdname; (void) setlocale(LC_ALL, ""); @@ -4114,20 +4274,16 @@ main(int argc, char **argv) return (1); } -#ifdef HAVE_ZPL /* * This command also doubles as the /etc/fs mount and unmount program. * Determine if we should take this behavior based on argv[0]. */ progname = basename(argv[0]); - if (strcmp(progname, "mount") == 0) { + if (strcmp(progname, "mount.zfs") == 0) { ret = manual_mount(argc, argv); - } else if (strcmp(progname, "umount") == 0) { + } else if (strcmp(progname, "umount.zfs") == 0) { ret = manual_unmount(argc, argv); } else { -#else - { -#endif /* HAVE_ZPL */ /* * Make sure the user has specified some command. */ -- 1.8.3.1 From 95c4cae39fd77b5b00810eb976c9a6462d86ccd4 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 16 Dec 2010 12:56:10 -0800 Subject: [PATCH 09/16] Disable umount.zfs helper For the moment, the only advantage in registering a umount helper would be to automatically unshare a zfs filesystem. Since under Linux this would be unexpected (but nice) behavior there is no harm in disabling it. This is desirable because the 'zfs unmount' path invokes the system umount. This is done to ensure correct mtab locking but has the side effect that the umount.zfs helper would be called if it exists. By default this helper calls back in to zfs to do the unmount on Solaris which we don't want under Linux. Once libmount is available and we have a safe way to correctly lock and update the /etc/mtab file we can reconsider the need for a umount helper. Using libmount is the prefered solution. --- cmd/zfs/zfs_main.c | 140 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 103 insertions(+), 37 deletions(-) diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 2aa3e2e..e1cca2d 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -4083,85 +4083,149 @@ manual_mount(int argc, char **argv) else (void) fprintf(stderr, gettext("too many arguments\n")); (void) fprintf(stderr, "usage: mount \n"); - return (2); + return (MOUNT_USAGE); } dataset = argv[0]; - path = argv[1]; + mntpoint = argv[1]; - /* try to open the dataset */ - if ((zhp = zfs_open(g_zfs, dataset, ZFS_TYPE_FILESYSTEM)) == NULL) - return (1); + /* try to open the dataset to access the mount point */ + if ((zhp = zfs_open(g_zfs, dataset, ZFS_TYPE_FILESYSTEM)) == NULL) { + (void) fprintf(stderr, gettext("filesystem '%s' cannot be " + "mounted, unable to open the dataset\n"), dataset); + return (MOUNT_USAGE); + } - (void) zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mountpoint, - sizeof (mountpoint), NULL, NULL, 0, B_FALSE); + (void) zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, legacy, + sizeof (legacy), NULL, NULL, 0, B_FALSE); - /* check for legacy mountpoint and complain appropriately */ - ret = 0; - if (strcmp(mountpoint, ZFS_MOUNTPOINT_LEGACY) == 0) { - if (mount(dataset, path, MS_OPTIONSTR | flags, MNTTYPE_ZFS, - NULL, 0, mntopts, sizeof (mntopts)) != 0) { - (void) fprintf(stderr, gettext("mount failed: %s\n"), - strerror(errno)); - ret = 1; - } - } else { + zfs_close(zhp); + + /* check for legacy mountpoint or util mount option */ + if ((!strcmp(legacy, ZFS_MOUNTPOINT_LEGACY) == 0) && + (strstr(mntopts, MNTOPT_ZFSUTIL) == NULL)) { (void) fprintf(stderr, gettext("filesystem '%s' cannot be " - "mounted using 'mount -F zfs'\n"), dataset); + "mounted using 'mount -a -t zfs'\n"), dataset); (void) fprintf(stderr, gettext("Use 'zfs set mountpoint=%s' " - "instead.\n"), path); - (void) fprintf(stderr, gettext("If you must use 'mount -F zfs' " - "or /etc/vfstab, use 'zfs set mountpoint=legacy'.\n")); - (void) fprintf(stderr, gettext("See zfs(1M) for more " + "instead.\n"), mntpoint); + (void) fprintf(stderr, gettext("If you must use 'mount -a -t " + "zfs' or /etc/fstab, use 'zfs set mountpoint=legacy'.\n")); + (void) fprintf(stderr, gettext("See zfs(8) for more " "information.\n")); - ret = 1; + return (MOUNT_USAGE); + } + + /* validate mount options and set mntflags */ + rc = parse_options(mntopts, &mntflags, sloppy, badopt); + if (rc) { + switch (rc) { + case ENOMEM: + (void) fprintf(stderr, gettext("filesystem '%s' " + "cannot be mounted due to a memory allocation " + "failure\n"), dataset); + return (MOUNT_SYSERR); + case EINVAL: + (void) fprintf(stderr, gettext("filesystem '%s' " + "cannot be mounted of due to the invalid option " + "'%s'\n"), dataset, badopt); + (void) fprintf(stderr, gettext("Use the '-s' option " + "to ignore the bad mount option.\n")); + return (MOUNT_USAGE); + default: + (void) fprintf(stderr, gettext("filesystem '%s' " + "cannot be mounted due to internal error %d\n"), + dataset, rc); + return (MOUNT_SOFTWARE); + } } - return (ret); + if (verbose > 2) + printf("mount.zfs: dataset: \"%s\", mountpoint: \"%s\" " + "mountflags: 0x%lx, mountopts: \"%s\"\n", dataset, + mntpoint, mntflags, mntopts); + + /* load the zfs posix layer module (zpl) */ + if (libzfs_load_module("zpl")) { + (void) fprintf(stderr, gettext("filesystem '%s' cannot be " + "mounted without the zpl kernel module\n"), dataset); + (void) fprintf(stderr, gettext("Use 'dmesg' to determine why " + "the module could not be loaded.\n")); + return (MOUNT_SYSERR); + } + + if (!fake) { + rc = mount(dataset, mntpoint, MNTTYPE_ZFS, mntflags, mntopts); + if (rc) { + (void) fprintf(stderr, gettext("filesystem '%s' can" + "not be mounted due to error %d\n"), dataset, rc); + return (MOUNT_USAGE); + } + } + + return (MOUNT_SUCCESS); } +#ifdef HAVE_UNMOUNT_HELPER /* - * Called when invoked as /etc/fs/zfs/umount. Unlike a manual mount, we allow - * unmounts of non-legacy filesystems, as this is the dominant administrative - * interface. + * Called when invoked as /sbin/umount.zfs, mount helper for mount(8). + * Unlike a manual mount, we allow unmounts of non-legacy filesystems, + * as this is the dominant administrative interface. */ static int manual_unmount(int argc, char **argv) { - int flags = 0; + int verbose = 0, flags = 0; int c; /* check options */ - while ((c = getopt(argc, argv, "f")) != -1) { + while ((c = getopt(argc, argv, "nlfvrh?")) != -1) { switch (c) { + case 'n': + /* Ignored, handled by mount(8) */ + break; + case 'l': + flags = MS_DETACH; + break; case 'f': flags = MS_FORCE; break; + case 'v': + verbose++; + break; + case 'r': + /* Remount read-only on umount failure, unsupported */ + (void) fprintf(stderr, gettext("Unsupported option " + "'%c'\n"), optopt); + return (MOUNT_USAGE); + case 'h': case '?': - (void) fprintf(stderr, gettext("invalid option '%c'\n"), + (void) fprintf(stderr, gettext("Invalid option '%c'\n"), optopt); - (void) fprintf(stderr, gettext("usage: unmount [-f] " - "\n")); - return (2); + (void) fprintf(stderr, gettext("Usage: umount.zfs " + "[-nlfvr] \n")); + return (MOUNT_USAGE); } } argc -= optind; argv += optind; - /* check arguments */ + /* check that we only have one argument */ if (argc != 1) { if (argc == 0) - (void) fprintf(stderr, gettext("missing path " + (void) fprintf(stderr, gettext("missing mountpoint " "argument\n")); else (void) fprintf(stderr, gettext("too many arguments\n")); - (void) fprintf(stderr, gettext("usage: unmount [-f] \n")); - return (2); + + (void) fprintf(stderr, gettext("Usage: umount.zfs [-nlfvr] " + "\n")); + return (MOUNT_USAGE); } return (unshare_unmount_path(OP_MOUNT, argv[0], flags, B_TRUE)); } +#endif /* HAVE_UNMOUNT_HELPER */ static int find_command_idx(char *command, int *idx) @@ -4281,8 +4345,10 @@ main(int argc, char **argv) progname = basename(argv[0]); if (strcmp(progname, "mount.zfs") == 0) { ret = manual_mount(argc, argv); +#ifdef HAVE_UNMOUNT_HELPER } else if (strcmp(progname, "umount.zfs") == 0) { ret = manual_unmount(argc, argv); +#endif /* HAVE_UNMOUNT_HELPER */ } else { /* * Make sure the user has specified some command. -- 1.8.3.1 From feb46b92a7619a3bb67b925e24184fe70464d261 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 16 Dec 2010 15:47:40 -0800 Subject: [PATCH 10/16] Open up libzfs_run_process/libzfs_load_module Recently helper functions were added to libzfs_util to load a kernel module or execute a process. Initially this functionality was limited to libzfs but it has become clear there will be other consumers. This change opens up the interface so it may be used where appropriate. --- include/libzfs.h | 6 ++++++ lib/libzfs/libzfs_util.c | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/libzfs.h b/include/libzfs.h index 6752579..082b690 100644 --- a/include/libzfs.h +++ b/include/libzfs.h @@ -673,6 +673,12 @@ extern void zfs_nicenum(uint64_t, char *, size_t); extern int zfs_nicestrtonum(libzfs_handle_t *, const char *, uint64_t *); /* + * Utility functions to run an external process. + */ +int libzfs_run_process(const char *, char **); +int libzfs_load_module(const char *); + +/* * Given a device or file, determine if it is part of a pool. */ extern int zpool_in_use(libzfs_handle_t *, int, pool_state_t *, char **, diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index 33c440c..37dba8d 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -631,7 +631,7 @@ libzfs_module_loaded(const char *module) return result; } -static int +int libzfs_run_process(const char *path, char *argv[]) { pid_t pid; @@ -657,13 +657,14 @@ libzfs_run_process(const char *path, char *argv[]) return -1; } -static int +int libzfs_load_module(const char *module) { char *argv[4] = {"/sbin/modprobe", "-q", (char *)module, (char *)0}; if (libzfs_module_loaded(module)) return 0; + return libzfs_run_process("/sbin/modprobe", argv); } -- 1.8.3.1 From 3fb1fcdea167d705e050a0383ec61b95fbe8a0ed Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 16 Dec 2010 16:16:25 -0800 Subject: [PATCH 11/16] Add 'zfs mount' support By design the zfs utility is supposed to handle mounting and unmounting a zfs filesystem. We could allow zfs to do this directly. There are system calls available to mount/umount a filesystem. And there are library calls available to manipulate /etc/mtab. But there are a couple very good reasons not to take this appraoch... for now. Instead of directly calling the system and library calls to (u)mount the filesystem we fork and exec a (u)mount process. The principle reason for this is to delegate the responsibility for locking and updating /etc/mtab to (u)mount(8). This ensures maximum portability and ensures the right locking scheme for your version of (u)mount will be used. If we didn't do this we would have to resort to an autoconf test to determine what locking mechanism is used. The downside to using mount(8) instead of mount(2) is that we lose the exact errno which was returned by the kernel. The return code from mount(8) provides some insight in to what went wrong but it not quite as good. For the moment this is translated as a best guess in to a errno for the higher layers of zfs. In the long term a shared library called libmount is under development which provides a common API to address the locking and errno issues. Once the standard mount utility has been updated to use this library we can then leverage it. Until then this is the only safe solution. http://www.kernel.org/pub/linux/utils/util-linux/libmount-docs/index.html --- cmd/zfs/zfs_main.c | 5 +- lib/libspl/include/sys/mntent.h | 164 +++++++++++++++------------------------- lib/libspl/include/sys/mnttab.h | 12 +-- lib/libspl/include/sys/mount.h | 10 ++- lib/libzfs/libzfs_mount.c | 110 +++++++++++++++++++++++---- 5 files changed, 169 insertions(+), 132 deletions(-) diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index e1cca2d..2a38cc0 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -3275,7 +3275,7 @@ share_mount(int op, int argc, char **argv) int flags = 0; /* check options */ - while ((c = getopt(argc, argv, op == OP_MOUNT ? ":avo:O" : "a")) + while ((c = getopt(argc, argv, op == OP_MOUNT ? ":avo:" : "a")) != -1) { switch (c) { case 'a': @@ -3298,9 +3298,6 @@ share_mount(int op, int argc, char **argv) append_options(options, optarg); break; - case 'O': - flags |= MS_OVERLAY; - break; case ':': (void) fprintf(stderr, gettext("missing argument for " "'%c' option\n"), optopt); diff --git a/lib/libspl/include/sys/mntent.h b/lib/libspl/include/sys/mntent.h index c0594ca..d552c9c 100644 --- a/lib/libspl/include/sys/mntent.h +++ b/lib/libspl/include/sys/mntent.h @@ -29,114 +29,74 @@ #ifndef _SYS_MNTENT_H #define _SYS_MNTENT_H +#define MNTTYPE_ZFS "zfs" /* ZFS file system */ - -#ifdef __cplusplus -extern "C" { -#endif - -#define MNTTAB "/proc/mounts" -#define VFSTAB "/etc/vfstab" +#define FSTAB "/etc/fstab" #define MNTMAXSTR 128 -#define MNTTYPE_ZFS "zfs" /* ZFS file system */ -#define MNTTYPE_UFS "ufs" /* Unix file system */ -#define MNTTYPE_SMBFS "smbfs" /* SMBFS file system */ -#define MNTTYPE_NFS "nfs" /* NFS file system */ -#define MNTTYPE_NFS3 "nfs3" /* NFS Version 3 file system */ -#define MNTTYPE_NFS4 "nfs4" /* NFS Version 4 file system */ -#define MNTTYPE_CACHEFS "cachefs" /* Cache File System */ -#define MNTTYPE_PCFS "pcfs" /* PC (MSDOS) file system */ -#define MNTTYPE_PC MNTTYPE_PCFS /* Deprecated name; use MNTTYPE_PCFS */ -#define MNTTYPE_LOFS "lofs" /* Loop back file system */ -#define MNTTYPE_LO MNTTYPE_LOFS /* Deprecated name; use MNTTYPE_LOFS */ -#define MNTTYPE_HSFS "hsfs" /* High Sierra (9660) file system */ -#define MNTTYPE_SWAP "swap" /* Swap file system */ -#define MNTTYPE_TMPFS "tmpfs" /* Tmp volatile file system */ -#define MNTTYPE_AUTOFS "autofs" /* Automounter ``file'' system */ -#define MNTTYPE_MNTFS "mntfs" /* In-kernel mnttab */ -#define MNTTYPE_DEV "dev" /* /dev file system */ -#define MNTTYPE_CTFS "ctfs" /* Contract file system */ -#define MNTTYPE_OBJFS "objfs" /* Kernel object file system */ -#define MNTTYPE_SHAREFS "sharefs" /* Kernel sharetab file system */ - +#define MOUNT_SUCCESS 0x00 /* Success */ +#define MOUNT_USAGE 0x01 /* Invalid invocation or permissions */ +#define MOUNT_SYSERR 0x02 /* System error (ENOMEM, etc) */ +#define MOUNT_SOFTWARE 0x04 /* Internal mount bug */ +#define MOUNT_USER 0x08 /* Interrupted by user (EINTR) */ +#define MOUNT_FILEIO 0x10 /* Error updating/locking /etc/mtab */ +#define MOUNT_FAIL 0x20 /* Mount failed */ +#define MOUNT_SOMEOK 0x40 /* At least on mount succeeded */ -#define MNTOPT_RO "ro" /* Read only */ -#define MNTOPT_RW "rw" /* Read/write */ -#define MNTOPT_RQ "rq" /* Read/write with quotas */ -#define MNTOPT_QUOTA "quota" /* Check quotas */ -#define MNTOPT_NOQUOTA "noquota" /* Don't check quotas */ -#define MNTOPT_ONERROR "onerror" /* action to taken on error */ -#define MNTOPT_SOFT "soft" /* Soft mount */ -#define MNTOPT_SEMISOFT "semisoft" /* partial soft, uncommited interface */ -#define MNTOPT_HARD "hard" /* Hard mount */ -#define MNTOPT_SUID "suid" /* Both setuid and devices allowed */ -#define MNTOPT_NOSUID "nosuid" /* Neither setuid nor devices allowed */ -#define MNTOPT_DEVICES "devices" /* Device-special allowed */ -#define MNTOPT_NODEVICES "nodevices" /* Device-special disallowed */ -#define MNTOPT_SETUID "setuid" /* Set uid allowed */ -#define MNTOPT_NOSETUID "nosetuid" /* Set uid not allowed */ -#define MNTOPT_GRPID "grpid" /* SysV-compatible gid on create */ -#define MNTOPT_REMOUNT "remount" /* Change mount options */ -#define MNTOPT_NOSUB "nosub" /* Disallow mounts on subdirs */ -#define MNTOPT_MULTI "multi" /* Do multi-component lookup */ -#define MNTOPT_INTR "intr" /* Allow NFS ops to be interrupted */ -#define MNTOPT_NOINTR "nointr" /* Don't allow interrupted ops */ -#define MNTOPT_PORT "port" /* NFS server IP port number */ -#define MNTOPT_SECURE "secure" /* Secure (AUTH_DES) mounting */ -#define MNTOPT_RSIZE "rsize" /* Max NFS read size (bytes) */ -#define MNTOPT_WSIZE "wsize" /* Max NFS write size (bytes) */ -#define MNTOPT_TIMEO "timeo" /* NFS timeout (1/10 sec) */ -#define MNTOPT_RETRANS "retrans" /* Max retransmissions (soft mnts) */ -#define MNTOPT_ACTIMEO "actimeo" /* Attr cache timeout (sec) */ -#define MNTOPT_ACREGMIN "acregmin" /* Min attr cache timeout (files) */ -#define MNTOPT_ACREGMAX "acregmax" /* Max attr cache timeout (files) */ -#define MNTOPT_ACDIRMIN "acdirmin" /* Min attr cache timeout (dirs) */ -#define MNTOPT_ACDIRMAX "acdirmax" /* Max attr cache timeout (dirs) */ -#define MNTOPT_NOAC "noac" /* Don't cache attributes at all */ -#define MNTOPT_NOCTO "nocto" /* No close-to-open consistency */ -#define MNTOPT_BG "bg" /* Do mount retries in background */ -#define MNTOPT_FG "fg" /* Do mount retries in foreground */ -#define MNTOPT_RETRY "retry" /* Number of mount retries */ -#define MNTOPT_DEV "dev" /* Device id of mounted fs */ -#define MNTOPT_POSIX "posix" /* Get static pathconf for mount */ -#define MNTOPT_MAP "map" /* Automount map */ -#define MNTOPT_DIRECT "direct" /* Automount direct map mount */ -#define MNTOPT_INDIRECT "indirect" /* Automount indirect map mount */ -#define MNTOPT_LLOCK "llock" /* Local locking (no lock manager) */ -#define MNTOPT_IGNORE "ignore" /* Ignore this entry */ -#define MNTOPT_VERS "vers" /* protocol version number indicator */ -#define MNTOPT_PROTO "proto" /* protocol network_id indicator */ -#define MNTOPT_SEC "sec" /* Security flavor indicator */ -#define MNTOPT_SYNCDIR "syncdir" /* Synchronous local directory ops */ -#define MNTOPT_NOSETSEC "nosec" /* Do no allow setting sec attrs */ -#define MNTOPT_NOPRINT "noprint" /* Do not print messages */ -#define MNTOPT_LARGEFILES "largefiles" /* allow large files */ -#define MNTOPT_NOLARGEFILES "nolargefiles" /* don't allow large files */ -#define MNTOPT_FORCEDIRECTIO "forcedirectio" /* Force DirectIO on all files */ -#define MNTOPT_NOFORCEDIRECTIO "noforcedirectio" /* No Force DirectIO */ -#define MNTOPT_DISABLEDIRECTIO "disabledirectio" /* Disable DirectIO ioctls */ -#define MNTOPT_PUBLIC "public" /* Use NFS public file handlee */ -#define MNTOPT_LOGGING "logging" /* enable logging */ -#define MNTOPT_NOLOGGING "nologging" /* disable logging */ +#define MNTOPT_ASYNC "async" /* all I/O is asynchronous */ #define MNTOPT_ATIME "atime" /* update atime for files */ -#define MNTOPT_NOATIME "noatime" /* do not update atime for files */ -#define MNTOPT_GLOBAL "global" /* Cluster-wide global mount */ -#define MNTOPT_NOGLOBAL "noglobal" /* Mount local to single node */ -#define MNTOPT_DFRATIME "dfratime" /* Deferred access time updates */ -#define MNTOPT_NODFRATIME "nodfratime" /* No Deferred access time updates */ -#define MNTOPT_NBMAND "nbmand" /* allow non-blocking mandatory locks */ -#define MNTOPT_NONBMAND "nonbmand" /* deny non-blocking mandatory locks */ -#define MNTOPT_XATTR "xattr" /* enable extended attributes */ -#define MNTOPT_NOXATTR "noxattr" /* disable extended attributes */ +#define MNTOPT_NOATIME "noatime" /* do not update atime for files */ +#define MNTOPT_AUTO "auto" /* automount */ +#define MNTOPT_NOAUTO "noauto" /* do not automount */ +#define MNTOPT_CONTEXT "context" /* selinux context */ +#define MNTOPT_FSCONTEXT "fscontext" /* selinux fscontext */ +#define MNTOPT_DEFCONTEXT "defcontext" /* selinux defcontext */ +#define MNTOPT_ROOTCONTEXT "rootcontext" /* selinux rootcontext */ +#define MNTOPT_DEFAULTS "defaults" /* defaults */ +#define MNTOPT_DEVICES "dev" /* device-special allowed */ +#define MNTOPT_NODEVICES "nodev" /* device-special disallowed */ +#define MNTOPT_DIRATIME "diratime" /* update atime for dirs */ +#define MNTOPT_NODIRATIME "nodiratime" /* do not update atime for dirs */ +#define MNTOPT_DIRSYNC "dirsync" /* do dir updates synchronously */ #define MNTOPT_EXEC "exec" /* enable executables */ #define MNTOPT_NOEXEC "noexec" /* disable executables */ -#define MNTOPT_RESTRICT "restrict" /* restricted autofs mount */ -#define MNTOPT_BROWSE "browse" /* browsable autofs mount */ -#define MNTOPT_NOBROWSE "nobrowse" /* non-browsable autofs mount */ - -#ifdef __cplusplus -} -#endif +#define MNTOPT_GROUP "group" /* allow group mount */ +#define MNTOPT_NOGROUP "nogroup" /* do not allow group mount */ +#define MNTOPT_IVERSION "iversion" /* update inode version */ +#define MNTOPT_NOIVERSION "noiversion" /* do not update inode version */ +#define MNTOPT_NBMAND "mand" /* allow non-blocking mandatory locks */ +#define MNTOPT_NONBMAND "nomand" /* deny non-blocking mandatory locks */ +#define MNTOPT_NETDEV "_netdev" /* network device */ +#define MNTOPT_NOFAIL "nofail" /* no failure */ +#define MNTOPT_RELATIME "relatime" /* allow relative time updates */ +#define MNTOPT_NORELATIME "norelatime" /* do not allow relative time updates */ +#define MNTOPT_DFRATIME "strictatime" /* Deferred access time updates */ +#define MNTOPT_NODFRATIME "nostrictatime" /* No Deferred access time updates */ +#define MNTOPT_SETUID "suid" /* Both setuid and devices allowed */ +#define MNTOPT_NOSETUID "nosuid" /* Neither setuid nor devices allowed */ +#define MNTOPT_OWNER "owner" /* allow owner mount */ +#define MNTOPT_NOOWNER "noowner" /* do not allow owner mount */ +#define MNTOPT_REMOUNT "remount" /* change mount options */ +#define MNTOPT_RO "ro" /* read only */ +#define MNTOPT_RW "rw" /* read/write */ +#define MNTOPT_SYNC "sync" /* all I/O is synchronous */ +#define MNTOPT_USER "user" /* allow user mount */ +#define MNTOPT_NOUSER "nouser" /* do not allow user mount */ +#define MNTOPT_USERS "users" /* allow user mount */ +#define MNTOPT_NOUSERS "nousers" /* do not allow user mount */ +#define MNTOPT_SUB "sub" /* allow mounts on subdirs */ +#define MNTOPT_NOSUB "nosub" /* do not allow mounts on subdirs */ +#define MNTOPT_QUIET "quiet" /* quiet mount */ +#define MNTOPT_LOUD "loud" /* verbose mount */ +#define MNTOPT_BIND "bind" /* remount part of a tree */ +#define MNTOPT_RBIND "rbind" /* include subtrees */ +#define MNTOPT_XATTR "user_xattr" /* enable extended attributes */ +#define MNTOPT_NOXATTR "nouser_xattr" /* disable extended attributes */ +#define MNTOPT_COMMENT "comment" /* comment */ +#define MNTOPT_BOOTWAIT "bootwait" +#define MNTOPT_NOBOOTWAIT "nobootwait" +#define MNTOPT_OPTIONAL "optional" +#define MNTOPT_SHOWTHROUGH "showthrough" +#define MNTOPT_ZFSUTIL "zfsutil" /* called by zfs utility */ #endif /* _SYS_MNTENT_H */ diff --git a/lib/libspl/include/sys/mnttab.h b/lib/libspl/include/sys/mnttab.h index 70f1449..a30549a 100644 --- a/lib/libspl/include/sys/mnttab.h +++ b/lib/libspl/include/sys/mnttab.h @@ -36,14 +36,14 @@ #ifdef MNTTAB #undef MNTTAB -#endif +#endif /* MNTTAB */ -#define MNTTAB "/proc/mounts" -#define MNT_LINE_MAX 1024 +#define MNTTAB "/etc/mtab" +#define MNT_LINE_MAX 1024 -#define MNT_TOOLONG 1 /* entry exceeds MNT_LINE_MAX */ -#define MNT_TOOMANY 2 /* too many fields in line */ -#define MNT_TOOFEW 3 /* too few fields in line */ +#define MNT_TOOLONG 1 /* entry exceeds MNT_LINE_MAX */ +#define MNT_TOOMANY 2 /* too many fields in line */ +#define MNT_TOOFEW 3 /* too few fields in line */ struct mnttab { char *mnt_special; diff --git a/lib/libspl/include/sys/mount.h b/lib/libspl/include/sys/mount.h index 144f915..f6a67c6 100644 --- a/lib/libspl/include/sys/mount.h +++ b/lib/libspl/include/sys/mount.h @@ -42,9 +42,11 @@ #define BLKGETSIZE64 _IOR(0x12, 114, size_t) #endif -#define MS_FORCE MNT_FORCE -#define MS_OVERLAY 32768 -#define MS_NOMNTTAB 0 /* Not supported in Linux */ -#define MS_OPTIONSTR 0 /* Not necessary in Linux */ +#define MS_USERS 0x40000000 +#define MS_OWNER 0x10000000 +#define MS_GROUP 0x08000000 +#define MS_COMMENT 0x02000000 +#define MS_FORCE MNT_FORCE +#define MS_DETACH MNT_DETACH #endif /* _LIBSPL_SYS_MOUNT_H */ diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index 9950bf9..75ce367 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -259,6 +259,82 @@ zfs_is_mountable(zfs_handle_t *zhp, char *buf, size_t buflen, } /* + * The filesystem is mounted by invoking the system mount utility rather + * than by the system call mount(2). This ensures that the /etc/mtab + * file is correctly locked for the update. Performing our own locking + * and /etc/mtab update requires making an unsafe assumption about how + * the mount utility performs its locking. Unfortunately, this also means + * in the case of a mount failure we do not have the exact errno. We must + * make due with return value from the mount process. + * + * In the long term a shared library called libmount is under development + * which provides a common API to address the locking and errno issues. + * Once the standard mount utility has been updated to use this library + * we can add an autoconf check to conditionally use it. + * + * http://www.kernel.org/pub/linux/utils/util-linux/libmount-docs/index.html + */ + +static int +do_mount(const char *src, const char *mntpt, char *opts) +{ + char *argv[8] = { + "/bin/mount", + "-t", MNTTYPE_ZFS, + "-o", opts, + (char *)src, + (char *)mntpt, + (char *)NULL }; + int rc; + + /* Return only the most critical mount error */ + rc = libzfs_run_process(argv[0], argv); + if (rc) { + if (rc & MOUNT_FILEIO) + return EIO; + if (rc & MOUNT_USER) + return EINTR; + if (rc & MOUNT_SOFTWARE) + return EPIPE; + if (rc & MOUNT_SYSERR) + return EAGAIN; + if (rc & MOUNT_USAGE) + return EINVAL; + + return ENXIO; /* Generic error */ + } + + return 0; +} + +static int +do_unmount(const char *mntpt, int flags) +{ + char force_opt[] = "-f"; + char lazy_opt[] = "-l"; + char *argv[7] = { + "/bin/umount", + "-t", MNTTYPE_ZFS, + NULL, NULL, NULL, NULL }; + int rc, count = 3; + + if (flags & MS_FORCE) { + argv[count] = force_opt; + count++; + } + + if (flags & MS_DETACH) { + argv[count] = lazy_opt; + count++; + } + + argv[count] = (char *)mntpt; + rc = libzfs_run_process(argv[0], argv); + + return (rc ? EINVAL : 0); +} + +/* * Mount the given filesystem. */ int @@ -268,9 +344,10 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags) char mountpoint[ZFS_MAXPROPLEN]; char mntopts[MNT_LINE_MAX]; libzfs_handle_t *hdl = zhp->zfs_hdl; + int rc; if (options == NULL) - mntopts[0] = '\0'; + (void) strlcpy(mntopts, MNTOPT_DEFAULTS, sizeof (mntopts)); else (void) strlcpy(mntopts, options, sizeof (mntopts)); @@ -278,7 +355,12 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags) * If the pool is imported read-only then all mounts must be read-only */ if (zpool_get_prop_int(zhp->zpool_hdl, ZPOOL_PROP_READONLY, NULL)) - flags |= MS_RDONLY; + (void) strlcat(mntopts, "," MNTOPT_RO, sizeof (mntopts)); + + /* + * Append zfsutil option so the mount helper allow the mount + */ + strlcat(mntopts, "," MNTOPT_ZFSUTIL, sizeof (mntopts)); #ifdef HAVE_LIBSELINUX if (is_selinux_enabled()) @@ -302,12 +384,9 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags) /* * Determine if the mountpoint is empty. If so, refuse to perform the - * mount. We don't perform this check if MS_OVERLAY is specified, which - * would defeat the point. We also avoid this check if 'remount' is - * specified. + * mount. We don't perform this check if 'remount' is specified. */ - if ((flags & MS_OVERLAY) == 0 && - strstr(mntopts, MNTOPT_REMOUNT) == NULL && + if (strstr(mntopts, MNTOPT_REMOUNT) == NULL && !dir_is_empty(mountpoint)) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "directory is not empty")); @@ -316,20 +395,20 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags) } /* perform the mount */ - if (mount(zfs_get_name(zhp), mountpoint, MS_OPTIONSTR | flags, - MNTTYPE_ZFS, NULL, 0, mntopts, sizeof (mntopts)) != 0) { + rc = do_mount(zfs_get_name(zhp), mountpoint, mntopts); + if (rc) { /* * Generic errors are nasty, but there are just way too many * from mount(), and they're well-understood. We pick a few * common ones to improve upon. */ - if (errno == EBUSY) { + if (rc == EBUSY) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "mountpoint or dataset is busy")); - } else if (errno == EPERM) { + } else if (rc == EPERM) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "Insufficient privileges")); - } else if (errno == ENOTSUP) { + } else if (rc == ENOTSUP) { char buf[256]; int spa_version; @@ -342,7 +421,7 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags) ZFS_PROP_VERSION), spa_version); zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, buf)); } else { - zfs_error_aux(hdl, strerror(errno)); + zfs_error_aux(hdl, strerror(rc)); } return (zfs_error_fmt(hdl, EZFS_MOUNTFAILED, dgettext(TEXT_DOMAIN, "cannot mount '%s'"), @@ -350,8 +429,7 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags) } /* add the mounted entry into our cache */ - libzfs_mnttab_add(hdl, zfs_get_name(zhp), mountpoint, - mntopts); + libzfs_mnttab_add(hdl, zfs_get_name(zhp), mountpoint, mntopts); return (0); } @@ -361,7 +439,7 @@ zfs_mount(zfs_handle_t *zhp, const char *options, int flags) static int unmount_one(libzfs_handle_t *hdl, const char *mountpoint, int flags) { - if (umount2(mountpoint, flags) != 0) { + if (do_unmount(mountpoint, flags) != 0) { zfs_error_aux(hdl, strerror(errno)); return (zfs_error_fmt(hdl, EZFS_UMOUNTFAILED, dgettext(TEXT_DOMAIN, "cannot unmount '%s'"), -- 1.8.3.1 From c5d915f4237bbd1f5623b5044a1924a3cb91852b Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 16 Dec 2010 13:47:30 -0800 Subject: [PATCH 12/16] Minimal libshare infrastructure ZFS even under Solaris does not strictly require libshare to be available. The current implementation attempts to dlopen() the library to access the needed symbols. If this fails libshare support is simply disabled. This means that on Linux we only need the most minimal libshare implementation. In fact just enough to prevent the build from failing. Longer term we can decide if we want to implement a libshare library like Solaris. At best this would be an abstraction layer between ZFS and NFS/SMB. Alternately, we can drop libshare entirely and directly integrate ZFS with Linux's NFS/SMB. Finally the bare bones user-libshare.m4 test was dropped. If we do decide to implement libshare at some point it will surely be as part of this package so the check is not needed. --- Makefile.in | 1 - cmd/Makefile.in | 1 - cmd/zdb/Makefile.in | 1 - cmd/zfs/Makefile.in | 1 - cmd/zinject/Makefile.in | 1 - cmd/zpios/Makefile.in | 1 - cmd/zpool/Makefile.in | 1 - cmd/zpool_id/Makefile.in | 1 - cmd/zpool_layout/Makefile.in | 1 - cmd/ztest/Makefile.in | 1 - config/user-libshare.m4 | 8 -- config/user.m4 | 1 - configure | 150 ---------------------------- etc/Makefile.in | 1 - include/Makefile.in | 1 - include/sys/Makefile.in | 1 - include/sys/fm/Makefile.in | 1 - include/sys/fm/fs/Makefile.in | 1 - include/sys/fs/Makefile.in | 1 - lib/Makefile.in | 1 - lib/libavl/Makefile.in | 1 - lib/libefi/Makefile.in | 1 - lib/libnvpair/Makefile.in | 1 - lib/libspl/Makefile.in | 1 - lib/libspl/asm-generic/Makefile.in | 1 - lib/libspl/asm-i386/Makefile.in | 1 - lib/libspl/asm-x86_64/Makefile.in | 1 - lib/libspl/include/Makefile.in | 1 - lib/libspl/include/ia32/Makefile.in | 1 - lib/libspl/include/ia32/sys/Makefile.in | 1 - lib/libspl/include/libshare.h | 18 +++- lib/libspl/include/rpc/Makefile.in | 1 - lib/libspl/include/sys/Makefile.in | 1 - lib/libspl/include/sys/dktp/Makefile.in | 1 - lib/libspl/include/sys/sysevent/Makefile.in | 1 - lib/libspl/include/util/Makefile.in | 1 - lib/libunicode/Makefile.in | 1 - lib/libuutil/Makefile.in | 1 - lib/libzfs/Makefile.in | 1 - lib/libzfs/libzfs_mount.c | 35 ++----- lib/libzpool/Makefile.in | 1 - man/Makefile.in | 1 - man/man8/Makefile.in | 1 - scripts/Makefile.in | 1 - scripts/zpios-profile/Makefile.in | 1 - scripts/zpios-test/Makefile.in | 1 - scripts/zpool-config/Makefile.in | 1 - scripts/zpool-layout/Makefile.in | 1 - zfs_config.h.in | 3 - 49 files changed, 24 insertions(+), 234 deletions(-) delete mode 100644 config/user-libshare.m4 diff --git a/Makefile.in b/Makefile.in index 09708bf..0d10478 100644 --- a/Makefile.in +++ b/Makefile.in @@ -77,7 +77,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/cmd/Makefile.in b/cmd/Makefile.in index bed2951..016045a 100644 --- a/cmd/Makefile.in +++ b/cmd/Makefile.in @@ -62,7 +62,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/cmd/zdb/Makefile.in b/cmd/zdb/Makefile.in index b84eb2c..ce17224 100644 --- a/cmd/zdb/Makefile.in +++ b/cmd/zdb/Makefile.in @@ -65,7 +65,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/cmd/zfs/Makefile.in b/cmd/zfs/Makefile.in index 6bd1f3f..654a381 100644 --- a/cmd/zfs/Makefile.in +++ b/cmd/zfs/Makefile.in @@ -65,7 +65,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/cmd/zinject/Makefile.in b/cmd/zinject/Makefile.in index c259867..daced68 100644 --- a/cmd/zinject/Makefile.in +++ b/cmd/zinject/Makefile.in @@ -65,7 +65,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/cmd/zpios/Makefile.in b/cmd/zpios/Makefile.in index c30a3e0..69747f3 100644 --- a/cmd/zpios/Makefile.in +++ b/cmd/zpios/Makefile.in @@ -65,7 +65,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/cmd/zpool/Makefile.in b/cmd/zpool/Makefile.in index b628756..a6f96f7 100644 --- a/cmd/zpool/Makefile.in +++ b/cmd/zpool/Makefile.in @@ -65,7 +65,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/cmd/zpool_id/Makefile.in b/cmd/zpool_id/Makefile.in index 932bc25..5d32e81 100644 --- a/cmd/zpool_id/Makefile.in +++ b/cmd/zpool_id/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/cmd/zpool_layout/Makefile.in b/cmd/zpool_layout/Makefile.in index 9b1b5eb..ef53493 100644 --- a/cmd/zpool_layout/Makefile.in +++ b/cmd/zpool_layout/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/cmd/ztest/Makefile.in b/cmd/ztest/Makefile.in index 3b4e7c4..ec16a73 100644 --- a/cmd/ztest/Makefile.in +++ b/cmd/ztest/Makefile.in @@ -65,7 +65,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/config/user-libshare.m4 b/config/user-libshare.m4 deleted file mode 100644 index 3b92bba..0000000 --- a/config/user-libshare.m4 +++ /dev/null @@ -1,8 +0,0 @@ -dnl # -dnl # Check for libshare -dnl # -AC_DEFUN([ZFS_AC_CONFIG_USER_LIBSHARE], [ - AC_CHECK_LIB([share], [sa_init], - [AC_DEFINE([HAVE_LIBSHARE], 1, - [Define to 1 if 'libshare' library available])]) -]) diff --git a/config/user.m4 b/config/user.m4 index 6f02769..a79deef 100644 --- a/config/user.m4 +++ b/config/user.m4 @@ -3,7 +3,6 @@ dnl # Default ZFS user configuration dnl # AC_DEFUN([ZFS_AC_CONFIG_USER], [ ZFS_AC_CONFIG_USER_ARCH - ZFS_AC_CONFIG_USER_LIBSHARE ZFS_AC_CONFIG_USER_IOCTL ZFS_AC_CONFIG_USER_ZLIB ZFS_AC_CONFIG_USER_LIBUUID diff --git a/configure b/configure index 48bf4cb..d962704 100755 --- a/configure +++ b/configure @@ -13849,81 +13849,6 @@ $as_echo_n "checking for target asm dir... " >&6; } $as_echo "$TARGET_ASM_DIR" >&6; } - { $as_echo "$as_me:$LINENO: checking for sa_init in -lshare" >&5 -$as_echo_n "checking for sa_init in -lshare... " >&6; } -if test "${ac_cv_lib_share_sa_init+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lshare $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char sa_init (); -int -main () -{ -return sa_init (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_lib_share_sa_init=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_share_sa_init=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_share_sa_init" >&5 -$as_echo "$ac_cv_lib_share_sa_init" >&6; } -if test "x$ac_cv_lib_share_sa_init" = x""yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_LIBSHARE 1 -_ACEOF - -fi - - - { $as_echo "$as_me:$LINENO: checking for ioctl()" >&5 $as_echo_n "checking for ioctl()... " >&6; } cat >conftest.$ac_ext <<_ACEOF @@ -17446,81 +17371,6 @@ $as_echo_n "checking for target asm dir... " >&6; } $as_echo "$TARGET_ASM_DIR" >&6; } - { $as_echo "$as_me:$LINENO: checking for sa_init in -lshare" >&5 -$as_echo_n "checking for sa_init in -lshare... " >&6; } -if test "${ac_cv_lib_share_sa_init+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lshare $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char sa_init (); -int -main () -{ -return sa_init (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_lib_share_sa_init=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_share_sa_init=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_share_sa_init" >&5 -$as_echo "$ac_cv_lib_share_sa_init" >&6; } -if test "x$ac_cv_lib_share_sa_init" = x""yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_LIBSHARE 1 -_ACEOF - -fi - - - { $as_echo "$as_me:$LINENO: checking for ioctl()" >&5 $as_echo_n "checking for ioctl()... " >&6; } cat >conftest.$ac_ext <<_ACEOF diff --git a/etc/Makefile.in b/etc/Makefile.in index eb8ad95..4d39394 100644 --- a/etc/Makefile.in +++ b/etc/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/include/Makefile.in b/include/Makefile.in index 7a1f40a..851bd8a 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/include/sys/Makefile.in b/include/sys/Makefile.in index d3985cc..2e8af81 100644 --- a/include/sys/Makefile.in +++ b/include/sys/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/include/sys/fm/Makefile.in b/include/sys/fm/Makefile.in index b275659..4099398 100644 --- a/include/sys/fm/Makefile.in +++ b/include/sys/fm/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/include/sys/fm/fs/Makefile.in b/include/sys/fm/fs/Makefile.in index e8d289a..ddad523 100644 --- a/include/sys/fm/fs/Makefile.in +++ b/include/sys/fm/fs/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/include/sys/fs/Makefile.in b/include/sys/fs/Makefile.in index d1ee3b2..903b08d 100644 --- a/include/sys/fs/Makefile.in +++ b/include/sys/fs/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/Makefile.in b/lib/Makefile.in index 18ff052..d607102 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -62,7 +62,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libavl/Makefile.in b/lib/libavl/Makefile.in index 500846a..9159093 100644 --- a/lib/libavl/Makefile.in +++ b/lib/libavl/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libefi/Makefile.in b/lib/libefi/Makefile.in index 1f44090..7839c13 100644 --- a/lib/libefi/Makefile.in +++ b/lib/libefi/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libnvpair/Makefile.in b/lib/libnvpair/Makefile.in index e1027d5..0bafbab 100644 --- a/lib/libnvpair/Makefile.in +++ b/lib/libnvpair/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libspl/Makefile.in b/lib/libspl/Makefile.in index 385a567..8aa947a 100644 --- a/lib/libspl/Makefile.in +++ b/lib/libspl/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libspl/asm-generic/Makefile.in b/lib/libspl/asm-generic/Makefile.in index 162c386..0a8ff7c 100644 --- a/lib/libspl/asm-generic/Makefile.in +++ b/lib/libspl/asm-generic/Makefile.in @@ -63,7 +63,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libspl/asm-i386/Makefile.in b/lib/libspl/asm-i386/Makefile.in index 9a26bb4..6ef7483 100644 --- a/lib/libspl/asm-i386/Makefile.in +++ b/lib/libspl/asm-i386/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libspl/asm-x86_64/Makefile.in b/lib/libspl/asm-x86_64/Makefile.in index a00f235..5c1aeaf 100644 --- a/lib/libspl/asm-x86_64/Makefile.in +++ b/lib/libspl/asm-x86_64/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libspl/include/Makefile.in b/lib/libspl/include/Makefile.in index 3605600..0f2a688 100644 --- a/lib/libspl/include/Makefile.in +++ b/lib/libspl/include/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libspl/include/ia32/Makefile.in b/lib/libspl/include/ia32/Makefile.in index a9f80cd..d3a8f6f 100644 --- a/lib/libspl/include/ia32/Makefile.in +++ b/lib/libspl/include/ia32/Makefile.in @@ -62,7 +62,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libspl/include/ia32/sys/Makefile.in b/lib/libspl/include/ia32/sys/Makefile.in index fb0fe3f..5f7e05f 100644 --- a/lib/libspl/include/ia32/sys/Makefile.in +++ b/lib/libspl/include/ia32/sys/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libspl/include/libshare.h b/lib/libspl/include/libshare.h index afbdf5b..f1fbfad 100644 --- a/lib/libspl/include/libshare.h +++ b/lib/libspl/include/libshare.h @@ -23,12 +23,20 @@ * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ - -/* - * basic API declarations for share management - */ - #ifndef _LIBSPL_LIBSHARE_H #define _LIBSPL_LIBSHARE_H +typedef void *sa_handle_t; /* opaque handle to access core functions */ +typedef void *sa_group_t; +typedef void *sa_share_t; + +/* API Initialization */ +#define SA_INIT_SHARE_API 0x0001 /* init share specific interface */ +#define SA_INIT_CONTROL_API 0x0002 /* init control specific interface */ + +/* Error values */ +#define SA_OK 0 +#define SA_NO_MEMORY 2 /* no memory for data structures */ +#define SA_CONFIG_ERR 6 /* system configuration error */ + #endif /* _LIBSPL_LIBSHARE_H */ diff --git a/lib/libspl/include/rpc/Makefile.in b/lib/libspl/include/rpc/Makefile.in index 1fd162a..850f045 100644 --- a/lib/libspl/include/rpc/Makefile.in +++ b/lib/libspl/include/rpc/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libspl/include/sys/Makefile.in b/lib/libspl/include/sys/Makefile.in index 0746ded..f8f8294 100644 --- a/lib/libspl/include/sys/Makefile.in +++ b/lib/libspl/include/sys/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libspl/include/sys/dktp/Makefile.in b/lib/libspl/include/sys/dktp/Makefile.in index 499081a..19b0f3b 100644 --- a/lib/libspl/include/sys/dktp/Makefile.in +++ b/lib/libspl/include/sys/dktp/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libspl/include/sys/sysevent/Makefile.in b/lib/libspl/include/sys/sysevent/Makefile.in index 0a9c6d1..96af2d3 100644 --- a/lib/libspl/include/sys/sysevent/Makefile.in +++ b/lib/libspl/include/sys/sysevent/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libspl/include/util/Makefile.in b/lib/libspl/include/util/Makefile.in index 27aa363..bfaec7a 100644 --- a/lib/libspl/include/util/Makefile.in +++ b/lib/libspl/include/util/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libunicode/Makefile.in b/lib/libunicode/Makefile.in index 5daee2b..fb075e8 100644 --- a/lib/libunicode/Makefile.in +++ b/lib/libunicode/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libuutil/Makefile.in b/lib/libuutil/Makefile.in index 1a28249..32d6a74 100644 --- a/lib/libuutil/Makefile.in +++ b/lib/libuutil/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libzfs/Makefile.in b/lib/libzfs/Makefile.in index c8b5004..cad8e6c 100644 --- a/lib/libzfs/Makefile.in +++ b/lib/libzfs/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index 75ce367..42036a4 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -121,20 +121,21 @@ zfs_share_proto_t share_all_proto[] = { }; /* - * Search the sharetab for the given mountpoint and protocol, returning + * Search for NFS and SMB exports for the given mountpoint and protocol, returning * a zfs_share_type_t value. */ static zfs_share_type_t is_shared(libzfs_handle_t *hdl, const char *mountpoint, zfs_share_proto_t proto) { char buf[MAXPATHLEN], *tab; - char *ptr; if (hdl->libzfs_sharetab == NULL) return (SHARED_NOT_SHARED); (void) fseek(hdl->libzfs_sharetab, 0, SEEK_SET); + /* Search /etc/exports for NFS exports */ + /* FIXME: Assumes the file is tab delimited. */ while (fgets(buf, sizeof (buf), hdl->libzfs_sharetab) != NULL) { /* the mountpoint is the first entry on each line */ @@ -143,31 +144,15 @@ is_shared(libzfs_handle_t *hdl, const char *mountpoint, zfs_share_proto_t proto) *tab = '\0'; if (strcmp(buf, mountpoint) == 0) { - /* - * the protocol field is the third field - * skip over second field - */ - ptr = ++tab; - if ((tab = strchr(ptr, '\t')) == NULL) - continue; - ptr = ++tab; - if ((tab = strchr(ptr, '\t')) == NULL) - continue; - *tab = '\0'; - if (strcmp(ptr, - proto_table[proto].p_name) == 0) { - switch (proto) { - case PROTO_NFS: - return (SHARED_NFS); - case PROTO_SMB: - return (SHARED_SMB); - default: - return (0); - } - } + if (proto == PROTO_NFS) + return (SHARED_NFS); + else + return (SHARED_NOT_SHARED); } } + /* XXX: Search /etc/samba/smb.conf for SMB exports, return SHARED_SMB */ + return (SHARED_NOT_SHARED); } @@ -808,10 +793,12 @@ zfs_share_proto(zfs_handle_t *zhp, zfs_share_proto_t *proto) return (0); if ((ret = zfs_init_libshare(hdl, SA_INIT_SHARE_API)) != SA_OK) { +#ifdef HAVE_SHARE (void) zfs_error_fmt(hdl, EZFS_SHARENFSFAILED, dgettext(TEXT_DOMAIN, "cannot share '%s': %s"), zfs_get_name(zhp), _sa_errorstr != NULL ? _sa_errorstr(ret) : ""); +#endif /* HAVE_SHARE */ return (-1); } diff --git a/lib/libzpool/Makefile.in b/lib/libzpool/Makefile.in index 421e55c..209b859 100644 --- a/lib/libzpool/Makefile.in +++ b/lib/libzpool/Makefile.in @@ -64,7 +64,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/man/Makefile.in b/man/Makefile.in index 47a16fe..3dbed30 100644 --- a/man/Makefile.in +++ b/man/Makefile.in @@ -62,7 +62,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/man/man8/Makefile.in b/man/man8/Makefile.in index 0a96d97..f3cd856 100644 --- a/man/man8/Makefile.in +++ b/man/man8/Makefile.in @@ -62,7 +62,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/scripts/Makefile.in b/scripts/Makefile.in index 076fc6c..6653bf3 100644 --- a/scripts/Makefile.in +++ b/scripts/Makefile.in @@ -63,7 +63,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/scripts/zpios-profile/Makefile.in b/scripts/zpios-profile/Makefile.in index fe89e1d..fd95774 100644 --- a/scripts/zpios-profile/Makefile.in +++ b/scripts/zpios-profile/Makefile.in @@ -63,7 +63,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/scripts/zpios-test/Makefile.in b/scripts/zpios-test/Makefile.in index 09f0503..fcb6dfe 100644 --- a/scripts/zpios-test/Makefile.in +++ b/scripts/zpios-test/Makefile.in @@ -63,7 +63,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/scripts/zpool-config/Makefile.in b/scripts/zpool-config/Makefile.in index 71ef3c5..da8b65e 100644 --- a/scripts/zpool-config/Makefile.in +++ b/scripts/zpool-config/Makefile.in @@ -63,7 +63,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/scripts/zpool-layout/Makefile.in b/scripts/zpool-layout/Makefile.in index d270230..dde427b 100644 --- a/scripts/zpool-layout/Makefile.in +++ b/scripts/zpool-layout/Makefile.in @@ -63,7 +63,6 @@ am__aclocal_m4_deps = \ $(top_srcdir)/config/user-frame-larger-than.m4 \ $(top_srcdir)/config/user-ioctl.m4 \ $(top_srcdir)/config/user-libblkid.m4 \ - $(top_srcdir)/config/user-libshare.m4 \ $(top_srcdir)/config/user-libuuid.m4 \ $(top_srcdir)/config/user-nptl_guard_within_stack.m4 \ $(top_srcdir)/config/user-selinux.m4 \ diff --git a/zfs_config.h.in b/zfs_config.h.in index e1532f6..f8e2182 100644 --- a/zfs_config.h.in +++ b/zfs_config.h.in @@ -87,9 +87,6 @@ /* Define if you have selinux */ #undef HAVE_LIBSELINUX -/* Define to 1 if 'libshare' library available */ -#undef HAVE_LIBSHARE - /* Define if you have libuuid */ #undef HAVE_LIBUUID -- 1.8.3.1 From 9a616b5d17185c7fa5cd0d39ff8bc101cad8466d Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 16 Dec 2010 15:43:37 -0800 Subject: [PATCH 13/16] Documentation updates Minor Linux specific documentation updates to the comments and man pages. --- cmd/zfs/zfs_main.c | 18 +++++++++--------- cmd/zinject/translate.c | 2 +- lib/libzfs/libzfs_dataset.c | 4 ++-- lib/libzfs/libzfs_mount.c | 2 +- man/man8/zfs.8 | 6 +++--- module/zfs/zfs_ctldir.c | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 2a38cc0..8d75d2a 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -3365,7 +3365,7 @@ share_mount(int op, int argc, char **argv) } /* - * When mount is given no arguments, go through /etc/mnttab and + * When mount is given no arguments, go through /etc/mtab and * display any active ZFS mounts. We hide any snapshots, since * they are controlled automatically. */ @@ -3453,7 +3453,7 @@ unshare_unmount_compare(const void *larg, const void *rarg, void *unused) /* * Convenience routine used by zfs_do_umount() and manual_unmount(). Given an - * absolute path, find the entry /etc/mnttab, verify that its a ZFS filesystem, + * absolute path, find the entry /etc/mtab, verify that its a ZFS filesystem, * and unmount it appropriately. */ static int @@ -3467,7 +3467,7 @@ unshare_unmount_path(int op, char *path, int flags, boolean_t is_manual) ino_t path_inode; /* - * Search for the path in /etc/mnttab. Rather than looking for the + * Search for the path in /etc/mtab. Rather than looking for the * specific path, which can be fooled by non-standard paths (i.e. ".." * or "//"), we stat() the path and search for the corresponding * (major,minor) device pair. @@ -3494,7 +3494,7 @@ unshare_unmount_path(int op, char *path, int flags, boolean_t is_manual) "currently mounted\n"), cmdname, path); return (1); } - (void) fprintf(stderr, gettext("warning: %s not in mnttab\n"), + (void) fprintf(stderr, gettext("warning: %s not in mtab\n"), path); if ((ret = umount2(path, flags)) != 0) (void) fprintf(stderr, gettext("%s: %s\n"), path, @@ -3536,8 +3536,8 @@ unshare_unmount_path(int op, char *path, int flags, boolean_t is_manual) strcmp(smbshare_prop, "off") == 0) { (void) fprintf(stderr, gettext("cannot unshare " "'%s': legacy share\n"), path); - (void) fprintf(stderr, gettext("use " - "unshare(1M) to unshare this filesystem\n")); + (void) fprintf(stderr, gettext("use exportfs(8) " + "or smbcontrol(1) to unshare this filesystem\n")); } else if (!zfs_is_shared(zhp)) { (void) fprintf(stderr, gettext("cannot unshare '%s': " "not currently shared\n"), path); @@ -3556,7 +3556,7 @@ unshare_unmount_path(int op, char *path, int flags, boolean_t is_manual) (void) fprintf(stderr, gettext("cannot unmount " "'%s': legacy mountpoint\n"), zfs_get_name(zhp)); - (void) fprintf(stderr, gettext("use umount(1M) " + (void) fprintf(stderr, gettext("use umount(8) " "to unmount this filesystem\n")); } else { ret = zfs_unmountall(zhp, flags); @@ -3606,8 +3606,8 @@ unshare_unmount(int op, int argc, char **argv) /* * We could make use of zfs_for_each() to walk all datasets in * the system, but this would be very inefficient, especially - * since we would have to linearly search /etc/mnttab for each - * one. Instead, do one pass through /etc/mnttab looking for + * since we would have to linearly search /etc/mtab for each + * one. Instead, do one pass through /etc/mtab looking for * zfs entries and call zfs_unmount() for each one. * * Things get a little tricky if the administrator has created diff --git a/cmd/zinject/translate.c b/cmd/zinject/translate.c index 9960752..1607866 100644 --- a/cmd/zinject/translate.c +++ b/cmd/zinject/translate.c @@ -115,7 +115,7 @@ parse_pathname(const char *inpath, char *dataset, char *relpath, } if ((fp = fopen(MNTTAB, "r")) == NULL) { - (void) fprintf(stderr, "cannot open /etc/mnttab\n"); + (void) fprintf(stderr, "cannot open /etc/mtab\n"); return (-1); } diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index d876e5d..d4b59f2 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -1600,7 +1600,7 @@ zfs_unset_recvd_props_mode(zfs_handle_t *zhp, uint64_t *cookie) * zfs_prop_get_int() are built using this interface. * * Certain properties can be overridden using 'mount -o'. In this case, scan - * the contents of the /etc/mnttab entry, searching for the appropriate options. + * the contents of the /etc/mtab entry, searching for the appropriate options. * If they differ from the on-disk values, report the current values and mark * the source "temporary". */ @@ -1658,7 +1658,7 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src, /* * Because looking up the mount options is potentially expensive - * (iterating over all of /etc/mnttab), we defer its calculation until + * (iterating over all of /etc/mtab), we defer its calculation until * we're looking up a property which requires its presence. */ if (!zhp->zfs_mntcheck && diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index 42036a4..977b2ee 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -1212,7 +1212,7 @@ mountpoint_compare(const void *a, const void *b) * Unshare and unmount all datasets within the given pool. We don't want to * rely on traversing the DSL to discover the filesystems within the pool, * because this may be expensive (if not all of them are mounted), and can fail - * arbitrarily (on I/O error, for example). Instead, we walk /etc/mnttab and + * arbitrarily (on I/O error, for example). Instead, we walk /etc/mtab and * gather all the filesystems that are currently mounted. */ int diff --git a/man/man8/zfs.8 b/man/man8/zfs.8 index ecde1d9..a7404e6 100644 --- a/man/man8/zfs.8 +++ b/man/man8/zfs.8 @@ -302,19 +302,19 @@ The clone parent-child dependency relationship can be reversed by using the \fBp .SS "Mount Points" .sp .LP -Creating a \fBZFS\fR file system is a simple operation, so the number of file systems per system is likely to be numerous. To cope with this, \fBZFS\fR automatically manages mounting and unmounting file systems without the need to edit the \fB/etc/vfstab\fR file. All automatically managed file systems are mounted by \fBZFS\fR at boot time. +Creating a \fBZFS\fR file system is a simple operation, so the number of file systems per system is likely to be numerous. To cope with this, \fBZFS\fR automatically manages mounting and unmounting file systems without the need to edit the \fB/etc/fstab\fR file. All automatically managed file systems are mounted by \fBZFS\fR at boot time. .sp .LP By default, file systems are mounted under \fB/\fIpath\fR\fR, where \fIpath\fR is the name of the file system in the \fBZFS\fR namespace. Directories are created and destroyed as needed. .sp .LP -A file system can also have a mount point set in the \fBmountpoint\fR property. This directory is created as needed, and \fBZFS\fR automatically mounts the file system when the \fBzfs mount -a\fR command is invoked (without editing \fB/etc/vfstab\fR). The \fBmountpoint\fR property can be inherited, so if \fBpool/home\fR has a mount point of \fB/export/stuff\fR, then \fBpool/home/user\fR automatically inherits a mount point of \fB/export/stuff/user\fR. +A file system can also have a mount point set in the \fBmountpoint\fR property. This directory is created as needed, and \fBZFS\fR automatically mounts the file system when the \fBzfs mount -a\fR command is invoked (without editing \fB/etc/fstab\fR). The \fBmountpoint\fR property can be inherited, so if \fBpool/home\fR has a mount point of \fB/export/stuff\fR, then \fBpool/home/user\fR automatically inherits a mount point of \fB/export/stuff/user\fR. .sp .LP A file system \fBmountpoint\fR property of \fBnone\fR prevents the file system from being mounted. .sp .LP -If needed, \fBZFS\fR file systems can also be managed with traditional tools (\fBmount\fR, \fBumount\fR, \fB/etc/vfstab\fR). If a file system's mount point is set to \fBlegacy\fR, \fBZFS\fR makes no attempt to manage the file system, and the administrator is responsible for mounting and unmounting the file system. +If needed, \fBZFS\fR file systems can also be managed with traditional tools (\fBmount\fR, \fBumount\fR, \fB/etc/fstab\fR). If a file system's mount point is set to \fBlegacy\fR, \fBZFS\fR makes no attempt to manage the file system, and the administrator is responsible for mounting and unmounting the file system. .SS "Zones" .sp .LP diff --git a/module/zfs/zfs_ctldir.c b/module/zfs/zfs_ctldir.c index 51b12a1..b7dac21 100644 --- a/module/zfs/zfs_ctldir.c +++ b/module/zfs/zfs_ctldir.c @@ -31,7 +31,7 @@ * does not actually exist on disk. * * For 'snapshot', we don't want to have all snapshots always mounted, because - * this would take up a huge amount of space in /etc/mnttab. We have three + * this would take up a huge amount of space in /etc/mtab. We have three * types of objects: * * ctldir ------> snapshotdir -------> snapshot -- 1.8.3.1 From b4ead57cfb410247eee4d2a8a6e488cf4542ac77 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 16 Dec 2010 15:11:40 -0800 Subject: [PATCH 14/16] Remove HAVE_ZPL from commands and libraries Thanks to the previous few commits we can now build all of the user space commands and libraries with support for the zpl. --- cmd/zfs/zfs_main.c | 34 ---------------------------- cmd/zinject/zinject.c | 4 ---- cmd/zpool/zpool_main.c | 10 --------- lib/libzfs/libzfs_changelist.c | 12 ---------- lib/libzfs/libzfs_dataset.c | 26 --------------------- lib/libzfs/libzfs_mount.c | 51 ------------------------------------------ lib/libzfs/libzfs_util.c | 2 -- 7 files changed, 139 deletions(-) diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 8d75d2a..d27fcbf 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -318,7 +318,6 @@ safe_malloc(size_t size) return (data); } -#ifdef HAVE_ZPL static char * safe_strdup(char *str) { @@ -329,7 +328,6 @@ safe_strdup(char *str) return (dupstr); } -#endif /* HAVE_ZPL */ /* * Callback routine that will print out information for each of @@ -497,7 +495,6 @@ parse_depth(char *opt, int *flags) #define PROGRESS_DELAY 2 /* seconds */ -#ifdef HAVE_ZPL static char *pt_reverse = "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"; static time_t pt_begin; static char *pt_header = NULL; @@ -549,7 +546,6 @@ finish_progress(char *done) free(pt_header); pt_header = NULL; } -#endif /* HAVE_ZPL */ /* * zfs clone [-p] [-o prop=value] ... @@ -631,7 +627,6 @@ zfs_do_clone(int argc, char **argv) ret = zfs_clone(zhp, argv[1], props); /* create the mountpoint if necessary */ -#ifdef HAVE_ZPL if (ret == 0) { zfs_handle_t *clone; @@ -643,7 +638,6 @@ zfs_do_clone(int argc, char **argv) zfs_close(clone); } } -#endif /* HAVE_ZPL */ zfs_close(zhp); nvlist_free(props); @@ -831,7 +825,6 @@ zfs_do_create(int argc, char **argv) * verbose error message to let the user know that their filesystem was * in fact created, even if we failed to mount or share it. */ -#ifdef HAVE_ZPL if (canmount == ZFS_CANMOUNT_ON) { if (zfs_mount(zhp, NULL, 0) != 0) { (void) fprintf(stderr, gettext("filesystem " @@ -843,7 +836,6 @@ zfs_do_create(int argc, char **argv) ret = 1; } } -#endif /* HAVE_ZPL */ error: if (zhp) @@ -2340,7 +2332,6 @@ typedef struct rollback_cbdata { * 'cb_dependent' is set, then this is a dependent and we should report it * without checking the transaction group. */ -#ifdef HAVE_ZPL static int rollback_check(zfs_handle_t *zhp, void *data) { @@ -2400,12 +2391,10 @@ rollback_check(zfs_handle_t *zhp, void *data) zfs_close(zhp); return (0); } -#endif /* HAVE_ZPL */ static int zfs_do_rollback(int argc, char **argv) { -#ifdef HAVE_ZPL int ret; int c; boolean_t force = B_FALSE; @@ -2487,9 +2476,6 @@ out: return (0); else return (1); -#else - return ENOSYS; -#endif /*HAVE_ZPL*/ } /* @@ -2955,7 +2941,6 @@ zfs_do_release(int argc, char **argv) #define SPINNER_TIME 3 /* seconds */ #define MOUNT_TIME 5 /* seconds */ -#ifdef HAVE_ZPL static int get_one_dataset(zfs_handle_t *zhp, void *data) { @@ -3400,7 +3385,6 @@ share_mount(int op, int argc, char **argv) return (ret); } -#endif /* HAVE_ZPL */ /* * zfs mount -a [nfs] @@ -3411,11 +3395,7 @@ share_mount(int op, int argc, char **argv) static int zfs_do_mount(int argc, char **argv) { -#ifdef HAVE_ZPL return (share_mount(OP_MOUNT, argc, argv)); -#else - return ENOSYS; -#endif /* HAVE_ZPL */ } /* @@ -3427,14 +3407,9 @@ zfs_do_mount(int argc, char **argv) static int zfs_do_share(int argc, char **argv) { -#ifdef HAVE_ZPL return (share_mount(OP_SHARE, argc, argv)); -#else - return ENOSYS; -#endif /* HAVE_ZPL */ } -#ifdef HAVE_ZPL typedef struct unshare_unmount_node { zfs_handle_t *un_zhp; char *un_mountp; @@ -3818,7 +3793,6 @@ unshare_unmount(int op, int argc, char **argv) return (ret); } -#endif /* HAVE_ZPL */ /* * zfs unmount -a @@ -3829,11 +3803,7 @@ unshare_unmount(int op, int argc, char **argv) static int zfs_do_unmount(int argc, char **argv) { -#ifdef HAVE_ZPL return (unshare_unmount(OP_MOUNT, argc, argv)); -#else - return ENOSYS; -#endif /* HAVE_ZPL */ } /* @@ -3845,11 +3815,7 @@ zfs_do_unmount(int argc, char **argv) static int zfs_do_unshare(int argc, char **argv) { -#ifdef HAVE_ZPL return (unshare_unmount(OP_SHARE, argc, argv)); -#else - return ENOSYS; -#endif /* HAVE_ZPL */ } /* ARGSUSED */ diff --git a/cmd/zinject/zinject.c b/cmd/zinject/zinject.c index e76e626..d584ead 100644 --- a/cmd/zinject/zinject.c +++ b/cmd/zinject/zinject.c @@ -951,20 +951,16 @@ main(int argc, char **argv) if (dataset[0] != '\0' && domount) { if ((zhp = zfs_open(g_zfs, dataset, ZFS_TYPE_DATASET)) == NULL) return (1); -#ifdef HAVE_ZPL if (zfs_unmount(zhp, NULL, 0) != 0) return (1); -#endif /* HAVE_ZPL */ } record.zi_error = error; ret = register_handler(pool, flags, &record, quiet); -#ifdef HAVE_ZPL if (dataset[0] != '\0' && domount) ret = (zfs_mount(zhp, NULL, 0) != 0); -#endif /* HAVE_ZPL */ libzfs_fini(g_zfs); diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 1e9b3b6..bad4e2a 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -716,9 +716,7 @@ zpool_do_create(int argc, char **argv) (strcmp(mountpoint, ZFS_MOUNTPOINT_LEGACY) != 0 && strcmp(mountpoint, ZFS_MOUNTPOINT_NONE) != 0)) { char buf[MAXPATHLEN]; -#ifdef HAVE_ZPL DIR *dirp; -#endif if (mountpoint && mountpoint[0] != '/') { (void) fprintf(stderr, gettext("invalid mountpoint " @@ -743,7 +741,6 @@ zpool_do_create(int argc, char **argv) mountpoint); } -#ifdef HAVE_ZPL if ((dirp = opendir(buf)) == NULL && errno != ENOENT) { (void) fprintf(stderr, gettext("mountpoint '%s' : " "%s\n"), buf, strerror(errno)); @@ -766,7 +763,6 @@ zpool_do_create(int argc, char **argv) goto errout; } } -#endif /* HAVE_ZPL */ } if (dryrun) { @@ -797,12 +793,8 @@ zpool_do_create(int argc, char **argv) zfs_prop_to_name( ZFS_PROP_MOUNTPOINT), mountpoint) == 0); -#ifdef HAVE_ZPL if (zfs_mount(pool, NULL, 0) == 0) ret = zfs_shareall(pool); -#else - ret = 0; -#endif /* HAVE_ZPL */ zfs_close(pool); } } else if (libzfs_errno(g_zfs) == EZFS_INVALIDNAME) { @@ -1579,14 +1571,12 @@ do_import(nvlist_t *config, const char *newname, const char *mntopts, if ((zhp = zpool_open_canfail(g_zfs, name)) == NULL) return (1); -#if HAVE_ZPL if (zpool_get_state(zhp) != POOL_STATE_UNAVAIL && !(flags & ZFS_IMPORT_ONLY) && zpool_enable_datasets(zhp, mntopts, 0) != 0) { zpool_close(zhp); return (1); } -#endif /* HAVE_ZPL */ zpool_close(zhp); return (0); diff --git a/lib/libzfs/libzfs_changelist.c b/lib/libzfs/libzfs_changelist.c index 6f067d5..0bcfc04 100644 --- a/lib/libzfs/libzfs_changelist.c +++ b/lib/libzfs/libzfs_changelist.c @@ -93,7 +93,6 @@ struct prop_changelist { int changelist_prefix(prop_changelist_t *clp) { -#ifdef HAVE_ZPL prop_changenode_t *cn; int ret = 0; @@ -142,9 +141,6 @@ changelist_prefix(prop_changelist_t *clp) (void) changelist_postfix(clp); return (ret); -#else - return 0; -#endif /* HAVE_ZPL */ } /* @@ -159,7 +155,6 @@ changelist_prefix(prop_changelist_t *clp) int changelist_postfix(prop_changelist_t *clp) { -#ifdef HAVE_ZPL prop_changenode_t *cn; char shareopts[ZFS_MAXPROPLEN]; int errors = 0; @@ -260,9 +255,6 @@ changelist_postfix(prop_changelist_t *clp) } return (errors ? -1 : 0); -#else - return 0; -#endif /* HAVE_ZPL */ } /* @@ -325,7 +317,6 @@ changelist_rename(prop_changelist_t *clp, const char *src, const char *dst) int changelist_unshare(prop_changelist_t *clp, zfs_share_proto_t *proto) { -#ifdef HAVE_ZPL prop_changenode_t *cn; int ret = 0; @@ -340,9 +331,6 @@ changelist_unshare(prop_changelist_t *clp, zfs_share_proto_t *proto) } return (ret); -#else - return 0; -#endif } /* diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index d4b59f2..378bbc7 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -995,7 +995,6 @@ badlabel: /*FALLTHRU*/ -#ifdef HAVE_ZPL case ZFS_PROP_SHARESMB: case ZFS_PROP_SHARENFS: /* @@ -1106,7 +1105,6 @@ badlabel: } break; -#endif /* HAVE_ZPL */ case ZFS_PROP_UTF8ONLY: chosen_utf = (int)intval; break; @@ -2745,7 +2743,6 @@ create_parents(libzfs_handle_t *hdl, char *target, int prefixlen) goto ancestorerr; } -#ifdef HAVE_ZPL if (zfs_mount(h, NULL, 0) != 0) { opname = dgettext(TEXT_DOMAIN, "mount"); goto ancestorerr; @@ -2755,7 +2752,6 @@ create_parents(libzfs_handle_t *hdl, char *target, int prefixlen) opname = dgettext(TEXT_DOMAIN, "share"); goto ancestorerr; } -#endif /* HAVE_ZPL */ zfs_close(h); } @@ -4037,28 +4033,6 @@ zfs_expand_proplist(zfs_handle_t *zhp, zprop_list_t **plp, boolean_t received) return (0); } -#ifdef HAVE_ZPL -int -zfs_deleg_share_nfs(libzfs_handle_t *hdl, char *dataset, char *path, - char *resource, void *export, void *sharetab, - int sharemax, zfs_share_op_t operation) -{ - zfs_cmd_t zc = { "\0", "\0", "\0", "\0", 0 }; - int error; - - (void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name)); - (void) strlcpy(zc.zc_value, path, sizeof (zc.zc_value)); - if (resource) - (void) strlcpy(zc.zc_string, resource, sizeof (zc.zc_string)); - zc.zc_share.z_sharedata = (uint64_t)(uintptr_t)sharetab; - zc.zc_share.z_exportdata = (uint64_t)(uintptr_t)export; - zc.zc_share.z_sharetype = operation; - zc.zc_share.z_sharemax = sharemax; - error = ioctl(hdl->libzfs_fd, ZFS_IOC_SHARE, &zc); - return (error); -} -#endif /* HAVE_ZPL */ - void zfs_prune_proplist(zfs_handle_t *zhp, uint8_t *props) { diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index 977b2ee..f55b16b 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -84,7 +84,6 @@ #include #define MAXISALEN 257 /* based on sysinfo(2) man page */ -#ifdef HAVE_ZPL static int zfs_share_proto(zfs_handle_t *, zfs_share_proto_t *); zfs_share_type_t zfs_is_shared_proto(zfs_handle_t *, char **, zfs_share_proto_t); @@ -1343,53 +1342,3 @@ out: return (ret); } - -#else /* HAVE_ZPL */ - -int -zfs_unshare_iscsi(zfs_handle_t *zhp) -{ - return 0; -} - -int -zfs_unmount(zfs_handle_t *zhp, const char *mountpoint, int flags) -{ - return 0; -} - -void -remove_mountpoint(zfs_handle_t *zhp) { - return; -} - -boolean_t -is_mounted(libzfs_handle_t *zfs_hdl, const char *special, char **where) -{ - return B_FALSE; -} - -boolean_t -zfs_is_mounted(zfs_handle_t *zhp, char **where) -{ - return is_mounted(zhp->zfs_hdl, zfs_get_name(zhp), where); -} - -boolean_t -zfs_is_shared(zfs_handle_t *zhp) -{ - return B_FALSE; -} - -int -zpool_enable_datasets(zpool_handle_t *zhp, const char *mntopts, int flags) -{ - return B_FALSE; -} - -int -zpool_disable_datasets(zpool_handle_t *zhp, boolean_t force) -{ - return B_FALSE; -} -#endif /* HAVE_ZPL */ diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index 37dba8d..163cd16 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -727,9 +727,7 @@ libzfs_fini(libzfs_handle_t *hdl) #endif if (hdl->libzfs_sharetab) (void) fclose(hdl->libzfs_sharetab); -#ifdef HAVE_ZPL zfs_uninit_libshare(hdl); -#endif if (hdl->libzfs_log_str) (void) free(hdl->libzfs_log_str); zpool_free_handles(hdl); -- 1.8.3.1 From 872e8d26978a8e1caa1ca7d931db7f95d987a3e7 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 17 Dec 2010 09:14:38 -0800 Subject: [PATCH 15/16] Add initial rw_uio functions to the dmu These functions were dropped originally because I felt they would need to be rewritten anyway to avoid using uios. However, this patch readds then with they dea they can just be reworked and the uio bits dropped. --- include/sys/dmu.h | 10 ++++- module/zfs/dmu.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 117 insertions(+), 5 deletions(-) diff --git a/include/sys/dmu.h b/include/sys/dmu.h index 575cb2d..a8edfdb 100644 --- a/include/sys/dmu.h +++ b/include/sys/dmu.h @@ -515,12 +515,18 @@ void dmu_prealloc(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, dmu_tx_t *tx); #ifdef _KERNEL int dmu_read_req(objset_t *os, uint64_t object, struct request *req); -int dmu_write_req(objset_t *os, uint64_t object, struct request *req, dmu_tx_t *tx); -#endif +int dmu_write_req(objset_t *os, uint64_t object, struct request *req, + dmu_tx_t *tx); +int dmu_read_uio(objset_t *os, uint64_t object, struct uio *uio, uint64_t size); +int dmu_write_uio(objset_t *os, uint64_t object, struct uio *uio, uint64_t size, + dmu_tx_t *tx); +int dmu_write_uio_dbuf(dmu_buf_t *zdb, struct uio *uio, uint64_t size, + dmu_tx_t *tx); #ifdef HAVE_ZPL int dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, struct page *pp, dmu_tx_t *tx); #endif +#endif struct arc_buf *dmu_request_arcbuf(dmu_buf_t *handle, int size); void dmu_return_arcbuf(struct arc_buf *buf); void dmu_assign_arcbuf(dmu_buf_t *handle, uint64_t offset, struct arc_buf *buf, diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c index aaeec41..79024e1 100644 --- a/module/zfs/dmu.c +++ b/module/zfs/dmu.c @@ -1122,9 +1122,113 @@ dmu_write_req(objset_t *os, uint64_t object, struct request *req, dmu_tx_t *tx) dmu_buf_rele_array(dbp, numbufs, FTAG); return (err); } -#endif -#ifdef HAVE_ZPL +int +dmu_read_uio(objset_t *os, uint64_t object, uio_t *uio, uint64_t size) +{ + dmu_buf_t **dbp; + int numbufs, i, err; + xuio_t *xuio = NULL; + + /* + * NB: we could do this block-at-a-time, but it's nice + * to be reading in parallel. + */ + err = dmu_buf_hold_array(os, object, uio->uio_loffset, size, TRUE, FTAG, + &numbufs, &dbp); + if (err) + return (err); + + for (i = 0; i < numbufs; i++) { + int tocpy; + int bufoff; + dmu_buf_t *db = dbp[i]; + + ASSERT(size > 0); + + bufoff = uio->uio_loffset - db->db_offset; + tocpy = (int)MIN(db->db_size - bufoff, size); + + if (xuio) { + dmu_buf_impl_t *dbi = (dmu_buf_impl_t *)db; + arc_buf_t *dbuf_abuf = dbi->db_buf; + arc_buf_t *abuf = dbuf_loan_arcbuf(dbi); + err = dmu_xuio_add(xuio, abuf, bufoff, tocpy); + if (!err) { + uio->uio_resid -= tocpy; + uio->uio_loffset += tocpy; + } + + if (abuf == dbuf_abuf) + XUIOSTAT_BUMP(xuiostat_rbuf_nocopy); + else + XUIOSTAT_BUMP(xuiostat_rbuf_copied); + } else { + err = uiomove((char *)db->db_data + bufoff, tocpy, + UIO_READ, uio); + } + if (err) + break; + + size -= tocpy; + } + dmu_buf_rele_array(dbp, numbufs, FTAG); + + return (err); +} + +static int +dmu_write_uio_dnode(dnode_t *dn, uio_t *uio, uint64_t size, dmu_tx_t *tx) +{ + dmu_buf_t **dbp; + int numbufs; + int err = 0; + int i; + + err = dmu_buf_hold_array_by_dnode(dn, uio->uio_loffset, size, + FALSE, FTAG, &numbufs, &dbp, DMU_READ_PREFETCH); + if (err) + return (err); + + for (i = 0; i < numbufs; i++) { + int tocpy; + int bufoff; + dmu_buf_t *db = dbp[i]; + + ASSERT(size > 0); + + bufoff = uio->uio_loffset - db->db_offset; + tocpy = (int)MIN(db->db_size - bufoff, size); + + ASSERT(i == 0 || i == numbufs-1 || tocpy == db->db_size); + + if (tocpy == db->db_size) + dmu_buf_will_fill(db, tx); + else + dmu_buf_will_dirty(db, tx); + + /* + * XXX uiomove could block forever (eg.nfs-backed + * pages). There needs to be a uiolockdown() function + * to lock the pages in memory, so that uiomove won't + * block. + */ + err = uiomove((char *)db->db_data + bufoff, tocpy, + UIO_WRITE, uio); + + if (tocpy == db->db_size) + dmu_buf_fill_done(db, tx); + + if (err) + break; + + size -= tocpy; + } + + dmu_buf_rele_array(dbp, numbufs, FTAG); + return (err); +} + int dmu_write_uio_dbuf(dmu_buf_t *zdb, uio_t *uio, uint64_t size, dmu_tx_t *tx) @@ -1165,6 +1269,7 @@ dmu_write_uio(objset_t *os, uint64_t object, uio_t *uio, uint64_t size, return (err); } +#ifdef HAVE_ZPL int dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, page_t *pp, dmu_tx_t *tx) @@ -1219,7 +1324,8 @@ dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, dmu_buf_rele_array(dbp, numbufs, FTAG); return (err); } -#endif +#endif /* HAVE_ZPL */ +#endif /* _KERNEL */ /* * Allocate a loaned anonymous arc buffer. -- 1.8.3.1 From 72d5e2da3e45a6865806f1be908232f5fea8787b Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 17 Dec 2010 14:04:40 -0800 Subject: [PATCH 16/16] Add HAVE_SCANSTAMP This functionality is not supported under Linux, perhaps it will be some day if it's decided it's useful. --- module/zfs/zfs_sa.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/module/zfs/zfs_sa.c b/module/zfs/zfs_sa.c index 88fd789..f4c599f 100644 --- a/module/zfs/zfs_sa.c +++ b/module/zfs/zfs_sa.c @@ -67,7 +67,6 @@ sa_attr_reg_t zfs_attr_table[ZPL_END+1] = { }; #ifdef _KERNEL -#ifdef HAVE_ZPL int zfs_sa_readlink(znode_t *zp, uio_t *uio) { @@ -119,6 +118,7 @@ zfs_sa_symlink(znode_t *zp, char *link, int len, dmu_tx_t *tx) } } +#ifdef HAVE_SCANSTAMP void zfs_sa_get_scanstamp(znode_t *zp, xvattr_t *xvap) { @@ -183,6 +183,7 @@ zfs_sa_set_scanstamp(znode_t *zp, xvattr_t *xvap, dmu_tx_t *tx) &zp->z_pflags, sizeof (uint64_t), tx)); } } +#endif /* HAVE_SCANSTAMP */ /* * I'm not convinced we should do any of this upgrade. @@ -205,7 +206,9 @@ zfs_sa_upgrade(sa_handle_t *hdl, dmu_tx_t *tx) uint64_t uid, gid, mode, rdev, xattr, parent; uint64_t crtime[2], mtime[2], ctime[2]; zfs_acl_phys_t znode_acl; +#ifdef HAVE_SCANSTAMP char scanstamp[AV_SCANSTAMP_SZ]; +#endif /* HAVE_SCANSTAMP */ boolean_t drop_lock = B_FALSE; /* @@ -293,6 +296,7 @@ zfs_sa_upgrade(sa_handle_t *hdl, dmu_tx_t *tx) SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_XATTR(zfsvfs), NULL, &xattr, 8); +#ifdef HAVE_SCANSTAMP /* if scanstamp then add scanstamp */ if (zp->z_pflags & ZFS_BONUS_SCANSTAMP) { @@ -302,6 +306,7 @@ zfs_sa_upgrade(sa_handle_t *hdl, dmu_tx_t *tx) NULL, scanstamp, AV_SCANSTAMP_SZ); zp->z_pflags &= ~ZFS_BONUS_SCANSTAMP; } +#endif /* HAVE_SCANSTAMP */ VERIFY(dmu_set_bonustype(db, DMU_OT_SA, tx) == 0); VERIFY(sa_replace_all_by_template_locked(hdl, sa_attrs, @@ -331,5 +336,4 @@ zfs_sa_upgrade_txholds(dmu_tx_t *tx, znode_t *zp) } } -#endif /* HAVE_ZPL */ #endif -- 1.8.3.1