From owner-svn-src-projects@freebsd.org Tue Aug 7 03:07:56 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 208B41071133 for ; Tue, 7 Aug 2018 03:07:56 +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 BA35078E3C; Tue, 7 Aug 2018 03:07:55 +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 95BD8160BA; Tue, 7 Aug 2018 03:07:55 +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 w7737tSW007819; Tue, 7 Aug 2018 03:07:55 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7737tU0007818; Tue, 7 Aug 2018 03:07:55 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201808070307.w7737tU0007818@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 7 Aug 2018 03:07:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r337406 - 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: 337406 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: Tue, 07 Aug 2018 03:07:56 -0000 Author: kevans Date: Tue Aug 7 03:07:54 2018 New Revision: 337406 URL: https://svnweb.freebsd.org/changeset/base/337406 Log: libbe(3): Check that dataset is to be mounted at / for be_exists This makes the be_exists behavior match the comments that assert that we've already checked that the dataset derived from the BE name is set to mount at /. Other changes of note: - bectl_list sees another change; changing mountpoint based on mount status turns out to be a bad idea, so instead make the mounted property of the returned nvlist the path that it's mounted at - Always return the "mountpoint" property in "mountpoint" if it's ste Modified: projects/bectl/lib/libbe/be_info.c projects/bectl/sbin/bectl/bectl_list.c Modified: projects/bectl/lib/libbe/be_info.c ============================================================================== --- projects/bectl/lib/libbe/be_info.c Tue Aug 7 03:01:04 2018 (r337405) +++ projects/bectl/lib/libbe/be_info.c Tue Aug 7 03:07:54 2018 (r337406) @@ -172,11 +172,14 @@ prop_list_builder_cb(zfs_handle_t *zfs_hdl, void *data nvlist_add_string(props, "name", name); mounted = zfs_is_mounted(zfs_hdl, &mountpoint); - nvlist_add_boolean_value(props, "mounted", mounted); if (mounted) - nvlist_add_string(props, "mountpoint", mountpoint); + nvlist_add_string(props, "mounted", mountpoint); + if (zfs_prop_get(zfs_hdl, ZFS_PROP_MOUNTPOINT, buf, 512, + NULL, NULL, 0, 1) == 0) + nvlist_add_string(props, "mountpoint", buf); + if (zfs_prop_get(zfs_hdl, ZFS_PROP_ORIGIN, buf, 512, NULL, NULL, 0, 1) == 0) nvlist_add_string(props, "origin", buf); @@ -282,12 +285,32 @@ bool be_exists(libbe_handle_t *lbh, char *be) { char buf[BE_MAXPATHLEN]; + nvlist_t *dsprops; + char *mntpoint; + bool valid; be_root_concat(lbh, be, buf); - /* - * XXX TODO: check mountpoint prop and see if its /, AND that result - * with below expression. - */ - return (zfs_dataset_exists(lbh->lzh, buf, ZFS_TYPE_DATASET)); + if (!zfs_dataset_exists(lbh->lzh, buf, ZFS_TYPE_DATASET)) + return (false); + + /* Also check if it's mounted at / */ + if (be_prop_list_alloc(&dsprops) != 0) { + set_error(lbh, BE_ERR_UNKNOWN); + return (false); + } + + if (be_get_dataset_props(lbh, buf, dsprops) != 0) { + nvlist_free(dsprops); + return (false); + } + + if (nvlist_lookup_string(dsprops, "mountpoint", &mntpoint) == 0) { + valid = (strcmp(mntpoint, "/") == 0); + nvlist_free(dsprops); + return (valid); + } + + nvlist_free(dsprops); + return (false); } Modified: projects/bectl/sbin/bectl/bectl_list.c ============================================================================== --- projects/bectl/sbin/bectl/bectl_list.c Tue Aug 7 03:01:04 2018 (r337405) +++ projects/bectl/sbin/bectl/bectl_list.c Tue Aug 7 03:07:54 2018 (r337406) @@ -175,7 +175,7 @@ print_info(const char *name, nvlist_t *dsprops, struct const char *oname; char *dsname, *propstr; int active_colsz; - boolean_t active_now, active_reboot, mounted; + boolean_t active_now, active_reboot; dsname = NULL; originprops = NULL; @@ -228,10 +228,7 @@ print_info(const char *name, nvlist_t *dsprops, struct active_colsz--; } print_padding(NULL, active_colsz, pc); - if (nvlist_lookup_boolean_value(dsprops, "mounted", &mounted) != 0) - mounted = false; - if (mounted && nvlist_lookup_string(dsprops, "mountpoint", - &propstr) == 0) { + if (nvlist_lookup_string(dsprops, "mounted", &propstr) == 0) { printf("%s", propstr); print_padding(propstr, pc->mount_colsz, pc); } else {