Merge commit 'refs/top-bases/linux-zfs-branch' into linux-zfs-branch

This commit is contained in:
Brian Behlendorf 2008-12-22 12:24:48 -08:00
commit 31fbf5aa5c
8 changed files with 106 additions and 1 deletions

View File

@ -505,6 +505,7 @@ zfs_do_clone(int argc, char **argv)
ret = zfs_clone(zhp, argv[1], props); ret = zfs_clone(zhp, argv[1], props);
/* create the mountpoint if necessary */ /* create the mountpoint if necessary */
#ifdef HAVE_ZPL
if (ret == 0) { if (ret == 0) {
zfs_handle_t *clone; zfs_handle_t *clone;
@ -515,6 +516,7 @@ zfs_do_clone(int argc, char **argv)
zfs_close(clone); zfs_close(clone);
} }
} }
#endif /* HAVE_ZPL */
zfs_close(zhp); zfs_close(zhp);
nvlist_free(props); nvlist_free(props);
@ -712,6 +714,7 @@ zfs_do_create(int argc, char **argv)
* in fact created, even if we failed to mount or share it. * in fact created, even if we failed to mount or share it.
*/ */
ret = 0; ret = 0;
#ifdef HAVE_ZPL
if (canmount == ZFS_CANMOUNT_ON) { if (canmount == ZFS_CANMOUNT_ON) {
if (zfs_mount(zhp, NULL, 0) != 0) { if (zfs_mount(zhp, NULL, 0) != 0) {
(void) fprintf(stderr, gettext("filesystem " (void) fprintf(stderr, gettext("filesystem "
@ -723,6 +726,7 @@ zfs_do_create(int argc, char **argv)
ret = 1; ret = 1;
} }
} }
#endif /* HAVE_ZPL */
error: error:
if (zhp) if (zhp)
@ -832,6 +836,7 @@ destroy_callback(zfs_handle_t *zhp, void *data)
return (0); return (0);
} }
#ifdef HAVE_ZPL
/* /*
* Bail out on the first error. * Bail out on the first error.
*/ */
@ -840,6 +845,7 @@ destroy_callback(zfs_handle_t *zhp, void *data)
zfs_close(zhp); zfs_close(zhp);
return (-1); return (-1);
} }
#endif /* HAVE_ZPL */
zfs_close(zhp); zfs_close(zhp);
return (0); return (0);
@ -3006,6 +3012,7 @@ dataset_cmp(const void *a, const void *b)
return (strcmp(zfs_get_name(a), zfs_get_name(b))); return (strcmp(zfs_get_name(a), zfs_get_name(b)));
} }
#if HAVE_ZPL
/* /*
* Generic callback for sharing or mounting filesystems. Because the code is so * Generic callback for sharing or mounting filesystems. Because the code is so
* similar, we have a common function with an extra parameter to determine which * similar, we have a common function with an extra parameter to determine which
@ -3240,6 +3247,7 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol,
return (0); return (0);
} }
#endif /* HAVE_ZPL */
/* /*
* Reports progress in the form "(current/total)". Not thread-safe. * Reports progress in the form "(current/total)". Not thread-safe.
@ -3295,6 +3303,7 @@ append_options(char *mntopts, char *newopts)
(void) strcpy(&mntopts[len], newopts); (void) strcpy(&mntopts[len], newopts);
} }
#ifdef HAVE_ZPL
static int static int
share_mount(int op, int argc, char **argv) share_mount(int op, int argc, char **argv)
{ {
@ -3443,6 +3452,7 @@ share_mount(int op, int argc, char **argv)
return (ret); return (ret);
} }
#endif /* HAVE_ZPL */
/* /*
* zfs mount -a [nfs | iscsi] * zfs mount -a [nfs | iscsi]
@ -3453,7 +3463,11 @@ share_mount(int op, int argc, char **argv)
static int static int
zfs_do_mount(int argc, char **argv) zfs_do_mount(int argc, char **argv)
{ {
#ifdef HAVE_ZPL
return (share_mount(OP_MOUNT, argc, argv)); return (share_mount(OP_MOUNT, argc, argv));
#else
return ENOSYS;
#endif /* HAVE_ZPL */
} }
/* /*
@ -3465,9 +3479,14 @@ zfs_do_mount(int argc, char **argv)
static int static int
zfs_do_share(int argc, char **argv) zfs_do_share(int argc, char **argv)
{ {
#ifdef HAVE_ZPL
return (share_mount(OP_SHARE, argc, argv)); return (share_mount(OP_SHARE, argc, argv));
#else
return ENOSYS;
#endif /* HAVE_ZPL */
} }
#ifdef HAVE_ZPL
typedef struct unshare_unmount_node { typedef struct unshare_unmount_node {
zfs_handle_t *un_zhp; zfs_handle_t *un_zhp;
char *un_mountp; char *un_mountp;
@ -3920,6 +3939,7 @@ unshare_unmount(int op, int argc, char **argv)
return (ret); return (ret);
} }
#endif /* HAVE_ZPL */
/* /*
* zfs unmount -a * zfs unmount -a
@ -3930,7 +3950,11 @@ unshare_unmount(int op, int argc, char **argv)
static int static int
zfs_do_unmount(int argc, char **argv) zfs_do_unmount(int argc, char **argv)
{ {
#ifdef HAVE_ZPL
return (unshare_unmount(OP_MOUNT, argc, argv)); return (unshare_unmount(OP_MOUNT, argc, argv));
#else
return ENOSYS;
#endif /* HAVE_ZPL */
} }
/* /*
@ -3942,13 +3966,18 @@ zfs_do_unmount(int argc, char **argv)
static int static int
zfs_do_unshare(int argc, char **argv) zfs_do_unshare(int argc, char **argv)
{ {
#ifdef HAVE_ZPL
return (unshare_unmount(OP_SHARE, argc, argv)); return (unshare_unmount(OP_SHARE, argc, argv));
#else
return ENOSYS;
#endif /* HAVE_ZPL */
} }
/* /*
* Called when invoked as /etc/fs/zfs/mount. Do the mount if the mountpoint is * 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'. * 'legacy'. Otherwise, complain that use should be using 'zfs mount'.
*/ */
#ifdef HAVE_ZPL
static int static int
manual_mount(int argc, char **argv) manual_mount(int argc, char **argv)
{ {
@ -4079,6 +4108,7 @@ manual_unmount(int argc, char **argv)
return (unshare_unmount_path(OP_MOUNT, argv[0], flags, B_TRUE)); return (unshare_unmount_path(OP_MOUNT, argv[0], flags, B_TRUE));
} }
#endif /* HAVE_ZPL */
static int static int
volcheck(zpool_handle_t *zhp, void *data) volcheck(zpool_handle_t *zhp, void *data)
@ -4148,6 +4178,7 @@ main(int argc, char **argv)
return (1); return (1);
} }
#ifdef HAVE_ZPL
/* /*
* This command also doubles as the /etc/fs mount and unmount program. * This command also doubles as the /etc/fs mount and unmount program.
* Determine if we should take this behavior based on argv[0]. * Determine if we should take this behavior based on argv[0].
@ -4158,6 +4189,9 @@ main(int argc, char **argv)
} else if (strcmp(progname, "umount") == 0) { } else if (strcmp(progname, "umount") == 0) {
ret = manual_unmount(argc, argv); ret = manual_unmount(argc, argv);
} else { } else {
#else
{
#endif /* HAVE_ZPL */
/* /*
* Make sure the user has specified some command. * Make sure the user has specified some command.
*/ */

View File

@ -722,6 +722,7 @@ zpool_do_create(int argc, char **argv)
mountpoint); mountpoint);
} }
#ifdef HAVE_ZPL
if ((dirp = opendir(buf)) == NULL && errno != ENOENT) { if ((dirp = opendir(buf)) == NULL && errno != ENOENT) {
(void) fprintf(stderr, gettext("mountpoint '%s' : " (void) fprintf(stderr, gettext("mountpoint '%s' : "
"%s\n"), buf, strerror(errno)); "%s\n"), buf, strerror(errno));
@ -744,6 +745,7 @@ zpool_do_create(int argc, char **argv)
goto errout; goto errout;
} }
} }
#endif /* HAVE_ZPL */
} }
if (dryrun) { if (dryrun) {
@ -774,8 +776,12 @@ zpool_do_create(int argc, char **argv)
zfs_prop_to_name( zfs_prop_to_name(
ZFS_PROP_MOUNTPOINT), ZFS_PROP_MOUNTPOINT),
mountpoint) == 0); mountpoint) == 0);
#ifdef HAVE_ZPL
if (zfs_mount(pool, NULL, 0) == 0) if (zfs_mount(pool, NULL, 0) == 0)
ret = zfs_shareall(pool); ret = zfs_shareall(pool);
#else
ret = 0;
#endif /* HAVE_ZPL */
zfs_close(pool); zfs_close(pool);
} }
} else if (libzfs_errno(g_zfs) == EZFS_INVALIDNAME) { } else if (libzfs_errno(g_zfs) == EZFS_INVALIDNAME) {
@ -1315,10 +1321,12 @@ do_import(nvlist_t *config, const char *newname, const char *mntopts,
verify((zhp = zpool_open_canfail(g_zfs, name)) != NULL); verify((zhp = zpool_open_canfail(g_zfs, name)) != NULL);
#if HAVE_ZPL
if (zpool_enable_datasets(zhp, mntopts, 0) != 0) { if (zpool_enable_datasets(zhp, mntopts, 0) != 0) {
zpool_close(zhp); zpool_close(zhp);
return (1); return (1);
} }
#endif /* HAVE_ZPL */
zpool_close(zhp); zpool_close(zhp);
return (error); return (error);

View File

@ -93,6 +93,7 @@ struct prop_changelist {
int int
changelist_prefix(prop_changelist_t *clp) changelist_prefix(prop_changelist_t *clp)
{ {
#ifdef HAVE_ZPL
prop_changenode_t *cn; prop_changenode_t *cn;
int ret = 0; int ret = 0;
@ -168,6 +169,9 @@ changelist_prefix(prop_changelist_t *clp)
(void) changelist_postfix(clp); (void) changelist_postfix(clp);
return (ret); return (ret);
#else
return 0;
#endif /* HAVE_ZPL */
} }
/* /*
@ -182,6 +186,7 @@ changelist_prefix(prop_changelist_t *clp)
int int
changelist_postfix(prop_changelist_t *clp) changelist_postfix(prop_changelist_t *clp)
{ {
#ifdef HAVE_ZPL
prop_changenode_t *cn; prop_changenode_t *cn;
char shareopts[ZFS_MAXPROPLEN]; char shareopts[ZFS_MAXPROPLEN];
int errors = 0; int errors = 0;
@ -296,6 +301,9 @@ changelist_postfix(prop_changelist_t *clp)
} }
return (errors ? -1 : 0); return (errors ? -1 : 0);
#else
return 0;
#endif /* HAVE_ZPL */
} }
/* /*
@ -358,6 +366,7 @@ changelist_rename(prop_changelist_t *clp, const char *src, const char *dst)
int int
changelist_unshare(prop_changelist_t *clp, zfs_share_proto_t *proto) changelist_unshare(prop_changelist_t *clp, zfs_share_proto_t *proto)
{ {
#ifdef HAVE_ZPL
prop_changenode_t *cn; prop_changenode_t *cn;
int ret = 0; int ret = 0;
@ -372,6 +381,9 @@ changelist_unshare(prop_changelist_t *clp, zfs_share_proto_t *proto)
} }
return (ret); return (ret);
#else
return 0;
#endif
} }
/* /*

View File

@ -735,6 +735,7 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
/*FALLTHRU*/ /*FALLTHRU*/
#ifdef HAVE_ZPL
case ZFS_PROP_SHARESMB: case ZFS_PROP_SHARESMB:
case ZFS_PROP_SHARENFS: case ZFS_PROP_SHARENFS:
/* /*
@ -845,6 +846,7 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
} }
break; break;
#endif /* HAVE_ZPL */
case ZFS_PROP_UTF8ONLY: case ZFS_PROP_UTF8ONLY:
chosen_utf = (int)intval; chosen_utf = (int)intval;
break; break;
@ -2873,6 +2875,7 @@ create_parents(libzfs_handle_t *hdl, char *target, int prefixlen)
goto ancestorerr; goto ancestorerr;
} }
#ifdef HAVE_ZPL
if (zfs_mount(h, NULL, 0) != 0) { if (zfs_mount(h, NULL, 0) != 0) {
opname = dgettext(TEXT_DOMAIN, "mount"); opname = dgettext(TEXT_DOMAIN, "mount");
goto ancestorerr; goto ancestorerr;
@ -2882,6 +2885,7 @@ create_parents(libzfs_handle_t *hdl, char *target, int prefixlen)
opname = dgettext(TEXT_DOMAIN, "share"); opname = dgettext(TEXT_DOMAIN, "share");
goto ancestorerr; goto ancestorerr;
} }
#endif /* HAVE_ZPL */
zfs_close(h); zfs_close(h);
} }
@ -3098,9 +3102,11 @@ zfs_destroy(zfs_handle_t *zhp)
* abort the request. This would only happen for a * abort the request. This would only happen for a
* non-privileged user. * non-privileged user.
*/ */
#ifdef HAVE_ZPL
if (zfs_unshare_iscsi(zhp) != 0) { if (zfs_unshare_iscsi(zhp) != 0) {
return (-1); return (-1);
} }
#endif
if (zvol_remove_link(zhp->zfs_hdl, zhp->zfs_name) != 0) if (zvol_remove_link(zhp->zfs_hdl, zhp->zfs_name) != 0)
return (-1); return (-1);

View File

@ -86,6 +86,7 @@
#include <sys/systeminfo.h> #include <sys/systeminfo.h>
#define MAXISALEN 257 /* based on sysinfo(2) man page */ #define MAXISALEN 257 /* based on sysinfo(2) man page */
#ifdef HAVE_ZPL
static int zfs_share_proto(zfs_handle_t *, zfs_share_proto_t *); 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_type_t zfs_is_shared_proto(zfs_handle_t *, char **,
zfs_share_proto_t); zfs_share_proto_t);
@ -1234,7 +1235,6 @@ out:
return (ret); return (ret);
} }
static int static int
zvol_cb(const char *dataset, void *data) zvol_cb(const char *dataset, void *data)
{ {
@ -1407,3 +1407,42 @@ out:
return (ret); return (ret);
} }
#else /* HAVE_ZPL */
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_TRUE;
}
int
zpool_disable_datasets(zpool_handle_t *zhp, boolean_t force)
{
return B_TRUE;
}
#endif /* HAVE_ZPL */

View File

@ -1936,6 +1936,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
* created). Also mount any children of the target filesystem * created). Also mount any children of the target filesystem
* if we did an incremental receive. * if we did an incremental receive.
*/ */
#ifdef HAVE_ZPL
cp = strchr(zc.zc_value, '@'); cp = strchr(zc.zc_value, '@');
if (cp && (ioctl_err == 0 || !newfs)) { if (cp && (ioctl_err == 0 || !newfs)) {
zfs_handle_t *h; zfs_handle_t *h;
@ -1962,6 +1963,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
} }
*cp = '@'; *cp = '@';
} }
#endif /* HAVE_ZPL */
if (clp) { if (clp) {
err |= changelist_postfix(clp); err |= changelist_postfix(clp);

View File

@ -595,7 +595,9 @@ libzfs_fini(libzfs_handle_t *hdl)
#endif #endif
if (hdl->libzfs_sharetab) if (hdl->libzfs_sharetab)
(void) fclose(hdl->libzfs_sharetab); (void) fclose(hdl->libzfs_sharetab);
#ifdef HAVE_ZPL
zfs_uninit_libshare(hdl); zfs_uninit_libshare(hdl);
#endif
if (hdl->libzfs_log_str) if (hdl->libzfs_log_str)
(void) free(hdl->libzfs_log_str); (void) free(hdl->libzfs_log_str);
zpool_free_handles(hdl); zpool_free_handles(hdl);

View File

@ -1638,6 +1638,7 @@ zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value)
return (error); return (error);
} }
#ifdef HAVE_ZPL
static vfsdef_t vfw = { static vfsdef_t vfw = {
VFSDEF_VERSION, VFSDEF_VERSION,
MNTTYPE_ZFS, MNTTYPE_ZFS,
@ -1650,3 +1651,4 @@ static vfsdef_t vfw = {
struct modlfs zfs_modlfs = { struct modlfs zfs_modlfs = {
&mod_fsops, "ZFS filesystem version " SPA_VERSION_STRING, &vfw &mod_fsops, "ZFS filesystem version " SPA_VERSION_STRING, &vfw
}; };
#endif /* HAVE_ZPL */