From owner-svn-src-projects@freebsd.org Wed Jul 25 14:30:49 2018 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 64076104C95B for ; Wed, 25 Jul 2018 14:30:49 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 178A380774; Wed, 25 Jul 2018 14:30:49 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EE8C91B617; Wed, 25 Jul 2018 14:30:48 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6PEUmEJ012400; Wed, 25 Jul 2018 14:30:48 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6PEUm6e012394; Wed, 25 Jul 2018 14:30:48 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807251430.w6PEUm6e012394@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 25 Jul 2018 14:30:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336708 - in projects/bectl: lib/libbe sbin/bectl X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in projects/bectl: lib/libbe sbin/bectl X-SVN-Commit-Revision: 336708 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Jul 2018 14:30:49 -0000 Author: kevans Date: Wed Jul 25 14:30:47 2018 New Revision: 336708 URL: https://svnweb.freebsd.org/changeset/base/336708 Log: bectl(8): Start dumping out BE information with `bectl list` For the moment, this is a primitive nvlist dump of what we get back from be_get_bootenv_props as a proof-of-concept and to make sure that we're getting back the kind of information we want to see from list. Modified: projects/bectl/lib/libbe/be.h projects/bectl/lib/libbe/be_info.c projects/bectl/sbin/bectl/Makefile projects/bectl/sbin/bectl/bectl.c Modified: projects/bectl/lib/libbe/be.h ============================================================================== --- projects/bectl/lib/libbe/be.h Wed Jul 25 14:05:17 2018 (r336707) +++ projects/bectl/lib/libbe/be.h Wed Jul 25 14:30:47 2018 (r336708) @@ -29,6 +29,7 @@ #ifndef _LIBBE_H #define _LIBBE_H +#include #include #define BE_MAXPATHLEN 512 @@ -63,7 +64,7 @@ const char *be_active_name(libbe_handle_t *); const char *be_active_path(libbe_handle_t *); const char *be_root_path(libbe_handle_t *); -/* nvlist_t *be_get_bootenv_props(libbe_handle_t *); */ +int be_get_bootenv_props(libbe_handle_t *, nvlist_t *); int be_activate(libbe_handle_t *, char *, bool); Modified: projects/bectl/lib/libbe/be_info.c ============================================================================== --- projects/bectl/lib/libbe/be_info.c Wed Jul 25 14:05:17 2018 (r336707) +++ projects/bectl/lib/libbe/be_info.c Wed Jul 25 14:30:47 2018 (r336708) @@ -71,18 +71,17 @@ be_root_path(libbe_handle_t *lbh) /* - * Returns an nvlist of the bootenv's properties - * TODO: the nvlist should be passed as a param and ints should return status + * Populates dsnvl with one nvlist per bootenv dataset describing the properties + * of that dataset that we've declared ourselves to care about. */ -nvlist_t * -be_get_bootenv_props(libbe_handle_t *lbh) +int +be_get_bootenv_props(libbe_handle_t *lbh, nvlist_t *dsnvl) { prop_data_t data; data.lbh = lbh; - prop_list_builder(&data); - - return (data.list); + data.list = dsnvl; + return (prop_list_builder(&data)); } @@ -176,10 +175,6 @@ static int prop_list_builder(prop_data_t *data) { zfs_handle_t *root_hdl; - - if (nvlist_alloc(&(data->list), NV_UNIQUE_NAME, KM_SLEEP) != 0) - /* XXX TODO: actually handle error */ - return (1); if ((root_hdl = zfs_open(data->lbh->lzh, data->lbh->root, ZFS_TYPE_FILESYSTEM)) == NULL) Modified: projects/bectl/sbin/bectl/Makefile ============================================================================== --- projects/bectl/sbin/bectl/Makefile Wed Jul 25 14:05:17 2018 (r336707) +++ projects/bectl/sbin/bectl/Makefile Wed Jul 25 14:30:47 2018 (r336708) @@ -7,4 +7,10 @@ MAN= bectl.8 LIBADD+= be LIBADD+= nvpair +CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs/common +CFLAGS+= -I${SRCTOP}/sys/cddl/compat/opensolaris +CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common + +CFLAGS+= -DNEED_SOLARIS_BOOLEAN + .include Modified: projects/bectl/sbin/bectl/bectl.c ============================================================================== --- projects/bectl/sbin/bectl/bectl.c Wed Jul 25 14:05:17 2018 (r336707) +++ projects/bectl/sbin/bectl/bectl.c Wed Jul 25 14:30:47 2018 (r336708) @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -38,7 +39,6 @@ #include #include -#include #include static int bectl_cmd_activate(int argc, char *argv[]); @@ -417,8 +417,8 @@ bectl_cmd_jail(int argc, char *argv[]) static int bectl_cmd_list(int argc, char *argv[]) { - char *bootenv; nvlist_t *props; + char *bootenv; int opt; bool show_all_datasets, show_space, hide_headers, show_snaps; @@ -451,7 +451,20 @@ bectl_cmd_list(int argc, char *argv[]) return (usage(false)); } - /* props = be_get_bootenv_props(be); */ + + if (nvlist_alloc(&props, NV_UNIQUE_NAME, M_WAITOK) != 0) { + fprintf(stderr, "bectl list: failed to allocate prop nvlist\n"); + return (1); + } + if (be_get_bootenv_props(be, props) != 0) { + /* XXX TODO: Real errors */ + fprintf(stderr, "bectl list: failed to fetch boot environments\n"); + return (1); + } + + dump_nvlist(props, 0); + nvlist_free(props); + return (0); }