diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index 24ff074c4ee0..c583053dbaec 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -52,6 +52,8 @@ #include #include #include +#include +#include #include #include #include @@ -78,7 +80,6 @@ #include "zfs_iter.h" #include "zfs_util.h" #include "zfs_comutil.h" -#include "libzfs_impl.h" #include "zfs_projectutil.h" libzfs_handle_t *g_zfs; @@ -3315,7 +3316,7 @@ zfs_do_userspace(int argc, char **argv) if ((zhp = zfs_path_to_zhandle(g_zfs, argv[0], ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT)) == NULL) return (1); - if (zhp->zfs_head_type != ZFS_TYPE_FILESYSTEM) { + if (zfs_get_underlying_type(zhp) != ZFS_TYPE_FILESYSTEM) { (void) fprintf(stderr, gettext("operation is only applicable " "to filesystems and their snapshots\n")); zfs_close(zhp); diff --git a/cmd/zpool_influxdb/zpool_influxdb.c b/cmd/zpool_influxdb/zpool_influxdb.c index 71ffcb25381a..5dc39afe830f 100644 --- a/cmd/zpool_influxdb/zpool_influxdb.c +++ b/cmd/zpool_influxdb/zpool_influxdb.c @@ -71,7 +71,7 @@ #include #include #include -#include +#include #define POOL_MEASUREMENT "zpool_stats" #define SCAN_MEASUREMENT "zpool_scan_stats" @@ -101,9 +101,10 @@ typedef int (*stat_printer_f)(nvlist_t *, const char *, const char *); * caller is responsible for freeing result */ static char * -escape_string(char *s) +escape_string(const char *s) { - char *c, *d; + const char *c; + char *d; char *t = (char *)malloc(ZFS_MAX_DATASET_NAME_LEN * 2); if (t == NULL) { fprintf(stderr, "error: cannot allocate memory\n"); @@ -714,7 +715,7 @@ print_stats(zpool_handle_t *zhp, void *data) /* if not this pool return quickly */ if (data && - strncmp(data, zhp->zpool_name, ZFS_MAX_DATASET_NAME_LEN) != 0) { + strncmp(data, zpool_get_name(zhp), ZFS_MAX_DATASET_NAME_LEN) != 0) { zpool_close(zhp); return (0); } @@ -742,7 +743,7 @@ print_stats(zpool_handle_t *zhp, void *data) return (3); } - pool_name = escape_string(zhp->zpool_name); + pool_name = escape_string(zpool_get_name(zhp)); err = print_recursive_stats(print_summary_stats, nvroot, pool_name, NULL, 1); /* if any of these return an error, skip the rest */ diff --git a/cmd/zstream/zstream_redup.c b/cmd/zstream/zstream_redup.c index 15dd8a1ed126..474527e76ea7 100644 --- a/cmd/zstream/zstream_redup.c +++ b/cmd/zstream/zstream_redup.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include diff --git a/include/libzfs.h b/include/libzfs.h index eeb4daae723b..344d2146f50e 100644 --- a/include/libzfs.h +++ b/include/libzfs.h @@ -468,6 +468,7 @@ extern zfs_handle_t *zfs_open(libzfs_handle_t *, const char *, int); extern zfs_handle_t *zfs_handle_dup(zfs_handle_t *); extern void zfs_close(zfs_handle_t *); extern zfs_type_t zfs_get_type(const zfs_handle_t *); +extern zfs_type_t zfs_get_underlying_type(const zfs_handle_t *); extern const char *zfs_get_name(const zfs_handle_t *); extern zpool_handle_t *zfs_get_pool_handle(const zfs_handle_t *); extern const char *zfs_get_pool_name(const zfs_handle_t *); @@ -826,6 +827,7 @@ extern int zfs_mount(zfs_handle_t *, const char *, int); extern int zfs_mount_at(zfs_handle_t *, const char *, int, const char *); extern int zfs_unmount(zfs_handle_t *, const char *, int); extern int zfs_unmountall(zfs_handle_t *, int); +extern int zfs_mount_delegation_check(void); #if defined(__linux__) extern int zfs_parse_mount_options(char *mntopts, unsigned long *mntflags, diff --git a/include/libzfs_impl.h b/include/libzfs_impl.h index a2389daea46a..de67304085d1 100644 --- a/include/libzfs_impl.h +++ b/include/libzfs_impl.h @@ -30,7 +30,6 @@ #define _LIBZFS_IMPL_H #include -#include #include #include #include @@ -243,7 +242,6 @@ extern proto_table_t proto_table[PROTO_END]; extern int do_mount(zfs_handle_t *zhp, const char *mntpt, char *opts, int flags); extern int do_unmount(const char *mntpt, int flags); -extern int zfs_mount_delegation_check(void); extern int zfs_share_proto(zfs_handle_t *zhp, zfs_share_proto_t *proto); extern int unshare_one(libzfs_handle_t *hdl, const char *name, const char *mountpoint, zfs_share_proto_t proto); diff --git a/include/sys/fs/zfs.h b/include/sys/fs/zfs.h index 71d736d5cc97..254750642f16 100644 --- a/include/sys/fs/zfs.h +++ b/include/sys/fs/zfs.h @@ -1613,6 +1613,47 @@ typedef enum { #define ZFS_EV_HIST_DSID "history_dsid" #define ZFS_EV_RESILVER_TYPE "resilver_type" + +/* + * We currently support block sizes from 512 bytes to 16MB. + * The benefits of larger blocks, and thus larger IO, need to be weighed + * against the cost of COWing a giant block to modify one byte, and the + * large latency of reading or writing a large block. + * + * Note that although blocks up to 16MB are supported, the recordsize + * property can not be set larger than zfs_max_recordsize (default 1MB). + * See the comment near zfs_max_recordsize in dsl_dataset.c for details. + * + * Note that although the LSIZE field of the blkptr_t can store sizes up + * to 32MB, the dnode's dn_datablkszsec can only store sizes up to + * 32MB - 512 bytes. Therefore, we limit SPA_MAXBLOCKSIZE to 16MB. + */ +#define SPA_MINBLOCKSHIFT 9 +#define SPA_OLD_MAXBLOCKSHIFT 17 +#define SPA_MAXBLOCKSHIFT 24 +#define SPA_MINBLOCKSIZE (1ULL << SPA_MINBLOCKSHIFT) +#define SPA_OLD_MAXBLOCKSIZE (1ULL << SPA_OLD_MAXBLOCKSHIFT) +#define SPA_MAXBLOCKSIZE (1ULL << SPA_MAXBLOCKSHIFT) + + +/* supported encryption algorithms */ +enum zio_encrypt { + ZIO_CRYPT_INHERIT = 0, + ZIO_CRYPT_ON, + ZIO_CRYPT_OFF, + ZIO_CRYPT_AES_128_CCM, + ZIO_CRYPT_AES_192_CCM, + ZIO_CRYPT_AES_256_CCM, + ZIO_CRYPT_AES_128_GCM, + ZIO_CRYPT_AES_192_GCM, + ZIO_CRYPT_AES_256_GCM, + ZIO_CRYPT_FUNCTIONS +}; + +#define ZIO_CRYPT_ON_VALUE ZIO_CRYPT_AES_256_GCM +#define ZIO_CRYPT_DEFAULT ZIO_CRYPT_OFF + + #ifdef __cplusplus } #endif diff --git a/include/sys/spa.h b/include/sys/spa.h index c960478efe50..374d36e7327e 100644 --- a/include/sys/spa.h +++ b/include/sys/spa.h @@ -72,27 +72,6 @@ struct dsl_pool; struct dsl_dataset; struct dsl_crypto_params; -/* - * We currently support block sizes from 512 bytes to 16MB. - * The benefits of larger blocks, and thus larger IO, need to be weighed - * against the cost of COWing a giant block to modify one byte, and the - * large latency of reading or writing a large block. - * - * Note that although blocks up to 16MB are supported, the recordsize - * property can not be set larger than zfs_max_recordsize (default 1MB). - * See the comment near zfs_max_recordsize in dsl_dataset.c for details. - * - * Note that although the LSIZE field of the blkptr_t can store sizes up - * to 32MB, the dnode's dn_datablkszsec can only store sizes up to - * 32MB - 512 bytes. Therefore, we limit SPA_MAXBLOCKSIZE to 16MB. - */ -#define SPA_MINBLOCKSHIFT 9 -#define SPA_OLD_MAXBLOCKSHIFT 17 -#define SPA_MAXBLOCKSHIFT 24 -#define SPA_MINBLOCKSIZE (1ULL << SPA_MINBLOCKSHIFT) -#define SPA_OLD_MAXBLOCKSIZE (1ULL << SPA_OLD_MAXBLOCKSHIFT) -#define SPA_MAXBLOCKSIZE (1ULL << SPA_MAXBLOCKSHIFT) - /* * Alignment Shift (ashift) is an immutable, internal top-level vdev property * which can only be set at vdev creation time. Physical writes are always done diff --git a/include/sys/zio.h b/include/sys/zio.h index 3728550134ba..c792cb65b67a 100644 --- a/include/sys/zio.h +++ b/include/sys/zio.h @@ -108,23 +108,6 @@ enum zio_checksum { #define ZIO_DEDUPCHECKSUM ZIO_CHECKSUM_SHA256 -/* supported encryption algorithms */ -enum zio_encrypt { - ZIO_CRYPT_INHERIT = 0, - ZIO_CRYPT_ON, - ZIO_CRYPT_OFF, - ZIO_CRYPT_AES_128_CCM, - ZIO_CRYPT_AES_192_CCM, - ZIO_CRYPT_AES_256_CCM, - ZIO_CRYPT_AES_128_GCM, - ZIO_CRYPT_AES_192_GCM, - ZIO_CRYPT_AES_256_GCM, - ZIO_CRYPT_FUNCTIONS -}; - -#define ZIO_CRYPT_ON_VALUE ZIO_CRYPT_AES_256_GCM -#define ZIO_CRYPT_DEFAULT ZIO_CRYPT_OFF - /* macros defining encryption lengths */ #define ZIO_OBJSET_MAC_LEN 32 #define ZIO_DATA_IV_LEN 12 diff --git a/lib/libzfs/libzfs.abi b/lib/libzfs/libzfs.abi index c23ea6f7652d..74465c365361 100644 --- a/lib/libzfs/libzfs.abi +++ b/lib/libzfs/libzfs.abi @@ -153,6 +153,7 @@ + @@ -965,18 +966,18 @@ - + - + - + @@ -995,11 +996,11 @@ - + - + @@ -1013,7 +1014,7 @@ - + @@ -1024,33 +1025,33 @@ - + - + - + - + + - + - - + @@ -1095,7 +1096,7 @@ - + @@ -1167,20 +1168,20 @@ - + - + - + @@ -1188,7 +1189,7 @@ - + @@ -1198,7 +1199,7 @@ - + @@ -1699,7 +1700,7 @@ - + @@ -1723,26 +1724,26 @@ - - - - + + + + - - - - - - - - + + + + + + + + - + @@ -1840,32 +1841,32 @@ - - - - - + + + + + - - - + + + - + - - - - + + + + @@ -2022,21 +2023,21 @@ - - + + - - - - + + + + - + @@ -2049,7 +2050,7 @@ - + @@ -2513,7 +2514,7 @@ - + @@ -2710,7 +2711,7 @@ - + @@ -2731,7 +2732,7 @@ - + @@ -2834,10 +2835,10 @@ - - - - + + + + @@ -2902,7 +2903,7 @@ - + @@ -3058,7 +3059,7 @@ - + @@ -3166,36 +3167,40 @@ - - - - + + + + + + + + - - - - + + + + - - - - + + + + - - - - - + + + + + - + - + @@ -3208,7 +3213,7 @@ - + @@ -3231,14 +3236,14 @@ - - - + + + - - - + + + @@ -3263,16 +3268,16 @@ - - - - + + + + - - - - + + + + @@ -3288,13 +3293,13 @@ - - - - + + + + - + @@ -3307,8 +3312,8 @@ - - + + @@ -3317,10 +3322,10 @@ - - - - + + + + @@ -3329,20 +3334,20 @@ - - - - - + + + + + - - - - + + + + - + @@ -3356,22 +3361,22 @@ - + - + - + - + - - - - - + + + + + @@ -3380,50 +3385,50 @@ - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - - - - - + + + + + @@ -3433,9 +3438,9 @@ - - - + + + @@ -3444,11 +3449,11 @@ - - - - - + + + + + @@ -3457,25 +3462,25 @@ - - - - - + + + + + - - - - + + + + - - - - - - + + + + + + @@ -3497,26 +3502,26 @@ - - - - - - + + + + + + - - - - - - + + + + + + - - - - + + + + @@ -3525,11 +3530,11 @@ - - - - - + + + + + @@ -3548,9 +3553,9 @@ - - - + + + @@ -3560,10 +3565,10 @@ - - - - + + + + @@ -3580,9 +3585,9 @@ - - - + + + @@ -3604,11 +3609,11 @@ - - - - - + + + + + @@ -3652,7 +3657,7 @@ - + @@ -3715,7 +3720,7 @@ - + @@ -3924,7 +3929,7 @@ - + @@ -3943,7 +3948,7 @@ - + @@ -4027,20 +4032,20 @@ - + - + - + @@ -4173,21 +4178,21 @@ - + - - - - + + + + - - - - + + + + @@ -4199,12 +4204,12 @@ - - - + + + - + @@ -4222,17 +4227,17 @@ - - + + - - - + + + - - + + @@ -4242,22 +4247,22 @@ - - - - + + + + - - - - - + + + + + - - - + + + @@ -4267,12 +4272,12 @@ - - + + - - + + @@ -4280,23 +4285,23 @@ - - + + - - - + + + - - - + + + - - - + + + @@ -4304,76 +4309,76 @@ - - + + - - + + - - + + - - + + - - - + + + - - - + + + - - + + - - + + - - - + + + - - - - + + + + - - + + - + - + - + - + - + - - - + + + @@ -4383,13 +4388,13 @@ - - - - - - - + + + + + + + @@ -4424,15 +4429,15 @@ - - - - + + + + - - - + + + @@ -4441,7 +4446,7 @@ - + @@ -4449,12 +4454,12 @@ - - - - - - + + + + + + @@ -4472,7 +4477,7 @@ - + @@ -4577,8 +4582,8 @@ - - + + @@ -4600,18 +4605,18 @@ - - + + - + - - - - + + + + @@ -4681,39 +4686,39 @@ - - - + + + - - + + - - - - + + + + - - - - - + + + + + - - - - + + + + @@ -4728,27 +4733,27 @@ - - - - + + + + - - - + + + - - + + - - - - - - + + + + + + @@ -4758,36 +4763,36 @@ - - - + + + - - + + - - + + - - - + + + - - - - + + + + @@ -4797,31 +4802,31 @@ - - - + + + - - - - - + + + + + - - - - - + + + + + - - - - - - + + + + + + @@ -4844,8 +4849,8 @@ - - + + @@ -4853,11 +4858,11 @@ - - - - - + + + + + @@ -4868,10 +4873,10 @@ - - - - + + + + @@ -4904,10 +4909,10 @@ - - - - + + + + @@ -4934,11 +4939,11 @@ - - - - - + + + + + @@ -4956,12 +4961,12 @@ - - - - - - + + + + + + @@ -4979,18 +4984,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + @@ -4999,23 +5004,23 @@ - - - - + + + + - - - + + + - - - - - + + + + + @@ -5024,37 +5029,37 @@ - + - - - - + + + + - - - - + + + + - - - - + + + + - - - - - - - + + + + + + + @@ -5075,9 +5080,9 @@ - - - + + + @@ -5092,12 +5097,12 @@ - - - - - - + + + + + + @@ -5107,39 +5112,39 @@ - - - + + + - - + + - - - - + + + + - - - - + + + + - - - + + + - - + + - - - + + + @@ -5151,9 +5156,9 @@ - - - + + + @@ -5168,33 +5173,33 @@ - - - + + + - - - + + + - - - - - + + + + + - - - + + + - - - - - + + + + + @@ -5205,45 +5210,45 @@ - - - - - - + + + + + + - - - + + + - - - - + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - + + + @@ -5252,18 +5257,18 @@ - - - - - + + + + + - - - + + + @@ -5273,9 +5278,9 @@ - - - + + + @@ -5308,69 +5313,69 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -5456,20 +5461,16 @@ - + - + - - - - @@ -5482,6 +5483,10 @@ + + + + @@ -5527,60 +5532,60 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - + + + + + + + - + @@ -5605,7 +5610,7 @@ - + @@ -5613,7 +5618,7 @@ - + @@ -6131,7 +6136,7 @@ - + @@ -6158,7 +6163,7 @@ - + @@ -6303,6 +6308,9 @@ + + + @@ -6316,23 +6324,23 @@ - + - + - + - + @@ -6372,7 +6380,7 @@ - + @@ -6655,33 +6663,33 @@ - + - + - + - + - + - + - + - + - + - + @@ -6690,7 +6698,7 @@ - + @@ -6701,7 +6709,7 @@ - + @@ -6795,7 +6803,7 @@ - + @@ -7903,19 +7911,19 @@ - + - - + + - + - + diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 823fcb284d2e..99e352dd4883 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -1261,9 +1261,9 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl, intval > maxbs || !ISP2(intval))) { zfs_nicebytes(maxbs, buf, sizeof (buf)); zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "invalid '%s=%d' property: must be zero or " - "a power of 2 from 512B to %s"), propname, - intval, buf); + "invalid '%s=%llu' property: must be zero " + "or a power of 2 from 512B to %s"), + propname, (unsigned long long)intval, buf); (void) zfs_error(hdl, EZFS_BADPROP, errbuf); goto error; } @@ -3333,6 +3333,16 @@ zfs_get_type(const zfs_handle_t *zhp) return (zhp->zfs_type); } +/* + * Returns the type of the given zfs handle, + * or, if a snapshot, the type of the snapshotted dataset. + */ +zfs_type_t +zfs_get_underlying_type(const zfs_handle_t *zhp) +{ + return (zhp->zfs_head_type); +} + /* * Is one dataset name a child dataset of another? * @@ -4835,8 +4845,6 @@ zfs_userspace(zfs_handle_t *zhp, zfs_userquota_prop_t type, zc.zc_nvlist_dst_size = sizeof (buf); if (zfs_ioctl(hdl, ZFS_IOC_USERSPACE_MANY, &zc) != 0) { - char errbuf[1024]; - if ((errno == ENOTSUP && (type == ZFS_PROP_USEROBJUSED || type == ZFS_PROP_GROUPOBJUSED || @@ -4848,10 +4856,9 @@ zfs_userspace(zfs_handle_t *zhp, zfs_userquota_prop_t type, type == ZFS_PROP_PROJECTQUOTA))) break; - (void) snprintf(errbuf, sizeof (errbuf), + return (zfs_standard_error_fmt(hdl, errno, dgettext(TEXT_DOMAIN, - "cannot get used/quota for %s"), zc.zc_name); - return (zfs_standard_error_fmt(hdl, errno, errbuf)); + "cannot get used/quota for %s"), zc.zc_name)); } if (zc.zc_nvlist_dst_size == 0) break; @@ -5080,7 +5087,7 @@ zfs_release(zfs_handle_t *zhp, const char *snapname, const char *tag, (void) zfs_error(hdl, EZFS_BADVERSION, errbuf); break; default: - (void) zfs_standard_error_fmt(hdl, errno, errbuf); + (void) zfs_standard_error(hdl, errno, errbuf); } } @@ -5099,7 +5106,7 @@ zfs_release(zfs_handle_t *zhp, const char *snapname, const char *tag, (void) zfs_error(hdl, EZFS_BADTYPE, errbuf); break; default: - (void) zfs_standard_error_fmt(hdl, + (void) zfs_standard_error(hdl, fnvpair_value_int32(elem), errbuf); } } @@ -5156,17 +5163,16 @@ zfs_get_fsacl(zfs_handle_t *zhp, nvlist_t **nvl) err = zfs_error(hdl, EZFS_NOENT, errbuf); break; default: - err = zfs_standard_error_fmt(hdl, errno, errbuf); + err = zfs_standard_error(hdl, errno, errbuf); break; } } else { /* success */ int rc = nvlist_unpack(nvbuf, zc.zc_nvlist_dst_size, nvl, 0); if (rc) { - (void) snprintf(errbuf, sizeof (errbuf), dgettext( + err = zfs_standard_error_fmt(hdl, rc, dgettext( TEXT_DOMAIN, "cannot get permissions on '%s'"), zc.zc_name); - err = zfs_standard_error_fmt(hdl, rc, errbuf); } } @@ -5219,7 +5225,7 @@ zfs_set_fsacl(zfs_handle_t *zhp, boolean_t un, nvlist_t *nvl) err = zfs_error(hdl, EZFS_NOENT, errbuf); break; default: - err = zfs_standard_error_fmt(hdl, errno, errbuf); + err = zfs_standard_error(hdl, errno, errbuf); break; } } @@ -5256,7 +5262,7 @@ zfs_get_holds(zfs_handle_t *zhp, nvlist_t **nvl) err = zfs_error(hdl, EZFS_NOENT, errbuf); break; default: - err = zfs_standard_error_fmt(hdl, errno, errbuf); + err = zfs_standard_error(hdl, errno, errbuf); break; } } diff --git a/lib/libzfs/libzfs_diff.c b/lib/libzfs/libzfs_diff.c index 12e079b0eeb7..3dbe1b8eee8e 100644 --- a/lib/libzfs/libzfs_diff.c +++ b/lib/libzfs/libzfs_diff.c @@ -732,7 +732,7 @@ zfs_show_diffs(zfs_handle_t *zhp, int outfd, const char *fromsnap, } if (pipe2(pipefd, O_CLOEXEC)) { - zfs_error_aux(zhp->zfs_hdl, strerror(errno)); + zfs_error_aux(zhp->zfs_hdl, "%s", strerror(errno)); teardown_differ_info(&di); return (zfs_error(zhp->zfs_hdl, EZFS_PIPEFAILED, errbuf)); } @@ -745,7 +745,7 @@ zfs_show_diffs(zfs_handle_t *zhp, int outfd, const char *fromsnap, di.datafd = pipefd[0]; if (pthread_create(&tid, NULL, differ, &di)) { - zfs_error_aux(zhp->zfs_hdl, strerror(errno)); + zfs_error_aux(zhp->zfs_hdl, "%s", strerror(errno)); (void) close(pipefd[0]); (void) close(pipefd[1]); teardown_differ_info(&di); @@ -771,14 +771,14 @@ zfs_show_diffs(zfs_handle_t *zhp, int outfd, const char *fromsnap, zfs_error_aux(zhp->zfs_hdl, dgettext(TEXT_DOMAIN, "\n Not an earlier snapshot from the same fs")); } else if (errno != EPIPE || di.zerr == 0) { - zfs_error_aux(zhp->zfs_hdl, strerror(errno)); + zfs_error_aux(zhp->zfs_hdl, "%s", strerror(errno)); } (void) close(pipefd[1]); (void) pthread_cancel(tid); (void) pthread_join(tid, NULL); teardown_differ_info(&di); if (di.zerr != 0 && di.zerr != EPIPE) { - zfs_error_aux(zhp->zfs_hdl, strerror(di.zerr)); + zfs_error_aux(zhp->zfs_hdl, "%s", strerror(di.zerr)); return (zfs_error(zhp->zfs_hdl, EZFS_DIFF, di.errbuf)); } else { return (zfs_error(zhp->zfs_hdl, EZFS_DIFFDATA, errbuf)); @@ -789,7 +789,7 @@ zfs_show_diffs(zfs_handle_t *zhp, int outfd, const char *fromsnap, (void) pthread_join(tid, NULL); if (di.zerr != 0) { - zfs_error_aux(zhp->zfs_hdl, strerror(di.zerr)); + zfs_error_aux(zhp->zfs_hdl, "%s", strerror(di.zerr)); return (zfs_error(zhp->zfs_hdl, EZFS_DIFF, di.errbuf)); } teardown_differ_info(&di); diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index 3df42e2dc3e1..528ae4946c88 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -538,19 +538,17 @@ zfs_mount_at(zfs_handle_t *zhp, const char *options, int flags, zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "Insufficient privileges")); } else if (rc == ENOTSUP) { - char buf[256]; int spa_version; VERIFY(zfs_spa_version(zhp, &spa_version) == 0); - (void) snprintf(buf, sizeof (buf), - dgettext(TEXT_DOMAIN, "Can't mount a version %lld " + zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, + "Can't mount a version %llu " "file system on a version %d pool. Pool must be" " upgraded to mount this file system."), (u_longlong_t)zfs_prop_get_int(zhp, ZFS_PROP_VERSION), spa_version); - zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, buf)); } else { - zfs_error_aux(hdl, strerror(rc)); + zfs_error_aux(hdl, "%s", strerror(rc)); } return (zfs_error_fmt(hdl, EZFS_MOUNTFAILED, dgettext(TEXT_DOMAIN, "cannot mount '%s'"), diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index d4849ee5bd9b..67133c360b72 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -563,8 +563,8 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname, if (intval < version || !SPA_VERSION_IS_SUPPORTED(intval)) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "property '%s' number %d is invalid."), - propname, intval); + "property '%s' number %llu is invalid."), + propname, (unsigned long long)intval); (void) zfs_error(hdl, EZFS_BADVERSION, errbuf); goto error; } @@ -574,10 +574,11 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname, if (intval != 0 && (intval < ASHIFT_MIN || intval > ASHIFT_MAX)) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "property '%s' number %d is invalid, only " - "values between %" PRId32 " and " - "%" PRId32 " are allowed."), - propname, intval, ASHIFT_MIN, ASHIFT_MAX); + "property '%s' number %llu is invalid, " + "only values between %" PRId32 " and %" + PRId32 " are allowed."), + propname, (unsigned long long)intval, + ASHIFT_MIN, ASHIFT_MAX); (void) zfs_error(hdl, EZFS_BADPROP, errbuf); goto error; } @@ -685,7 +686,7 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname, case ZPOOL_COMPATIBILITY_BADFILE: case ZPOOL_COMPATIBILITY_BADTOKEN: case ZPOOL_COMPATIBILITY_NOFILES: - zfs_error_aux(hdl, report); + zfs_error_aux(hdl, "%s", report); (void) zfs_error(hdl, EZFS_BADPROP, errbuf); goto error; } @@ -1648,10 +1649,6 @@ zpool_export_common(zpool_handle_t *zhp, boolean_t force, boolean_t hardforce, const char *log_str) { zfs_cmd_t zc = {"\0"}; - char msg[1024]; - - (void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN, - "cannot export '%s'"), zhp->zpool_name); (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name)); zc.zc_cookie = force; @@ -1666,11 +1663,13 @@ zpool_export_common(zpool_handle_t *zhp, boolean_t force, boolean_t hardforce, "'%s' has an active shared spare which could be" " used by other pools once '%s' is exported."), zhp->zpool_name, zhp->zpool_name); - return (zfs_error(zhp->zpool_hdl, EZFS_ACTIVE_SPARE, - msg)); + return (zfs_error_fmt(zhp->zpool_hdl, EZFS_ACTIVE_SPARE, + dgettext(TEXT_DOMAIN, "cannot export '%s'"), + zhp->zpool_name)); default: return (zpool_standard_error_fmt(zhp->zpool_hdl, errno, - msg)); + dgettext(TEXT_DOMAIN, "cannot export '%s'"), + zhp->zpool_name)); } } @@ -2080,7 +2079,7 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname, "the zgenhostid(8) command.\n")); } - (void) zfs_error_aux(hdl, aux); + (void) zfs_error_aux(hdl, "%s", aux); } (void) zfs_error(hdl, EZFS_ACTIVE_POOL, desc); break; @@ -4520,13 +4519,10 @@ int zpool_events_clear(libzfs_handle_t *hdl, int *count) { zfs_cmd_t zc = {"\0"}; - char msg[1024]; - - (void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN, - "cannot clear events")); if (zfs_ioctl(hdl, ZFS_IOC_EVENTS_CLEAR, &zc) != 0) - return (zpool_standard_error_fmt(hdl, errno, msg)); + return (zpool_standard_error(hdl, errno, + dgettext(TEXT_DOMAIN, "cannot clear events"))); if (count != NULL) *count = (int)zc.zc_cookie; /* # of events cleared */ diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index 511895d18658..8b732bb222a4 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -768,7 +768,7 @@ zfs_send_space(zfs_handle_t *zhp, const char *snapname, const char *from, case EFAULT: case EROFS: case EINVAL: - zfs_error_aux(hdl, strerror(error)); + zfs_error_aux(hdl, "%s", strerror(error)); return (zfs_error(hdl, EZFS_BADBACKUP, errbuf)); default: @@ -849,7 +849,7 @@ dump_ioctl(zfs_handle_t *zhp, const char *fromsnap, uint64_t fromsnap_obj, case ERANGE: case EFAULT: case EROFS: - zfs_error_aux(hdl, strerror(errno)); + zfs_error_aux(hdl, "%s", strerror(errno)); return (zfs_error(hdl, EZFS_BADBACKUP, errbuf)); default: @@ -1479,7 +1479,7 @@ estimate_size(zfs_handle_t *zhp, const char *from, int fd, sendflags_t *flags, err = pthread_create(&ptid, NULL, send_progress_thread, &pa); if (err != 0) { - zfs_error_aux(zhp->zfs_hdl, strerror(errno)); + zfs_error_aux(zhp->zfs_hdl, "%s", strerror(errno)); return (zfs_error(zhp->zfs_hdl, EZFS_THREADCREATEFAILED, errbuf)); } @@ -1505,7 +1505,7 @@ estimate_size(zfs_handle_t *zhp, const char *from, int fd, sendflags_t *flags, } if (err != 0) { - zfs_error_aux(zhp->zfs_hdl, strerror(err)); + zfs_error_aux(zhp->zfs_hdl, "%s", strerror(err)); return (zfs_error(zhp->zfs_hdl, EZFS_BADBACKUP, errbuf)); } @@ -1822,7 +1822,7 @@ zfs_send_resume_impl(libzfs_handle_t *hdl, sendflags_t *flags, int outfd, case ERANGE: case EFAULT: case EROFS: - zfs_error_aux(hdl, strerror(errno)); + zfs_error_aux(hdl, "%s", strerror(errno)); return (zfs_error(hdl, EZFS_BADBACKUP, errbuf)); default: @@ -2082,13 +2082,13 @@ send_prelim_records(zfs_handle_t *zhp, const char *from, int fd, err = dump_record(&drr, packbuf, buflen, &zc, fd); free(packbuf); if (err != 0) { - zfs_error_aux(zhp->zfs_hdl, strerror(err)); + zfs_error_aux(zhp->zfs_hdl, "%s", strerror(err)); return (zfs_error(zhp->zfs_hdl, EZFS_BADBACKUP, errbuf)); } err = send_conclusion_record(fd, &zc); if (err != 0) { - zfs_error_aux(zhp->zfs_hdl, strerror(err)); + zfs_error_aux(zhp->zfs_hdl, "%s", strerror(err)); return (zfs_error(zhp->zfs_hdl, EZFS_BADBACKUP, errbuf)); } @@ -2507,7 +2507,7 @@ zfs_send_one(zfs_handle_t *zhp, const char *from, int fd, sendflags_t *flags, err = pthread_create(&ptid, NULL, send_progress_thread, &pa); if (err != 0) { - zfs_error_aux(zhp->zfs_hdl, strerror(errno)); + zfs_error_aux(zhp->zfs_hdl, "%s", strerror(errno)); return (zfs_error(zhp->zfs_hdl, EZFS_THREADCREATEFAILED, errbuf)); } @@ -2522,13 +2522,10 @@ zfs_send_one(zfs_handle_t *zhp, const char *from, int fd, sendflags_t *flags, (void) pthread_cancel(ptid); (void) pthread_join(ptid, &status); int error = (int)(uintptr_t)status; - if (error != 0 && status != PTHREAD_CANCELED) { - char errbuf[1024]; - (void) snprintf(errbuf, sizeof (errbuf), - dgettext(TEXT_DOMAIN, "progress thread exited " - "nonzero")); - return (zfs_standard_error(hdl, error, errbuf)); - } + if (error != 0 && status != PTHREAD_CANCELED) + return (zfs_standard_error_fmt(hdl, error, + dgettext(TEXT_DOMAIN, + "progress thread exited nonzero"))); } if (flags->props || flags->holds || flags->backup) { @@ -2576,7 +2573,7 @@ zfs_send_one(zfs_handle_t *zhp, const char *from, int fd, sendflags_t *flags, case EPIPE: case ERANGE: case EROFS: - zfs_error_aux(hdl, strerror(errno)); + zfs_error_aux(hdl, "%s", strerror(errno)); return (zfs_error(hdl, EZFS_BADBACKUP, errbuf)); default: @@ -5078,8 +5075,8 @@ zfs_receive_impl(libzfs_handle_t *hdl, const char *tosnap, if (!DMU_STREAM_SUPPORTED(featureflags) || (hdrtype != DMU_SUBSTREAM && hdrtype != DMU_COMPOUNDSTREAM)) { zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, - "stream has unsupported feature, feature flags = %lx"), - featureflags); + "stream has unsupported feature, feature flags = %llx"), + (unsigned long long)featureflags); return (zfs_error(hdl, EZFS_BADSTREAM, errbuf)); } diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index 6abf21ac3023..68e97e4830d8 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -486,7 +486,7 @@ zfs_standard_error_fmt(libzfs_handle_t *hdl, int error, const char *fmt, ...) zfs_verror(hdl, EZFS_BADPROP, fmt, ap); break; default: - zfs_error_aux(hdl, strerror(error)); + zfs_error_aux(hdl, "%s", strerror(error)); zfs_verror(hdl, EZFS_UNKNOWN, fmt, ap); break; } @@ -737,7 +737,7 @@ zpool_standard_error_fmt(libzfs_handle_t *hdl, int error, const char *fmt, ...) zfs_verror(hdl, EZFS_IOC_NOTSUPPORTED, fmt, ap); break; default: - zfs_error_aux(hdl, strerror(error)); + zfs_error_aux(hdl, "%s", strerror(error)); zfs_verror(hdl, EZFS_UNKNOWN, fmt, ap); }