diff --git a/include/sys/nvpair.h b/include/sys/nvpair.h index 09b3a81f7c..548e5a72e4 100644 --- a/include/sys/nvpair.h +++ b/include/sys/nvpair.h @@ -310,7 +310,9 @@ _SYS_NVPAIR_H int nvpair_value_double(const nvpair_t *, double *); _SYS_NVPAIR_H nvlist_t *fnvlist_alloc(void); _SYS_NVPAIR_H void fnvlist_free(nvlist_t *); _SYS_NVPAIR_H size_t fnvlist_size(nvlist_t *); +_SYS_NVPAIR_H size_t fnvlist_size_xdr(nvlist_t *); _SYS_NVPAIR_H char *fnvlist_pack(nvlist_t *, size_t *); +_SYS_NVPAIR_H char *fnvlist_pack_xdr(nvlist_t *, size_t *); _SYS_NVPAIR_H void fnvlist_pack_free(char *, size_t); _SYS_NVPAIR_H nvlist_t *fnvlist_unpack(char *, size_t); _SYS_NVPAIR_H nvlist_t *fnvlist_dup(const nvlist_t *); diff --git a/module/nvpair/fnvpair.c b/module/nvpair/fnvpair.c index 86b0b4cdfc..301346e73d 100644 --- a/module/nvpair/fnvpair.c +++ b/module/nvpair/fnvpair.c @@ -69,6 +69,14 @@ fnvlist_size(nvlist_t *nvl) return (size); } +size_t +fnvlist_size_xdr(nvlist_t *nvl) +{ + size_t size; + VERIFY0(nvlist_size(nvl, &size, NV_ENCODE_XDR)); + return (size); +} + /* * Returns allocated buffer of size *sizep. Caller must free the buffer with * fnvlist_pack_free(). @@ -82,6 +90,15 @@ fnvlist_pack(nvlist_t *nvl, size_t *sizep) return (packed); } +char * +fnvlist_pack_xdr(nvlist_t *nvl, size_t *sizep) +{ + char *packed = 0; + VERIFY3U(nvlist_pack(nvl, &packed, sizep, NV_ENCODE_XDR, + KM_SLEEP), ==, 0); + return (packed); +} + void fnvlist_pack_free(char *pack, size_t size) {