zfs_ioctl.c revision fb09f5aad449c97fe309678f3f604982b563a96f
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
#include "zfs_namecheck.h"
#include "zfs_prop.h"
#include "zfs_deleg.h"
#include "zfs_comutil.h"
extern void zfs_init(void);
extern void zfs_fini(void);
typedef struct zfs_ioc_vec {
const char *zvec_name;
static const char *userquota_perms[] = {
boolean_t *);
const char *newfile;
* /stringof(arg0) == "dbuf.c"/ \
char *buf;
return (NULL);
return (NULL);
return (buf);
static boolean_t
return (ret);
return (B_FALSE);
static boolean_t
return (B_TRUE);
return (rc);
char *buf;
return (ENOENT);
return (ENOENT);
return (EPERM);
if (!zoned)
return (EPERM);
if (!writable)
return (EPERM);
return (ENOENT);
return (ENOENT);
int error;
if (error != 0)
return (error);
if (error == 0) {
if (error)
return (error);
int error;
if (error == 0) {
if (error)
return (error);
int error;
if (error)
return (EPERM);
return (EINVAL);
return (EPERM);
return (EPERM);
if (!zoned) {
return (EPERM);
if (error)
return (EPERM);
if (new_default) {
goto out_check;
return (EPERM);
if (!new_default)
char *strval;
switch (prop) {
case ZFS_PROP_ZONED:
return (EPERM);
case ZFS_PROP_QUOTA:
setpoint))
return (EPERM);
return (EPERM);
case ZFS_PROP_MLSLABEL:
if (!is_system_labeled())
return (EPERM);
int err;
if (err != 0)
return (err);
int error;
if (error)
return (error);
char *cp;
int error;
return (EINVAL);
if (error)
return (error);
if (error)
return (error);
return (error);
int error;
return (error);
return (EPERM);
return (EPERM);
return (EPERM);
char *cp;
return (ENOENT);
int error;
return (error);
int error = 0;
return (EINVAL);
if (error == 0) {
error = 0;
if (error != 0)
return (error);
int error;
return (error);
return (error);
sizeof (parentname))) != 0)
return (error);
return (error);
return (error);
return (error);
int error;
if (error)
return (error);
if (error == 0) {
if (error) {
return (error);
if (error == 0)
return (error);
int error;
return (error);
return (error);
int error;
return (EINVAL);
if (error != 0)
return (error);
return (EPERM);
int error;
char *origin;
sizeof (parentname))) != 0)
return (error);
return (error);
return (error);
return (EPERM);
int error;
return (error);
return (EINVAL);
if (err)
return (err);
return (EINVAL);
if (err)
return (err);
return (EINVAL);
int error;
if (!error)
if (!error)
if (!error)
return (error);
char *packed;
int error;
if (size == 0)
return (EINVAL);
iflag)) != 0) {
return (error);
return (error);
return (ENOMEM);
int error = 0;
return (error);
int error;
if (error)
return (error);
return (EINVAL);
if (*zfvp) {
return (error);
int error = 0;
if (error == 0) {
return (EBUSY);
return (error);
int error;
return (error);
return (error);
if (props) {
goto pool_props_bad;
if (nvl) {
if (error != 0) {
return (error);
if (error)
goto pool_props_bad;
return (error);
int error;
if (error == 0)
return (error);
int error;
return (error);
return (error);
int err;
if (props)
return (error);
int error;
if (error == 0)
return (error);
int error;
return (EEXIST);
return (error);
int error;
int ret = 0;
return (ret);
int error;
return (error);
return (EINVAL);
return (error);
int error;
return (error);
return (error);
int error;
if (error == 0) {
return (error);
int error;
return (error);
return (EINVAL);
return (error);
char *hist_buf;
int error;
return (EINVAL);
return (error);
return (ENOTSUP);
return (error);
int error;
if (error == 0) {
return (error);
int error;
return (error);
int error;
return (error);
return (EINVAL);
return (error);
int error;
return (error);
return (EINVAL);
return (error);
int error;
if (error != 0)
return (error);
return (EDOM);
if (error == 0) {
return (error);
int error;
if (error != 0)
return (error);
return (error);
int error;
return (error);
case VDEV_STATE_ONLINE:
case VDEV_STATE_OFFLINE:
case VDEV_STATE_FAULTED:
case VDEV_STATE_DEGRADED:
return (error);
int error;
return (error);
return (error);
int error;
return (error);
return (error);
int error;
return (error);
return (error);
return (error);
return (error);
int error;
if (error != 0)
return (error);
return (error);
int error;
if (error != 0)
return (error);
return (error);
int error = 0;
return (error);
return (error);
int error;
return (error);
return (error);
int error;
return (error);
return (ENOTSUP);
return (error);
int error;
return (error);
int err;
return (err);
return (err);
static boolean_t
return (B_TRUE);
return (B_TRUE);
return (B_TRUE);
return (B_FALSE);
int error;
top:
return (error);
goto top;
return (error);
int error;
top:
if (error)
return (ESRCH);
NULL);
if (error == 0) {
if (error) {
goto top;
if (error == 0)
if (error)
return (error);
unsigned int vallen;
const char *domain;
char *dash;
int err;
&pair) != 0)
return (EINVAL);
return (EINVAL);
if (err == 0) {
return (err);
* these special cases in dsl_prop.c (in the dsl layer).
int err;
&pair) == 0);
switch (prop) {
case ZFS_PROP_QUOTA:
case ZFS_PROP_REFQUOTA:
case ZFS_PROP_RESERVATION:
case ZFS_PROP_REFRESERVATION:
case ZFS_PROP_VOLSIZE:
intval);
case ZFS_PROP_VERSION:
return (err);
int rv = 0;
char *strval;
int err = 0;
&propval) != 0)
} else if (err == 0) {
const char *unused;
case PROP_TYPE_NUMBER:
case PROP_TYPE_STRING:
case PROP_TYPE_INDEX:
if (err == 0)
if (err == 0) {
if (err != 0) {
goto retry;
int err = 0;
if (err != 0) {
err);
return (rv);
int error = 0;
char *valstr;
return (EINVAL);
return (error);
return (ENAMETOOLONG);
return (E2BIG);
int err = 0;
return (err);
int error;
return (error);
if (received) {
return (error);
if (received) {
int err;
return (EINVAL);
return (EINVAL);
switch (type) {
case PROP_TYPE_STRING:
case PROP_TYPE_NUMBER:
case PROP_TYPE_INDEX:
return (EINVAL);
return (EINVAL);
int error;
return (error);
return (error);
return (error);
int error;
return (error);
int error;
return (error);
return (EINVAL);
if (error) {
if (error == 0)
return (error);
int error;
return (error);
static vfs_t *
return (vfs_found);
if (createprops) {
return (ENOTSUP);
if (norm)
if (is_ci)
char *cp;
int error;
return (error);
return (error);
return (error);
int error;
return (error);
int error = 0;
return (EINVAL);
switch (type) {
case DMU_OST_ZFS:
case DMU_OST_ZVOL:
return (EINVAL);
return (EINVAL);
return (EINVAL);
return (EINVAL);
return (EINVAL);
if (error != 0)
volblocksize)) != 0 ||
volblocksize)) != 0)
return (error);
int error;
if (error != 0) {
return (error);
if (error == 0) {
if (error != 0)
return (error);
int error = 0;
char *origin_name;
return (EINVAL);
return (EINVAL);
return (EINVAL);
if (error)
return (error);
if (error)
return (error);
if (error == 0) {
if (error != 0)
return (error);
return (error);
return (ENOTSUP);
return (EINVAL);
return (EINVAL);
return (EXDEV);
return (EXDEV);
return (error);
char *message;
int error;
char *poolname;
if (error != 0)
return (error);
return (EINVAL);
return (ENOTSUP);
return (error);
int err;
return (err);
int poollen;
return (EINVAL);
return (EXDEV);
int err;
if (err)
return (err);
return (err);
int error;
char *clone_name;
if (error)
return (error);
return (EINVAL);
return (EINVAL);
if (error)
goto out;
if (error)
goto out;
if (error == 0) {
int resume_err;
B_TRUE);
out:
if (ds)
return (error);
return (EINVAL);
if (err)
return (err);
int err;
return (err);
const char *uq_prefix =
const char *gq_prefix =
return (EINVAL);
return (err);
return (EINVAL);
if (issnap)
return (EINVAL);
&pair) == 0);
switch (prop) {
case ZFS_PROP_COMPRESSION:
return (ENOTSUP);
return (ENOTSUP);
return (ERANGE);
case ZFS_PROP_COPIES:
return (ENOTSUP);
case ZFS_PROP_DEDUP:
return (ENOTSUP);
case ZFS_PROP_SHARESMB:
return (ENOTSUP);
case ZFS_PROP_ACLINHERIT:
return (ENOTSUP);
return (rv);
static boolean_t
&p1) == 0);
&p2) == 0);
return (B_FALSE);
next:
#ifdef DEBUG
int fd;
int error = 0;
int props_error = 0;
char *tosnap;
return (EINVAL);
return (error);
return (EBADF);
if (!first_recvd_props)
&errlist) != 0)
if (error)
goto out;
if (origin)
if (error)
goto out;
if (props) {
if (error == 0) {
int end_err;
if (error == 0)
#ifdef DEBUG
if (zfs_ioc_recv_inject_err) {
} else if (first_recvd_props) {
out:
if (error == 0)
return (error);
int error;
if (error)
return (error);
if (error)
return (error);
if (error) {
return (error);
if (error) {
return (error);
if (error) {
return (error);
return (EINVAL);
if (error) {
return (error);
if (error) {
return (error);
if (estimate) {
if (dsfrom)
return (EBADF);
if (dsfrom)
return (error);
int error;
return (error);
return (error);
if (error == 0)
return (error);
int error;
return (error);
int error;
return (error);
&count);
if (error == 0)
return (error);
int error;
return (EIO);
return (EINVAL);
int err;
if (error)
return (error);
return (ENODEV);
return (error);
int error;
if (error)
return (error);
char *cp;
if (cp)
int error;
return (EINVAL);
if (error)
return (error);
return (error);
if (bufsize <= 0)
return (ENOMEM);
if (error)
return (error);
if (error == 0) {
return (error);
int error = 0;
if (error == 0)
if (error == 0)
if (error)
return (error);
return (error);
int zfs_nfsshare_inited;
int zfs_smbshare_inited;
int error;
return (ENOSYS);
return (ENOSYS);
int error;
int opcode;
case ZFS_SHARE_NFS:
case ZFS_UNSHARE_NFS:
if (zfs_nfsshare_inited == 0) {
return (ENOSYS);
((znfsexport_fs = (int (*)(void *))
return (ENOSYS);
if (error) {
return (ENOSYS);
case ZFS_SHARE_SMB:
case ZFS_UNSHARE_SMB:
if (zfs_smbshare_inited == 0) {
return (ENOSYS);
return (ENOSYS);
if (error) {
return (ENOSYS);
return (EINVAL);
case ZFS_SHARE_NFS:
case ZFS_UNSHARE_NFS:
if (error =
znfsexport_fs((void *)
return (error);
case ZFS_SHARE_SMB:
case ZFS_UNSHARE_SMB:
return (error);
return (error);
int error;
if (error)
return (error);
return (error);
char *snap_name;
int error;
return (E2BIG);
if (error != 0) {
return (error);
int error;
if (error)
return (error);
if (error) {
return (error);
return (EBADF);
return (error);
int error;
NULL, 0)) != 0)
return (error);
int error = 0;
return (error);
return (EINVAL);
if (error) {
if (error) {
return (error);
return (error);
case ZFS_SMB_ACL_ADD:
if (resourcevp)
case ZFS_SMB_ACL_REMOVE:
NULL, 0);
case ZFS_SMB_ACL_RENAME:
return (error);
&target)) {
return (error);
case ZFS_SMB_ACL_PURGE:
return (error);
int error;
return (EINVAL);
if (recursive)
return (EINVAL);
if (error)
return (error);
if (error)
return (error);
return (ENOENT);
if (error) {
return (error);
if (minor != 0) {
if (error == 0) {
minor);
return (error);
return (EINVAL);
int error;
return (error);
int error;
if (error != 0)
return (error);
if (error != 0) {
return (error);
return (error);
int error;
char *firstsnap;
return (EINVAL);
if (error != 0)
return (error);
if (error != 0) {
return (error);
return (error);
int error;
char *fromname;
int fd;
if (error != 0)
return (EINVAL);
if (error)
return (error);
if (error == 0) {
if (error) {
return (error);
return (EBADF);
return (error);
int error;
char *fromname;
if (error)
return (error);
if (error == 0) {
if (error) {
return (error);
return (error);
zfs_ioctl_init(void)
int error;
if (error == 0) {
return (error);
zfsdev_minor_alloc(void)
minor_t m;
if (m > ZFSDEV_MAX_MINOR)
last_minor = m;
if (minor == 0)
return (ENXIO);
return (EAGAIN);
return (NULL);
int error = 0;
return (error);
if (minor == 0)
if (minor != 0 &&
return (EINVAL);
if (error != 0) {
goto out;
if (error != 0)
goto out;
case POOL_NAME:
case DATASET_NAME:
case NO_NAME:
if (error != 0)
goto out;
int puterror = 0;
innvl);
outnvl);
int smusherror = 0;
if (smusherror == 0)
if (puterror != 0)
out:
if (s != NULL)
strfree(s);
return (error);
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_SUCCESS);
return (DDI_FAILURE);
return (DDI_FAILURE);
return (DDI_SUCCESS);
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
return (DDI_SUCCESS);
case DDI_INFO_DEVT2INSTANCE:
*result = (void *)0;
return (DDI_SUCCESS);
return (DDI_FAILURE);
* so most of the standard driver entry points are in zvol.c.
(void *)&zfs_modlfs,
(void *)&zfs_modldrv,
_init(void)
int error;
zfs_init();
zvol_init();
zvol_fini();
zfs_fini();
spa_fini();
return (error);
_fini(void)
int error;
return (EBUSY);
return (error);
zvol_fini();
zfs_fini();
spa_fini();
if (zfs_nfsshare_inited)
if (zfs_smbshare_inited)
return (error);