Merge commit 'refs/top-bases/linux-zfs-branch' into linux-zfs-branch
This commit is contained in:
commit
de228b9ca7
|
@ -837,7 +837,7 @@ destroy_callback(zfs_handle_t *zhp, void *data)
|
|||
zfs_close(zhp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef HAVE_ZPL
|
||||
/*
|
||||
* Bail out on the first error.
|
||||
*/
|
||||
|
@ -846,6 +846,7 @@ destroy_callback(zfs_handle_t *zhp, void *data)
|
|||
zfs_close(zhp);
|
||||
return (-1);
|
||||
}
|
||||
#endif /* HAVE_ZPL */
|
||||
|
||||
zfs_close(zhp);
|
||||
return (0);
|
||||
|
@ -3012,6 +3013,7 @@ dataset_cmp(const void *a, const void *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
|
||||
* similar, we have a common function with an extra parameter to determine which
|
||||
|
@ -3262,6 +3264,7 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol,
|
|||
|
||||
return (0);
|
||||
}
|
||||
#endif /* HAVE_ZPL */
|
||||
|
||||
/*
|
||||
* Reports progress in the form "(current/total)". Not thread-safe.
|
||||
|
@ -3317,6 +3320,7 @@ append_options(char *mntopts, char *newopts)
|
|||
(void) strcpy(&mntopts[len], newopts);
|
||||
}
|
||||
|
||||
#ifdef HAVE_ZPL
|
||||
static int
|
||||
share_mount(int op, int argc, char **argv)
|
||||
{
|
||||
|
@ -3465,6 +3469,7 @@ share_mount(int op, int argc, char **argv)
|
|||
|
||||
return (ret);
|
||||
}
|
||||
#endif /* HAVE_ZPL */
|
||||
|
||||
/*
|
||||
* zfs mount -a [nfs | iscsi]
|
||||
|
@ -3475,7 +3480,9 @@ 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));
|
||||
#endif /* HAVE_ZPL */
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3487,9 +3494,12 @@ 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));
|
||||
#endif /* HAVE_ZPL */
|
||||
}
|
||||
|
||||
#ifdef HAVE_ZPL
|
||||
typedef struct unshare_unmount_node {
|
||||
zfs_handle_t *un_zhp;
|
||||
char *un_mountp;
|
||||
|
@ -3942,6 +3952,7 @@ unshare_unmount(int op, int argc, char **argv)
|
|||
|
||||
return (ret);
|
||||
}
|
||||
#endif /* HAVE_ZPL */
|
||||
|
||||
/*
|
||||
* zfs unmount -a
|
||||
|
@ -3952,7 +3963,9 @@ 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));
|
||||
#endif /* HAVE_ZPL */
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3964,7 +3977,9 @@ 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));
|
||||
#endif /* HAVE_ZPL */
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -6,11 +6,13 @@ DEFAULT_INCLUDES += \
|
|||
lib_LTLIBRARIES = libspl.la
|
||||
|
||||
libspl_la_SOURCES = \
|
||||
${top_srcdir}/lib/libspl/getmntany.c \
|
||||
${top_srcdir}/lib/libspl/list.c \
|
||||
${top_srcdir}/lib/libspl/mkdirp.c \
|
||||
${top_srcdir}/lib/libspl/strlcat.c \
|
||||
${top_srcdir}/lib/libspl/strlcpy.c \
|
||||
${top_srcdir}/lib/libspl/strnlen.c \
|
||||
${top_srcdir}/lib/libspl/u8_textprep.c \
|
||||
${top_srcdir}/lib/libspl/zone.c \
|
||||
${top_srcdir}/lib/libspl/include/sys/list.h \
|
||||
${top_srcdir}/lib/libspl/include/sys/list_impl.h
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* 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 2005 Sun Microsystems, Inc. All rights reserved.
|
||||
* Copyright 2006 Ricardo Correia. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
/* Copyright (c) 1988 AT&T */
|
||||
/* All Rights Reserved */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <mntent.h>
|
||||
#include <sys/mnttab.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define BUFSIZE (MNT_LINE_MAX + 2)
|
||||
|
||||
__thread char buf[BUFSIZE];
|
||||
|
||||
#define DIFF(xx) ((mrefp->xx != NULL) && \
|
||||
(mgetp->xx == NULL || strcmp(mrefp->xx, mgetp->xx) != 0))
|
||||
|
||||
int
|
||||
getmntany(FILE *fp, struct mnttab *mgetp, struct mnttab *mrefp)
|
||||
{
|
||||
int ret;
|
||||
|
||||
while (((ret = _sol_getmntent(fp, mgetp)) == 0) &&
|
||||
(DIFF(mnt_special) || DIFF(mnt_mountp) ||
|
||||
DIFF(mnt_fstype) || DIFF(mnt_mntopts)));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
_sol_getmntent(FILE *fp, struct mnttab *mgetp)
|
||||
{
|
||||
struct mntent mntbuf;
|
||||
struct mntent *ret;
|
||||
|
||||
ret = getmntent_r(fp, &mntbuf, buf, BUFSIZE);
|
||||
|
||||
if (ret != NULL) {
|
||||
mgetp->mnt_special = mntbuf.mnt_fsname;
|
||||
mgetp->mnt_mountp = mntbuf.mnt_dir;
|
||||
mgetp->mnt_fstype = mntbuf.mnt_type;
|
||||
mgetp->mnt_mntopts = mntbuf.mnt_opts;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (feof(fp))
|
||||
return -1;
|
||||
|
||||
return MNT_TOOLONG;
|
||||
}
|
||||
|
||||
int
|
||||
getextmntent(FILE *fp, struct extmnttab *mp, int len)
|
||||
{
|
||||
int ret;
|
||||
struct stat64 st;
|
||||
|
||||
ret = _sol_getmntent(fp, (struct mnttab *) mp);
|
||||
if (ret == 0) {
|
||||
if (stat64(mp->mnt_mountp, &st) != 0) {
|
||||
mp->mnt_major = 0;
|
||||
mp->mnt_minor = 0;
|
||||
return ret;
|
||||
}
|
||||
mp->mnt_major = major(st.st_dev);
|
||||
mp->mnt_minor = minor(st.st_dev);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* CDDL HEADER START
|
||||
*
|
||||
* The contents of this file are subject to the terms of the
|
||||
* Common Development and Distribution License (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 2006 Ricardo Correia. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
#include <zone.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
zoneid_t getzoneid()
|
||||
{
|
||||
return GLOBAL_ZONEID;
|
||||
}
|
||||
|
||||
zoneid_t getzoneidbyname(const char *name)
|
||||
{
|
||||
if(name == NULL)
|
||||
return GLOBAL_ZONEID;
|
||||
|
||||
if(strcmp(name, GLOBAL_ZONEID_NAME) == 0)
|
||||
return GLOBAL_ZONEID;
|
||||
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
ssize_t getzonenamebyid(zoneid_t id, char *buf, size_t buflen)
|
||||
{
|
||||
if(id != GLOBAL_ZONEID)
|
||||
return EINVAL;
|
||||
|
||||
ssize_t ret = strlen(GLOBAL_ZONEID_NAME) + 1;
|
||||
|
||||
if(buf == NULL || buflen == 0)
|
||||
return ret;
|
||||
|
||||
strncpy(buf, GLOBAL_ZONEID_NAME, buflen);
|
||||
buf[buflen - 1] = '\0';
|
||||
|
||||
return ret;
|
||||
}
|
Loading…
Reference in New Issue