diff options
author | Don Brady <don.brady@delphix.com> | 2020-02-05 14:01:39 -0700 |
---|---|---|
committer | Jerry Jelinek <jerry.jelinek@joyent.com> | 2020-02-07 07:51:26 -0700 |
commit | d8ab6e129d75d7c3f21a7909bf811a3de65faea8 (patch) | |
tree | e9eef2432a5a3e513cd5d156d0aee1b241dbb529 /usr/src/lib/libzfs/common/libzfs_pool.c | |
parent | fdefee4c75361dc5ea202f7e1f7c49f8a27ea043 (diff) | |
download | illumos-gate-d8ab6e129d75d7c3f21a7909bf811a3de65faea8.tar.gz |
12235 Add libzutil for libzfs or libzpool consumers
Portions contributed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed by: C Fraire <cfraire@me.com>
Reviewed by: Jason King <jason.king@joyent.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Diffstat (limited to 'usr/src/lib/libzfs/common/libzfs_pool.c')
-rw-r--r-- | usr/src/lib/libzfs/common/libzfs_pool.c | 42 |
1 files changed, 1 insertions, 41 deletions
diff --git a/usr/src/lib/libzfs/common/libzfs_pool.c b/usr/src/lib/libzfs/common/libzfs_pool.c index 20894d450a..f1784dae9c 100644 --- a/usr/src/lib/libzfs/common/libzfs_pool.c +++ b/usr/src/lib/libzfs/common/libzfs_pool.c @@ -43,6 +43,7 @@ #include <sys/vtoc.h> #include <sys/zfs_ioctl.h> #include <dlfcn.h> +#include <libzutil.h> #include "zfs_namecheck.h" #include "zfs_prop.h" @@ -4298,47 +4299,6 @@ get_history(zpool_handle_t *zhp, char *buf, uint64_t *off, uint64_t *len) } /* - * Process the buffer of nvlists, unpacking and storing each nvlist record - * into 'records'. 'leftover' is set to the number of bytes that weren't - * processed as there wasn't a complete record. - */ -int -zpool_history_unpack(char *buf, uint64_t bytes_read, uint64_t *leftover, - nvlist_t ***records, uint_t *numrecords) -{ - uint64_t reclen; - nvlist_t *nv; - int i; - - while (bytes_read > sizeof (reclen)) { - - /* get length of packed record (stored as little endian) */ - for (i = 0, reclen = 0; i < sizeof (reclen); i++) - reclen += (uint64_t)(((uchar_t *)buf)[i]) << (8*i); - - if (bytes_read < sizeof (reclen) + reclen) - break; - - /* unpack record */ - if (nvlist_unpack(buf + sizeof (reclen), reclen, &nv, 0) != 0) - return (ENOMEM); - bytes_read -= sizeof (reclen) + reclen; - buf += sizeof (reclen) + reclen; - - /* add record to nvlist array */ - (*numrecords)++; - if (ISP2(*numrecords + 1)) { - *records = realloc(*records, - *numrecords * 2 * sizeof (nvlist_t *)); - } - (*records)[*numrecords - 1] = nv; - } - - *leftover = bytes_read; - return (0); -} - -/* * Retrieve the command history of a pool. */ int |