From owner-svn-src-projects@freebsd.org Wed Jul 25 14:45:02 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 4EEDA104CD94 for ; Wed, 25 Jul 2018 14:45:02 +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 03681810D1; Wed, 25 Jul 2018 14:45:02 +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 D4A9E1B928; Wed, 25 Jul 2018 14:45:01 +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 w6PEj19p022026; Wed, 25 Jul 2018 14:45:01 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6PEj1Md022024; Wed, 25 Jul 2018 14:45:01 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807251445.w6PEj1Md022024@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:45:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336709 - projects/bectl/lib/libbe X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: projects/bectl/lib/libbe X-SVN-Commit-Revision: 336709 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:45:02 -0000 Author: kevans Date: Wed Jul 25 14:45:00 2018 New Revision: 336709 URL: https://svnweb.freebsd.org/changeset/base/336709 Log: libbe(3): Add nextboot flag to returned BE information Modified: projects/bectl/lib/libbe/be.c projects/bectl/lib/libbe/be.h projects/bectl/lib/libbe/be_info.c Modified: projects/bectl/lib/libbe/be.c ============================================================================== --- projects/bectl/lib/libbe/be.c Wed Jul 25 14:30:47 2018 (r336708) +++ projects/bectl/lib/libbe/be.c Wed Jul 25 14:45:00 2018 (r336709) @@ -138,6 +138,9 @@ libbe_init(void) zfs_iter_filesystems(rootds, be_locate_rootfs, lbh); zfs_close(rootds); + rootds = NULL; + if (lbh->rootfs == NULL) + goto err; return (lbh); err: Modified: projects/bectl/lib/libbe/be.h ============================================================================== --- projects/bectl/lib/libbe/be.h Wed Jul 25 14:30:47 2018 (r336708) +++ projects/bectl/lib/libbe/be.h Wed Jul 25 14:45:00 2018 (r336709) @@ -62,6 +62,8 @@ void libbe_close(libbe_handle_t *); /* Bootenv information functions: be_info.c */ const char *be_active_name(libbe_handle_t *); const char *be_active_path(libbe_handle_t *); +const char *be_nextboot_name(libbe_handle_t *); +const char *be_nextboot_path(libbe_handle_t *); const char *be_root_path(libbe_handle_t *); int be_get_bootenv_props(libbe_handle_t *, nvlist_t *); Modified: projects/bectl/lib/libbe/be_info.c ============================================================================== --- projects/bectl/lib/libbe/be_info.c Wed Jul 25 14:30:47 2018 (r336708) +++ projects/bectl/lib/libbe/be_info.c Wed Jul 25 14:45:00 2018 (r336709) @@ -58,8 +58,29 @@ be_active_path(libbe_handle_t *lbh) return (lbh->rootfs); } +/* + * Returns the name of the next active boot environment + */ +const char * +be_nextboot_name(libbe_handle_t *lbh) +{ + return (strrchr(lbh->bootfs, '/') + sizeof(char)); +} + + /* + * Returns full path of the active boot environment + */ +const char * +be_nextboot_path(libbe_handle_t *lbh) +{ + + return (lbh->bootfs); +} + + +/* * Returns the path of the boot environment root dataset */ const char * @@ -157,7 +178,8 @@ prop_list_builder_cb(zfs_handle_t *zfs_hdl, void *data NULL, NULL, 0, 1)) nvlist_add_string(props, "referenced", buf); - /* XXX TODO: Add bootfs info */ + nvlist_add_boolean_value(props, "nextboot", + (strcmp(be_nextboot_path(lbh), dataset) == 0)); nvlist_add_nvlist(data->list, name, props);