libzfs_util.c revision 88f61dee20b358671b1b643e9d1dbf220a1d69be
500c7b4af641362c362ab27d4339299ce3de7172Mike Jang * CDDL HEADER START
500c7b4af641362c362ab27d4339299ce3de7172Mike Jang * The contents of this file are subject to the terms of the
500c7b4af641362c362ab27d4339299ce3de7172Mike Jang * Common Development and Distribution License (the "License").
500c7b4af641362c362ab27d4339299ce3de7172Mike Jang * You may not use this file except in compliance with the License.
500c7b4af641362c362ab27d4339299ce3de7172Mike Jang * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
500c7b4af641362c362ab27d4339299ce3de7172Mike Jang * See the License for the specific language governing permissions
500c7b4af641362c362ab27d4339299ce3de7172Mike Jang * and limitations under the License.
500c7b4af641362c362ab27d4339299ce3de7172Mike Jang * When distributing Covered Code, include this CDDL HEADER in each
500c7b4af641362c362ab27d4339299ce3de7172Mike Jang * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
500c7b4af641362c362ab27d4339299ce3de7172Mike Jang * If applicable, add the following below this CDDL HEADER, with the
500c7b4af641362c362ab27d4339299ce3de7172Mike Jang * fields enclosed by brackets "[]" replaced with your own identifying
500c7b4af641362c362ab27d4339299ce3de7172Mike Jang * information: Portions Copyright [yyyy] [name of copyright owner]
500c7b4af641362c362ab27d4339299ce3de7172Mike Jang * CDDL HEADER END
#include <errno.h>
#include <fcntl.h>
#include <libintl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
#include <ctype.h>
#include <math.h>
#include <libzfs.h>
#include <libzfs_core.h>
#include "libzfs_impl.h"
#include "zfs_prop.h"
#include "zfeature_common.h"
case EZFS_NOMEM:
case EZFS_BADPROP:
case EZFS_PROPREADONLY:
case EZFS_PROPTYPE:
case EZFS_PROPNONINHERIT:
case EZFS_PROPSPACE:
case EZFS_BADTYPE:
case EZFS_BUSY:
case EZFS_EXISTS:
case EZFS_NOENT:
case EZFS_BADSTREAM:
case EZFS_DSREADONLY:
case EZFS_VOLTOOBIG:
case EZFS_INVALIDNAME:
case EZFS_BADRESTORE:
case EZFS_BADBACKUP:
case EZFS_BADTARGET:
case EZFS_NODEVICE:
case EZFS_BADDEV:
case EZFS_NOREPLICAS:
case EZFS_RESILVERING:
case EZFS_BADVERSION:
case EZFS_POOLUNAVAIL:
case EZFS_DEVOVERFLOW:
case EZFS_BADPATH:
case EZFS_CROSSTARGET:
case EZFS_ZONED:
case EZFS_MOUNTFAILED:
case EZFS_UMOUNTFAILED:
case EZFS_UNSHARENFSFAILED:
case EZFS_SHARENFSFAILED:
case EZFS_UNSHARESMBFAILED:
case EZFS_SHARESMBFAILED:
case EZFS_PERM:
case EZFS_NOSPC:
case EZFS_FAULT:
case EZFS_IO:
case EZFS_INTR:
case EZFS_ISSPARE:
case EZFS_INVALCONFIG:
case EZFS_RECURSIVE:
case EZFS_NOHISTORY:
case EZFS_POOLPROPS:
case EZFS_POOL_NOTSUP:
case EZFS_POOL_INVALARG:
case EZFS_NAMETOOLONG:
case EZFS_OPENFAILED:
case EZFS_NOCAP:
case EZFS_LABELFAILED:
case EZFS_BADWHO:
case EZFS_BADPERM:
case EZFS_BADPERMSET:
case EZFS_NODELEGATION:
case EZFS_BADCACHE:
case EZFS_ISL2CACHE:
case EZFS_VDEVNOTSUP:
case EZFS_NOTSUP:
case EZFS_ACTIVE_SPARE:
case EZFS_UNPLAYED_LOGS:
case EZFS_REFTAG_RELE:
case EZFS_REFTAG_HOLD:
case EZFS_TAGTOOLONG:
case EZFS_PIPEFAILED:
case EZFS_THREADCREATEFAILED:
case EZFS_POSTSPLIT_ONLINE:
case EZFS_SCRUBBING:
case EZFS_NO_SCRUB:
case EZFS_DIFF:
case EZFS_DIFFDATA:
case EZFS_POOLREADONLY:
case EZFS_UNKNOWN:
abort();
switch (error) {
case EPERM:
case EACCES:
case ECANCELED:
case EIO:
case EFAULT:
case EINTR:
switch (error) {
case ENXIO:
case ENODEV:
case EPIPE:
case ENOENT:
case ENOSPC:
case EDQUOT:
case EEXIST:
case EBUSY:
case EROFS:
case ENAMETOOLONG:
case ENOTSUP:
case EAGAIN:
switch (error) {
case ENODEV:
case ENOENT:
case EEXIST:
case EBUSY:
case ENXIO:
case ENAMETOOLONG:
case ENOTSUP:
case EINVAL:
case ENOSPC:
case EDQUOT:
case EAGAIN:
case EROFS:
void *data;
return (data);
char *ret;
int err;
if (err < 0)
return (ret);
void *ret;
return (NULL);
return (ret);
char *ret;
return (ret);
int index = 0;
index++;
if (index == 0) {
libzfs_init(void)
return (NULL);
return (NULL);
return (NULL);
if (libzfs_core_init() != 0) {
return (NULL);
return (hdl);
int ret;
return (NULL);
if (ret != 0) {
return (NULL);
path);
return (NULL);
if (len == 0)
char *packed;
char *title;
ZFS_PROP_NAME) &&
for (i = 0; i < ZFS_GET_NCOLS; i++) {
case GET_COL_NAME:
case GET_COL_PROPERTY:
case GET_COL_VALUE:
case GET_COL_RECVD:
case GET_COL_SOURCE:
title);
for (i = 0; i < ZFS_GET_NCOLS; i++) {
case GET_COL_NAME:
case GET_COL_PROPERTY:
case GET_COL_VALUE:
case GET_COL_SOURCE:
switch (sourcetype) {
case ZPROP_SRC_NONE:
case ZPROP_SRC_DEFAULT:
case ZPROP_SRC_LOCAL:
case ZPROP_SRC_TEMPORARY:
case ZPROP_SRC_INHERITED:
case ZPROP_SRC_RECEIVED:
case GET_COL_RECVD:
str);
char *end;
int shift;
*num = 0;
if (hdl)
errno = 0;
if (hdl)
if (hdl)
if (hdl)
const char *errbuf)
const char *propname;
char *value;
*ivalp = 0;
switch (proptype) {
case PROP_TYPE_STRING:
goto error;
goto error;
case PROP_TYPE_NUMBER:
goto error;
goto error;
goto error;
case PROP_TYPE_INDEX:
goto error;
goto error;
abort();
int prop;
NULL) {
type);
if (len == 0) {
static char *spaceprops[] = {
for (i = 0; spaceprops[i]; i++) {
props = p;
props++;
typedef struct expand_data {
return (ZPROP_INVAL);
return (ZPROP_CONT);
return (errno);
return (err);
return (err);
return (errno);