From owner-svn-src-projects@freebsd.org Tue Jul 24 12:55:55 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 95FB0104B345 for ; Tue, 24 Jul 2018 12:55:55 +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 3BBE18E006; Tue, 24 Jul 2018 12:55: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 171923D58; Tue, 24 Jul 2018 12:55: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 w6OCtsuB018383; Tue, 24 Jul 2018 12:55:54 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6OCtsSu018382; Tue, 24 Jul 2018 12:55:54 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807241255.w6OCtsSu018382@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 24 Jul 2018 12:55:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336666 - projects/bectl X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: projects/bectl X-SVN-Commit-Revision: 336666 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, 24 Jul 2018 12:55:55 -0000 Author: kevans Date: Tue Jul 24 12:55:54 2018 New Revision: 336666 URL: https://svnweb.freebsd.org/changeset/base/336666 Log: Create a project branch for bectl(8) This will contain an import of libbe/be(1) by Kyle Kneitinger from GSoC '17, and further work will happen here until it's deemed ready for import to head. Discussed with: allanjude Added: - copied from r336665, head/ Directory Properties: projects/bectl/ (props changed) From owner-svn-src-projects@freebsd.org Tue Jul 24 13:17:41 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 504DF104B960 for ; Tue, 24 Jul 2018 13:17:41 +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 E5A658EB49; Tue, 24 Jul 2018 13:17:40 +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 C059F40D8; Tue, 24 Jul 2018 13:17:40 +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 w6ODHeum029908; Tue, 24 Jul 2018 13:17:40 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6ODHe3X029905; Tue, 24 Jul 2018 13:17:40 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807241317.w6ODHe3X029905@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 24 Jul 2018 13:17:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336668 - in projects/bectl: lib/libbe sbin sbin/be share/mk X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in projects/bectl: lib/libbe sbin sbin/be share/mk X-SVN-Commit-Revision: 336668 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, 24 Jul 2018 13:17:41 -0000 Author: kevans Date: Tue Jul 24 13:17:40 2018 New Revision: 336668 URL: https://svnweb.freebsd.org/changeset/base/336668 Log: Import libbe(3)/be(1) from socsvn/soc2017/kneitinger/libbe-head Added: projects/bectl/lib/libbe/ projects/bectl/lib/libbe/Makefile (contents, props changed) projects/bectl/lib/libbe/be.c (contents, props changed) projects/bectl/lib/libbe/be.h (contents, props changed) projects/bectl/lib/libbe/be_access.c (contents, props changed) projects/bectl/lib/libbe/be_error.c (contents, props changed) projects/bectl/lib/libbe/be_impl.h (contents, props changed) projects/bectl/lib/libbe/be_info.c (contents, props changed) projects/bectl/lib/libbe/libbe.3 (contents, props changed) projects/bectl/sbin/be/ projects/bectl/sbin/be/Makefile (contents, props changed) projects/bectl/sbin/be/be.1 (contents, props changed) projects/bectl/sbin/be/be.c (contents, props changed) Modified: projects/bectl/sbin/Makefile projects/bectl/share/mk/src.libnames.mk Added: projects/bectl/lib/libbe/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/bectl/lib/libbe/Makefile Tue Jul 24 13:17:40 2018 (r336668) @@ -0,0 +1,53 @@ +# $FreeBSD$ +# +# Copyright (c) 2010 Hans Petter Selasky. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# + +PACKAGE= lib${LIB} +LIB= be +SHLIB_MAJOR= 1 +SHLIB_MINOR= 0 +SRCS= be.c be_access.c be_error.c be_info.c +INCS= be.h +MAN= libbe.3 + +WARNS?= 1 + +LIBADD+= zfs +LIBADD+= nvpair + +CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs/common +CFLAGS+= -I${SRCTOP}/sys/cddl/compat/opensolaris +CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include +CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/lib/libumem +CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzpool/common +CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/zfs +CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/fs/zfs +CFLAGS+= -I${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common +CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/head +LDFLAGS+= -v + +CFLAGS+= -DNEED_SOLARIS_BOOLEAN + +.include Added: projects/bectl/lib/libbe/be.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/bectl/lib/libbe/be.c Tue Jul 24 13:17:40 2018 (r336668) @@ -0,0 +1,876 @@ +/* + * be.c + * + * Copyright (c) 2017 Kyle J. Kneitinger + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "be.h" +#include "be_impl.h" + +/* + * Initializes the libbe context to operate in the root boot environment + * dataset, for example, zroot/ROOT. + */ +libbe_handle_t * +libbe_init(void) +{ + char buf[BE_MAXPATHLEN]; + struct stat sb; + dev_t root_dev, boot_dev; + libbe_handle_t *lbh; + char *pos; + + // TODO: use errno here?? + + /* Verify that /boot and / are mounted on the same filesystem */ + if (stat("/", &sb) != 0) { + return (NULL); + } + + root_dev = sb.st_dev; + + if (stat("/boot", &sb) != 0) { + return (NULL); + } + + boot_dev = sb.st_dev; + + if (root_dev != boot_dev) { + fprintf(stderr, "/ and /boot not on same device, quitting\n"); + return (NULL); + } + + if ((lbh = calloc(1, sizeof(libbe_handle_t))) == NULL) { + return (NULL); + } + + if ((lbh->lzh = libzfs_init()) == NULL) { + free(lbh); + return (NULL); + } + + /* Obtain path to active boot environment */ + if ((kenv(KENV_GET, "zfs_be_active", lbh->active, + BE_MAXPATHLEN)) == -1) { + libzfs_fini(lbh->lzh); + free(lbh); + return (NULL); + } + + /* Remove leading 'zfs:' if present, otherwise use value as-is */ + if ((pos = strrchr(lbh->active, ':')) != NULL) { + strncpy(lbh->active, pos + sizeof(char), BE_MAXPATHLEN); + } + + /* Obtain path to boot environment root */ + if ((kenv(KENV_GET, "zfs_be_root", lbh->root, BE_MAXPATHLEN)) == -1) { + libzfs_fini(lbh->lzh); + free(lbh); + return (NULL); + } + + /* Remove leading 'zfs:' if present, otherwise use value as-is */ + if ((pos = strrchr(lbh->root, ':')) != NULL) { + strncpy(lbh->root, pos + sizeof(char), BE_MAXPATHLEN); + } + + return (lbh); +} + + +/* + * Free memory allocated by libbe_init() + */ +void +libbe_close(libbe_handle_t *lbh) +{ + libzfs_fini(lbh->lzh); + free(lbh); +} + + +/* + * Destroy the boot environment or snapshot specified by the name + * parameter. Options are or'd together with the possible values: + * BE_DESTROY_FORCE : forces operation on mounted datasets + * TODO: Test destroying a non active but mounted be + */ +int +be_destroy(libbe_handle_t *lbh, char *name, int options) +{ + zfs_handle_t *fs; + char path[BE_MAXPATHLEN]; + char *p = path; + int mounted; + int force = options & BE_DESTROY_FORCE; + + int err = BE_ERR_SUCCESS; + + be_root_concat(lbh, name, path); + printf("path: %s\n", path); + + if (strchr(name, '@') == NULL) { + if (!zfs_dataset_exists(lbh->lzh, path, ZFS_TYPE_FILESYSTEM)) { + return (set_error(lbh, BE_ERR_NOENT)); + } + + if (strcmp(path, lbh->active) == 0) { + return (set_error(lbh, BE_ERR_DESTROYACT)); + } + + fs = zfs_open(lbh->lzh, p, ZFS_TYPE_FILESYSTEM); + } else { + + if (!zfs_dataset_exists(lbh->lzh, path, ZFS_TYPE_SNAPSHOT)) { + return (set_error(lbh, BE_ERR_NOENT)); + } + + fs = zfs_open(lbh->lzh, p, ZFS_TYPE_SNAPSHOT); + } + + if (fs == NULL) + return (set_error(lbh, BE_ERR_ZFSOPEN)); + + /* Check if mounted, unmount if force is specified */ + if (mounted = zfs_is_mounted(fs, NULL)) { + if (force) { + zfs_unmount(fs, NULL, 0); + } else { + return (set_error(lbh, BE_ERR_DESTROYMNT)); + } + } + + + // TODO: convert this to use zfs_iter_children first for deep bes + // XXX note: errno 16 (device busy) occurs when chilren are present + if ((err = zfs_destroy(fs, false)) != 0) { + fprintf(stderr, "delete failed errno: %d\n", errno); + } + + return (err); +} + + +int +be_snapshot(libbe_handle_t *lbh, char *source, char *snap_name, + bool recursive, char *result) +{ + char buf[BE_MAXPATHLEN]; + time_t rawtime; + int len, err; + + be_root_concat(lbh, source, buf); + + if (!be_exists(lbh, buf)) { + return (BE_ERR_NOENT); + } + + if (snap_name != NULL) { + strcat(buf, "@"); + strcat(buf, snap_name); + if (result != NULL) { + snprintf(result, BE_MAXPATHLEN, "%s@%s", source, + snap_name); + } + } else { + time(&rawtime); + len = strlen(buf); + strftime(buf + len, BE_MAXPATHLEN - len, + "@%F-%T", localtime(&rawtime)); + if (result != NULL) { + strcpy(result, strrchr(buf, '/') + 1); + } + } + + if (err = zfs_snapshot(lbh->lzh, buf, recursive, NULL) != 0) { + switch (err) { + case EZFS_INVALIDNAME: + return (set_error(lbh, BE_ERR_INVALIDNAME)); + + default: + // TODO: elaborate return codes + return (set_error(lbh, BE_ERR_UNKNOWN)); + } + } + + return (BE_ERR_SUCCESS); +} + + +/* + * Create the boot environment specified by the name parameter + */ +int +be_create(libbe_handle_t *lbh, char *name) +{ + int err; + + err = be_create_from_existing(lbh, name, (char *)be_active_path(lbh)); + + return (set_error(lbh, err)); +} + + +static int +be_deep_clone_prop(int prop, void *cb) +{ + int err; + struct libbe_dccb *dccb = cb; + zprop_source_t src; + char pval[BE_MAXPATHLEN]; + char source[BE_MAXPATHLEN]; + + /* Skip some properties we don't want to touch */ + switch (prop) { + case ZFS_PROP_CANMOUNT: + return (ZPROP_CONT); + break; + } + + /* Don't copy readonly properties */ + if (zfs_prop_readonly(prop)) { + return (ZPROP_CONT); + } + + if ((err = zfs_prop_get(dccb->zhp, prop, (char *)&pval, + sizeof(pval), &src, (char *)&source, sizeof(source), false))) { + /* Just continue if we fail to read a property */ + return (ZPROP_CONT); + } + /* Only copy locally defined properties */ + if (src != ZPROP_SRC_LOCAL) { + return (ZPROP_CONT); + } + + nvlist_add_string(dccb->props, zfs_prop_to_name(prop), (char *)pval); + + return (ZPROP_CONT); +} + +static int +be_deep_clone(zfs_handle_t *ds, void *data) +{ + int err; + char be_path[BE_MAXPATHLEN]; + char snap_path[BE_MAXPATHLEN]; + char mp[BE_MAXPATHLEN]; + const char *dspath; + char *dsname; + zfs_handle_t *snap_hdl; + nvlist_t *props; + struct libbe_deep_clone sdc; + struct libbe_deep_clone *isdc = (struct libbe_deep_clone *)data; + struct libbe_dccb dccb; + + dspath = zfs_get_name(ds); + if ((dsname = strrchr(dspath, '/')) == NULL) { + return (BE_ERR_UNKNOWN); + } + dsname++; + if (isdc->bename == NULL) { + snprintf(be_path, sizeof(be_path), "%s/%s", isdc->be_root, dsname); + } else { + snprintf(be_path, sizeof(be_path), "%s/%s", isdc->be_root, isdc->bename); + } + snprintf(snap_path, sizeof(snap_path), "%s@%s", dspath, isdc->snapname); + + if (zfs_dataset_exists(isdc->lbh->lzh, be_path, ZFS_TYPE_DATASET)) { + return (set_error(isdc->lbh, BE_ERR_EXISTS)); + } + + if ((snap_hdl = + zfs_open(isdc->lbh->lzh, snap_path, ZFS_TYPE_SNAPSHOT)) == NULL) { + return (set_error(isdc->lbh, BE_ERR_ZFSOPEN)); + } + + nvlist_alloc(&props, NV_UNIQUE_NAME, KM_SLEEP); + nvlist_add_string(props, "canmount", "noauto"); + + dccb.zhp = ds; + dccb.props = props; + if (zprop_iter(be_deep_clone_prop, &dccb, B_FALSE, B_FALSE, + ZFS_TYPE_FILESYSTEM) == ZPROP_INVAL) { + return (-1); + } + + if (err = zfs_clone(snap_hdl, be_path, props)) { + switch (err) { + case EZFS_SUCCESS: + err = BE_ERR_SUCCESS; + break; + default: + err = BE_ERR_ZFSCLONE; + break; + } + } + + nvlist_free(props); + zfs_close(snap_hdl); + + sdc.lbh = isdc->lbh; + sdc.bename = NULL; + sdc.snapname = isdc->snapname; + sdc.be_root = (char *)&be_path; + + err = zfs_iter_filesystems(ds, be_deep_clone, &sdc); + + return (err); +} + +/* + * Create the boot environment from pre-existing snapshot + */ +int +be_create_from_existing_snap(libbe_handle_t *lbh, char *name, char *snap) +{ + int err; + char be_path[BE_MAXPATHLEN]; + char snap_path[BE_MAXPATHLEN]; + char *parentname, *bename, *snapname; + zfs_handle_t *parent_hdl; + struct libbe_deep_clone sdc; + + if (err = be_validate_name(lbh, name)) { + return (set_error(lbh, err)); + } + + if (err = be_root_concat(lbh, snap, snap_path)) { + return (set_error(lbh, err)); + } + + if (err = be_validate_snap(lbh, snap_path)) { + return (set_error(lbh, err)); + } + + if (err = be_root_concat(lbh, name, be_path)) { + return (set_error(lbh, err)); + } + + if ((bename = strrchr(name, '/')) == NULL) { + bename = name; + } else { + bename++; + } + if ((parentname = strdup(snap_path)) == NULL) { + err = BE_ERR_UNKNOWN; + return (set_error(lbh, err)); + } + snapname = strchr(parentname, '@'); + if (snapname == NULL) { + err = BE_ERR_UNKNOWN; + return (set_error(lbh, err)); + } + *snapname = '\0'; + snapname++; + + sdc.lbh = lbh; + sdc.bename = bename; + sdc.snapname = snapname; + sdc.be_root = lbh->root; + + parent_hdl = zfs_open(lbh->lzh, parentname, ZFS_TYPE_DATASET); + err = be_deep_clone(parent_hdl, &sdc); + + return (set_error(lbh, err)); +} + + +/* + * Create a boot environment from an existing boot environment + */ +int +be_create_from_existing(libbe_handle_t *lbh, char *name, char *old) +{ + int err; + char buf[BE_MAXPATHLEN]; + + if ((err = be_snapshot(lbh, old, NULL, true, (char *)&buf))) { + return (set_error(lbh, err)); + } + + err = be_create_from_existing_snap(lbh, name, (char *)buf); + + return (set_error(lbh, err)); +} + + +/* + * Verifies that a snapshot has a valid name, exists, and has a mountpoint of + * '/'. Returns BE_ERR_SUCCESS (0), upon success, or the relevant BE_ERR_* upon + * failure. Does not set the internal library error state. + */ +int +be_validate_snap(libbe_handle_t *lbh, char *snap_name) +{ + zfs_handle_t *zfs_hdl; + char buf[BE_MAXPATHLEN]; + char *delim_pos; + char *mountpoint; + int err = BE_ERR_SUCCESS; + + if (strlen(snap_name) >= BE_MAXPATHLEN) { + return (BE_ERR_PATHLEN); + } + + if (!zfs_dataset_exists(lbh->lzh, snap_name, + ZFS_TYPE_SNAPSHOT)) { + return (BE_ERR_NOENT); + } + + strncpy(buf, snap_name, BE_MAXPATHLEN); + + /* Find the base filesystem of the snapshot */ + if ((delim_pos = strchr(buf, '@')) == NULL) { + return (BE_ERR_INVALIDNAME); + } + *delim_pos = '\0'; + + if ((zfs_hdl = + zfs_open(lbh->lzh, buf, ZFS_TYPE_DATASET)) == NULL) { + return (BE_ERR_NOORIGIN); + } + + if (err = + zfs_prop_get(zfs_hdl, ZFS_PROP_MOUNTPOINT, buf, + BE_MAXPATHLEN, + NULL, NULL, 0, 1)) { + err = BE_ERR_INVORIGIN; + } + + if ((err != 0) && (strncmp(buf, "/", BE_MAXPATHLEN) != 0)) { + err = BE_ERR_INVORIGIN; + } + + zfs_close(zfs_hdl); + + return (err); +} + + +/* + * Idempotently appends the name argument to the root boot environment path + * and copies the resulting string into the result buffer (which is assumed + * to be at least BE_MAXPATHLEN characters long. Returns BE_ERR_SUCCESS upon + * success, BE_ERR_PATHLEN if the resulting path is longer than BE_MAXPATHLEN, + * or BE_ERR_INVALIDNAME if the name is a path that does not begin with + * zfs_be_root. Does not set internal library error state. + */ +int +be_root_concat(libbe_handle_t *lbh, char *name, char *result) +{ + size_t name_len, root_len; + + name_len = strlen(name); + root_len = strlen(lbh->root); + + /* Act idempotently; return be name if it is already a full path */ + if (strrchr(name, '/') != NULL) { + if (strstr(name, lbh->root) != name) { + return (BE_ERR_INVALIDNAME); + } + + if (name_len >= BE_MAXPATHLEN) { + return (BE_ERR_PATHLEN); + } + + strncpy(result, name, BE_MAXPATHLEN); + return (BE_ERR_SUCCESS); + } else if (name_len + root_len + 1 < BE_MAXPATHLEN) { + snprintf(result, BE_MAXPATHLEN, "%s/%s", lbh->root, + name); + return (BE_ERR_SUCCESS); + } + + return (BE_ERR_PATHLEN); +} + + +/* + * Verifies the validity of a boot environment name (A-Za-z0-9-_.). Returns + * BE_ERR_SUCCESS (0) if name is valid, otherwise returns BE_ERR_INVALIDNAME. + * Does not set internal library error state. + */ +int +be_validate_name(libbe_handle_t *lbh, char *name) +{ + for (int i = 0; *name; i++) { + char c = *(name++); + if (isalnum(c) || (c == '-') || (c == '_') || + (c == '.')) { + continue; + } + return (BE_ERR_INVALIDNAME); + } + + return (BE_ERR_SUCCESS); +} + + +/* + * usage + */ +int +be_rename(libbe_handle_t *lbh, char *old, char *new) +{ + char full_old[BE_MAXPATHLEN]; + char full_new[BE_MAXPATHLEN]; + zfs_handle_t *zfs_hdl; + int err; + + + if (err = be_root_concat(lbh, old, full_old)) { + return (set_error(lbh, err)); + } + if (err = be_root_concat(lbh, new, full_new)) { + return (set_error(lbh, err)); + } + + if (be_validate_name(lbh, new)) { + return (BE_ERR_UNKNOWN); + // TODO set and return correct error + } + + // check if old is active be + if (strcmp(full_new, be_active_path(lbh)) == 0) { + return (BE_ERR_UNKNOWN); + // TODO set and return correct error + } + + if (!zfs_dataset_exists(lbh->lzh, full_old, ZFS_TYPE_DATASET)) { + return (BE_ERR_UNKNOWN); + // TODO set and return correct error + } + + if (zfs_dataset_exists(lbh->lzh, full_new, ZFS_TYPE_DATASET)) { + return (BE_ERR_UNKNOWN); + // TODO set and return correct error + } + + // TODO: what about mounted bes? + // - if mounted error out unless a force flag is set? + + + if ((zfs_hdl = zfs_open(lbh->lzh, full_old, + ZFS_TYPE_FILESYSTEM)) == NULL) { + return (BE_ERR_UNKNOWN); + // TODO set and return correct error + } + + + // recurse, nounmount, forceunmount + struct renameflags flags = { 0, 0, 0 }; + + // TODO: error log on this call + err = zfs_rename(zfs_hdl, NULL, full_new, flags); + + zfs_close(zfs_hdl); + + return (set_error(lbh, err)); +} + + +int +be_export(libbe_handle_t *lbh, char *bootenv, int fd) +{ + char snap_name[BE_MAXPATHLEN]; + char buf[BE_MAXPATHLEN]; + zfs_handle_t *zfs; + int err; + + if (err = be_snapshot(lbh, bootenv, NULL, true, snap_name)) { + // TODO error handle + return (-1); + } + + be_root_concat(lbh, snap_name, buf); + + if ((zfs = zfs_open(lbh->lzh, buf, ZFS_TYPE_DATASET)) == NULL) { + return (BE_ERR_ZFSOPEN); + } + + err = zfs_send_one(zfs, NULL, fd, 0); + return (err); +} + + +int +be_import(libbe_handle_t *lbh, char *bootenv, int fd) +{ + char buf[BE_MAXPATHLEN]; + time_t rawtime; + nvlist_t *props; + zfs_handle_t *zfs; + int err, len; + + // TODO: this is a very likely name for someone to already have used + if (err = be_root_concat(lbh, "be_import_temp", buf)) { + // TODO error handle + return (-1); + } + + time(&rawtime); + len = strlen(buf); + strftime(buf + len, BE_MAXPATHLEN - len, + "@%F-%T", localtime(&rawtime)); + + + // lzc_receive(SNAPNAME, PROPS, ORIGIN, FORCE, fd)) { + if (err = lzc_receive(buf, NULL, NULL, false, fd)) { + /* TODO: go through libzfs_core's recv_impl and find returned + * errors and set appropriate BE_ERR + * edit: errors are not in libzfs_core, my assumption is + * that they use libzfs errors + * note: 17 is err for dataset already existing */ + return (err); + } + + if ((zfs = zfs_open(lbh->lzh, buf, ZFS_TYPE_SNAPSHOT)) == NULL) { + // TODO correct error + return (-1); + } + + nvlist_alloc(&props, NV_UNIQUE_NAME, KM_SLEEP); + nvlist_add_string(props, "canmount", "noauto"); + nvlist_add_string(props, "mountpoint", "/"); + + be_root_concat(lbh, bootenv, buf); + + err = zfs_clone(zfs, buf, props); + zfs_close(zfs); + + nvlist_free(props); + + // TODO: recursively delete be_import_temp dataset + + return (err); +} + + +int +be_add_child(libbe_handle_t *lbh, char *child_path, bool cp_if_exists) +{ + char active[BE_MAXPATHLEN]; + char buf[BE_MAXPATHLEN]; + nvlist_t *props; + zfs_handle_t *zfs; + struct stat sb; + int err; + + /* Require absolute paths */ + if (*child_path != '/') { + /* TODO: create appropriate error */ + return (-1); + } + + strncpy(active, be_active_path(lbh), BE_MAXPATHLEN); + strcpy(buf, active); + + /* Create non-mountable parent dataset(s) */ + char *s = child_path; + for (char *p; (p = strchr(s+1, '/')) != NULL; s = p) { + size_t len = p - s; + strncat(buf, s, len); + + nvlist_alloc(&props, NV_UNIQUE_NAME, KM_SLEEP); + nvlist_add_string(props, "canmount", "off"); + nvlist_add_string(props, "mountpoint", "none"); + zfs_create(lbh->lzh, buf, ZFS_TYPE_DATASET, props); + nvlist_free(props); + } + + + /* Path does not exist as a descendent of / yet */ + int pos = strlen(active); + + /* TODO: Verify that resulting str is less than BE_MAXPATHLEN */ + strncpy(&active[pos], child_path, BE_MAXPATHLEN-pos); + + + if (stat(child_path, &sb) != 0) { + /* Verify that error is ENOENT */ + if (errno != 2) { + /* TODO: create appropriate error */ + return (-1); + } + + nvlist_alloc(&props, NV_UNIQUE_NAME, KM_SLEEP); + nvlist_add_string(props, "canmount", "noauto"); + nvlist_add_string(props, "mountpoint", child_path); + + // create + if (err = + zfs_create(lbh->lzh, active, ZFS_TYPE_DATASET, props)) { + /* TODO handle error */ + return (-1); + } + nvlist_free(props); + + if ((zfs = + zfs_open(lbh->lzh, active, ZFS_TYPE_DATASET)) == NULL) { + /* TODO handle error */ + return (-1); + } + + // set props + if (err = zfs_prop_set(zfs, "canmount", "noauto")) { + /* TODO handle error */ + return (-1); + } + } else if (cp_if_exists) { + /* Path is already a descendent of / and should be copied */ + + + + // TODO + + /* + * Establish if the existing path is a zfs dataset or just + * the subdirectory of one + */ + + + // TODO: use mktemp + long int snap_name = random(); + + snprintf(buf, BE_MAXPATHLEN, "%s@%ld", child_path, snap_name); + + if (err = zfs_snapshot(lbh->lzh, buf, false, NULL)) { + // TODO correct error + return (-1); + } + + // clone + if ((zfs = + zfs_open(lbh->lzh, buf, ZFS_TYPE_SNAPSHOT)) == NULL) { + // TODO correct error + return (-1); + } + + if (err = zfs_clone(zfs, active, NULL)) { + // TODO correct error + return (-1); + } + + + // set props + } else { + /* TODO: error code for exists, but not cp? */ + return (-1); + } + + + return (BE_ERR_SUCCESS); +} + + +int +be_activate(libbe_handle_t *lbh, char *bootenv, bool temporary) +{ + char be_path[BE_MAXPATHLEN]; + char buf[BE_MAXPATHLEN]; + zpool_handle_t *zph; + uint64_t pool_guid; + uint64_t vdev_guid; + int zfs_fd; + int len; + int err; + + be_root_concat(lbh, bootenv, be_path); + + + /* Note: be_exists fails if mountpoint is not / */ + if (!be_exists(lbh, be_path)) { + return (BE_ERR_NOENT); + } + + if (temporary) { + // TODO: give proper attribution to author(s) of zfsbootcfg + // for this snippet + + if (kenv(KENV_GET, "vfs.zfs.boot.primary_pool", buf, + sizeof(buf)) <= 0) { + return (1); + } + pool_guid = strtoumax(buf, NULL, 10); + if (pool_guid == 0) { + return (1); + } + + if (kenv(KENV_GET, "vfs.zfs.boot.primary_vdev", buf, + sizeof(buf)) <= 0) { + return (1); + } + vdev_guid = strtoumax(buf, NULL, 10); + if (vdev_guid == 0) { + return (1); + } + + /* Expected format according to zfsbootcfg(8) man */ + strcpy(buf, "zfs:"); + strcat(buf, be_path); + strcat(buf, ":"); + + if (zpool_nextboot(lbh->lzh, pool_guid, vdev_guid, buf) != 0) { + perror("ZFS_IOC_NEXTBOOT failed"); + return (1); + } + + return (BE_ERR_SUCCESS); + } else { + /* Obtain bootenv zpool */ + strncpy(buf, be_path, BE_MAXPATHLEN); + *(strchr(buf, '/')) = '\0'; + + if ((zph = zpool_open(lbh->lzh, buf)) == NULL) { + // TODO: create error for this + return (-1); + } + printf("asdf\n"); + + err = zpool_set_prop(zph, "bootfs", be_path); + zpool_close(zph); + + switch (err) { + case 0: + return (BE_ERR_SUCCESS); + + default: + // TODO correct errors + return (-1); + } + } +} Added: projects/bectl/lib/libbe/be.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/bectl/lib/libbe/be.h Tue Jul 24 13:17:40 2018 (r336668) @@ -0,0 +1,113 @@ +/* + * be.h + * + * Copyright (c) 2017 Kyle J. Kneitinger + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _LIBBE_H +#define _LIBBE_H + +#include + +#define BE_MAXPATHLEN 512 + +typedef struct libbe_handle libbe_handle_t; + +typedef enum be_error { + BE_ERR_SUCCESS = 0, /* No error */ + BE_ERR_INVALIDNAME, /* invalid boot env name */ + BE_ERR_EXISTS, /* boot env name already taken */ + BE_ERR_NOENT, /* boot env doesn't exist */ + BE_ERR_PERMS, /* insufficient permissions */ + BE_ERR_DESTROYACT, /* cannot destroy active boot env */ + BE_ERR_DESTROYMNT, /* destroying a mounted be requires force */ + BE_ERR_PATHLEN, /* provided name exceeds maximum length limit */ + BE_ERR_INVORIGIN, /* snapshot origin's mountpoint is not '/' */ + BE_ERR_NOORIGIN, /* could not open snapshot's origin */ + BE_ERR_MOUNTED, /* boot environment is already mounted */ + BE_ERR_NOMOUNT, /* boot environment is not mounted */ + BE_ERR_ZFSOPEN, /* calling zfs_open() failed */ + BE_ERR_ZFSCLONE, /* error when calling zfs_clone to create be */ + BE_ERR_UNKNOWN, /* unknown error */ +} be_error_t; + + +/* Library handling functions: be.c */ +libbe_handle_t *libbe_init(void); +void libbe_close(libbe_handle_t *); + +/* Bootenv information functions: be_info.c */ +const char *be_active_name(libbe_handle_t *); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-projects@freebsd.org Tue Jul 24 13:21:46 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 D9C2B104BA6E for ; Tue, 24 Jul 2018 13:21:45 +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 8B42D8ED8C; Tue, 24 Jul 2018 13:21:45 +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 6C2BC4137; Tue, 24 Jul 2018 13:21:45 +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 w6ODLj6G030824; Tue, 24 Jul 2018 13:21:45 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6ODLifY030817; Tue, 24 Jul 2018 13:21:44 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807241321.w6ODLifY030817@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 24 Jul 2018 13:21:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336669 - in projects/bectl/sbin: . be bectl X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in projects/bectl/sbin: . be bectl X-SVN-Commit-Revision: 336669 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, 24 Jul 2018 13:21:46 -0000 Author: kevans Date: Tue Jul 24 13:21:44 2018 New Revision: 336669 URL: https://svnweb.freebsd.org/changeset/base/336669 Log: Rename be(1) to bectl(8); continues to live in /sbin Discussed with: rpokala, allanjude Added: projects/bectl/sbin/bectl/ - copied from r336668, projects/bectl/sbin/be/ projects/bectl/sbin/bectl/bectl.8 - copied unchanged from r336668, projects/bectl/sbin/be/be.1 projects/bectl/sbin/bectl/bectl.c - copied unchanged from r336668, projects/bectl/sbin/be/be.c Deleted: projects/bectl/sbin/be/ projects/bectl/sbin/bectl/be.1 projects/bectl/sbin/bectl/be.c Modified: projects/bectl/sbin/Makefile projects/bectl/sbin/bectl/Makefile Modified: projects/bectl/sbin/Makefile ============================================================================== --- projects/bectl/sbin/Makefile Tue Jul 24 13:17:40 2018 (r336668) +++ projects/bectl/sbin/Makefile Tue Jul 24 13:21:44 2018 (r336669) @@ -86,7 +86,7 @@ SUBDIR.${MK_PF}+= pfctl SUBDIR.${MK_PF}+= pflogd SUBDIR.${MK_QUOTAS}+= quotacheck SUBDIR.${MK_ROUTED}+= routed -SUBDIR.${MK_ZFS}+= be +SUBDIR.${MK_ZFS}+= bectl SUBDIR.${MK_ZFS}+= zfsbootcfg SUBDIR.${MK_TESTS}+= tests Modified: projects/bectl/sbin/bectl/Makefile ============================================================================== --- projects/bectl/sbin/be/Makefile Tue Jul 24 13:17:40 2018 (r336668) +++ projects/bectl/sbin/bectl/Makefile Tue Jul 24 13:21:44 2018 (r336669) @@ -1,8 +1,8 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 -PROG= be +PROG= bectl WARNS?= 1 -MAN= be.1 +MAN= bectl.8 LIBADD+= be LIBADD+= nvpair Copied: projects/bectl/sbin/bectl/bectl.8 (from r336668, projects/bectl/sbin/be/be.1) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/bectl/sbin/bectl/bectl.8 Tue Jul 24 13:21:44 2018 (r336669, copy of r336668, projects/bectl/sbin/be/be.1) @@ -0,0 +1,220 @@ +.\" +.\" be - Utility to manage Boot Environments on the ZFS filesystem +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" +.\" @(#)be.1 +.\" $FreeBSD$ +.\" +.Dd June 15, 2017 +.Dt BE 1 +.Os FreeBSD +.Sh NAME +.Nm be +.Nd Utility to manage Boot Environments on ZFS +.Sh SYNOPSIS +.Nm +activate +.Op Fl t +.Ao Ar beName Ac +.Nm +create +.Op Fl r +.Op Fl e Ar nonActiveBe | Fl e Ar beName@snapshot +.Ao Ar beName Ac +.Nm +create +.Op Fl r +.Ao Ar beName@snapshot Ac +.Nm +destroy +.Op Fl F +.Ao Ar beName | beName@snapshot Ac +.Nm +jail +.Ao Ar jailID | jailName Ac +.Ao Ar bootenv Ac +.Nm +list +.Op Fl a +.Op Fl D +.Op Fl H +.Op Fl s +.Nm +mount +.Ao Ar beName Ac +.Op mountpoint +.Nm +rename +.Ao Ar origBeName Ac +.Ao Ar newBeName Ac +.Nm +{ ujail | unjail } +.Ao Ar jailID | jailName Ac +.Ao Ar bootenv Ac +.Nm +{ umount | unmount } +.Op Fl f +.Ao Ar beName Ac +.Sh DESCRIPTION +The +.Nm +command is used to setup and interact with ZFS boot environments, which are bootable clones of datasets. +.Pp +.Em Boot Environments +allows the system to be upgraded, while preserving the old system environment in a separate ZFS dataset. +.Pp +.Sh COMMANDS +The following commands are supported by +.Nm : +.Bl -tag -width activate +.It Ic activate +.Op Fl t +.Ar +.Pp +Activate the given +.Ar beName +as the default boot filesystem. If the +.Op Fl t +flag is given, this takes effect only for the next boot. +.Pp +.It Ic create +.Op Fl r +.Op Fl e Ar nonActiveBe | Fl e Ar beName@snapshot +.Ao Ar beName Ac +.Pp +Creates a new boot environment named +.Ar beName . +If the -e param is specified, the new environment will be cloned from the given +.Ar nonActiveBe | Ar beName@snapshot . +If the +.Op Fl r +flag is given, a recursive boot environment will be made. +.Pp +.It Ic create +.Op Fl r +.Ao Ar beName@snapshot Ac +.Pp +Creates a snapshot of the existing boot environment named +.Ar beName . +If the +.Op Fl r +flag is given, a recursive boot environment will be made. +.Pp +.It Ic destroy +.Op Fl F +.Ao Ar beName | beName@snapshot Ac +.Pp +Destroys the given +.Ar beName +boot environment or +.Ar beName@snapshot +snapshot. +Specifying +.Fl F +will automatically unmount without confirmation. +.Pp +.It Ic jail +.Ao Ar jailID | jailName Ac +.Ao Ar bootenv Ac +.Pp +Creates a jail of the given boot environment. +.Pp +.It Ic list +.Op Fl a +.Op Fl D +.Op Fl H +.Op Fl s +.Pp +Displays all boot environments. +The Active field indicates whether the boot environment is active now (N); active on reboot (R); or both (NR). +.Pp +If +.Fl a +is used, display all datasets. +If +.Fl D +is used, display the full space usage for each boot environment, assuming all other boot environments were destroyed. +The +.Fl H +option is used for scripting. It does not print headers and separate fields by a single tab instead of arbitrary white space. +If +.Fl s +is used, display all snapshots as well. +.Pp +.It Ic mount +.Ao Ar beName Ac +.Op mountpoint +.Pp +Temporarily mount the boot environment. +Mount at the specified +.Ar mountpoint +if provided. +.Pp +.It Ic rename Ao Ar origBeName Ac Ao Ar newBeName Ac +.Pp +Renames the given nonactive +.Ar origBeName +to the given +.Ar newBeName +.Pp +.It Ic unmount +.Op Fl f +.Ao Ar beName Ac +.Pp +Unmount the given boot environment, if it is mounted. +Specifying +.Fl f +will force the unmount if busy. +.Pp +.It Ic unjail +.Ao Ar beName Ac +.Pp +Destroys the jail created from the given boot environment. +.Pp +.El +.Sh EXAMPLES +.Bl -bullet +.It +To fill in with jail upgrade example when behavior is firm. +.Pp +.Sh SEE ALSO +.Xr jail 8 , +.Xr zfs 8 , +.Xr zpool 8 +.Sh HISTORY +.Nm +is based on +.Xr beadm 1 +and was implemented as a project for the 2017 Summer of Code, along with +.Xr libbe 3 . +.Sh AUTHORS +.Bl -bullet +.It +Kyle Kneitinger (kneitinger) +.Ar kyle@kneit.in +.Pp +Creator of +.Nm . +.It +Slawomir Wojciech Wojtczak (vermaden) +.Ar vermaden@interia.pl +.Pp +Creator and maintainer of +.Xr beadm 1 . +.It +Bryan Drewery (bdrewery) +.Ar bryan@shatow.net +.Pp +Wrote the original +.Xr beadm 1 +manual page that this one is derived from. +.El Copied: projects/bectl/sbin/bectl/bectl.c (from r336668, projects/bectl/sbin/be/be.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/bectl/sbin/bectl/bectl.c Tue Jul 24 13:21:44 2018 (r336669, copy of r336668, projects/bectl/sbin/be/be.c) @@ -0,0 +1,664 @@ +/* + * be.c + * + * Copyright (c) 2017 Kyle J. Kneitinger + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +static int be_cmd_activate(int argc, char *argv[]); +static int be_cmd_create(int argc, char *argv[]); +static int be_cmd_destroy(int argc, char *argv[]); +static int be_cmd_export(int argc, char *argv[]); +static int be_cmd_import(int argc, char *argv[]); +static int be_cmd_add(int argc, char *argv[]); +static int be_cmd_jail(int argc, char *argv[]); +static int be_cmd_list(int argc, char *argv[]); +static int be_cmd_mount(int argc, char *argv[]); +static int be_cmd_rename(int argc, char *argv[]); +static int be_cmd_unjail(int argc, char *argv[]); +static int be_cmd_unmount(int argc, char *argv[]); + +libbe_handle_t *be; + +static int +usage(bool explicit) +{ + FILE *fp = explicit ? stdout : stderr; + + fprintf(fp, + "usage:\tbe ( -h | -? | subcommand [args...] )\n" + "\tbe activate [-t] beName\n" + "\tbe create [-e nonActiveBe | -e beName@snapshot] beName\n" + "\tbe create beName@snapshot\n" + "\tbe destroy [-F] beName | beName@snapshot⟩\n" + "\tbe export sourceBe\n" + "\tbe import targetBe\n" + "\tbe add (path)*\n" + "\tbe jail bootenv\n" + "\tbe list [-a] [-D] [-H] [-s]\n" + "\tbe mount beName [mountpoint]\n" + "\tbe rename origBeName newBeName\n" + "\tbe { ujail | unjail } ⟨jailID | jailName⟩ bootenv\n" + "\tbe { umount | unmount } [-f] beName\n"); + + return (explicit ? 0 : EX_USAGE); +} + + +/* + * Represents a relationship between the command name and the parser action + * that handles it. + */ +struct command_map_entry { + const char *command; + int (*fn)(int argc, char *argv[]); +}; + +static struct command_map_entry command_map[] = +{ + { "activate", be_cmd_activate }, + { "create", be_cmd_create }, + { "destroy", be_cmd_destroy }, + { "export", be_cmd_export }, + { "import", be_cmd_import }, + { "add", be_cmd_add }, + { "jail", be_cmd_jail }, + { "list", be_cmd_list }, + { "mount", be_cmd_mount }, + { "rename", be_cmd_rename }, + { "unjail", be_cmd_unjail }, + { "unmount", be_cmd_unmount }, +}; + +static int +get_cmd_index(char *cmd, int *index) +{ + int map_size = sizeof(command_map) / sizeof(struct command_map_entry); + + for (int i = 0; i < map_size; ++i) { + if (strcmp(cmd, command_map[i].command) == 0) { + *index = i; + return (0); + } + } + + return (1); +} + + +static int +be_cmd_activate(int argc, char *argv[]) +{ + int err, opt; + bool temp; + char *bootenv; + + temp = false; + while ((opt = getopt(argc, argv, "t")) != -1) { + switch (opt) { + case 't': + temp = true; + break; + default: + fprintf(stderr, "be activate: unknown option '-%c'\n", + optopt); + return (usage(false)); + } + } + + argc -= optind; + argv += optind; + + if (argc != 1) { + fprintf(stderr, "be activate: wrong number of arguments\n"); + return (usage(false)); + } + + + /* activate logic goes here */ + if ((err = be_activate(be, argv[0], temp)) != 0) { + // TODO: more specific error msg based on err + printf("did not successfully activate boot environment %s\n", + argv[0]); + } else { + printf("successfully activated boot environment %s\n", argv[0]); + } + + if (temp) { + printf("for next boot\n"); + } + + return (err); +} + + +// TODO: when only one arg is given, and it contains an "@" the this should +// create that snapshot +static int +be_cmd_create(int argc, char *argv[]) +{ + int err, opt; + char *snapname; + char *bootenv; + char *source; + + snapname = NULL; + while ((opt = getopt(argc, argv, "e:")) != -1) { + switch (opt) { + case 'e': + snapname = optarg; + break; + default: + fprintf(stderr, "be create: unknown option '-%c'\n", + optopt); + return (usage(false)); + } + } + + argc -= optind; + argv += optind; + + if (argc != 1) { + fprintf(stderr, "be create: wrong number of arguments\n"); + return (usage(false)); + } + + bootenv = *argv; + + + if (snapname != NULL) { + if (strchr(snapname, '@') != NULL) { + err = be_create_from_existing_snap(be, bootenv, + snapname); + } else { + err = be_create_from_existing(be, bootenv, snapname); + } + } else { + if ((snapname = strchr(bootenv, '@')) != NULL) { + *(snapname++) = '\0'; + if ((err = be_snapshot(be, (char *)be_active_path(be), + snapname, true, NULL)) != BE_ERR_SUCCESS) { + fprintf(stderr, "failed to create snapshot\n"); + } + asprintf(&source, "%s@%s", be_active_path(be), snapname); + err = be_create_from_existing_snap(be, bootenv, + source); + return (err); + } else { + err = be_create(be, bootenv); + } + } + + switch (err) { + case BE_ERR_SUCCESS: + break; + default: + if (snapname == NULL) { + fprintf(stderr, + "failed to create bootenv %s\n", bootenv); + } else { + fprintf(stderr, + "failed to create bootenv %s from snapshot %s\n", + bootenv, snapname); + } + } + + return (err); +} + + +static int +be_cmd_export(int argc, char *argv[]) +{ + int opt; + char *bootenv; + + + if (argc == 1) { + fprintf(stderr, "be export: missing boot environment name\n"); + return (usage(false)); + } + + if (argc > 2) { + fprintf(stderr, "be export: extra arguments provided\n"); + return (usage(false)); + } + + bootenv = argv[1]; + + if (isatty(STDOUT_FILENO)) { + fprintf(stderr, "be export: must redirect output\n"); + return (EX_USAGE); + } + + be_export(be, bootenv, STDOUT_FILENO); + + return (0); +} + + +static int +be_cmd_import(int argc, char *argv[]) +{ + char *bootenv; + int err; + + + if (argc == 1) { + fprintf(stderr, "be import: missing boot environment name\n"); + return (usage(false)); + } + + + if (argc > 2) { + fprintf(stderr, "be import: extra arguments provided\n"); + return (usage(false)); + } + + bootenv = argv[1]; + + if (isatty(STDIN_FILENO)) { + fprintf(stderr, "be import: input can not be from terminal\n"); + return (EX_USAGE); + } + + err = be_import(be, bootenv, STDIN_FILENO); + + return (err); +} + + +static int +be_cmd_add(int argc, char *argv[]) +{ + char *bootenv; + + if (argc < 2) { + fprintf(stderr, "be add: must provide at least one path\n"); + return (usage(false)); + } + + for (int i = 1; i < argc; ++i) { + printf("arg %d: %s\n", i, argv[i]); + // TODO catch err + be_add_child(be, argv[i], true); + } + + return (0); +} + + +static int +be_cmd_destroy(int argc, char *argv[]) +{ + int opt, err; + bool force; + char *target; + + force = false; + while ((opt = getopt(argc, argv, "F")) != -1) { + switch (opt) { + case 'F': + force = true; + break; + default: + fprintf(stderr, "be destroy: unknown option '-%c'\n", + optopt); + return (usage(false)); + } + } + + argc -= optind; + argv += optind; + + if (argc != 1) { + fprintf(stderr, "be destroy: wrong number of arguments\n"); + return (usage(false)); + } + + target = argv[0]; + + err = be_destroy(be, target, force); + + return (err); +} + + +static int +be_cmd_jail(int argc, char *argv[]) +{ + char *bootenv; + char mnt_loc[BE_MAXPATHLEN]; + char buf[BE_MAXPATHLEN*2]; + int err, jid; + + //struct jail be_jail = { 0 }; + + if (argc == 1) { + fprintf(stderr, "be jail: missing boot environment name\n"); + return (usage(false)); + } + if (argc > 2) { + fprintf(stderr, "be jail: too many arguments\n"); + return (usage(false)); + } + + bootenv = argv[1]; + + // TODO: if its already mounted, perhaps there should be a flag to + // indicate its okay to proceed?? + if ((err = be_mount(be, bootenv, NULL, 0, mnt_loc)) != BE_ERR_SUCCESS) { + fprintf(stderr, "could not mount bootenv\n"); + } + + // NOTE: this is not quite functional: + // see https://github.com/vermaden/beadm/blob/master/HOWTO.htm on + // neccesary modifications to correctly boot the jail + + //snprintf(buf, BE_MAXPATHLEN*2, "jail %s %s %s /bin/sh /etc/rc", mnt_loc, bootenv, "192.168.1.123"); + snprintf(buf, BE_MAXPATHLEN*2, "jail %s %s %s /bin/sh", mnt_loc, + bootenv, "192.168.1.123"); + system(buf); + + unmount(mnt_loc, 0); + + /* + * be_jail.version = JAIL_API_VERSION; + * be_jail.path = "/tmp/be_mount.hCCk"; + * be_jail.jailname = "sdfs"; + * + * if ((jid = jail(&be_jail)) != -1) { + * printf("jail %d created at %s\n", jid, mnt_loc); + * err = 0; + * } else { + * fprintf(stderr, "unable to create jail. error: %d\n", errno); + * err = errno; + * } + */ + + return (0); +} + + +static int +be_cmd_list(int argc, char *argv[]) +{ + int opt; + bool show_all_datasets, show_space, hide_headers, show_snaps; + char *bootenv; + nvlist_t *props; + + show_all_datasets = show_space = hide_headers = show_snaps = false; + while ((opt = getopt(argc, argv, "aDHs")) != -1) { + switch (opt) { + case 'a': + show_all_datasets = true; + break; + case 'D': + show_space = true; + break; + case 'H': + hide_headers = true; + break; + case 's': + show_space = true; + break; + default: + fprintf(stderr, "be list: unknown option '-%c'\n", + optopt); + return (usage(false)); + } + } + + argc -= optind; + + if (argc != 0) { + fprintf(stderr, "be list: extra argument provided\n"); + return (usage(false)); + } + + //props = be_get_bootenv_props(be); + + return (0); +} + + +static int +be_cmd_mount(int argc, char *argv[]) +{ + int err; + char result_loc[BE_MAXPATHLEN]; + char *bootenv; + char *mountpoint; + + if (argc < 2) { + fprintf(stderr, "be mount: missing argument(s)\n"); + return (usage(false)); + } + + if (argc > 3) { + fprintf(stderr, "be mount: too many arguments\n"); + return (usage(false)); + } + + bootenv = argv[1]; + mountpoint = ((argc == 3) ? argv[2] : NULL); + + + err = be_mount(be, bootenv, mountpoint, 0, result_loc); + + switch (err) { + case BE_ERR_SUCCESS: + printf("successfully mounted %s at %s\n", bootenv, result_loc); + break; + default: + fprintf(stderr, + (argc == 3) ? "failed to mount bootenv %s at %s\n" : + "failed to mount bootenv %s at temporary path %s\n", + bootenv, mountpoint); + } + + return (err); +} + + +static int +be_cmd_rename(int argc, char *argv[]) +{ + char *src; + char *dest; + int err; + + if (argc < 3) { + fprintf(stderr, "be rename: missing argument\n"); + return (usage(false)); + } + + if (argc > 3) { + fprintf(stderr, "be rename: too many arguments\n"); + return (usage(false)); + } + + src = argv[1]; + dest = argv[2]; + + err = be_rename(be, src, dest); + + switch (err) { + case BE_ERR_SUCCESS: + break; + default: + fprintf(stderr, "failed to rename bootenv %s to %s\n", + src, dest); + } + + return (0); +} + + +static int +be_cmd_unjail(int argc, char *argv[]) +{ + int opt; + char *cmd, *target; + bool force; + + /* Store alias used */ + cmd = argv[0]; + + force = false; + while ((opt = getopt(argc, argv, "f")) != -1) { + switch (opt) { + case 'f': + force = true; + break; + default: + fprintf(stderr, "be %s: unknown option '-%c'\n", + cmd, optopt); + return (usage(false)); + } + } + + argc -= optind; + argv += optind; + + if (argc != 1) { + fprintf(stderr, "be %s: wrong number of arguments\n", cmd); + return (usage(false)); + } + + target = argv[0]; + + /* unjail logic goes here */ + + return (0); +} + + +static int +be_cmd_unmount(int argc, char *argv[]) +{ + int err, flags, opt; + char *cmd, *bootenv; + + /* Store alias used */ + cmd = argv[0]; + + flags = 0; + while ((opt = getopt(argc, argv, "f")) != -1) { + switch (opt) { + case 'f': + flags |= BE_MNT_FORCE; + break; + default: + fprintf(stderr, "be %s: unknown option '-%c'\n", + cmd, optopt); + return (usage(false)); + } + } + + argc -= optind; + argv += optind; + + if (argc != 1) { + fprintf(stderr, "be %s: wrong number of arguments\n", cmd); + return (usage(false)); + } + + bootenv = argv[0]; + + err = be_unmount(be, bootenv, flags); + + switch (err) { + case BE_ERR_SUCCESS: + break; + default: + fprintf(stderr, "failed to unmount bootenv %s\n", bootenv); + } + + return (err); +} + + +int +main(int argc, char *argv[]) +{ + char *command; + int command_index, rc; + + if (argc < 2) { + fprintf(stderr, "missing command\n"); + return (usage(false)); + } + + command = argv[1]; + + /* Handle command aliases */ + if (strcmp(command, "umount") == 0) { + command = "unmount"; + } + + if (strcmp(command, "ujail") == 0) { + command = "unjail"; + } + + if ((strcmp(command, "-?") == 0) || (strcmp(command, "-h") == 0)) { + return (usage(true)); + } + + if (get_cmd_index(command, &command_index)) { + fprintf(stderr, "unknown command: %s\n", command); + return (usage(false)); + } + + + if ((be = libbe_init()) == NULL) { + return (-1); + } + + libbe_print_on_error(be, true); + + /* TODO: can be simplified if offset by 2 instead of one */ + rc = command_map[command_index].fn(argc-1, argv+1); + + libbe_close(be); + + + return (rc); +} From owner-svn-src-projects@freebsd.org Tue Jul 24 13:24:31 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 57047104BC63 for ; Tue, 24 Jul 2018 13:24:31 +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 03B638F18E; Tue, 24 Jul 2018 13:24:31 +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 D89974293; Tue, 24 Jul 2018 13:24:30 +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 w6ODOUeT034825; Tue, 24 Jul 2018 13:24:30 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6ODOU44034824; Tue, 24 Jul 2018 13:24:30 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807241324.w6ODOU44034824@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 24 Jul 2018 13:24:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336670 - projects/bectl/sbin/bectl X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: projects/bectl/sbin/bectl X-SVN-Commit-Revision: 336670 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, 24 Jul 2018 13:24:31 -0000 Author: kevans Date: Tue Jul 24 13:24:30 2018 New Revision: 336670 URL: https://svnweb.freebsd.org/changeset/base/336670 Log: bectl(8): Chase rename in manpage Modified: projects/bectl/sbin/bectl/bectl.8 Modified: projects/bectl/sbin/bectl/bectl.8 ============================================================================== --- projects/bectl/sbin/bectl/bectl.8 Tue Jul 24 13:21:44 2018 (r336669) +++ projects/bectl/sbin/bectl/bectl.8 Tue Jul 24 13:24:30 2018 (r336670) @@ -14,11 +14,11 @@ .\" @(#)be.1 .\" $FreeBSD$ .\" -.Dd June 15, 2017 -.Dt BE 1 +.Dd July 24, 2018 +.Dt BECTL 8 .Os FreeBSD .Sh NAME -.Nm be +.Nm bectl .Nd Utility to manage Boot Environments on ZFS .Sh SYNOPSIS .Nm From owner-svn-src-projects@freebsd.org Tue Jul 24 13:31:51 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 9A7E7104C156 for ; Tue, 24 Jul 2018 13:31:51 +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 497A58F719; Tue, 24 Jul 2018 13:31:51 +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 2AEC4444F; Tue, 24 Jul 2018 13:31:51 +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 w6ODVou7039571; Tue, 24 Jul 2018 13:31:50 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6ODVo3o039570; Tue, 24 Jul 2018 13:31:50 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807241331.w6ODVo3o039570@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 24 Jul 2018 13:31:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336671 - projects/bectl/share/mk X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: projects/bectl/share/mk X-SVN-Commit-Revision: 336671 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, 24 Jul 2018 13:31:51 -0000 Author: kevans Date: Tue Jul 24 13:31:50 2018 New Revision: 336671 URL: https://svnweb.freebsd.org/changeset/base/336671 Log: src.libnames.mk: Make libbe entry consistent with others Perhaps using libbe.a from "${DESTDIR}${LIBDIR}" might have been the prevailing technique at one point, but nowadays it appears to be to preferred to spell this as "${OBJTOP}/lib" -- make it so. Modified: projects/bectl/share/mk/src.libnames.mk Modified: projects/bectl/share/mk/src.libnames.mk ============================================================================== --- projects/bectl/share/mk/src.libnames.mk Tue Jul 24 13:24:30 2018 (r336670) +++ projects/bectl/share/mk/src.libnames.mk Tue Jul 24 13:31:50 2018 (r336671) @@ -474,7 +474,8 @@ LIBBSNMPTOOLS?= ${LIBBSNMPTOOLSDIR}/libbsnmptools.a LIBAMUDIR= ${OBJTOP}/usr.sbin/amd/libamu LIBAMU?= ${LIBAMUDIR}/libamu.a -LIBBE?= ${DESTDIR}${LIBDIR}/libbe.a +LIBBEDIR= ${OBJTOP}/lib/libbe +LIBBE?= ${LIBBEDIR}/libbe.a LIBPMCSTATDIR= ${OBJTOP}/lib/libpmcstat LIBPMCSTAT?= ${LIBPMCSTATDIR}/libpmcstat.a From owner-svn-src-projects@freebsd.org Tue Jul 24 15:42:25 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 DA768104F057 for ; Tue, 24 Jul 2018 15:42:24 +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 8EF9A73F1A; Tue, 24 Jul 2018 15:42:24 +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 7189259B0; Tue, 24 Jul 2018 15:42:24 +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 w6OFgO3H005888; Tue, 24 Jul 2018 15:42:24 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6OFgNVT005886; Tue, 24 Jul 2018 15:42:23 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807241542.w6OFgNVT005886@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 24 Jul 2018 15:42:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336673 - in projects/bectl: cddl/lib cddl/lib/libbe lib/libbe share/mk X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in projects/bectl: cddl/lib cddl/lib/libbe lib/libbe share/mk X-SVN-Commit-Revision: 336673 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, 24 Jul 2018 15:42:25 -0000 Author: kevans Date: Tue Jul 24 15:42:23 2018 New Revision: 336673 URL: https://svnweb.freebsd.org/changeset/base/336673 Log: libbe(3): Add to cddl build, adjust src.libnames.mk as needed Added: projects/bectl/cddl/lib/libbe/ projects/bectl/cddl/lib/libbe/Makefile - copied, changed from r336672, projects/bectl/lib/libbe/Makefile Deleted: projects/bectl/lib/libbe/Makefile Modified: projects/bectl/cddl/lib/Makefile projects/bectl/share/mk/src.libnames.mk Modified: projects/bectl/cddl/lib/Makefile ============================================================================== --- projects/bectl/cddl/lib/Makefile Tue Jul 24 14:55:47 2018 (r336672) +++ projects/bectl/cddl/lib/Makefile Tue Jul 24 15:42:23 2018 (r336673) @@ -4,6 +4,7 @@ SUBDIR= ${_drti} \ libavl \ + ${_libbe} \ libctf \ ${_libdtrace} \ libnvpair \ @@ -16,6 +17,7 @@ SUBDIR= ${_drti} \ SUBDIR.${MK_TESTS}+= tests .if ${MK_ZFS} != "no" +_libbe= libbe _libzfs_core= libzfs_core _libzfs= libzfs .if ${MK_LIBTHR} != "no" @@ -28,6 +30,7 @@ _drti= drti _libdtrace= libdtrace .endif +SUBDIR_DEPEND_libbe= libnvpair libzfs SUBDIR_DEPEND_libdtrace= libctf SUBDIR_DEPEND_libzfs_core= libnvpair SUBDIR_DEPEND_libzfs= libavl libnvpair libumem libuutil libzfs_core Copied and modified: projects/bectl/cddl/lib/libbe/Makefile (from r336672, projects/bectl/lib/libbe/Makefile) ============================================================================== --- projects/bectl/lib/libbe/Makefile Tue Jul 24 14:55:47 2018 (r336672, copy source) +++ projects/bectl/cddl/lib/libbe/Makefile Tue Jul 24 15:42:23 2018 (r336673) @@ -28,6 +28,9 @@ PACKAGE= lib${LIB} LIB= be SHLIB_MAJOR= 1 SHLIB_MINOR= 0 +LIBBE_SRC= ${SRCTOP}/lib/libbe + +.PATH: ${LIBBE_SRC} SRCS= be.c be_access.c be_error.c be_info.c INCS= be.h MAN= libbe.3 @@ -37,7 +40,10 @@ WARNS?= 1 LIBADD+= zfs LIBADD+= nvpair +CFLAGS+= -I${LIBBE_SRC} +CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libnvpair CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs/common +CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs_core/common CFLAGS+= -I${SRCTOP}/sys/cddl/compat/opensolaris CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/lib/libumem Modified: projects/bectl/share/mk/src.libnames.mk ============================================================================== --- projects/bectl/share/mk/src.libnames.mk Tue Jul 24 14:55:47 2018 (r336672) +++ projects/bectl/share/mk/src.libnames.mk Tue Jul 24 15:42:23 2018 (r336673) @@ -474,7 +474,6 @@ LIBBSNMPTOOLS?= ${LIBBSNMPTOOLSDIR}/libbsnmptools.a LIBAMUDIR= ${OBJTOP}/usr.sbin/amd/libamu LIBAMU?= ${LIBAMUDIR}/libamu.a -LIBBEDIR= ${OBJTOP}/lib/libbe LIBBE?= ${LIBBEDIR}/libbe.a LIBPMCSTATDIR= ${OBJTOP}/lib/libpmcstat @@ -487,6 +486,7 @@ LIBC_NOSSP_PIC?= ${LIBC_NOSSP_PICDIR}/libc_nossp_pic.a # not using a --sysroot or for meta mode bootstrapping when there is no # Makefile.depend. These are sorted by directory. LIBAVLDIR= ${OBJTOP}/cddl/lib/libavl +LIBBEDIR= ${OBJTOP}/cddl/lib/libbe LIBCTFDIR= ${OBJTOP}/cddl/lib/libctf LIBDTRACEDIR= ${OBJTOP}/cddl/lib/libdtrace LIBNVPAIRDIR= ${OBJTOP}/cddl/lib/libnvpair From owner-svn-src-projects@freebsd.org Tue Jul 24 16:20:47 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 8E3B2104FBC5 for ; Tue, 24 Jul 2018 16:20:47 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id ECCB8751A8; Tue, 24 Jul 2018 16:20:46 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-lf1-x12b.google.com with SMTP id g6-v6so3386162lfb.11; Tue, 24 Jul 2018 09:20:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=5dANkdXYjqXMW9pwI5du9q1nNcyLyy3EaOPf5xvcEbA=; b=GaMWCwlxU297igeh2XBhytEW11xrgOpemQcSWJX8MC0m+CfoBhJ2ZfHHXw1LS2LTAi LN2guL0XQkpHq9UlbdQpFYc9YjLOF/34EKtF96M+UgqDUdYRxWtmoyh2CzTdXZBJBmBt gP6+uWugaDfdvf0LHoBgWWKoXK40ymtAH4oZE79Ofurbox3L/qnuyDVPs9aIE+V2+GVB p/l8KTSLp+S/OxwmvLyWjpOr/K4GX5aFYKe+sh7bsrNzUwFfsBoleaGVvJl6xR2NloIe kGuwlekhLkB8uFPIRchrO0IaG669MeNhIHgAJ86pZJl/aTOP7JLtkqkUwhZLHv7rsVsE ytKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=5dANkdXYjqXMW9pwI5du9q1nNcyLyy3EaOPf5xvcEbA=; b=Qlq3gl3rJ08wvhePaOcTMixhL4MJZH3aYU+c3ks9oXGOSIdsvPUyylrNMdcSI39eFd kL24MkkV+oITtV2Y2fHWs+ERIdGRImR3Ihc6m2NyGFRKHxd2h0LAI6zLSELRWK642jx6 mdIo+7nD2qAIEDzNGjMgVx9OtCqdIe4AUQqY6wKh7X7wB680sB4y2P/hZcqhR+n4b2sh Ukor0DaMfYAaH57/2sjmRDpN/ppyG9eTgqty8Uk0z3L0obTXUsefPdGyb1TXcPgkU0Y3 BDT7AlB9vuSfG9LRzcoqvJ2dpyqDvX3htCcu5KTVzRG7HeIw9EjORPuj39vHlrbscMqB o5uA== X-Gm-Message-State: AOUpUlHywv1/CVjDZvj/+wOcCuH/7/fqskSuqLUMLqhOHXaowyOXGQjK 5j61WgGeAJRs+vZ0tTt6x65VPvu9NFok+FF5MiPiWA== X-Google-Smtp-Source: AAOMgpcfKOVoeKD26YEKzU4x2kQn5gI2HjD+dYXNM5KPhotLac7G2h6kh7JrfH+/MTgjAdUOrPXdlIuC69Wl6jnez2I= X-Received: by 2002:a19:d095:: with SMTP id h143-v6mr10344101lfg.16.1532449245293; Tue, 24 Jul 2018 09:20:45 -0700 (PDT) MIME-Version: 1.0 Sender: asomers@gmail.com Received: by 2002:ab3:7851:0:0:0:0:0 with HTTP; Tue, 24 Jul 2018 09:20:44 -0700 (PDT) In-Reply-To: <201807241255.w6OCtsSu018382@repo.freebsd.org> References: <201807241255.w6OCtsSu018382@repo.freebsd.org> From: Alan Somers Date: Tue, 24 Jul 2018 10:20:44 -0600 X-Google-Sender-Auth: tuAA8uqnfm2cAfm4qN146kbP4G4 Message-ID: Subject: Re: svn commit: r336666 - projects/bectl To: Kyle Evans Cc: src-committers , svn-src-projects@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 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, 24 Jul 2018 16:20:47 -0000 So what's the difference between bectl and sysutils/beadm? On Tue, Jul 24, 2018 at 6:55 AM, Kyle Evans wrote: > Author: kevans > Date: Tue Jul 24 12:55:54 2018 > New Revision: 336666 > URL: https://svnweb.freebsd.org/changeset/base/336666 > > Log: > Create a project branch for bectl(8) > > This will contain an import of libbe/be(1) by Kyle Kneitinger from GSoC > '17, > and further work will happen here until it's deemed ready for import to > head. > > Discussed with: allanjude > > Added: > - copied from r336665, head/ > Directory Properties: > projects/bectl/ (props changed) > > From owner-svn-src-projects@freebsd.org Tue Jul 24 16:30:18 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 D2534104FEC8 for ; Tue, 24 Jul 2018 16:30:18 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 80DF3756CB; Tue, 24 Jul 2018 16:30:18 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id 213CA1500F; Tue, 24 Jul 2018 16:30:18 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-lf1-f48.google.com with SMTP id f18-v6so3414441lfc.2; Tue, 24 Jul 2018 09:30:18 -0700 (PDT) X-Gm-Message-State: AOUpUlFW9ewI/7UUMOCy5aEOpt8lf3rGCWGBRhOUGDW7INiL/PL7WHz3 DZftcjFJ+eZkBKVlQWwmahtkjeS264itLan0K1A= X-Google-Smtp-Source: AAOMgpfuugqGSHYiCiiIEsHnalXIE2PNtZarvIHr5OnZmKwa+FTVU7Y6Xf5sMofTetikxg7LcIoNWemPVCro6HMt5xk= X-Received: by 2002:a19:138b:: with SMTP id 11-v6mr10942131lft.74.1532449816492; Tue, 24 Jul 2018 09:30:16 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:5742:0:0:0:0:0 with HTTP; Tue, 24 Jul 2018 09:29:55 -0700 (PDT) In-Reply-To: References: <201807241255.w6OCtsSu018382@repo.freebsd.org> From: Kyle Evans Date: Tue, 24 Jul 2018 11:29:55 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r336666 - projects/bectl To: Alan Somers Cc: Kyle Evans , src-committers , svn-src-projects@freebsd.org Content-Type: text/plain; charset="UTF-8" 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, 24 Jul 2018 16:30:19 -0000 bectl is intending to be a C version of sysutils/beadm with the actual functional parts split out into libbe(3). On Tue, Jul 24, 2018 at 11:20 AM, Alan Somers wrote: > So what's the difference between bectl and sysutils/beadm? > > > On Tue, Jul 24, 2018 at 6:55 AM, Kyle Evans wrote: >> >> Author: kevans >> Date: Tue Jul 24 12:55:54 2018 >> New Revision: 336666 >> URL: https://svnweb.freebsd.org/changeset/base/336666 >> >> Log: >> Create a project branch for bectl(8) >> >> This will contain an import of libbe/be(1) by Kyle Kneitinger from GSoC >> '17, >> and further work will happen here until it's deemed ready for import to >> head. >> >> Discussed with: allanjude >> >> Added: >> - copied from r336665, head/ >> Directory Properties: >> projects/bectl/ (props changed) >> > From owner-svn-src-projects@freebsd.org Tue Jul 24 16:31:44 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 BA499105008A for ; Tue, 24 Jul 2018 16:31:44 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 38E7B75B20; Tue, 24 Jul 2018 16:31:44 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w6OGVgoq037197; Tue, 24 Jul 2018 09:31:42 -0700 (PDT) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w6OGVgH2037196; Tue, 24 Jul 2018 09:31:42 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201807241631.w6OGVgH2037196@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r336668 - in projects/bectl: lib/libbe sbin sbin/be share/mk In-Reply-To: <201807241317.w6ODHe3X029905@repo.freebsd.org> To: Kyle Evans Date: Tue, 24 Jul 2018 09:31:42 -0700 (PDT) CC: src-committers@freebsd.org, svn-src-projects@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII 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, 24 Jul 2018 16:31:44 -0000 > Author: kevans > Date: Tue Jul 24 13:17:40 2018 > New Revision: 336668 > URL: https://svnweb.freebsd.org/changeset/base/336668 > > Log: > Import libbe(3)/be(1) from socsvn/soc2017/kneitinger/libbe-head > > Added: > projects/bectl/lib/libbe/ > projects/bectl/lib/libbe/Makefile (contents, props changed) > projects/bectl/lib/libbe/be.c (contents, props changed) > projects/bectl/lib/libbe/be.h (contents, props changed) > projects/bectl/lib/libbe/be_access.c (contents, props changed) > projects/bectl/lib/libbe/be_error.c (contents, props changed) > projects/bectl/lib/libbe/be_impl.h (contents, props changed) > projects/bectl/lib/libbe/be_info.c (contents, props changed) > projects/bectl/lib/libbe/libbe.3 (contents, props changed) > projects/bectl/sbin/be/ > projects/bectl/sbin/be/Makefile (contents, props changed) > projects/bectl/sbin/be/be.1 (contents, props changed) > projects/bectl/sbin/be/be.c (contents, props changed) > Modified: > projects/bectl/sbin/Makefile > projects/bectl/share/mk/src.libnames.mk > > Added: projects/bectl/lib/libbe/Makefile > ============================================================================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ projects/bectl/lib/libbe/Makefile Tue Jul 24 13:17:40 2018 (r336668) > @@ -0,0 +1,53 @@ > +# $FreeBSD$ > +# > +# Copyright (c) 2010 Hans Petter Selasky. All rights reserved. > +# > +# Redistribution and use in source and binary forms, with or without ... Makefile(s) generally do not have copyrights or license text. -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-projects@freebsd.org Tue Jul 24 16:35: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 A810E1050199 for ; Tue, 24 Jul 2018 16:35:02 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1203B75D8D; Tue, 24 Jul 2018 16:35:01 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-lf1-x134.google.com with SMTP id j143-v6so3412644lfj.12; Tue, 24 Jul 2018 09:35:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=hGRlNclb0x+0K88iWH0KsgvmqlGbN/KKFrGJkgOt/j0=; b=jjE423rYMktymn/QcDpOPkUXRFy5uN2p/h1+9EMvrbYz+C55Ml+a1DImR/ACtbpwWw lcJViDxmXlLgrUjjUVLaADvvFFUIU1ZRYy3V4ewBk6XIGYZGg341nUgMF811gzlfyZ+q Qbz5kziU48z0nDJJmiDX4Lg9YLJCwVRLDihNGmuuPKxedxxLpatcklWv7kn7KqYCM6pp qLheNLdVUve20YBUKGhKEJ/ZkBk0Yu3BwTbpqNxlyurtOUnfcQP2k97Kz16+YDNJrOqu yEx77m3fguPChfuir4beZrE2UeWED4X4tiIQ7ECaQhg7KC+s+MIyxn9d8N/fQyGmpkPJ ItRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=hGRlNclb0x+0K88iWH0KsgvmqlGbN/KKFrGJkgOt/j0=; b=FKLg4fUPisBJaOQDqYa8QRr/EQlbEJxBoWAmqmCuMCSPSoDyN/P2tR25T5CNgU2B4m lCstEWdKOWiSCNBXWaJ6xEs4gnpOGBcIWdBgfmsm75zl9Eoluiewiab74UcE416LdOjc C3gTGmFD+wY4UuJQnR/GvE4VNyH3yxZfC8TSyF+oYg5d25g5hxel5iEGqrckPxCU8x7l oveSt0RDZcrqgq9Xqdh+jzDD/jWvyqZPBbzHZAHxdM9rvlOgan5WtqfYYU7tyA/Z4f0j zz9S6//YZ/1jvF7Y1UwrduRMct18dioC/LkCFSQwm/MT8Un6VpWMD9Bk7vCg1ZOca9Xu zWhg== X-Gm-Message-State: AOUpUlGnd9wJVHI4W4N8XierycBfKMkPnYIBmStc2aYWVrFEY8MYw2cS iPSFfdhT0F/6DkiBoxJLR3/Fc5YyiuNzZOw5xkVXMQ== X-Google-Smtp-Source: AAOMgpcSKYG9mmX0/t2Z+apjGRQNhKOdLfx5QBKZ1IO6ROLiBzE8JRo2mKkqHKmr5iDUTxFwUcPGE/TRqMUuKHcEeDc= X-Received: by 2002:a19:d095:: with SMTP id h143-v6mr10370387lfg.16.1532450100067; Tue, 24 Jul 2018 09:35:00 -0700 (PDT) MIME-Version: 1.0 Sender: asomers@gmail.com Received: by 2002:ab3:7851:0:0:0:0:0 with HTTP; Tue, 24 Jul 2018 09:34:59 -0700 (PDT) In-Reply-To: References: <201807241255.w6OCtsSu018382@repo.freebsd.org> From: Alan Somers Date: Tue, 24 Jul 2018 10:34:59 -0600 X-Google-Sender-Auth: rnpZ2jVnfQTbn9WEN9rZ2_HX2QY Message-ID: Subject: Re: svn commit: r336666 - projects/bectl To: Kyle Evans Cc: src-committers , svn-src-projects@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 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, 24 Jul 2018 16:35:02 -0000 Ahh, that sounds like a good GSoC project. Is it intended to be fully compatible with sysutils/beadm? If so, then it should probably retain the same name. On Tue, Jul 24, 2018 at 10:29 AM, Kyle Evans wrote: > bectl is intending to be a C version of sysutils/beadm with the actual > functional parts split out into libbe(3). > > On Tue, Jul 24, 2018 at 11:20 AM, Alan Somers wrote: > > So what's the difference between bectl and sysutils/beadm? > > > > > > On Tue, Jul 24, 2018 at 6:55 AM, Kyle Evans wrote: > >> > >> Author: kevans > >> Date: Tue Jul 24 12:55:54 2018 > >> New Revision: 336666 > >> URL: https://svnweb.freebsd.org/changeset/base/336666 > >> > >> Log: > >> Create a project branch for bectl(8) > >> > >> This will contain an import of libbe/be(1) by Kyle Kneitinger from > GSoC > >> '17, > >> and further work will happen here until it's deemed ready for import > to > >> head. > >> > >> Discussed with: allanjude > >> > >> Added: > >> - copied from r336665, head/ > >> Directory Properties: > >> projects/bectl/ (props changed) > >> > > > From owner-svn-src-projects@freebsd.org Tue Jul 24 16:36:52 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 2ACCD10502B4 for ; Tue, 24 Jul 2018 16:36:52 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CABC17616D; Tue, 24 Jul 2018 16:36:51 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id 6772A15125; Tue, 24 Jul 2018 16:36:51 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-lj1-f174.google.com with SMTP id p6-v6so4155550ljc.5; Tue, 24 Jul 2018 09:36:51 -0700 (PDT) X-Gm-Message-State: AOUpUlEAmiKJzI8cAxXfLQ0gcqiC6OtsPbsPZdqL7ieoNc0m9Eu2IIDG MOQ6OIVHMECFnt1SpgLR8OO8a9dl44LxqhrWjGE= X-Google-Smtp-Source: AAOMgpfTtqVKFKEt2Ep7DzBi6BEJhP4SLsgxiTsVSK//enlbzp8fcnQ0LOkoqDLfFrReRsqEYHC1acuIsmypRKeqZJc= X-Received: by 2002:a2e:1004:: with SMTP id j4-v6mr13260537lje.2.1532450209959; Tue, 24 Jul 2018 09:36:49 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:5742:0:0:0:0:0 with HTTP; Tue, 24 Jul 2018 09:36:29 -0700 (PDT) In-Reply-To: <201807241631.w6OGVgH2037196@pdx.rh.CN85.dnsmgr.net> References: <201807241317.w6ODHe3X029905@repo.freebsd.org> <201807241631.w6OGVgH2037196@pdx.rh.CN85.dnsmgr.net> From: Kyle Evans Date: Tue, 24 Jul 2018 11:36:29 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r336668 - in projects/bectl: lib/libbe sbin sbin/be share/mk To: "Rodney W. Grimes" Cc: src-committers , svn-src-projects@freebsd.org Content-Type: text/plain; charset="UTF-8" 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, 24 Jul 2018 16:36:52 -0000 On Tue, Jul 24, 2018 at 11:31 AM, Rodney W. Grimes wrote: >> Author: kevans >> Date: Tue Jul 24 13:17:40 2018 >> New Revision: 336668 >> URL: https://svnweb.freebsd.org/changeset/base/336668 >> >> Log: >> Import libbe(3)/be(1) from socsvn/soc2017/kneitinger/libbe-head >> >> Added: >> projects/bectl/lib/libbe/ >> projects/bectl/lib/libbe/Makefile (contents, props changed) >> projects/bectl/lib/libbe/be.c (contents, props changed) >> projects/bectl/lib/libbe/be.h (contents, props changed) >> projects/bectl/lib/libbe/be_access.c (contents, props changed) >> projects/bectl/lib/libbe/be_error.c (contents, props changed) >> projects/bectl/lib/libbe/be_impl.h (contents, props changed) >> projects/bectl/lib/libbe/be_info.c (contents, props changed) >> projects/bectl/lib/libbe/libbe.3 (contents, props changed) >> projects/bectl/sbin/be/ >> projects/bectl/sbin/be/Makefile (contents, props changed) >> projects/bectl/sbin/be/be.1 (contents, props changed) >> projects/bectl/sbin/be/be.c (contents, props changed) >> Modified: >> projects/bectl/sbin/Makefile >> projects/bectl/share/mk/src.libnames.mk >> >> Added: projects/bectl/lib/libbe/Makefile >> ============================================================================== >> --- /dev/null 00:00:00 1970 (empty, because file is newly added) >> +++ projects/bectl/lib/libbe/Makefile Tue Jul 24 13:17:40 2018 (r336668) >> @@ -0,0 +1,53 @@ >> +# $FreeBSD$ >> +# >> +# Copyright (c) 2010 Hans Petter Selasky. All rights reserved. >> +# >> +# Redistribution and use in source and binary forms, with or without > ... > Makefile(s) generally do not have copyrights or license text. > Hi, Right, right- I'll chop that off soon(-ish). Still working through a plan of attack on this stuff. It's just imported from the GSoC repo as-is in this commit. Thanks, Kyle Evans From owner-svn-src-projects@freebsd.org Tue Jul 24 16:41:09 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 6B38010504EE for ; Tue, 24 Jul 2018 16:41:09 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1631476516; Tue, 24 Jul 2018 16:41:09 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id A7E0A15127; Tue, 24 Jul 2018 16:41:08 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-lj1-f181.google.com with SMTP id 203-v6so4134304ljj.13; Tue, 24 Jul 2018 09:41:08 -0700 (PDT) X-Gm-Message-State: AOUpUlGRpmsAMuFz8NJLOMpI5lXGd00KqU/d53cH/LxSLitfnTfXgWq4 QDli4WYD65+JXHjLr04ax//4gz21PQ8SiscZSoI= X-Google-Smtp-Source: AAOMgpcsp2ogNtXHtC+RMLjiTRRMo1C1DnybvvGkR3ZTNspOXxdsWsPFYeWHKlH2nsf75kZXVqWWLReTVXHHExMeiIA= X-Received: by 2002:a2e:1004:: with SMTP id j4-v6mr13270719lje.2.1532450467354; Tue, 24 Jul 2018 09:41:07 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:5742:0:0:0:0:0 with HTTP; Tue, 24 Jul 2018 09:40:46 -0700 (PDT) In-Reply-To: References: <201807241255.w6OCtsSu018382@repo.freebsd.org> From: Kyle Evans Date: Tue, 24 Jul 2018 11:40:46 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r336666 - projects/bectl To: Alan Somers Cc: src-committers , svn-src-projects@freebsd.org, Allan Jude Content-Type: text/plain; charset="UTF-8" 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, 24 Jul 2018 16:41:09 -0000 I've no idea what the actual intention was- CC'ing Allan Jude since I was not involved in any way in the original GSoC, I've just volunteered to try and get it in good enough shape to go into the tree. At initial glance of its usage, it seems to be a superset of the beadm functionality. I do know that it was originally called be(1) in the GSoC project, and I've renamed it to bectl(8) since: 1.) It's generally agreed that 'be' is too short of a name for something like this, 2.) It's not strictly compatible with beadm, and 3.) That seems to fit a naming scheme most similar to other similar utilities in base. On Tue, Jul 24, 2018 at 11:34 AM, Alan Somers wrote: > Ahh, that sounds like a good GSoC project. Is it intended to be fully > compatible with sysutils/beadm? If so, then it should probably retain the > same name. > > > On Tue, Jul 24, 2018 at 10:29 AM, Kyle Evans wrote: >> >> bectl is intending to be a C version of sysutils/beadm with the actual >> functional parts split out into libbe(3). >> >> On Tue, Jul 24, 2018 at 11:20 AM, Alan Somers wrote: >> > So what's the difference between bectl and sysutils/beadm? >> > >> > >> > On Tue, Jul 24, 2018 at 6:55 AM, Kyle Evans wrote: >> >> >> >> Author: kevans >> >> Date: Tue Jul 24 12:55:54 2018 >> >> New Revision: 336666 >> >> URL: https://svnweb.freebsd.org/changeset/base/336666 >> >> >> >> Log: >> >> Create a project branch for bectl(8) >> >> >> >> This will contain an import of libbe/be(1) by Kyle Kneitinger from >> >> GSoC >> >> '17, >> >> and further work will happen here until it's deemed ready for import >> >> to >> >> head. >> >> >> >> Discussed with: allanjude >> >> >> >> Added: >> >> - copied from r336665, head/ >> >> Directory Properties: >> >> projects/bectl/ (props changed) >> >> >> > > > From owner-svn-src-projects@freebsd.org Tue Jul 24 17:23:59 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 DEAE510517EE for ; Tue, 24 Jul 2018 17:23:59 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 36D467822D; Tue, 24 Jul 2018 17:23:58 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w6OHNtuM037402; Tue, 24 Jul 2018 10:23:55 -0700 (PDT) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w6OHNsNR037401; Tue, 24 Jul 2018 10:23:54 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201807241723.w6OHNsNR037401@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r336668 - in projects/bectl: lib/libbe sbin sbin/be share/mk In-Reply-To: To: Kyle Evans Date: Tue, 24 Jul 2018 10:23:54 -0700 (PDT) CC: "Rodney W. Grimes" , src-committers , svn-src-projects@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII 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, 24 Jul 2018 17:24:00 -0000 > On Tue, Jul 24, 2018 at 11:31 AM, Rodney W. Grimes > wrote: > >> Author: kevans > >> Date: Tue Jul 24 13:17:40 2018 > >> New Revision: 336668 > >> URL: https://svnweb.freebsd.org/changeset/base/336668 > >> > >> Log: > >> Import libbe(3)/be(1) from socsvn/soc2017/kneitinger/libbe-head > >> > >> Added: > >> projects/bectl/lib/libbe/ > >> projects/bectl/lib/libbe/Makefile (contents, props changed) > >> projects/bectl/lib/libbe/be.c (contents, props changed) > >> projects/bectl/lib/libbe/be.h (contents, props changed) > >> projects/bectl/lib/libbe/be_access.c (contents, props changed) > >> projects/bectl/lib/libbe/be_error.c (contents, props changed) > >> projects/bectl/lib/libbe/be_impl.h (contents, props changed) > >> projects/bectl/lib/libbe/be_info.c (contents, props changed) > >> projects/bectl/lib/libbe/libbe.3 (contents, props changed) > >> projects/bectl/sbin/be/ > >> projects/bectl/sbin/be/Makefile (contents, props changed) > >> projects/bectl/sbin/be/be.1 (contents, props changed) > >> projects/bectl/sbin/be/be.c (contents, props changed) > >> Modified: > >> projects/bectl/sbin/Makefile > >> projects/bectl/share/mk/src.libnames.mk > >> > >> Added: projects/bectl/lib/libbe/Makefile > >> ============================================================================== > >> --- /dev/null 00:00:00 1970 (empty, because file is newly added) > >> +++ projects/bectl/lib/libbe/Makefile Tue Jul 24 13:17:40 2018 (r336668) > >> @@ -0,0 +1,53 @@ > >> +# $FreeBSD$ > >> +# > >> +# Copyright (c) 2010 Hans Petter Selasky. All rights reserved. > >> +# > >> +# Redistribution and use in source and binary forms, with or without > > ... > > Makefile(s) generally do not have copyrights or license text. > > > > Hi, > > Right, right- I'll chop that off soon(-ish). Still working through a > plan of attack on this stuff. It's just imported from the GSoC repo > as-is in this commit. That would be great, just make sure you get Hans Petter Selasky approval before you do so. Thanks, -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-projects@freebsd.org Tue Jul 24 19:55:04 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 D56B7105482C for ; Tue, 24 Jul 2018 19:55:03 +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 8BE807D4ED; Tue, 24 Jul 2018 19:55:03 +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 69AF310311; Tue, 24 Jul 2018 19:55:03 +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 w6OJt3fi037635; Tue, 24 Jul 2018 19:55:03 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6OJt3EW037633; Tue, 24 Jul 2018 19:55:03 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807241955.w6OJt3EW037633@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 24 Jul 2018 19:55:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336684 - in projects/bectl: cddl/lib/libbe sbin/bectl X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in projects/bectl: cddl/lib/libbe sbin/bectl X-SVN-Commit-Revision: 336684 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, 24 Jul 2018 19:55:04 -0000 Author: kevans Date: Tue Jul 24 19:55:02 2018 New Revision: 336684 URL: https://svnweb.freebsd.org/changeset/base/336684 Log: Normalize bectl(8)/libbe(3) Makefiles, remove Makefile copyright/license Approved by: hselaskey Modified: projects/bectl/cddl/lib/libbe/Makefile projects/bectl/sbin/bectl/Makefile Modified: projects/bectl/cddl/lib/libbe/Makefile ============================================================================== --- projects/bectl/cddl/lib/libbe/Makefile Tue Jul 24 19:22:52 2018 (r336683) +++ projects/bectl/cddl/lib/libbe/Makefile Tue Jul 24 19:55:02 2018 (r336684) @@ -1,28 +1,4 @@ # $FreeBSD$ -# -# Copyright (c) 2010 Hans Petter Selasky. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# PACKAGE= lib${LIB} LIB= be Modified: projects/bectl/sbin/bectl/Makefile ============================================================================== --- projects/bectl/sbin/bectl/Makefile Tue Jul 24 19:22:52 2018 (r336683) +++ projects/bectl/sbin/bectl/Makefile Tue Jul 24 19:55:02 2018 (r336684) @@ -1,4 +1,4 @@ -# @(#)Makefile 8.1 (Berkeley) 6/6/93 +# $FreeBSD$ PROG= bectl WARNS?= 1 From owner-svn-src-projects@freebsd.org Wed Jul 25 01:04:51 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 8E1F510351C3 for ; Wed, 25 Jul 2018 01:04:51 +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 4143E88D0A; Wed, 25 Jul 2018 01:04:51 +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 227AE13559; Wed, 25 Jul 2018 01:04:51 +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 w6P14puP000590; Wed, 25 Jul 2018 01:04:51 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6P14pHm000589; Wed, 25 Jul 2018 01:04:51 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807250104.w6P14pHm000589@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 01:04:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336694 - projects/bectl/sbin/bectl X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: projects/bectl/sbin/bectl X-SVN-Commit-Revision: 336694 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 01:04:51 -0000 Author: kevans Date: Wed Jul 25 01:04:50 2018 New Revision: 336694 URL: https://svnweb.freebsd.org/changeset/base/336694 Log: bectl.c: Chase rename Modified: projects/bectl/sbin/bectl/bectl.c Modified: projects/bectl/sbin/bectl/bectl.c ============================================================================== --- projects/bectl/sbin/bectl/bectl.c Wed Jul 25 00:33:09 2018 (r336693) +++ projects/bectl/sbin/bectl/bectl.c Wed Jul 25 01:04:50 2018 (r336694) @@ -41,18 +41,18 @@ #include #include -static int be_cmd_activate(int argc, char *argv[]); -static int be_cmd_create(int argc, char *argv[]); -static int be_cmd_destroy(int argc, char *argv[]); -static int be_cmd_export(int argc, char *argv[]); -static int be_cmd_import(int argc, char *argv[]); -static int be_cmd_add(int argc, char *argv[]); -static int be_cmd_jail(int argc, char *argv[]); -static int be_cmd_list(int argc, char *argv[]); -static int be_cmd_mount(int argc, char *argv[]); -static int be_cmd_rename(int argc, char *argv[]); -static int be_cmd_unjail(int argc, char *argv[]); -static int be_cmd_unmount(int argc, char *argv[]); +static int bectl_cmd_activate(int argc, char *argv[]); +static int bectl_cmd_create(int argc, char *argv[]); +static int bectl_cmd_destroy(int argc, char *argv[]); +static int bectl_cmd_export(int argc, char *argv[]); +static int bectl_cmd_import(int argc, char *argv[]); +static int bectl_cmd_add(int argc, char *argv[]); +static int bectl_cmd_jail(int argc, char *argv[]); +static int bectl_cmd_list(int argc, char *argv[]); +static int bectl_cmd_mount(int argc, char *argv[]); +static int bectl_cmd_rename(int argc, char *argv[]); +static int bectl_cmd_unjail(int argc, char *argv[]); +static int bectl_cmd_unmount(int argc, char *argv[]); libbe_handle_t *be; @@ -62,20 +62,20 @@ usage(bool explicit) FILE *fp = explicit ? stdout : stderr; fprintf(fp, - "usage:\tbe ( -h | -? | subcommand [args...] )\n" - "\tbe activate [-t] beName\n" - "\tbe create [-e nonActiveBe | -e beName@snapshot] beName\n" - "\tbe create beName@snapshot\n" - "\tbe destroy [-F] beName | beName@snapshot⟩\n" - "\tbe export sourceBe\n" - "\tbe import targetBe\n" - "\tbe add (path)*\n" - "\tbe jail bootenv\n" - "\tbe list [-a] [-D] [-H] [-s]\n" - "\tbe mount beName [mountpoint]\n" - "\tbe rename origBeName newBeName\n" - "\tbe { ujail | unjail } ⟨jailID | jailName⟩ bootenv\n" - "\tbe { umount | unmount } [-f] beName\n"); + "usage:\tbectl ( -h | -? | subcommand [args...] )\n" + "\tbectl activate [-t] beName\n" + "\tbectl create [-e nonActiveBe | -e beName@snapshot] beName\n" + "\tbectl create beName@snapshot\n" + "\tbectl destroy [-F] beName | beName@snapshot⟩\n" + "\tbectl export sourceBe\n" + "\tbectl import targetBe\n" + "\tbectl add (path)*\n" + "\tbectl jail bootenv\n" + "\tbectl list [-a] [-D] [-H] [-s]\n" + "\tbectl mount beName [mountpoint]\n" + "\tbectl rename origBeName newBeName\n" + "\tbectl { ujail | unjail } ⟨jailID | jailName⟩ bootenv\n" + "\tbectl { umount | unmount } [-f] beName\n"); return (explicit ? 0 : EX_USAGE); } @@ -92,18 +92,18 @@ struct command_map_entry { static struct command_map_entry command_map[] = { - { "activate", be_cmd_activate }, - { "create", be_cmd_create }, - { "destroy", be_cmd_destroy }, - { "export", be_cmd_export }, - { "import", be_cmd_import }, - { "add", be_cmd_add }, - { "jail", be_cmd_jail }, - { "list", be_cmd_list }, - { "mount", be_cmd_mount }, - { "rename", be_cmd_rename }, - { "unjail", be_cmd_unjail }, - { "unmount", be_cmd_unmount }, + { "activate", bectl_cmd_activate }, + { "create", bectl_cmd_create }, + { "destroy", bectl_cmd_destroy }, + { "export", bectl_cmd_export }, + { "import", bectl_cmd_import }, + { "add", bectl_cmd_add }, + { "jail", bectl_cmd_jail }, + { "list", bectl_cmd_list }, + { "mount", bectl_cmd_mount }, + { "rename", bectl_cmd_rename }, + { "unjail", bectl_cmd_unjail }, + { "unmount", bectl_cmd_unmount }, }; static int @@ -123,7 +123,7 @@ get_cmd_index(char *cmd, int *index) static int -be_cmd_activate(int argc, char *argv[]) +bectl_cmd_activate(int argc, char *argv[]) { int err, opt; bool temp; @@ -171,7 +171,7 @@ be_cmd_activate(int argc, char *argv[]) // TODO: when only one arg is given, and it contains an "@" the this should // create that snapshot static int -be_cmd_create(int argc, char *argv[]) +bectl_cmd_create(int argc, char *argv[]) { int err, opt; char *snapname; @@ -244,7 +244,7 @@ be_cmd_create(int argc, char *argv[]) static int -be_cmd_export(int argc, char *argv[]) +bectl_cmd_export(int argc, char *argv[]) { int opt; char *bootenv; @@ -274,7 +274,7 @@ be_cmd_export(int argc, char *argv[]) static int -be_cmd_import(int argc, char *argv[]) +bectl_cmd_import(int argc, char *argv[]) { char *bootenv; int err; @@ -305,7 +305,7 @@ be_cmd_import(int argc, char *argv[]) static int -be_cmd_add(int argc, char *argv[]) +bectl_cmd_add(int argc, char *argv[]) { char *bootenv; @@ -325,7 +325,7 @@ be_cmd_add(int argc, char *argv[]) static int -be_cmd_destroy(int argc, char *argv[]) +bectl_cmd_destroy(int argc, char *argv[]) { int opt, err; bool force; @@ -361,7 +361,7 @@ be_cmd_destroy(int argc, char *argv[]) static int -be_cmd_jail(int argc, char *argv[]) +bectl_cmd_jail(int argc, char *argv[]) { char *bootenv; char mnt_loc[BE_MAXPATHLEN]; @@ -417,7 +417,7 @@ be_cmd_jail(int argc, char *argv[]) static int -be_cmd_list(int argc, char *argv[]) +bectl_cmd_list(int argc, char *argv[]) { int opt; bool show_all_datasets, show_space, hide_headers, show_snaps; @@ -460,7 +460,7 @@ be_cmd_list(int argc, char *argv[]) static int -be_cmd_mount(int argc, char *argv[]) +bectl_cmd_mount(int argc, char *argv[]) { int err; char result_loc[BE_MAXPATHLEN]; @@ -499,7 +499,7 @@ be_cmd_mount(int argc, char *argv[]) static int -be_cmd_rename(int argc, char *argv[]) +bectl_cmd_rename(int argc, char *argv[]) { char *src; char *dest; @@ -533,7 +533,7 @@ be_cmd_rename(int argc, char *argv[]) static int -be_cmd_unjail(int argc, char *argv[]) +bectl_cmd_unjail(int argc, char *argv[]) { int opt; char *cmd, *target; @@ -572,7 +572,7 @@ be_cmd_unjail(int argc, char *argv[]) static int -be_cmd_unmount(int argc, char *argv[]) +bectl_cmd_unmount(int argc, char *argv[]) { int err, flags, opt; char *cmd, *bootenv; From owner-svn-src-projects@freebsd.org Wed Jul 25 03:08:12 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 9DAB5103BF17 for ; Wed, 25 Jul 2018 03:08:12 +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 441348BF35; Wed, 25 Jul 2018 03:08:12 +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 20135148DA; Wed, 25 Jul 2018 03:08:12 +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 w6P38BPE063671; Wed, 25 Jul 2018 03:08:11 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6P38Bub063668; Wed, 25 Jul 2018 03:08:11 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807250308.w6P38Bub063668@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 03:08:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336696 - 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: 336696 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 03:08:12 -0000 Author: kevans Date: Wed Jul 25 03:08:11 2018 New Revision: 336696 URL: https://svnweb.freebsd.org/changeset/base/336696 Log: libbe(3): Disambiguate 'active' a little bit, add 'bootfs' - Rename 'active' to 'rootfs', which is used in other places to describe the currently booted (or about to be booted) BE. - Add 'bootfs', which indicates the next boot environment to be booted. This is pulled from the BOOTFS zpool property. - Go ahead and keep an open handle to the active zpool. We might need to enumerate datasets, get properties, and set properties (e.g. bootfs) throughout other libbe bits, and a single handle isn't overly expensive. Modified: projects/bectl/lib/libbe/be.c projects/bectl/lib/libbe/be_impl.h projects/bectl/lib/libbe/be_info.c Modified: projects/bectl/lib/libbe/be.c ============================================================================== --- projects/bectl/lib/libbe/be.c Wed Jul 25 02:36:55 2018 (r336695) +++ projects/bectl/lib/libbe/be.c Wed Jul 25 03:08:11 2018 (r336696) @@ -52,63 +52,82 @@ libbe_init(void) struct stat sb; dev_t root_dev, boot_dev; libbe_handle_t *lbh; - char *pos; + char *poolname, *pos; + int pnamelen; - // TODO: use errno here?? - + lbh = NULL; + poolname = pos = NULL; + pnamelen = 0; /* Verify that /boot and / are mounted on the same filesystem */ - if (stat("/", &sb) != 0) { - return (NULL); - } + /* TODO: use errno here?? */ + if (stat("/", &sb) != 0) + goto err; root_dev = sb.st_dev; - if (stat("/boot", &sb) != 0) { - return (NULL); - } + if (stat("/boot", &sb) != 0) + goto err; boot_dev = sb.st_dev; if (root_dev != boot_dev) { fprintf(stderr, "/ and /boot not on same device, quitting\n"); - return (NULL); + goto err; } - if ((lbh = calloc(1, sizeof(libbe_handle_t))) == NULL) { - return (NULL); - } + if ((lbh = calloc(1, sizeof(libbe_handle_t))) == NULL) + goto err; - if ((lbh->lzh = libzfs_init()) == NULL) { - free(lbh); - return (NULL); - } + if ((lbh->lzh = libzfs_init()) == NULL) + goto err; - /* Obtain path to active boot environment */ - if ((kenv(KENV_GET, "zfs_be_active", lbh->active, - BE_MAXPATHLEN)) == -1) { - libzfs_fini(lbh->lzh); - free(lbh); - return (NULL); - } + /* Obtain path to boot environment root */ + if ((kenv(KENV_GET, "zfs_be_root", lbh->root, BE_MAXPATHLEN)) == -1) + goto err; /* Remove leading 'zfs:' if present, otherwise use value as-is */ - if ((pos = strrchr(lbh->active, ':')) != NULL) { - strncpy(lbh->active, pos + sizeof(char), BE_MAXPATHLEN); - } + if (strcmp(lbh->root, "zfs:") == 0) + strncpy(lbh->root, strchr(lbh->root, ':') + sizeof(char), + BE_MAXPATHLEN); - /* Obtain path to boot environment root */ - if ((kenv(KENV_GET, "zfs_be_root", lbh->root, BE_MAXPATHLEN)) == -1) { - libzfs_fini(lbh->lzh); - free(lbh); - return (NULL); - } + if ((pos = strchr(lbh->root, '/')) == NULL) + goto err; + pnamelen = pos - lbh->root; + poolname = malloc(pnamelen + 1); + if (poolname == NULL) + goto err; + + strncpy(poolname, lbh->root, pnamelen); + poolname[pnamelen] = '\0'; + if ((lbh->active_phandle = zpool_open(lbh->lzh, poolname)) == NULL) + goto err; + + if (zpool_get_prop(lbh->active_phandle, ZPOOL_PROP_BOOTFS, lbh->bootfs, + BE_MAXPATHLEN, NULL, true) != 0) + goto err; + + /* Obtain path to boot environment rootfs (currently booted) */ + /* XXX Get dataset mounted at / by kenv/GUID from mountroot? */ + if ((kenv(KENV_GET, "zfs_be_active", lbh->rootfs, BE_MAXPATHLEN)) == -1) + goto err; + /* Remove leading 'zfs:' if present, otherwise use value as-is */ - if ((pos = strrchr(lbh->root, ':')) != NULL) { - strncpy(lbh->root, pos + sizeof(char), BE_MAXPATHLEN); - } + if (strcmp(lbh->rootfs, "zfs:") == 0) + strncpy(lbh->rootfs, strchr(lbh->rootfs, ':') + sizeof(char), + BE_MAXPATHLEN); return (lbh); +err: + if (lbh != NULL) { + if (lbh->active_phandle != NULL) + zpool_close(lbh->active_phandle); + if (lbh->lzh != NULL) + libzfs_fini(lbh->lzh); + free(lbh); + } + free(poolname); + return (NULL); } @@ -118,6 +137,8 @@ libbe_init(void) void libbe_close(libbe_handle_t *lbh) { + if (lbh->active_phandle != NULL) + zpool_close(lbh->active_phandle); libzfs_fini(lbh->lzh); free(lbh); } @@ -148,7 +169,7 @@ be_destroy(libbe_handle_t *lbh, char *name, int option return (set_error(lbh, BE_ERR_NOENT)); } - if (strcmp(path, lbh->active) == 0) { + if (strcmp(path, lbh->rootfs) == 0) { return (set_error(lbh, BE_ERR_DESTROYACT)); } @@ -802,7 +823,6 @@ be_activate(libbe_handle_t *lbh, char *bootenv, bool t { char be_path[BE_MAXPATHLEN]; char buf[BE_MAXPATHLEN]; - zpool_handle_t *zph; uint64_t pool_guid; uint64_t vdev_guid; int zfs_fd; @@ -852,17 +872,7 @@ be_activate(libbe_handle_t *lbh, char *bootenv, bool t return (BE_ERR_SUCCESS); } else { /* Obtain bootenv zpool */ - strncpy(buf, be_path, BE_MAXPATHLEN); - *(strchr(buf, '/')) = '\0'; - - if ((zph = zpool_open(lbh->lzh, buf)) == NULL) { - // TODO: create error for this - return (-1); - } - printf("asdf\n"); - - err = zpool_set_prop(zph, "bootfs", be_path); - zpool_close(zph); + err = zpool_set_prop(lbh->active_phandle, "bootfs", be_path); switch (err) { case 0: Modified: projects/bectl/lib/libbe/be_impl.h ============================================================================== --- projects/bectl/lib/libbe/be_impl.h Wed Jul 25 02:36:55 2018 (r336695) +++ projects/bectl/lib/libbe/be_impl.h Wed Jul 25 03:08:11 2018 (r336696) @@ -36,8 +36,10 @@ struct libbe_handle { libzfs_handle_t *lzh; + zpool_handle_t *active_phandle; char root[BE_MAXPATHLEN]; - char active[BE_MAXPATHLEN]; + char rootfs[BE_MAXPATHLEN]; + char bootfs[BE_MAXPATHLEN]; be_error_t error; bool print_on_err; }; Modified: projects/bectl/lib/libbe/be_info.c ============================================================================== --- projects/bectl/lib/libbe/be_info.c Wed Jul 25 02:36:55 2018 (r336695) +++ projects/bectl/lib/libbe/be_info.c Wed Jul 25 03:08:11 2018 (r336696) @@ -43,7 +43,7 @@ static int prop_list_builder(prop_data_t *); const char * be_active_name(libbe_handle_t *lbh) { - return (strrchr(lbh->active, '/') + sizeof(char)); + return (strrchr(lbh->rootfs, '/') + sizeof(char)); } @@ -53,7 +53,7 @@ be_active_name(libbe_handle_t *lbh) const char * be_active_path(libbe_handle_t *lbh) { - return (lbh->active); + return (lbh->rootfs); } From owner-svn-src-projects@freebsd.org Wed Jul 25 03:10: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 3DB4C103BF79 for ; Wed, 25 Jul 2018 03:10:56 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DA1E08C0B7; Wed, 25 Jul 2018 03:10:55 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id 7C5BA191D5; Wed, 25 Jul 2018 03:10:55 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-lf1-f43.google.com with SMTP id f18-v6so4380852lfc.2; Tue, 24 Jul 2018 20:10:55 -0700 (PDT) X-Gm-Message-State: AOUpUlHqhhOXOJ4Pi4fobVnmHfTxOkY3IGr7ze2Jpud/X3QuauLjQwiz tUjdQ76c99zNSZdw4sDYu/4vf007WGjiKDU6tDY= X-Google-Smtp-Source: AAOMgpdVmSs1JhabGyf5HO6ckuzYcxYfT/8+Y8ph/qx8WBrloOBKlXqsAs+KE64Jdw8Ro+XHRWNTQ/H9XlQFan1Hsyw= X-Received: by 2002:a19:7b08:: with SMTP id w8-v6mr2606403lfc.22.1532488253689; Tue, 24 Jul 2018 20:10:53 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:5742:0:0:0:0:0 with HTTP; Tue, 24 Jul 2018 20:10:33 -0700 (PDT) In-Reply-To: <201807250308.w6P38Bub063668@repo.freebsd.org> References: <201807250308.w6P38Bub063668@repo.freebsd.org> From: Kyle Evans Date: Tue, 24 Jul 2018 22:10:33 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r336696 - projects/bectl/lib/libbe To: Kyle Evans Cc: src-committers , svn-src-projects@freebsd.org Content-Type: text/plain; charset="UTF-8" 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 03:10:56 -0000 On Tue, Jul 24, 2018 at 10:08 PM, Kyle Evans wrote: > Author: kevans > Date: Wed Jul 25 03:08:11 2018 > New Revision: 336696 > URL: https://svnweb.freebsd.org/changeset/base/336696 > > Log: > libbe(3): Disambiguate 'active' a little bit, add 'bootfs' > > - Rename 'active' to 'rootfs', which is used in other places to describe the > currently booted (or about to be booted) BE. > > - Add 'bootfs', which indicates the next boot environment to be booted. This > is pulled from the BOOTFS zpool property. > > - Go ahead and keep an open handle to the active zpool. We might need to > enumerate datasets, get properties, and set properties (e.g. bootfs) > throughout other libbe bits, and a single handle isn't overly expensive. Subtract "enumerate datasets" from that list... that doesn't require a zpool handle. This does reduce redundancy in pulling out pool names to exactly one place we do this, and we'll clean this stuff up more later. From owner-svn-src-projects@freebsd.org Wed Jul 25 03:30: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 63260103C77E for ; Wed, 25 Jul 2018 03:30: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 161EB8CD51; Wed, 25 Jul 2018 03:30: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 EB76014C3E; Wed, 25 Jul 2018 03:30: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 w6P3U1p5074117; Wed, 25 Jul 2018 03:30:01 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6P3U1Wi074116; Wed, 25 Jul 2018 03:30:01 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807250330.w6P3U1Wi074116@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 03:30:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336699 - 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: 336699 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 03:30:02 -0000 Author: kevans Date: Wed Jul 25 03:30:01 2018 New Revision: 336699 URL: https://svnweb.freebsd.org/changeset/base/336699 Log: libbe(3): Find rootfs instead by enumerating child datasets of BE root This makes us more resilient to a rename of the bootfs, but still wouldn't withstand pool renames or guid renames. More importantly, this allows `bectl create ` work out of the box to create a boot environment based on the currently booted one. Modified: projects/bectl/lib/libbe/be.c Modified: projects/bectl/lib/libbe/be.c ============================================================================== --- projects/bectl/lib/libbe/be.c Wed Jul 25 03:29:29 2018 (r336698) +++ projects/bectl/lib/libbe/be.c Wed Jul 25 03:30:01 2018 (r336699) @@ -42,22 +42,46 @@ #include "be_impl.h" /* + * Iterator function for locating the rootfs amongst the children of the + * zfs_be_root set by loader(8). data is expected to be a libbe_handle_t *. + */ +static int +be_locate_rootfs(zfs_handle_t *chkds, void *data) +{ + libbe_handle_t *lbh; + char *mntpoint; + + lbh = (libbe_handle_t *)data; + if (lbh == NULL) + return (1); + + if (zfs_is_mounted(chkds, &mntpoint) && strcmp(mntpoint, "/") == 0) { + strncpy(lbh->rootfs, zfs_get_name(chkds), BE_MAXPATHLEN); + return (1); + } + + return (0); +} + +/* * Initializes the libbe context to operate in the root boot environment * dataset, for example, zroot/ROOT. */ libbe_handle_t * libbe_init(void) { - char buf[BE_MAXPATHLEN]; struct stat sb; dev_t root_dev, boot_dev; libbe_handle_t *lbh; + zfs_handle_t *rootds; char *poolname, *pos; int pnamelen; lbh = NULL; poolname = pos = NULL; pnamelen = 0; + rootds = NULL; + /* Verify that /boot and / are mounted on the same filesystem */ /* TODO: use errno here?? */ if (stat("/", &sb) != 0) @@ -109,13 +133,11 @@ libbe_init(void) /* Obtain path to boot environment rootfs (currently booted) */ /* XXX Get dataset mounted at / by kenv/GUID from mountroot? */ - if ((kenv(KENV_GET, "zfs_be_active", lbh->rootfs, BE_MAXPATHLEN)) == -1) + if ((rootds = zfs_open(lbh->lzh, lbh->root, ZFS_TYPE_DATASET)) == NULL) goto err; - /* Remove leading 'zfs:' if present, otherwise use value as-is */ - if (strcmp(lbh->rootfs, "zfs:") == 0) - strncpy(lbh->rootfs, strchr(lbh->rootfs, ':') + sizeof(char), - BE_MAXPATHLEN); + zfs_iter_filesystems(rootds, be_locate_rootfs, lbh); + zfs_close(rootds); return (lbh); err: @@ -126,6 +148,8 @@ err: libzfs_fini(lbh->lzh); free(lbh); } + if (rootds != NULL) + zfs_close(rootds); free(poolname); return (NULL); } From owner-svn-src-projects@freebsd.org Wed Jul 25 03:50:03 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 E28E7103D012 for ; Wed, 25 Jul 2018 03:50: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 97BEE8DAD1; Wed, 25 Jul 2018 03:50: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 7896414FA3; Wed, 25 Jul 2018 03:50:02 +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 w6P3o2fL085013; Wed, 25 Jul 2018 03:50:02 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6P3o1e1085009; Wed, 25 Jul 2018 03:50:01 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807250350.w6P3o1e1085009@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 03:50:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336701 - 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: 336701 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 03:50:03 -0000 Author: kevans Date: Wed Jul 25 03:50:01 2018 New Revision: 336701 URL: https://svnweb.freebsd.org/changeset/base/336701 Log: libbe(3): make style consistent with what I'll use going forward Modified: projects/bectl/lib/libbe/be.c projects/bectl/lib/libbe/be_access.c projects/bectl/lib/libbe/be_error.c projects/bectl/lib/libbe/be_info.c Modified: projects/bectl/lib/libbe/be.c ============================================================================== --- projects/bectl/lib/libbe/be.c Wed Jul 25 03:42:07 2018 (r336700) +++ projects/bectl/lib/libbe/be.c Wed Jul 25 03:50:01 2018 (r336701) @@ -161,6 +161,7 @@ err: void libbe_close(libbe_handle_t *lbh) { + if (lbh->active_phandle != NULL) zpool_close(lbh->active_phandle); libzfs_fini(lbh->lzh); @@ -179,30 +180,27 @@ be_destroy(libbe_handle_t *lbh, char *name, int option { zfs_handle_t *fs; char path[BE_MAXPATHLEN]; - char *p = path; - int mounted; - int force = options & BE_DESTROY_FORCE; + char *p; + int err, force, mounted; - int err = BE_ERR_SUCCESS; + p = path; + force = options & BE_DESTROY_FORCE; + err = BE_ERR_SUCCESS; be_root_concat(lbh, name, path); - printf("path: %s\n", path); if (strchr(name, '@') == NULL) { - if (!zfs_dataset_exists(lbh->lzh, path, ZFS_TYPE_FILESYSTEM)) { + if (!zfs_dataset_exists(lbh->lzh, path, ZFS_TYPE_FILESYSTEM)) return (set_error(lbh, BE_ERR_NOENT)); - } - if (strcmp(path, lbh->rootfs) == 0) { + if (strcmp(path, lbh->rootfs) == 0) return (set_error(lbh, BE_ERR_DESTROYACT)); - } fs = zfs_open(lbh->lzh, p, ZFS_TYPE_FILESYSTEM); } else { - if (!zfs_dataset_exists(lbh->lzh, path, ZFS_TYPE_SNAPSHOT)) { + if (!zfs_dataset_exists(lbh->lzh, path, ZFS_TYPE_SNAPSHOT)) return (set_error(lbh, BE_ERR_NOENT)); - } fs = zfs_open(lbh->lzh, p, ZFS_TYPE_SNAPSHOT); } @@ -212,19 +210,17 @@ be_destroy(libbe_handle_t *lbh, char *name, int option /* Check if mounted, unmount if force is specified */ if (mounted = zfs_is_mounted(fs, NULL)) { - if (force) { + if (force) zfs_unmount(fs, NULL, 0); - } else { + else return (set_error(lbh, BE_ERR_DESTROYMNT)); - } } - // TODO: convert this to use zfs_iter_children first for deep bes - // XXX note: errno 16 (device busy) occurs when chilren are present - if ((err = zfs_destroy(fs, false)) != 0) { + /* XXX TODO: convert this to use zfs_iter_children first for deep BEs */ + /* XXX Note: errno 16 (device busy) occurs when chilren are present */ + if ((err = zfs_destroy(fs, false)) != 0) fprintf(stderr, "delete failed errno: %d\n", errno); - } return (err); } @@ -240,25 +236,22 @@ be_snapshot(libbe_handle_t *lbh, char *source, char *s be_root_concat(lbh, source, buf); - if (!be_exists(lbh, buf)) { + if (!be_exists(lbh, buf)) return (BE_ERR_NOENT); - } if (snap_name != NULL) { strcat(buf, "@"); strcat(buf, snap_name); - if (result != NULL) { + if (result != NULL) snprintf(result, BE_MAXPATHLEN, "%s@%s", source, snap_name); - } } else { time(&rawtime); len = strlen(buf); strftime(buf + len, BE_MAXPATHLEN - len, "@%F-%T", localtime(&rawtime)); - if (result != NULL) { + if (result != NULL) strcpy(result, strrchr(buf, '/') + 1); - } } if (err = zfs_snapshot(lbh->lzh, buf, recursive, NULL) != 0) { @@ -267,7 +260,7 @@ be_snapshot(libbe_handle_t *lbh, char *source, char *s return (set_error(lbh, BE_ERR_INVALIDNAME)); default: - // TODO: elaborate return codes + /* XXX TODO: elaborate return codes */ return (set_error(lbh, BE_ERR_UNKNOWN)); } } @@ -294,11 +287,12 @@ static int be_deep_clone_prop(int prop, void *cb) { int err; - struct libbe_dccb *dccb = cb; + struct libbe_dccb *dccb; zprop_source_t src; char pval[BE_MAXPATHLEN]; char source[BE_MAXPATHLEN]; + dccb = cb; /* Skip some properties we don't want to touch */ switch (prop) { case ZFS_PROP_CANMOUNT: @@ -307,19 +301,17 @@ be_deep_clone_prop(int prop, void *cb) } /* Don't copy readonly properties */ - if (zfs_prop_readonly(prop)) { + if (zfs_prop_readonly(prop)) return (ZPROP_CONT); - } if ((err = zfs_prop_get(dccb->zhp, prop, (char *)&pval, - sizeof(pval), &src, (char *)&source, sizeof(source), false))) { + sizeof(pval), &src, (char *)&source, sizeof(source), false))) /* Just continue if we fail to read a property */ return (ZPROP_CONT); - } + /* Only copy locally defined properties */ - if (src != ZPROP_SRC_LOCAL) { + if (src != ZPROP_SRC_LOCAL) return (ZPROP_CONT); - } nvlist_add_string(dccb->props, zfs_prop_to_name(prop), (char *)pval); @@ -337,30 +329,28 @@ be_deep_clone(zfs_handle_t *ds, void *data) char *dsname; zfs_handle_t *snap_hdl; nvlist_t *props; - struct libbe_deep_clone sdc; - struct libbe_deep_clone *isdc = (struct libbe_deep_clone *)data; + struct libbe_deep_clone *isdc, sdc; struct libbe_dccb dccb; + isdc = (struct libbe_deep_clone *)data; dspath = zfs_get_name(ds); - if ((dsname = strrchr(dspath, '/')) == NULL) { + if ((dsname = strrchr(dspath, '/')) == NULL) return (BE_ERR_UNKNOWN); - } dsname++; - if (isdc->bename == NULL) { + + if (isdc->bename == NULL) snprintf(be_path, sizeof(be_path), "%s/%s", isdc->be_root, dsname); - } else { + else snprintf(be_path, sizeof(be_path), "%s/%s", isdc->be_root, isdc->bename); - } + snprintf(snap_path, sizeof(snap_path), "%s@%s", dspath, isdc->snapname); - if (zfs_dataset_exists(isdc->lbh->lzh, be_path, ZFS_TYPE_DATASET)) { + if (zfs_dataset_exists(isdc->lbh->lzh, be_path, ZFS_TYPE_DATASET)) return (set_error(isdc->lbh, BE_ERR_EXISTS)); - } if ((snap_hdl = - zfs_open(isdc->lbh->lzh, snap_path, ZFS_TYPE_SNAPSHOT)) == NULL) { + zfs_open(isdc->lbh->lzh, snap_path, ZFS_TYPE_SNAPSHOT)) == NULL) return (set_error(isdc->lbh, BE_ERR_ZFSOPEN)); - } nvlist_alloc(&props, NV_UNIQUE_NAME, KM_SLEEP); nvlist_add_string(props, "canmount", "noauto"); @@ -368,9 +358,8 @@ be_deep_clone(zfs_handle_t *ds, void *data) dccb.zhp = ds; dccb.props = props; if (zprop_iter(be_deep_clone_prop, &dccb, B_FALSE, B_FALSE, - ZFS_TYPE_FILESYSTEM) == ZPROP_INVAL) { + ZFS_TYPE_FILESYSTEM) == ZPROP_INVAL) return (-1); - } if (err = zfs_clone(snap_hdl, be_path, props)) { switch (err) { @@ -409,27 +398,21 @@ be_create_from_existing_snap(libbe_handle_t *lbh, char zfs_handle_t *parent_hdl; struct libbe_deep_clone sdc; - if (err = be_validate_name(lbh, name)) { + if (err = be_validate_name(lbh, name)) return (set_error(lbh, err)); - } - - if (err = be_root_concat(lbh, snap, snap_path)) { + if (err = be_root_concat(lbh, snap, snap_path)) return (set_error(lbh, err)); - } - - if (err = be_validate_snap(lbh, snap_path)) { + if (err = be_validate_snap(lbh, snap_path)) return (set_error(lbh, err)); - } - if (err = be_root_concat(lbh, name, be_path)) { + if (err = be_root_concat(lbh, name, be_path)) return (set_error(lbh, err)); - } - if ((bename = strrchr(name, '/')) == NULL) { + if ((bename = strrchr(name, '/')) == NULL) bename = name; - } else { + else bename++; - } + if ((parentname = strdup(snap_path)) == NULL) { err = BE_ERR_UNKNOWN; return (set_error(lbh, err)); @@ -463,9 +446,8 @@ be_create_from_existing(libbe_handle_t *lbh, char *nam int err; char buf[BE_MAXPATHLEN]; - if ((err = be_snapshot(lbh, old, NULL, true, (char *)&buf))) { + if ((err = be_snapshot(lbh, old, NULL, true, (char *)&buf))) return (set_error(lbh, err)); - } err = be_create_from_existing_snap(lbh, name, (char *)buf); @@ -487,38 +469,30 @@ be_validate_snap(libbe_handle_t *lbh, char *snap_name) char *mountpoint; int err = BE_ERR_SUCCESS; - if (strlen(snap_name) >= BE_MAXPATHLEN) { + if (strlen(snap_name) >= BE_MAXPATHLEN) return (BE_ERR_PATHLEN); - } if (!zfs_dataset_exists(lbh->lzh, snap_name, - ZFS_TYPE_SNAPSHOT)) { + ZFS_TYPE_SNAPSHOT)) return (BE_ERR_NOENT); - } strncpy(buf, snap_name, BE_MAXPATHLEN); /* Find the base filesystem of the snapshot */ - if ((delim_pos = strchr(buf, '@')) == NULL) { + if ((delim_pos = strchr(buf, '@')) == NULL) return (BE_ERR_INVALIDNAME); - } *delim_pos = '\0'; if ((zfs_hdl = - zfs_open(lbh->lzh, buf, ZFS_TYPE_DATASET)) == NULL) { + zfs_open(lbh->lzh, buf, ZFS_TYPE_DATASET)) == NULL) return (BE_ERR_NOORIGIN); - } - if (err = - zfs_prop_get(zfs_hdl, ZFS_PROP_MOUNTPOINT, buf, - BE_MAXPATHLEN, - NULL, NULL, 0, 1)) { + if (err = zfs_prop_get(zfs_hdl, ZFS_PROP_MOUNTPOINT, buf, BE_MAXPATHLEN, + NULL, NULL, 0, 1)) err = BE_ERR_INVORIGIN; - } - if ((err != 0) && (strncmp(buf, "/", BE_MAXPATHLEN) != 0)) { + if ((err != 0) && (strncmp(buf, "/", BE_MAXPATHLEN) != 0)) err = BE_ERR_INVORIGIN; - } zfs_close(zfs_hdl); @@ -544,13 +518,11 @@ be_root_concat(libbe_handle_t *lbh, char *name, char * /* Act idempotently; return be name if it is already a full path */ if (strrchr(name, '/') != NULL) { - if (strstr(name, lbh->root) != name) { + if (strstr(name, lbh->root) != name) return (BE_ERR_INVALIDNAME); - } - if (name_len >= BE_MAXPATHLEN) { + if (name_len >= BE_MAXPATHLEN) return (BE_ERR_PATHLEN); - } strncpy(result, name, BE_MAXPATHLEN); return (BE_ERR_SUCCESS); @@ -574,10 +546,8 @@ be_validate_name(libbe_handle_t *lbh, char *name) { for (int i = 0; *name; i++) { char c = *(name++); - if (isalnum(c) || (c == '-') || (c == '_') || - (c == '.')) { + if (isalnum(c) || (c == '-') || (c == '_') || (c == '.')) continue; - } return (BE_ERR_INVALIDNAME); } @@ -596,50 +566,42 @@ be_rename(libbe_handle_t *lbh, char *old, char *new) zfs_handle_t *zfs_hdl; int err; - - if (err = be_root_concat(lbh, old, full_old)) { + if (err = be_root_concat(lbh, old, full_old)) return (set_error(lbh, err)); - } - if (err = be_root_concat(lbh, new, full_new)) { + if (err = be_root_concat(lbh, new, full_new)) return (set_error(lbh, err)); - } - if (be_validate_name(lbh, new)) { + if (be_validate_name(lbh, new)) return (BE_ERR_UNKNOWN); - // TODO set and return correct error - } + /* XXX TODO set and return correct error */ - // check if old is active be - if (strcmp(full_new, be_active_path(lbh)) == 0) { + /* Check if old is active BE */ + if (strcmp(full_new, be_active_path(lbh)) == 0) return (BE_ERR_UNKNOWN); - // TODO set and return correct error - } + /* XXX TODO set and return correct error */ - if (!zfs_dataset_exists(lbh->lzh, full_old, ZFS_TYPE_DATASET)) { + if (!zfs_dataset_exists(lbh->lzh, full_old, ZFS_TYPE_DATASET)) return (BE_ERR_UNKNOWN); - // TODO set and return correct error - } + /* XXX TODO set and return correct error */ - if (zfs_dataset_exists(lbh->lzh, full_new, ZFS_TYPE_DATASET)) { + if (zfs_dataset_exists(lbh->lzh, full_new, ZFS_TYPE_DATASET)) return (BE_ERR_UNKNOWN); - // TODO set and return correct error - } + /* XXX TODO set and return correct error */ - // TODO: what about mounted bes? - // - if mounted error out unless a force flag is set? - - + /* XXX TODO + * - What about mounted BEs? + * - if mounted error out unless a force flag is set? + */ if ((zfs_hdl = zfs_open(lbh->lzh, full_old, - ZFS_TYPE_FILESYSTEM)) == NULL) { + ZFS_TYPE_FILESYSTEM)) == NULL) return (BE_ERR_UNKNOWN); - // TODO set and return correct error - } + /* XXX TODO set and return correct error */ - // recurse, nounmount, forceunmount + /* recurse, nounmount, forceunmount */ struct renameflags flags = { 0, 0, 0 }; - // TODO: error log on this call + /* XXX TODO: error log on this call */ err = zfs_rename(zfs_hdl, NULL, full_new, flags); zfs_close(zfs_hdl); @@ -656,16 +618,14 @@ be_export(libbe_handle_t *lbh, char *bootenv, int fd) zfs_handle_t *zfs; int err; - if (err = be_snapshot(lbh, bootenv, NULL, true, snap_name)) { - // TODO error handle + if (err = be_snapshot(lbh, bootenv, NULL, true, snap_name)) + /* XXX TODO error handle */ return (-1); - } be_root_concat(lbh, snap_name, buf); - if ((zfs = zfs_open(lbh->lzh, buf, ZFS_TYPE_DATASET)) == NULL) { + if ((zfs = zfs_open(lbh->lzh, buf, ZFS_TYPE_DATASET)) == NULL) return (BE_ERR_ZFSOPEN); - } err = zfs_send_one(zfs, NULL, fd, 0); return (err); @@ -681,32 +641,33 @@ be_import(libbe_handle_t *lbh, char *bootenv, int fd) zfs_handle_t *zfs; int err, len; - // TODO: this is a very likely name for someone to already have used - if (err = be_root_concat(lbh, "be_import_temp", buf)) { - // TODO error handle + /* + * XXX TODO: this is a very likely name for someone to already have + * used... we should avoid it. + */ + if (err = be_root_concat(lbh, "be_import_temp", buf)) + /* XXX TODO error handle */ return (-1); - } time(&rawtime); len = strlen(buf); strftime(buf + len, BE_MAXPATHLEN - len, "@%F-%T", localtime(&rawtime)); - - // lzc_receive(SNAPNAME, PROPS, ORIGIN, FORCE, fd)) { + /* lzc_receive(SNAPNAME, PROPS, ORIGIN, FORCE, fd)) { */ if (err = lzc_receive(buf, NULL, NULL, false, fd)) { /* TODO: go through libzfs_core's recv_impl and find returned * errors and set appropriate BE_ERR * edit: errors are not in libzfs_core, my assumption is * that they use libzfs errors - * note: 17 is err for dataset already existing */ + * note: 17 is err for dataset already existing + */ return (err); } - if ((zfs = zfs_open(lbh->lzh, buf, ZFS_TYPE_SNAPSHOT)) == NULL) { - // TODO correct error + if ((zfs = zfs_open(lbh->lzh, buf, ZFS_TYPE_SNAPSHOT)) == NULL) + /* XXX TODO correct error */ return (-1); - } nvlist_alloc(&props, NV_UNIQUE_NAME, KM_SLEEP); nvlist_add_string(props, "canmount", "noauto"); @@ -719,8 +680,7 @@ be_import(libbe_handle_t *lbh, char *bootenv, int fd) nvlist_free(props); - // TODO: recursively delete be_import_temp dataset - + /* XXX TODO: recursively delete be_import_temp dataset */ return (err); } @@ -736,10 +696,9 @@ be_add_child(libbe_handle_t *lbh, char *child_path, bo int err; /* Require absolute paths */ - if (*child_path != '/') { - /* TODO: create appropriate error */ + if (*child_path != '/') + /* XXX TODO: create appropriate error */ return (-1); - } strncpy(active, be_active_path(lbh), BE_MAXPATHLEN); strcpy(buf, active); @@ -761,83 +720,69 @@ be_add_child(libbe_handle_t *lbh, char *child_path, bo /* Path does not exist as a descendent of / yet */ int pos = strlen(active); - /* TODO: Verify that resulting str is less than BE_MAXPATHLEN */ + /* XXX TODO: Verify that resulting str is less than BE_MAXPATHLEN */ strncpy(&active[pos], child_path, BE_MAXPATHLEN-pos); - if (stat(child_path, &sb) != 0) { /* Verify that error is ENOENT */ - if (errno != 2) { - /* TODO: create appropriate error */ + if (errno != 2) + /* XXX TODO: create appropriate error */ return (-1); - } nvlist_alloc(&props, NV_UNIQUE_NAME, KM_SLEEP); nvlist_add_string(props, "canmount", "noauto"); nvlist_add_string(props, "mountpoint", child_path); - // create + /* Create */ if (err = - zfs_create(lbh->lzh, active, ZFS_TYPE_DATASET, props)) { - /* TODO handle error */ + zfs_create(lbh->lzh, active, ZFS_TYPE_DATASET, props)) + /* XXX TODO handle error */ return (-1); - } nvlist_free(props); if ((zfs = - zfs_open(lbh->lzh, active, ZFS_TYPE_DATASET)) == NULL) { - /* TODO handle error */ + zfs_open(lbh->lzh, active, ZFS_TYPE_DATASET)) == NULL) + /* XXX TODO handle error */ return (-1); - } - // set props - if (err = zfs_prop_set(zfs, "canmount", "noauto")) { + /* Set props */ + if (err = zfs_prop_set(zfs, "canmount", "noauto")) /* TODO handle error */ return (-1); - } } else if (cp_if_exists) { /* Path is already a descendent of / and should be copied */ + /* XXX TODO ? */ - - // TODO - /* * Establish if the existing path is a zfs dataset or just * the subdirectory of one */ - - // TODO: use mktemp + /* XXX TODO: use mktemp */ long int snap_name = random(); snprintf(buf, BE_MAXPATHLEN, "%s@%ld", child_path, snap_name); - if (err = zfs_snapshot(lbh->lzh, buf, false, NULL)) { - // TODO correct error + if (err = zfs_snapshot(lbh->lzh, buf, false, NULL)) + /* XXX TODO correct error */ return (-1); - } - // clone + /* Clone */ if ((zfs = - zfs_open(lbh->lzh, buf, ZFS_TYPE_SNAPSHOT)) == NULL) { - // TODO correct error + zfs_open(lbh->lzh, buf, ZFS_TYPE_SNAPSHOT)) == NULL) + /* XXX TODO correct error */ return (-1); - } - if (err = zfs_clone(zfs, active, NULL)) { - // TODO correct error + if (err = zfs_clone(zfs, active, NULL)) + /* XXX TODO correct error */ return (-1); - } - - // set props - } else { + /* set props */ + } else /* TODO: error code for exists, but not cp? */ return (-1); - } - return (BE_ERR_SUCCESS); } @@ -855,29 +800,26 @@ be_activate(libbe_handle_t *lbh, char *bootenv, bool t be_root_concat(lbh, bootenv, be_path); - /* Note: be_exists fails if mountpoint is not / */ - if (!be_exists(lbh, be_path)) { + if (!be_exists(lbh, be_path)) return (BE_ERR_NOENT); - } if (temporary) { - // TODO: give proper attribution to author(s) of zfsbootcfg - // for this snippet + /* + * XXX TODO: give proper attribution to author(s) of zfsbootcfg + * for this snippet. + */ if (kenv(KENV_GET, "vfs.zfs.boot.primary_pool", buf, - sizeof(buf)) <= 0) { + sizeof(buf)) <= 0) return (1); - } pool_guid = strtoumax(buf, NULL, 10); - if (pool_guid == 0) { + if (pool_guid == 0) return (1); - } if (kenv(KENV_GET, "vfs.zfs.boot.primary_vdev", buf, - sizeof(buf)) <= 0) { + sizeof(buf)) <= 0) return (1); - } vdev_guid = strtoumax(buf, NULL, 10); if (vdev_guid == 0) { return (1); @@ -903,7 +845,7 @@ be_activate(libbe_handle_t *lbh, char *bootenv, bool t return (BE_ERR_SUCCESS); default: - // TODO correct errors + /* XXX TODO correct errors */ return (-1); } } Modified: projects/bectl/lib/libbe/be_access.c ============================================================================== --- projects/bectl/lib/libbe/be_access.c Wed Jul 25 03:42:07 2018 (r336700) +++ projects/bectl/lib/libbe/be_access.c Wed Jul 25 03:50:01 2018 (r336701) @@ -43,41 +43,36 @@ be_mount(libbe_handle_t *lbh, char *bootenv, char *mou int mntflags; int err; - if (err = be_root_concat(lbh, bootenv, be)) { + if (err = be_root_concat(lbh, bootenv, be)) return (set_error(lbh, err)); - } - if (!be_exists(lbh, bootenv)) { + if (!be_exists(lbh, bootenv)) return (set_error(lbh, BE_ERR_NOENT)); - } - if (is_mounted(lbh->lzh, be, &path)) { + if (is_mounted(lbh->lzh, be, &path)) return (set_error(lbh, BE_ERR_MOUNTED)); - } - mntflags = (flags & BE_MNT_FORCE) ? MNT_FORCE : 0; /* Create mountpoint if it is not specified */ if (mountpoint == NULL) { strcpy(mnt_temp, "/tmp/be_mount.XXXX"); - if (mkdtemp(mnt_temp) == NULL) { - // TODO: create error for this + if (mkdtemp(mnt_temp) == NULL) + /* XXX TODO: create error for this */ return (set_error(lbh, BE_ERR_UNKNOWN)); - } } char opt = '\0'; if (err = zmount(be, (mountpoint == NULL) ? mnt_temp : mountpoint, - mntflags, MNTTYPE_ZFS, NULL, 0, &opt, 1)) { - // TODO: zmount returns the nmount error, look into what kind of - // errors we can report from that + mntflags, MNTTYPE_ZFS, NULL, 0, &opt, 1)) + /* + * XXX TODO: zmount returns the nmount error, look into what + * kind of errors we can report from that + */ return (set_error(lbh, BE_ERR_UNKNOWN)); - } - if (result_loc != NULL) { + if (result_loc != NULL) strcpy(result_loc, mountpoint == NULL ? mnt_temp : mountpoint); - } return (BE_ERR_SUCCESS); } @@ -95,21 +90,18 @@ be_unmount(libbe_handle_t *lbh, char *bootenv, int fla int mntsize; char *mntpath; - if (err = be_root_concat(lbh, bootenv, be)) { + if (err = be_root_concat(lbh, bootenv, be)) return (set_error(lbh, err)); - } - if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) { - // TODO correct error + if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) + /* XXX TODO correct error */ return (set_error(lbh, BE_ERR_NOMOUNT)); - } mntpath = NULL; for (int i = 0; i < mntsize; ++i) { /* 0x000000de is the type number of zfs */ - if (mntbuf[i].f_type != 0x000000de) { + if (mntbuf[i].f_type != 0x000000de) continue; - } if (strcmp(mntbuf[i].f_mntfromname, be) == 0) { mntpath = mntbuf[i].f_mntonname; @@ -117,16 +109,14 @@ be_unmount(libbe_handle_t *lbh, char *bootenv, int fla } } - if (mntpath == NULL) { + if (mntpath == NULL) return (set_error(lbh, BE_ERR_NOMOUNT)); - } mntflags = (flags & BE_MNT_FORCE) ? MNT_FORCE : 0; - if (err = unmount(mntpath, mntflags)) { - // TODO correct error + if (err = unmount(mntpath, mntflags)) + /* XXX TODO correct error */ return (set_error(lbh, BE_ERR_NOMOUNT)); - } return (set_error(lbh, BE_ERR_SUCCESS)); } Modified: projects/bectl/lib/libbe/be_error.c ============================================================================== --- projects/bectl/lib/libbe/be_error.c Wed Jul 25 03:42:07 2018 (r336700) +++ projects/bectl/lib/libbe/be_error.c Wed Jul 25 03:50:01 2018 (r336701) @@ -35,6 +35,7 @@ int libbe_errno(libbe_handle_t *lbh) { + return (lbh->error); } @@ -42,6 +43,7 @@ libbe_errno(libbe_handle_t *lbh) const char * libbe_error_description(libbe_handle_t *lbh) { + switch (lbh->error) { case BE_ERR_INVALIDNAME: return ("invalid boot environment name"); @@ -95,6 +97,7 @@ libbe_error_description(libbe_handle_t *lbh) void libbe_print_on_error(libbe_handle_t *lbh, bool val) { + lbh->print_on_err = val; libzfs_print_on_error(lbh->lzh, val); } @@ -103,13 +106,11 @@ libbe_print_on_error(libbe_handle_t *lbh, bool val) int set_error(libbe_handle_t *lbh, be_error_t err) { - // TODO: should the old error be overwritten or no? + /* XXX TODO: should the old error be overwritten or no? */ lbh->error = err; - - if (lbh->print_on_err && (err != BE_ERR_SUCCESS)) { + if (lbh->print_on_err && (err != BE_ERR_SUCCESS)) fprintf(stderr, "%s\n", libbe_error_description(lbh)); - } return (err); } Modified: projects/bectl/lib/libbe/be_info.c ============================================================================== --- projects/bectl/lib/libbe/be_info.c Wed Jul 25 03:42:07 2018 (r336700) +++ projects/bectl/lib/libbe/be_info.c Wed Jul 25 03:50:01 2018 (r336701) @@ -43,6 +43,7 @@ static int prop_list_builder(prop_data_t *); const char * be_active_name(libbe_handle_t *lbh) { + return (strrchr(lbh->rootfs, '/') + sizeof(char)); } @@ -53,6 +54,7 @@ be_active_name(libbe_handle_t *lbh) const char * be_active_path(libbe_handle_t *lbh) { + return (lbh->rootfs); } @@ -63,6 +65,7 @@ be_active_path(libbe_handle_t *lbh) const char * be_root_path(libbe_handle_t *lbh) { + return (lbh->root); } @@ -91,38 +94,33 @@ be_get_bootenv_props(libbe_handle_t *lbh) static int prop_list_builder_cb(zfs_handle_t *zfs_hdl, void *data_p) { - /* - * TODO: - * some system for defining constants for the nvlist keys - * error checking - */ - char buf[512]; prop_data_t *data; + libbe_handle_t *lbh; + nvlist_t *props; + const char *dataset, *name; boolean_t mounted, active, nextboot; - + /* + * XXX TODO: + * some system for defining constants for the nvlist keys + * error checking + */ data = (prop_data_t *)data_p; + lbh = data->lbh; - - nvlist_t *props; - - libbe_handle_t *lbh = data->lbh; - - nvlist_alloc(&props, NV_UNIQUE_NAME, KM_SLEEP); - const char *dataset = zfs_get_name(zfs_hdl); + dataset = zfs_get_name(zfs_hdl); nvlist_add_string(props, "dataset", dataset); - const char *name = strrchr(dataset, '/') + 1; + name = strrchr(dataset, '/') + 1; nvlist_add_string(props, "name", name); - mounted = zfs_prop_get_int(zfs_hdl, ZFS_PROP_MOUNTED); nvlist_add_boolean_value(props, "mounted", mounted); - // TODO: NOT CORRECT! Must use is_mounted + /* XXX TODO: NOT CORRECT! Must use is_mounted */ if (mounted) { zfs_prop_get(zfs_hdl, ZFS_PROP_MOUNTPOINT, buf, 512, NULL, NULL, 0, 1); @@ -130,44 +128,37 @@ prop_list_builder_cb(zfs_handle_t *zfs_hdl, void *data } if (zfs_prop_get(zfs_hdl, ZFS_PROP_ORIGIN, buf, 512, - NULL, NULL, 0, 1)) { + NULL, NULL, 0, 1)) nvlist_add_string(props, "origin", buf); - } if (zfs_prop_get(zfs_hdl, ZFS_PROP_CREATION, buf, 512, - NULL, NULL, 0, 1)) { + NULL, NULL, 0, 1)) nvlist_add_string(props, "creation", buf); - } nvlist_add_boolean_value(props, "active", (strcmp(be_active_path(lbh), dataset) == 0)); if (zfs_prop_get(zfs_hdl, ZFS_PROP_USED, buf, 512, - NULL, NULL, 0, 1)) { + NULL, NULL, 0, 1)) nvlist_add_string(props, "used", buf); - } if (zfs_prop_get(zfs_hdl, ZFS_PROP_USEDDS, buf, 512, - NULL, NULL, 0, 1)) { + NULL, NULL, 0, 1)) nvlist_add_string(props, "usedds", buf); - } if (zfs_prop_get(zfs_hdl, ZFS_PROP_USEDSNAP, buf, 512, - NULL, NULL, 0, 1)) { + NULL, NULL, 0, 1)) nvlist_add_string(props, "usedsnap", buf); - } if (zfs_prop_get(zfs_hdl, ZFS_PROP_USEDREFRESERV, buf, 512, - NULL, NULL, 0, 1)) { + NULL, NULL, 0, 1)) nvlist_add_string(props, "usedrefreserv", buf); - } if (zfs_prop_get(zfs_hdl, ZFS_PROP_REFERENCED, buf, 512, - NULL, NULL, 0, 1)) { + NULL, NULL, 0, 1)) nvlist_add_string(props, "referenced", buf); - } - /* TODO figure out how to read nextboot (set in libzfs_pool.c) */ + /* XXX TODO: Add bootfs info */ nvlist_add_nvlist(data->list, name, props); @@ -177,8 +168,8 @@ prop_list_builder_cb(zfs_handle_t *zfs_hdl, void *data /* * Updates the properties of each bootenv in the libbe handle - * TODO: rename to be_proplist_update - * TODO: ensure that this is always consistent (run after adds, deletes, + * XXX TODO: rename to be_proplist_update + * XXX TODO: ensure that this is always consistent (run after adds, deletes, * renames,etc */ static int @@ -186,19 +177,15 @@ prop_list_builder(prop_data_t *data) { zfs_handle_t *root_hdl; - if (nvlist_alloc(&(data->list), NV_UNIQUE_NAME, KM_SLEEP) != 0) { - /* TODO: actually handle error */ + 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) { + if ((root_hdl = zfs_open(data->lbh->lzh, data->lbh->root, + ZFS_TYPE_FILESYSTEM)) == NULL) return (BE_ERR_ZFSOPEN); - } - // TODO: some error checking here + /* XXX TODO: some error checking here */ zfs_iter_filesystems(root_hdl, prop_list_builder_cb, data); zfs_close(root_hdl); @@ -214,17 +201,15 @@ void be_prop_list_free(nvlist_t *be_list) { nvlist_t *prop_list; + nvpair_t *be_pair; - nvpair_t *be_pair = nvlist_next_nvpair(be_list, NULL); - - if (nvpair_value_nvlist(be_pair, &prop_list) == 0) { + be_pair = nvlist_next_nvpair(be_list, NULL); + if (nvpair_value_nvlist(be_pair, &prop_list) == 0) nvlist_free(prop_list); - } while ((be_pair = nvlist_next_nvpair(be_list, be_pair)) != NULL) { - if (nvpair_value_nvlist(be_pair, &prop_list) == 0) { + if (nvpair_value_nvlist(be_pair, &prop_list) == 0) nvlist_free(prop_list); - } } } @@ -239,7 +224,9 @@ be_exists(libbe_handle_t *lbh, char *be) be_root_concat(lbh, be, buf); - // TODO: check mountpoint prop and see if its /, AND that result with below - // expression + /* + * 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)); } From owner-svn-src-projects@freebsd.org Wed Jul 25 03:57:29 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 30026103D3F6 for ; Wed, 25 Jul 2018 03:57:29 +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 DAA5C8E035; Wed, 25 Jul 2018 03:57:28 +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 BCE5D1513B; Wed, 25 Jul 2018 03:57:28 +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 w6P3vSpu090297; Wed, 25 Jul 2018 03:57:28 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6P3vSGE090296; Wed, 25 Jul 2018 03:57:28 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807250357.w6P3vSGE090296@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 03:57:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336702 - projects/bectl/sbin/bectl X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: projects/bectl/sbin/bectl X-SVN-Commit-Revision: 336702 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 03:57:29 -0000 Author: kevans Date: Wed Jul 25 03:57:28 2018 New Revision: 336702 URL: https://svnweb.freebsd.org/changeset/base/336702 Log: bectl(8): Rename error messages Modified: projects/bectl/sbin/bectl/bectl.c Modified: projects/bectl/sbin/bectl/bectl.c ============================================================================== --- projects/bectl/sbin/bectl/bectl.c Wed Jul 25 03:50:01 2018 (r336701) +++ projects/bectl/sbin/bectl/bectl.c Wed Jul 25 03:57:28 2018 (r336702) @@ -136,7 +136,7 @@ bectl_cmd_activate(int argc, char *argv[]) temp = true; break; default: - fprintf(stderr, "be activate: unknown option '-%c'\n", + fprintf(stderr, "bectl activate: unknown option '-%c'\n", optopt); return (usage(false)); } @@ -146,7 +146,7 @@ bectl_cmd_activate(int argc, char *argv[]) argv += optind; if (argc != 1) { - fprintf(stderr, "be activate: wrong number of arguments\n"); + fprintf(stderr, "bectl activate: wrong number of arguments\n"); return (usage(false)); } @@ -185,7 +185,7 @@ bectl_cmd_create(int argc, char *argv[]) snapname = optarg; break; default: - fprintf(stderr, "be create: unknown option '-%c'\n", + fprintf(stderr, "bectl create: unknown option '-%c'\n", optopt); return (usage(false)); } @@ -195,13 +195,12 @@ bectl_cmd_create(int argc, char *argv[]) argv += optind; if (argc != 1) { - fprintf(stderr, "be create: wrong number of arguments\n"); + fprintf(stderr, "bectl create: wrong number of arguments\n"); return (usage(false)); } bootenv = *argv; - if (snapname != NULL) { if (strchr(snapname, '@') != NULL) { err = be_create_from_existing_snap(be, bootenv, @@ -251,19 +250,19 @@ bectl_cmd_export(int argc, char *argv[]) if (argc == 1) { - fprintf(stderr, "be export: missing boot environment name\n"); + fprintf(stderr, "bectl export: missing boot environment name\n"); return (usage(false)); } if (argc > 2) { - fprintf(stderr, "be export: extra arguments provided\n"); + fprintf(stderr, "bectl export: extra arguments provided\n"); return (usage(false)); } bootenv = argv[1]; if (isatty(STDOUT_FILENO)) { - fprintf(stderr, "be export: must redirect output\n"); + fprintf(stderr, "bectl export: must redirect output\n"); return (EX_USAGE); } @@ -281,20 +280,20 @@ bectl_cmd_import(int argc, char *argv[]) if (argc == 1) { - fprintf(stderr, "be import: missing boot environment name\n"); + fprintf(stderr, "bectl import: missing boot environment name\n"); return (usage(false)); } if (argc > 2) { - fprintf(stderr, "be import: extra arguments provided\n"); + fprintf(stderr, "bectl import: extra arguments provided\n"); return (usage(false)); } bootenv = argv[1]; if (isatty(STDIN_FILENO)) { - fprintf(stderr, "be import: input can not be from terminal\n"); + fprintf(stderr, "bectl import: input can not be from terminal\n"); return (EX_USAGE); } @@ -310,7 +309,7 @@ bectl_cmd_add(int argc, char *argv[]) char *bootenv; if (argc < 2) { - fprintf(stderr, "be add: must provide at least one path\n"); + fprintf(stderr, "bectl add: must provide at least one path\n"); return (usage(false)); } @@ -338,7 +337,7 @@ bectl_cmd_destroy(int argc, char *argv[]) force = true; break; default: - fprintf(stderr, "be destroy: unknown option '-%c'\n", + fprintf(stderr, "bectl destroy: unknown option '-%c'\n", optopt); return (usage(false)); } @@ -348,7 +347,7 @@ bectl_cmd_destroy(int argc, char *argv[]) argv += optind; if (argc != 1) { - fprintf(stderr, "be destroy: wrong number of arguments\n"); + fprintf(stderr, "bectl destroy: wrong number of arguments\n"); return (usage(false)); } @@ -371,11 +370,11 @@ bectl_cmd_jail(int argc, char *argv[]) //struct jail be_jail = { 0 }; if (argc == 1) { - fprintf(stderr, "be jail: missing boot environment name\n"); + fprintf(stderr, "bectl jail: missing boot environment name\n"); return (usage(false)); } if (argc > 2) { - fprintf(stderr, "be jail: too many arguments\n"); + fprintf(stderr, "bectl jail: too many arguments\n"); return (usage(false)); } @@ -440,7 +439,7 @@ bectl_cmd_list(int argc, char *argv[]) show_space = true; break; default: - fprintf(stderr, "be list: unknown option '-%c'\n", + fprintf(stderr, "bectl list: unknown option '-%c'\n", optopt); return (usage(false)); } @@ -449,7 +448,7 @@ bectl_cmd_list(int argc, char *argv[]) argc -= optind; if (argc != 0) { - fprintf(stderr, "be list: extra argument provided\n"); + fprintf(stderr, "bectl list: extra argument provided\n"); return (usage(false)); } @@ -468,12 +467,12 @@ bectl_cmd_mount(int argc, char *argv[]) char *mountpoint; if (argc < 2) { - fprintf(stderr, "be mount: missing argument(s)\n"); + fprintf(stderr, "bectl mount: missing argument(s)\n"); return (usage(false)); } if (argc > 3) { - fprintf(stderr, "be mount: too many arguments\n"); + fprintf(stderr, "bectl mount: too many arguments\n"); return (usage(false)); } @@ -506,12 +505,12 @@ bectl_cmd_rename(int argc, char *argv[]) int err; if (argc < 3) { - fprintf(stderr, "be rename: missing argument\n"); + fprintf(stderr, "bectl rename: missing argument\n"); return (usage(false)); } if (argc > 3) { - fprintf(stderr, "be rename: too many arguments\n"); + fprintf(stderr, "bectl rename: too many arguments\n"); return (usage(false)); } @@ -549,7 +548,7 @@ bectl_cmd_unjail(int argc, char *argv[]) force = true; break; default: - fprintf(stderr, "be %s: unknown option '-%c'\n", + fprintf(stderr, "bectl %s: unknown option '-%c'\n", cmd, optopt); return (usage(false)); } @@ -559,7 +558,7 @@ bectl_cmd_unjail(int argc, char *argv[]) argv += optind; if (argc != 1) { - fprintf(stderr, "be %s: wrong number of arguments\n", cmd); + fprintf(stderr, "bectl %s: wrong number of arguments\n", cmd); return (usage(false)); } @@ -587,7 +586,7 @@ bectl_cmd_unmount(int argc, char *argv[]) flags |= BE_MNT_FORCE; break; default: - fprintf(stderr, "be %s: unknown option '-%c'\n", + fprintf(stderr, "bectl %s: unknown option '-%c'\n", cmd, optopt); return (usage(false)); } @@ -597,7 +596,7 @@ bectl_cmd_unmount(int argc, char *argv[]) argv += optind; if (argc != 1) { - fprintf(stderr, "be %s: wrong number of arguments\n", cmd); + fprintf(stderr, "bectl %s: wrong number of arguments\n", cmd); return (usage(false)); } From owner-svn-src-projects@freebsd.org Wed Jul 25 04:06:10 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 A2692103D83A for ; Wed, 25 Jul 2018 04:06:10 +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 553708E4CA; Wed, 25 Jul 2018 04:06:10 +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 35F29152E8; Wed, 25 Jul 2018 04:06:10 +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 w6P46AHN095393; Wed, 25 Jul 2018 04:06:10 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6P46A6i095392; Wed, 25 Jul 2018 04:06:10 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807250406.w6P46A6i095392@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 04:06:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336703 - projects/bectl/sbin/bectl X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: projects/bectl/sbin/bectl X-SVN-Commit-Revision: 336703 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 04:06:10 -0000 Author: kevans Date: Wed Jul 25 04:06:09 2018 New Revision: 336703 URL: https://svnweb.freebsd.org/changeset/base/336703 Log: bectl(8): Consistent style Modified: projects/bectl/sbin/bectl/bectl.c Modified: projects/bectl/sbin/bectl/bectl.c ============================================================================== --- projects/bectl/sbin/bectl/bectl.c Wed Jul 25 03:57:28 2018 (r336702) +++ projects/bectl/sbin/bectl/bectl.c Wed Jul 25 04:06:09 2018 (r336703) @@ -59,8 +59,9 @@ libbe_handle_t *be; static int usage(bool explicit) { - FILE *fp = explicit ? stdout : stderr; + FILE *fp; + fp = explicit ? stdout : stderr; fprintf(fp, "usage:\tbectl ( -h | -? | subcommand [args...] )\n" "\tbectl activate [-t] beName\n" @@ -109,8 +110,9 @@ static struct command_map_entry command_map[] = static int get_cmd_index(char *cmd, int *index) { - int map_size = sizeof(command_map) / sizeof(struct command_map_entry); + int map_size; + map_size = nitems(command_map); for (int i = 0; i < map_size; ++i) { if (strcmp(cmd, command_map[i].command) == 0) { *index = i; @@ -125,9 +127,9 @@ get_cmd_index(char *cmd, int *index) static int bectl_cmd_activate(int argc, char *argv[]) { + char *bootenv; int err, opt; bool temp; - char *bootenv; temp = false; while ((opt = getopt(argc, argv, "t")) != -1) { @@ -152,31 +154,29 @@ bectl_cmd_activate(int argc, char *argv[]) /* activate logic goes here */ - if ((err = be_activate(be, argv[0], temp)) != 0) { - // TODO: more specific error msg based on err + if ((err = be_activate(be, argv[0], temp)) != 0) + /* XXX TODO: more specific error msg based on err */ printf("did not successfully activate boot environment %s\n", argv[0]); - } else { + else printf("successfully activated boot environment %s\n", argv[0]); - } - if (temp) { + if (temp) printf("for next boot\n"); - } return (err); } -// TODO: when only one arg is given, and it contains an "@" the this should -// create that snapshot +/* + * TODO: when only one arg is given, and it contains an "@" the this should + * create that snapshot + */ static int bectl_cmd_create(int argc, char *argv[]) { + char *bootenv, *snapname, *source; int err, opt; - char *snapname; - char *bootenv; - char *source; snapname = NULL; while ((opt = getopt(argc, argv, "e:")) != -1) { @@ -202,40 +202,36 @@ bectl_cmd_create(int argc, char *argv[]) bootenv = *argv; if (snapname != NULL) { - if (strchr(snapname, '@') != NULL) { + if (strchr(snapname, '@') != NULL) err = be_create_from_existing_snap(be, bootenv, snapname); - } else { + else err = be_create_from_existing(be, bootenv, snapname); - } } else { if ((snapname = strchr(bootenv, '@')) != NULL) { *(snapname++) = '\0'; if ((err = be_snapshot(be, (char *)be_active_path(be), - snapname, true, NULL)) != BE_ERR_SUCCESS) { + snapname, true, NULL)) != BE_ERR_SUCCESS) fprintf(stderr, "failed to create snapshot\n"); - } asprintf(&source, "%s@%s", be_active_path(be), snapname); err = be_create_from_existing_snap(be, bootenv, source); return (err); - } else { + } else err = be_create(be, bootenv); - } } switch (err) { case BE_ERR_SUCCESS: break; default: - if (snapname == NULL) { + if (snapname == NULL) fprintf(stderr, "failed to create bootenv %s\n", bootenv); - } else { + else fprintf(stderr, "failed to create bootenv %s from snapshot %s\n", bootenv, snapname); - } } return (err); @@ -245,10 +241,9 @@ bectl_cmd_create(int argc, char *argv[]) static int bectl_cmd_export(int argc, char *argv[]) { - int opt; char *bootenv; + int opt; - if (argc == 1) { fprintf(stderr, "bectl export: missing boot environment name\n"); return (usage(false)); @@ -278,13 +273,11 @@ bectl_cmd_import(int argc, char *argv[]) char *bootenv; int err; - if (argc == 1) { fprintf(stderr, "bectl import: missing boot environment name\n"); return (usage(false)); } - if (argc > 2) { fprintf(stderr, "bectl import: extra arguments provided\n"); return (usage(false)); @@ -315,7 +308,7 @@ bectl_cmd_add(int argc, char *argv[]) for (int i = 1; i < argc; ++i) { printf("arg %d: %s\n", i, argv[i]); - // TODO catch err + /* XXX TODO catch err */ be_add_child(be, argv[i], true); } @@ -326,9 +319,9 @@ bectl_cmd_add(int argc, char *argv[]) static int bectl_cmd_destroy(int argc, char *argv[]) { + char *target; int opt, err; bool force; - char *target; force = false; while ((opt = getopt(argc, argv, "F")) != -1) { @@ -367,7 +360,7 @@ bectl_cmd_jail(int argc, char *argv[]) char buf[BE_MAXPATHLEN*2]; int err, jid; - //struct jail be_jail = { 0 }; + /* struct jail be_jail = { 0 }; */ if (argc == 1) { fprintf(stderr, "bectl jail: missing boot environment name\n"); @@ -380,17 +373,23 @@ bectl_cmd_jail(int argc, char *argv[]) bootenv = argv[1]; - // TODO: if its already mounted, perhaps there should be a flag to - // indicate its okay to proceed?? - if ((err = be_mount(be, bootenv, NULL, 0, mnt_loc)) != BE_ERR_SUCCESS) { + /* + * XXX TODO: if its already mounted, perhaps there should be a flag to + * indicate its okay to proceed?? + */ + if ((err = be_mount(be, bootenv, NULL, 0, mnt_loc)) != BE_ERR_SUCCESS) fprintf(stderr, "could not mount bootenv\n"); - } - // NOTE: this is not quite functional: - // see https://github.com/vermaden/beadm/blob/master/HOWTO.htm on - // neccesary modifications to correctly boot the jail + /* + * NOTE: this is not quite functional: + * see https://github.com/vermaden/beadm/blob/master/HOWTO.htm on + * neccesary modifications to correctly boot the jail + */ - //snprintf(buf, BE_MAXPATHLEN*2, "jail %s %s %s /bin/sh /etc/rc", mnt_loc, bootenv, "192.168.1.123"); + /* + * snprintf(buf, BE_MAXPATHLEN*2, "jail %s %s %s /bin/sh /etc/rc", + * mnt_loc, bootenv, "192.168.1.123"); + */ snprintf(buf, BE_MAXPATHLEN*2, "jail %s %s %s /bin/sh", mnt_loc, bootenv, "192.168.1.123"); system(buf); @@ -418,10 +417,10 @@ bectl_cmd_jail(int argc, char *argv[]) static int bectl_cmd_list(int argc, char *argv[]) { - int opt; - bool show_all_datasets, show_space, hide_headers, show_snaps; char *bootenv; nvlist_t *props; + int opt; + bool show_all_datasets, show_space, hide_headers, show_snaps; show_all_datasets = show_space = hide_headers = show_snaps = false; while ((opt = getopt(argc, argv, "aDHs")) != -1) { @@ -452,8 +451,7 @@ bectl_cmd_list(int argc, char *argv[]) return (usage(false)); } - //props = be_get_bootenv_props(be); - + /* props = be_get_bootenv_props(be); */ return (0); } @@ -461,10 +459,9 @@ bectl_cmd_list(int argc, char *argv[]) static int bectl_cmd_mount(int argc, char *argv[]) { - int err; char result_loc[BE_MAXPATHLEN]; - char *bootenv; - char *mountpoint; + char *bootenv, *mountpoint; + int err; if (argc < 2) { fprintf(stderr, "bectl mount: missing argument(s)\n"); @@ -479,7 +476,6 @@ bectl_cmd_mount(int argc, char *argv[]) bootenv = argv[1]; mountpoint = ((argc == 3) ? argv[2] : NULL); - err = be_mount(be, bootenv, mountpoint, 0, result_loc); switch (err) { @@ -500,8 +496,7 @@ bectl_cmd_mount(int argc, char *argv[]) static int bectl_cmd_rename(int argc, char *argv[]) { - char *src; - char *dest; + char *dest, *src; int err; if (argc < 3) { @@ -534,8 +529,8 @@ bectl_cmd_rename(int argc, char *argv[]) static int bectl_cmd_unjail(int argc, char *argv[]) { - int opt; char *cmd, *target; + int opt; bool force; /* Store alias used */ @@ -565,7 +560,6 @@ bectl_cmd_unjail(int argc, char *argv[]) target = argv[0]; /* unjail logic goes here */ - return (0); } @@ -573,8 +567,8 @@ bectl_cmd_unjail(int argc, char *argv[]) static int bectl_cmd_unmount(int argc, char *argv[]) { + char *bootenv, *cmd; int err, flags, opt; - char *cmd, *bootenv; /* Store alias used */ cmd = argv[0]; @@ -629,17 +623,14 @@ main(int argc, char *argv[]) command = argv[1]; /* Handle command aliases */ - if (strcmp(command, "umount") == 0) { + if (strcmp(command, "umount") == 0) command = "unmount"; - } - if (strcmp(command, "ujail") == 0) { + if (strcmp(command, "ujail") == 0) command = "unjail"; - } - if ((strcmp(command, "-?") == 0) || (strcmp(command, "-h") == 0)) { + if ((strcmp(command, "-?") == 0) || (strcmp(command, "-h") == 0)) return (usage(true)); - } if (get_cmd_index(command, &command_index)) { fprintf(stderr, "unknown command: %s\n", command); @@ -647,17 +638,14 @@ main(int argc, char *argv[]) } - if ((be = libbe_init()) == NULL) { + if ((be = libbe_init()) == NULL) return (-1); - } libbe_print_on_error(be, true); - /* TODO: can be simplified if offset by 2 instead of one */ + /* XXX TODO: can be simplified if offset by 2 instead of one */ rc = command_map[command_index].fn(argc-1, argv+1); libbe_close(be); - - return (rc); } 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); } 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); From owner-svn-src-projects@freebsd.org Wed Jul 25 15:14:38 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 42B7E104D9F3 for ; Wed, 25 Jul 2018 15:14:38 +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 DCEB982108; Wed, 25 Jul 2018 15:14:37 +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 B91011BDE5; Wed, 25 Jul 2018 15:14:37 +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 w6PFEb9w037310; Wed, 25 Jul 2018 15:14:37 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6PFEZ4P037301; Wed, 25 Jul 2018 15:14:35 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807251514.w6PFEZ4P037301@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 15:14:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336710 - in projects/bectl: cddl/lib/libbe lib/libbe sbin/bectl X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in projects/bectl: cddl/lib/libbe lib/libbe sbin/bectl X-SVN-Commit-Revision: 336710 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 15:14:38 -0000 Author: kevans Date: Wed Jul 25 15:14:35 2018 New Revision: 336710 URL: https://svnweb.freebsd.org/changeset/base/336710 Log: libbe(3)/be(8): Drop WARNS overrides, fix all fallout Based on the idea that we shouldn't have all-new library and utility going into base that need WARNS=1... - Decent amount of constification - Lots of parentheses - Minor other nits Modified: projects/bectl/cddl/lib/libbe/Makefile projects/bectl/lib/libbe/be.c projects/bectl/lib/libbe/be.h projects/bectl/lib/libbe/be_access.c projects/bectl/lib/libbe/be_impl.h projects/bectl/lib/libbe/be_info.c projects/bectl/lib/libbe/libbe.3 projects/bectl/sbin/bectl/Makefile projects/bectl/sbin/bectl/bectl.c Modified: projects/bectl/cddl/lib/libbe/Makefile ============================================================================== --- projects/bectl/cddl/lib/libbe/Makefile Wed Jul 25 14:45:00 2018 (r336709) +++ projects/bectl/cddl/lib/libbe/Makefile Wed Jul 25 15:14:35 2018 (r336710) @@ -11,8 +11,6 @@ SRCS= be.c be_access.c be_error.c be_info.c INCS= be.h MAN= libbe.3 -WARNS?= 1 - LIBADD+= zfs LIBADD+= nvpair Modified: projects/bectl/lib/libbe/be.c ============================================================================== --- projects/bectl/lib/libbe/be.c Wed Jul 25 14:45:00 2018 (r336709) +++ projects/bectl/lib/libbe/be.c Wed Jul 25 15:14:35 2018 (r336710) @@ -139,7 +139,7 @@ libbe_init(void) zfs_iter_filesystems(rootds, be_locate_rootfs, lbh); zfs_close(rootds); rootds = NULL; - if (lbh->rootfs == NULL) + if (*lbh->rootfs == '\0') goto err; return (lbh); @@ -212,7 +212,7 @@ be_destroy(libbe_handle_t *lbh, char *name, int option return (set_error(lbh, BE_ERR_ZFSOPEN)); /* Check if mounted, unmount if force is specified */ - if (mounted = zfs_is_mounted(fs, NULL)) { + if ((mounted = zfs_is_mounted(fs, NULL)) != 0) { if (force) zfs_unmount(fs, NULL, 0); else @@ -230,7 +230,7 @@ be_destroy(libbe_handle_t *lbh, char *name, int option int -be_snapshot(libbe_handle_t *lbh, char *source, char *snap_name, +be_snapshot(libbe_handle_t *lbh, const char *source, const char *snap_name, bool recursive, char *result) { char buf[BE_MAXPATHLEN]; @@ -257,7 +257,7 @@ be_snapshot(libbe_handle_t *lbh, char *source, char *s strcpy(result, strrchr(buf, '/') + 1); } - if (err = zfs_snapshot(lbh->lzh, buf, recursive, NULL) != 0) { + if ((err = zfs_snapshot(lbh->lzh, buf, recursive, NULL)) != 0) { switch (err) { case EZFS_INVALIDNAME: return (set_error(lbh, BE_ERR_INVALIDNAME)); @@ -280,7 +280,7 @@ be_create(libbe_handle_t *lbh, char *name) { int err; - err = be_create_from_existing(lbh, name, (char *)be_active_path(lbh)); + err = be_create_from_existing(lbh, name, be_active_path(lbh)); return (set_error(lbh, err)); } @@ -327,7 +327,6 @@ be_deep_clone(zfs_handle_t *ds, void *data) int err; char be_path[BE_MAXPATHLEN]; char snap_path[BE_MAXPATHLEN]; - char mp[BE_MAXPATHLEN]; const char *dspath; char *dsname; zfs_handle_t *snap_hdl; @@ -364,7 +363,7 @@ be_deep_clone(zfs_handle_t *ds, void *data) ZFS_TYPE_FILESYSTEM) == ZPROP_INVAL) return (-1); - if (err = zfs_clone(snap_hdl, be_path, props)) { + if ((err = zfs_clone(snap_hdl, be_path, props)) != 0) { switch (err) { case EZFS_SUCCESS: err = BE_ERR_SUCCESS; @@ -392,23 +391,25 @@ be_deep_clone(zfs_handle_t *ds, void *data) * Create the boot environment from pre-existing snapshot */ int -be_create_from_existing_snap(libbe_handle_t *lbh, char *name, char *snap) +be_create_from_existing_snap(libbe_handle_t *lbh, const char *name, + const char *snap) { int err; char be_path[BE_MAXPATHLEN]; char snap_path[BE_MAXPATHLEN]; - char *parentname, *bename, *snapname; + const char *bename; + char *parentname, *snapname; zfs_handle_t *parent_hdl; struct libbe_deep_clone sdc; - if (err = be_validate_name(lbh, name)) + if ((err = be_validate_name(lbh, name)) != 0) return (set_error(lbh, err)); - if (err = be_root_concat(lbh, snap, snap_path)) + if ((err = be_root_concat(lbh, snap, snap_path)) != 0) return (set_error(lbh, err)); - if (err = be_validate_snap(lbh, snap_path)) + if ((err = be_validate_snap(lbh, snap_path)) != 0) return (set_error(lbh, err)); - if (err = be_root_concat(lbh, name, be_path)) + if ((err = be_root_concat(lbh, name, be_path)) != 0) return (set_error(lbh, err)); if ((bename = strrchr(name, '/')) == NULL) @@ -444,7 +445,7 @@ be_create_from_existing_snap(libbe_handle_t *lbh, char * Create a boot environment from an existing boot environment */ int -be_create_from_existing(libbe_handle_t *lbh, char *name, char *old) +be_create_from_existing(libbe_handle_t *lbh, const char *name, const char *old) { int err; char buf[BE_MAXPATHLEN]; @@ -464,12 +465,11 @@ be_create_from_existing(libbe_handle_t *lbh, char *nam * failure. Does not set the internal library error state. */ int -be_validate_snap(libbe_handle_t *lbh, char *snap_name) +be_validate_snap(libbe_handle_t *lbh, const char *snap_name) { zfs_handle_t *zfs_hdl; char buf[BE_MAXPATHLEN]; char *delim_pos; - char *mountpoint; int err = BE_ERR_SUCCESS; if (strlen(snap_name) >= BE_MAXPATHLEN) @@ -490,8 +490,8 @@ be_validate_snap(libbe_handle_t *lbh, char *snap_name) zfs_open(lbh->lzh, buf, ZFS_TYPE_DATASET)) == NULL) return (BE_ERR_NOORIGIN); - if (err = zfs_prop_get(zfs_hdl, ZFS_PROP_MOUNTPOINT, buf, BE_MAXPATHLEN, - NULL, NULL, 0, 1)) + if ((err = zfs_prop_get(zfs_hdl, ZFS_PROP_MOUNTPOINT, buf, BE_MAXPATHLEN, + NULL, NULL, 0, 1)) != 0) err = BE_ERR_INVORIGIN; if ((err != 0) && (strncmp(buf, "/", BE_MAXPATHLEN) != 0)) @@ -512,7 +512,7 @@ be_validate_snap(libbe_handle_t *lbh, char *snap_name) * zfs_be_root. Does not set internal library error state. */ int -be_root_concat(libbe_handle_t *lbh, char *name, char *result) +be_root_concat(libbe_handle_t *lbh, const char *name, char *result) { size_t name_len, root_len; @@ -545,7 +545,7 @@ be_root_concat(libbe_handle_t *lbh, char *name, char * * Does not set internal library error state. */ int -be_validate_name(libbe_handle_t *lbh, char *name) +be_validate_name(libbe_handle_t *lbh __unused, const char *name) { for (int i = 0; *name; i++) { char c = *(name++); @@ -569,12 +569,12 @@ be_rename(libbe_handle_t *lbh, char *old, char *new) zfs_handle_t *zfs_hdl; int err; - if (err = be_root_concat(lbh, old, full_old)) + if ((err = be_root_concat(lbh, old, full_old)) != 0) return (set_error(lbh, err)); - if (err = be_root_concat(lbh, new, full_new)) + if ((err = be_root_concat(lbh, new, full_new)) != 0) return (set_error(lbh, err)); - if (be_validate_name(lbh, new)) + if (be_validate_name(lbh, new) != 0) return (BE_ERR_UNKNOWN); /* XXX TODO set and return correct error */ @@ -621,7 +621,7 @@ be_export(libbe_handle_t *lbh, char *bootenv, int fd) zfs_handle_t *zfs; int err; - if (err = be_snapshot(lbh, bootenv, NULL, true, snap_name)) + if ((err = be_snapshot(lbh, bootenv, NULL, true, snap_name)) != 0) /* XXX TODO error handle */ return (-1); @@ -648,7 +648,7 @@ be_import(libbe_handle_t *lbh, char *bootenv, int fd) * XXX TODO: this is a very likely name for someone to already have * used... we should avoid it. */ - if (err = be_root_concat(lbh, "be_import_temp", buf)) + if ((err = be_root_concat(lbh, "be_import_temp", buf)) != 0) /* XXX TODO error handle */ return (-1); @@ -658,7 +658,7 @@ be_import(libbe_handle_t *lbh, char *bootenv, int fd) "@%F-%T", localtime(&rawtime)); /* lzc_receive(SNAPNAME, PROPS, ORIGIN, FORCE, fd)) { */ - if (err = lzc_receive(buf, NULL, NULL, false, fd)) { + if ((err = lzc_receive(buf, NULL, NULL, false, fd)) != 0) { /* TODO: go through libzfs_core's recv_impl and find returned * errors and set appropriate BE_ERR * edit: errors are not in libzfs_core, my assumption is @@ -737,8 +737,8 @@ be_add_child(libbe_handle_t *lbh, char *child_path, bo nvlist_add_string(props, "mountpoint", child_path); /* Create */ - if (err = - zfs_create(lbh->lzh, active, ZFS_TYPE_DATASET, props)) + if ((err = + zfs_create(lbh->lzh, active, ZFS_TYPE_DATASET, props)) != 0) /* XXX TODO handle error */ return (-1); nvlist_free(props); @@ -749,7 +749,7 @@ be_add_child(libbe_handle_t *lbh, char *child_path, bo return (-1); /* Set props */ - if (err = zfs_prop_set(zfs, "canmount", "noauto")) + if ((err = zfs_prop_set(zfs, "canmount", "noauto")) != 0) /* TODO handle error */ return (-1); } else if (cp_if_exists) { @@ -767,7 +767,7 @@ be_add_child(libbe_handle_t *lbh, char *child_path, bo snprintf(buf, BE_MAXPATHLEN, "%s@%ld", child_path, snap_name); - if (err = zfs_snapshot(lbh->lzh, buf, false, NULL)) + if ((err = zfs_snapshot(lbh->lzh, buf, false, NULL)) != 0) /* XXX TODO correct error */ return (-1); @@ -777,7 +777,7 @@ be_add_child(libbe_handle_t *lbh, char *child_path, bo /* XXX TODO correct error */ return (-1); - if (err = zfs_clone(zfs, active, NULL)) + if ((err = zfs_clone(zfs, active, NULL)) != 0) /* XXX TODO correct error */ return (-1); @@ -797,8 +797,6 @@ be_activate(libbe_handle_t *lbh, char *bootenv, bool t char buf[BE_MAXPATHLEN]; uint64_t pool_guid; uint64_t vdev_guid; - int zfs_fd; - int len; int err; be_root_concat(lbh, bootenv, be_path); Modified: projects/bectl/lib/libbe/be.h ============================================================================== --- projects/bectl/lib/libbe/be.h Wed Jul 25 14:45:00 2018 (r336709) +++ projects/bectl/lib/libbe/be.h Wed Jul 25 15:14:35 2018 (r336710) @@ -67,14 +67,15 @@ 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 *); +void be_prop_list_free(nvlist_t *be_list); int be_activate(libbe_handle_t *, char *, bool); /* Bootenv creation functions */ int be_create(libbe_handle_t *, char *); -int be_create_from_existing(libbe_handle_t *, char *, char *); -int be_create_from_existing_snap(libbe_handle_t *, char *, char *); -int be_snapshot(libbe_handle_t *, char *, char *, bool, char *); +int be_create_from_existing(libbe_handle_t *, const char *, const char *); +int be_create_from_existing_snap(libbe_handle_t *, const char *, const char *); +int be_snapshot(libbe_handle_t *, const char *, const char *, bool, char *); /* Bootenv manipulation functions */ int be_rename(libbe_handle_t *, char *, char *); @@ -103,9 +104,9 @@ const char *libbe_error_description(libbe_handle_t *); void libbe_print_on_error(libbe_handle_t *, bool); /* Utility Functions */ -int be_root_concat(libbe_handle_t *, char *, char *); -int be_validate_name(libbe_handle_t *, char *); -int be_validate_snap(libbe_handle_t *, char *); +int be_root_concat(libbe_handle_t *, const char *, char *); +int be_validate_name(libbe_handle_t * __unused, const char *); +int be_validate_snap(libbe_handle_t *, const char *); bool be_exists(libbe_handle_t *, char *); int be_export(libbe_handle_t *, char *, int fd); Modified: projects/bectl/lib/libbe/be_access.c ============================================================================== --- projects/bectl/lib/libbe/be_access.c Wed Jul 25 14:45:00 2018 (r336709) +++ projects/bectl/lib/libbe/be_access.c Wed Jul 25 15:14:35 2018 (r336710) @@ -38,12 +38,11 @@ be_mount(libbe_handle_t *lbh, char *bootenv, char *mou { char be[BE_MAXPATHLEN]; char mnt_temp[BE_MAXPATHLEN]; - zfs_handle_t *zfs_hdl; char *path; int mntflags; int err; - if (err = be_root_concat(lbh, bootenv, be)) + if ((err = be_root_concat(lbh, bootenv, be)) != 0) return (set_error(lbh, err)); if (!be_exists(lbh, bootenv)) @@ -63,8 +62,8 @@ be_mount(libbe_handle_t *lbh, char *bootenv, char *mou } char opt = '\0'; - if (err = zmount(be, (mountpoint == NULL) ? mnt_temp : mountpoint, - mntflags, MNTTYPE_ZFS, NULL, 0, &opt, 1)) + if ((err = zmount(be, (mountpoint == NULL) ? mnt_temp : mountpoint, + mntflags, __DECONST(char *, MNTTYPE_ZFS), NULL, 0, &opt, 1)) != 0) /* * XXX TODO: zmount returns the nmount error, look into what * kind of errors we can report from that @@ -90,7 +89,7 @@ be_unmount(libbe_handle_t *lbh, char *bootenv, int fla int mntsize; char *mntpath; - if (err = be_root_concat(lbh, bootenv, be)) + if ((err = be_root_concat(lbh, bootenv, be)) != 0) return (set_error(lbh, err)); if ((mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)) == 0) @@ -114,7 +113,7 @@ be_unmount(libbe_handle_t *lbh, char *bootenv, int fla mntflags = (flags & BE_MNT_FORCE) ? MNT_FORCE : 0; - if (err = unmount(mntpath, mntflags)) + if ((err = unmount(mntpath, mntflags)) != 0) /* XXX TODO correct error */ return (set_error(lbh, BE_ERR_NOMOUNT)); Modified: projects/bectl/lib/libbe/be_impl.h ============================================================================== --- projects/bectl/lib/libbe/be_impl.h Wed Jul 25 14:45:00 2018 (r336709) +++ projects/bectl/lib/libbe/be_impl.h Wed Jul 25 15:14:35 2018 (r336710) @@ -46,9 +46,9 @@ struct libbe_handle { struct libbe_deep_clone { libbe_handle_t *lbh; - char *bename; - char *snapname; - char *be_root; + const char *bename; + const char *snapname; + const char *be_root; }; struct libbe_dccb { Modified: projects/bectl/lib/libbe/be_info.c ============================================================================== --- projects/bectl/lib/libbe/be_info.c Wed Jul 25 14:45:00 2018 (r336709) +++ projects/bectl/lib/libbe/be_info.c Wed Jul 25 15:14:35 2018 (r336710) @@ -119,7 +119,7 @@ prop_list_builder_cb(zfs_handle_t *zfs_hdl, void *data libbe_handle_t *lbh; nvlist_t *props; const char *dataset, *name; - boolean_t mounted, active, nextboot; + boolean_t mounted; /* * XXX TODO: Modified: projects/bectl/lib/libbe/libbe.3 ============================================================================== --- projects/bectl/lib/libbe/libbe.3 Wed Jul 25 14:45:00 2018 (r336709) +++ projects/bectl/lib/libbe/libbe.3 Wed Jul 25 15:14:35 2018 (r336710) @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 28, 2017 +.Dd July 25, 2018 .Dt LIBBE 3 .Os .Sh NAME @@ -76,7 +76,7 @@ of state to be retained, such as errors from previous .Fn be_create "libbe_handle_t *, char *" ; .Pp .Ft int -.Fn be_create_from_existing "libbe_handle_t *, char *, char *" ; +.Fn be_create_from_existing "libbe_handle_t *, const char *, const char *" ; .Pp .Ft int .Fn be_rename "libbe_handle_t *, char *, char *" ; @@ -109,13 +109,13 @@ of state to be retained, such as errors from previous .Fn libbe_print_on_error "libbe_handle_t *, bool" ; .Pp .Ft int -.Fn be_root_concat "libbe_handle_t *, char *, char *" ; +.Fn be_root_concat "libbe_handle_t *, const char *, char *" ; .Pp .Ft int -.Fn be_validate_name "libbe_handle_t *, char *" ; +.Fn be_validate_name "libbe_handle_t *, const char *" ; .Pp .Ft int -.Fn be_validate_snap "libbe_handle_t *, char *" ; +.Fn be_validate_snap "libbe_handle_t *, const char *" ; .Pp .Ft bool .Fn be_exists "libbe_handle_t *, char *" ; Modified: projects/bectl/sbin/bectl/Makefile ============================================================================== --- projects/bectl/sbin/bectl/Makefile Wed Jul 25 14:45:00 2018 (r336709) +++ projects/bectl/sbin/bectl/Makefile Wed Jul 25 15:14:35 2018 (r336710) @@ -1,7 +1,6 @@ # $FreeBSD$ PROG= bectl -WARNS?= 1 MAN= bectl.8 LIBADD+= be @@ -9,7 +8,6 @@ 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 Modified: projects/bectl/sbin/bectl/bectl.c ============================================================================== --- projects/bectl/sbin/bectl/bectl.c Wed Jul 25 14:45:00 2018 (r336709) +++ projects/bectl/sbin/bectl/bectl.c Wed Jul 25 15:14:35 2018 (r336710) @@ -54,7 +54,7 @@ static int bectl_cmd_rename(int argc, char *argv[]); static int bectl_cmd_unjail(int argc, char *argv[]); static int bectl_cmd_unmount(int argc, char *argv[]); -libbe_handle_t *be; +static libbe_handle_t *be; static int usage(bool explicit) @@ -108,7 +108,7 @@ static struct command_map_entry command_map[] = }; static int -get_cmd_index(char *cmd, int *index) +get_cmd_index(const char *cmd, int *index) { int map_size; @@ -127,7 +127,6 @@ get_cmd_index(char *cmd, int *index) static int bectl_cmd_activate(int argc, char *argv[]) { - char *bootenv; int err, opt; bool temp; @@ -210,7 +209,7 @@ bectl_cmd_create(int argc, char *argv[]) } else { if ((snapname = strchr(bootenv, '@')) != NULL) { *(snapname++) = '\0'; - if ((err = be_snapshot(be, (char *)be_active_path(be), + if ((err = be_snapshot(be, be_active_path(be), snapname, true, NULL)) != BE_ERR_SUCCESS) fprintf(stderr, "failed to create snapshot\n"); asprintf(&source, "%s@%s", be_active_path(be), snapname); @@ -242,7 +241,6 @@ static int bectl_cmd_export(int argc, char *argv[]) { char *bootenv; - int opt; if (argc == 1) { fprintf(stderr, "bectl export: missing boot environment name\n"); @@ -299,7 +297,6 @@ bectl_cmd_import(int argc, char *argv[]) static int bectl_cmd_add(int argc, char *argv[]) { - char *bootenv; if (argc < 2) { fprintf(stderr, "bectl add: must provide at least one path\n"); @@ -358,7 +355,7 @@ bectl_cmd_jail(int argc, char *argv[]) char *bootenv; char mnt_loc[BE_MAXPATHLEN]; char buf[BE_MAXPATHLEN*2]; - int err, jid; + int err; /* struct jail be_jail = { 0 }; */ @@ -418,7 +415,6 @@ static int bectl_cmd_list(int argc, char *argv[]) { nvlist_t *props; - char *bootenv; int opt; bool show_all_datasets, show_space, hide_headers, show_snaps; @@ -625,7 +621,7 @@ bectl_cmd_unmount(int argc, char *argv[]) int main(int argc, char *argv[]) { - char *command; + const char *command; int command_index, rc; if (argc < 2) { From owner-svn-src-projects@freebsd.org Wed Jul 25 15:45:43 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 E33AB104E30B for ; Wed, 25 Jul 2018 15:45:42 +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 9976883174; Wed, 25 Jul 2018 15:45:42 +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 7A7A41C2C4; Wed, 25 Jul 2018 15:45:42 +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 w6PFjgc7052974; Wed, 25 Jul 2018 15:45:42 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6PFjgGK052973; Wed, 25 Jul 2018 15:45:42 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807251545.w6PFjgGK052973@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 15:45:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336713 - 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: 336713 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 15:45:43 -0000 Author: kevans Date: Wed Jul 25 15:45:42 2018 New Revision: 336713 URL: https://svnweb.freebsd.org/changeset/base/336713 Log: libbe(3): Use zfs_is_mounted to check mounted and mountpoint Modified: projects/bectl/lib/libbe/be_info.c Modified: projects/bectl/lib/libbe/be_info.c ============================================================================== --- projects/bectl/lib/libbe/be_info.c Wed Jul 25 15:44:49 2018 (r336712) +++ projects/bectl/lib/libbe/be_info.c Wed Jul 25 15:45:42 2018 (r336713) @@ -114,7 +114,7 @@ be_get_bootenv_props(libbe_handle_t *lbh, nvlist_t *ds static int prop_list_builder_cb(zfs_handle_t *zfs_hdl, void *data_p) { - char buf[512]; + char buf[512], *mountpoint; prop_data_t *data; libbe_handle_t *lbh; nvlist_t *props; @@ -137,15 +137,11 @@ prop_list_builder_cb(zfs_handle_t *zfs_hdl, void *data name = strrchr(dataset, '/') + 1; nvlist_add_string(props, "name", name); - mounted = zfs_prop_get_int(zfs_hdl, ZFS_PROP_MOUNTED); + mounted = zfs_is_mounted(zfs_hdl, &mountpoint); nvlist_add_boolean_value(props, "mounted", mounted); - /* XXX TODO: NOT CORRECT! Must use is_mounted */ - if (mounted) { - zfs_prop_get(zfs_hdl, ZFS_PROP_MOUNTPOINT, buf, 512, - NULL, NULL, 0, 1); - nvlist_add_string(props, "mountpoint", buf); - } + if (mounted) + nvlist_add_string(props, "mountpoint", mountpoint); if (zfs_prop_get(zfs_hdl, ZFS_PROP_ORIGIN, buf, 512, NULL, NULL, 0, 1)) From owner-svn-src-projects@freebsd.org Wed Jul 25 16:00: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 BF120104E68C for ; Wed, 25 Jul 2018 16:00: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 752DA83A22; Wed, 25 Jul 2018 16:00: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 567C91C47F; Wed, 25 Jul 2018 16:00:49 +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 w6PG0nFv058853; Wed, 25 Jul 2018 16:00:49 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6PG0m34058850; Wed, 25 Jul 2018 16:00:48 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807251600.w6PG0m34058850@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 16:00:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336715 - 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: 336715 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 16:00:50 -0000 Author: kevans Date: Wed Jul 25 16:00:48 2018 New Revision: 336715 URL: https://svnweb.freebsd.org/changeset/base/336715 Log: libbe(3)/bectl(8): Provide and use proper alloc/free for property lists Modified: projects/bectl/lib/libbe/be.h projects/bectl/lib/libbe/be_info.c projects/bectl/lib/libbe/libbe.3 projects/bectl/sbin/bectl/bectl.c Modified: projects/bectl/lib/libbe/be.h ============================================================================== --- projects/bectl/lib/libbe/be.h Wed Jul 25 15:58:14 2018 (r336714) +++ projects/bectl/lib/libbe/be.h Wed Jul 25 16:00:48 2018 (r336715) @@ -67,6 +67,7 @@ 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 *); +int be_prop_list_alloc(nvlist_t **be_list); void be_prop_list_free(nvlist_t *be_list); 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 15:58:14 2018 (r336714) +++ projects/bectl/lib/libbe/be_info.c Wed Jul 25 16:00:48 2018 (r336715) @@ -207,6 +207,13 @@ prop_list_builder(prop_data_t *data) } +int +be_prop_list_alloc(nvlist_t **be_list) +{ + + return (nvlist_alloc(be_list, NV_UNIQUE_NAME, KM_SLEEP)); +} + /* * frees property list and its children */ Modified: projects/bectl/lib/libbe/libbe.3 ============================================================================== --- projects/bectl/lib/libbe/libbe.3 Wed Jul 25 15:58:14 2018 (r336714) +++ projects/bectl/lib/libbe/libbe.3 Wed Jul 25 16:00:48 2018 (r336715) @@ -129,6 +129,14 @@ of state to be retained, such as errors from previous .Ft int .Fn be_add_child "libbe_handle_t *, char *, bool" ; .Pp +.Ft int +.Fn be_prop_list_alloc "nvlist_t **" ; +.Pp +.Ft int +.Fn be_get_bootenv_props "libbe_handle_t *, nvlist_t *" ; +.Pp +.Ft void +.Fn be_prop_list_free "nvlist_t *" ; .\" .Ft void .\" .Fn mp_mfree "MINT *mp" ; .\" .Bd -ragged -offset indent Modified: projects/bectl/sbin/bectl/bectl.c ============================================================================== --- projects/bectl/sbin/bectl/bectl.c Wed Jul 25 15:58:14 2018 (r336714) +++ projects/bectl/sbin/bectl/bectl.c Wed Jul 25 16:00:48 2018 (r336715) @@ -28,7 +28,6 @@ #include #include -#include #include #include #include @@ -418,6 +417,7 @@ bectl_cmd_list(int argc, char *argv[]) int opt; bool show_all_datasets, show_space, hide_headers, show_snaps; + props = NULL; show_all_datasets = show_space = hide_headers = show_snaps = false; while ((opt = getopt(argc, argv, "aDHs")) != -1) { switch (opt) { @@ -448,7 +448,7 @@ bectl_cmd_list(int argc, char *argv[]) } - if (nvlist_alloc(&props, NV_UNIQUE_NAME, M_WAITOK) != 0) { + if (be_prop_list_alloc(&props) != 0) { fprintf(stderr, "bectl list: failed to allocate prop nvlist\n"); return (1); } @@ -459,7 +459,7 @@ bectl_cmd_list(int argc, char *argv[]) } dump_nvlist(props, 0); - nvlist_free(props); + be_prop_list_free(props); return (0); } From owner-svn-src-projects@freebsd.org Thu Jul 26 03:13:09 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 E0EBD105D492 for ; Thu, 26 Jul 2018 03:13:08 +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 974BD79ACA; Thu, 26 Jul 2018 03:13:08 +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 5E9F22346D; Thu, 26 Jul 2018 03:13:08 +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 w6Q3D8gP008554; Thu, 26 Jul 2018 03:13:08 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6Q3D7So008550; Thu, 26 Jul 2018 03:13:07 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807260313.w6Q3D7So008550@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 26 Jul 2018 03:13:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336729 - 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: 336729 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: Thu, 26 Jul 2018 03:13:09 -0000 Author: kevans Date: Thu Jul 26 03:13:07 2018 New Revision: 336729 URL: https://svnweb.freebsd.org/changeset/base/336729 Log: libbe(3): Add be_mounted_at to check a mount point At a bare minimum, this function will return 0 if a BE is mounted at the given path or non-zero otherwise. If the optional 'details' nvlist is supplied, it is filled with an nvpair containing just the information about the BE mounted at the path. This nvpair is structured just as it is for be_get_bootenv_props, except limited to just the single mount point. Modified: projects/bectl/lib/libbe/be.h projects/bectl/lib/libbe/be_access.c projects/bectl/lib/libbe/be_impl.h projects/bectl/lib/libbe/be_info.c projects/bectl/lib/libbe/libbe.3 Modified: projects/bectl/lib/libbe/be.h ============================================================================== --- projects/bectl/lib/libbe/be.h Thu Jul 26 00:16:41 2018 (r336728) +++ projects/bectl/lib/libbe/be.h Thu Jul 26 03:13:07 2018 (r336729) @@ -98,6 +98,7 @@ typedef enum { int be_mount(libbe_handle_t *, char *, char *, int, char *); int be_unmount(libbe_handle_t *, char *, int); +int be_mounted_at(libbe_handle_t *, const char *path, nvlist_t *); /* Error related functions: be_error.c */ int libbe_errno(libbe_handle_t *); Modified: projects/bectl/lib/libbe/be_access.c ============================================================================== --- projects/bectl/lib/libbe/be_access.c Thu Jul 26 00:16:41 2018 (r336728) +++ projects/bectl/lib/libbe/be_access.c Thu Jul 26 03:13:07 2018 (r336729) @@ -29,6 +29,69 @@ #include "be.h" #include "be_impl.h" +struct be_mountcheck_info { + const char *path; + char *name; +}; + +static int +be_mountcheck_cb(zfs_handle_t *zfs_hdl, void *data) +{ + struct be_mountcheck_info *info; + char *mountpoint; + + if (data == NULL) + return (1); + info = (struct be_mountcheck_info *)data; + if (!zfs_is_mounted(zfs_hdl, &mountpoint)) + return (0); + if (strcmp(mountpoint, info->path) == 0) { + info->name = strdup(zfs_get_name(zfs_hdl)); + return (1); + } + return (0); +} + +/* + * usage + */ +int +be_mounted_at(libbe_handle_t *lbh, const char *path, nvlist_t *details) +{ + char be[BE_MAXPATHLEN + 1]; + zfs_handle_t *root_hdl; + struct be_mountcheck_info info; + prop_data_t propinfo; + + bzero(&be, BE_MAXPATHLEN + 1); + if ((root_hdl = zfs_open(lbh->lzh, lbh->root, + ZFS_TYPE_FILESYSTEM)) == NULL) + return (BE_ERR_ZFSOPEN); + + info.path = path; + info.name = NULL; + zfs_iter_filesystems(root_hdl, be_mountcheck_cb, &info); + zfs_close(root_hdl); + + if (info.name != NULL) { + if (details != NULL) { + if ((root_hdl = zfs_open(lbh->lzh, lbh->root, + ZFS_TYPE_FILESYSTEM)) == NULL) { + free(info.name); + return (BE_ERR_ZFSOPEN); + } + + propinfo.lbh = lbh; + propinfo.list = details; + prop_list_builder_cb(root_hdl, &propinfo); + zfs_close(root_hdl); + } + free(info.name); + return (0); + } + return (1); +} + /* * usage */ Modified: projects/bectl/lib/libbe/be_impl.h ============================================================================== --- projects/bectl/lib/libbe/be_impl.h Thu Jul 26 00:16:41 2018 (r336728) +++ projects/bectl/lib/libbe/be_impl.h Thu Jul 26 03:13:07 2018 (r336729) @@ -33,7 +33,6 @@ #include "be.h" - struct libbe_handle { libzfs_handle_t *lzh; zpool_handle_t *active_phandle; @@ -55,6 +54,14 @@ struct libbe_dccb { zfs_handle_t *zhp; nvlist_t *props; }; + +typedef struct prop_data { + nvlist_t *list; + libbe_handle_t *lbh; +} prop_data_t; + +int prop_list_builder_cb(zfs_handle_t *, void *); +int prop_list_builder(prop_data_t *); int set_error(libbe_handle_t *, be_error_t); Modified: projects/bectl/lib/libbe/be_info.c ============================================================================== --- projects/bectl/lib/libbe/be_info.c Thu Jul 26 00:16:41 2018 (r336728) +++ projects/bectl/lib/libbe/be_info.c Thu Jul 26 03:13:07 2018 (r336729) @@ -29,14 +29,6 @@ #include "be.h" #include "be_impl.h" -typedef struct prop_data { - nvlist_t *list; - libbe_handle_t *lbh; -} prop_data_t; - -static int prop_list_builder_cb(zfs_handle_t *, void *); -static int prop_list_builder(prop_data_t *); - /* * Returns the name of the active boot environment */ @@ -111,7 +103,7 @@ be_get_bootenv_props(libbe_handle_t *lbh, nvlist_t *ds * the bootenv root, populate an nvlist_t of its relevant properties. * TODO: should any other properties be included? */ -static int +int prop_list_builder_cb(zfs_handle_t *zfs_hdl, void *data_p) { char buf[512], *mountpoint; @@ -189,7 +181,7 @@ prop_list_builder_cb(zfs_handle_t *zfs_hdl, void *data * XXX TODO: ensure that this is always consistent (run after adds, deletes, * renames,etc */ -static int +int prop_list_builder(prop_data_t *data) { zfs_handle_t *root_hdl; Modified: projects/bectl/lib/libbe/libbe.3 ============================================================================== --- projects/bectl/lib/libbe/libbe.3 Thu Jul 26 00:16:41 2018 (r336728) +++ projects/bectl/lib/libbe/libbe.3 Thu Jul 26 03:13:07 2018 (r336729) @@ -97,6 +97,9 @@ of state to be retained, such as errors from previous .Fn be_mount "libbe_handle_t *, char *, char *, int" ; .Pp .Ft int +.Fn be_mounted_at "libbe_handle_t *, const char *, nvlist_t" ; +.Pp +.Ft int .Fn be_unmount "libbe_handle_t *, char *, int" ; .Pp .Ft int From owner-svn-src-projects@freebsd.org Thu Jul 26 03:14:59 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 5E012105D651 for ; Thu, 26 Jul 2018 03:14:59 +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 149F379C71; Thu, 26 Jul 2018 03:14:59 +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 EB6992347C; Thu, 26 Jul 2018 03:14:58 +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 w6Q3EwaC008668; Thu, 26 Jul 2018 03:14:58 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6Q3Ewhf008665; Thu, 26 Jul 2018 03:14:58 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807260314.w6Q3Ewhf008665@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 26 Jul 2018 03:14:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336730 - projects/bectl/sbin/bectl X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: projects/bectl/sbin/bectl X-SVN-Commit-Revision: 336730 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: Thu, 26 Jul 2018 03:14:59 -0000 Author: kevans Date: Thu Jul 26 03:14:58 2018 New Revision: 336730 URL: https://svnweb.freebsd.org/changeset/base/336730 Log: bectl(8): Support unjailing a boot environment The given parameter may either be a jid, jail name, or a BE name. In all cases, the parameter will be resolved to a jid and bectl(8) will sanity-check that there's actually a BE mounted at the requested jail root before invoking jail_remove(2). Modified: projects/bectl/sbin/bectl/Makefile projects/bectl/sbin/bectl/bectl.8 projects/bectl/sbin/bectl/bectl.c Modified: projects/bectl/sbin/bectl/Makefile ============================================================================== --- projects/bectl/sbin/bectl/Makefile Thu Jul 26 03:13:07 2018 (r336729) +++ projects/bectl/sbin/bectl/Makefile Thu Jul 26 03:14:58 2018 (r336730) @@ -4,6 +4,7 @@ PROG= bectl MAN= bectl.8 LIBADD+= be +LIBADD+= jail LIBADD+= nvpair CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs/common Modified: projects/bectl/sbin/bectl/bectl.8 ============================================================================== --- projects/bectl/sbin/bectl/bectl.8 Thu Jul 26 03:13:07 2018 (r336729) +++ projects/bectl/sbin/bectl/bectl.8 Thu Jul 26 03:14:58 2018 (r336730) @@ -175,8 +175,7 @@ Specifying .Fl f will force the unmount if busy. .Pp -.It Ic unjail -.Ao Ar beName Ac +.It Ic unjail Ao Ar jailID | jailName | beName Ac .Pp Destroys the jail created from the given boot environment. .Pp Modified: projects/bectl/sbin/bectl/bectl.c ============================================================================== --- projects/bectl/sbin/bectl/bectl.c Thu Jul 26 03:13:07 2018 (r336729) +++ projects/bectl/sbin/bectl/bectl.c Thu Jul 26 03:14:58 2018 (r336730) @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,8 @@ static int bectl_cmd_jail(int argc, char *argv[]); static int bectl_cmd_list(int argc, char *argv[]); static int bectl_cmd_mount(int argc, char *argv[]); static int bectl_cmd_rename(int argc, char *argv[]); +static int bectl_search_jail_paths(const char *mnt); +static int bectl_locate_jail(const char *ident); static int bectl_cmd_unjail(int argc, char *argv[]); static int bectl_cmd_unmount(int argc, char *argv[]); @@ -74,7 +77,7 @@ usage(bool explicit) "\tbectl list [-a] [-D] [-H] [-s]\n" "\tbectl mount beName [mountpoint]\n" "\tbectl rename origBeName newBeName\n" - "\tbectl { ujail | unjail } ⟨jailID | jailName⟩ bootenv\n" + "\tbectl { ujail | unjail } ⟨jailID | jailName | bootenv)\n" "\tbectl { umount | unmount } [-f] beName\n"); return (explicit ? 0 : EX_USAGE); @@ -447,7 +450,6 @@ bectl_cmd_list(int argc, char *argv[]) return (usage(false)); } - if (be_prop_list_alloc(&props) != 0) { fprintf(stderr, "bectl list: failed to allocate prop nvlist\n"); return (1); @@ -534,41 +536,100 @@ bectl_cmd_rename(int argc, char *argv[]) return (0); } +static int +bectl_search_jail_paths(const char *mnt) +{ + char jailpath[MAXPATHLEN + 1]; + int jid; + jid = 0; + (void)mnt; + while ((jid = jail_getv(0, "lastjid", &jid, "path", &jailpath, + NULL)) != -1) { + if (strcmp(jailpath, mnt) == 0) + return (jid); + } + + return (-1); +} + +/* + * Locate a jail based on an arbitrary identifier. This may be either a name, + * a jid, or a BE name. Returns the jid or -1 on failure. + */ static int -bectl_cmd_unjail(int argc, char *argv[]) +bectl_locate_jail(const char *ident) { - char *cmd, *target; - int opt; - bool force; + nvlist_t *belist, *props; + char *mnt; + int jid; - /* Store alias used */ - cmd = argv[0]; + /* Try the easy-match first */ + jid = jail_getid(ident); + if (jid != -1) + return (jid); - force = false; - while ((opt = getopt(argc, argv, "f")) != -1) { - switch (opt) { - case 'f': - force = true; - break; - default: - fprintf(stderr, "bectl %s: unknown option '-%c'\n", - cmd, optopt); - return (usage(false)); + /* Attempt to try it as a BE name, first */ + if (be_prop_list_alloc(&belist) != 0) + return (-1); + + if (be_get_bootenv_props(be, belist) != 0) + return (-1); + + if (nvlist_lookup_nvlist(belist, ident, &props) == 0) { + /* We'll attempt to resolve the jid by way of mountpoint */ + if (nvlist_lookup_string(props, "mountpoint", &mnt) == 0) { + jid = bectl_search_jail_paths(mnt); + be_prop_list_free(belist); + return (jid); } + + be_prop_list_free(belist); } - argc -= optind; - argv += optind; + return (-1); +} - if (argc != 1) { +static int +bectl_cmd_unjail(int argc, char *argv[]) +{ + char path[MAXPATHLEN + 1]; + char *cmd, *name, *target; + int jid; + + /* Store alias used */ + cmd = argv[0]; + + if (argc != 2) { fprintf(stderr, "bectl %s: wrong number of arguments\n", cmd); return (usage(false)); } - target = argv[0]; + target = argv[1]; - /* unjail logic goes here */ + /* Locate the jail */ + if ((jid = bectl_locate_jail(target)) == -1) { + fprintf(stderr, "bectl %s: failed to locate BE by '%s'\n", cmd, target); + return (1); + } + + bzero(&path, MAXPATHLEN + 1); + name = jail_getname(jid); + if (jail_getv(0, "name", name, "path", path, NULL) != jid) { + free(name); + fprintf(stderr, "bectl %s: failed to get path for jail requested by '%s'\n", cmd, target); + return (1); + } + + free(name); + + if (be_mounted_at(be, path, NULL) != 0) { + fprintf(stderr, "bectl %s: jail requested by '%s' not a BE\n", cmd, target); + return (1); + } + + jail_remove(jid); + return (0); } From owner-svn-src-projects@freebsd.org Thu Jul 26 03:32:04 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 AC60B105E134 for ; Thu, 26 Jul 2018 03:32:04 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 621527A6E6; Thu, 26 Jul 2018 03:32:04 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id 03BDE225A9; Thu, 26 Jul 2018 03:32:04 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-lf1-f47.google.com with SMTP id j8-v6so188602lfb.4; Wed, 25 Jul 2018 20:32:03 -0700 (PDT) X-Gm-Message-State: AOUpUlGBd0meQASi1TGKCktT5HzYrLlwLfPxDI6thrYoR1XPmRkY9mCK BWPovqLFJLf2ruXo/ZOXBZinnDWaXOxrf4Fpw2M= X-Google-Smtp-Source: AAOMgpdYKKTIuVlPSI4PcrgYuL3NYloV+erUndAR5DkA8BZp6OqUZmfhjaHkF4zgs5SPOuydwe47BsmZwrgMT/6tXJI= X-Received: by 2002:a19:138b:: with SMTP id 11-v6mr116740lft.74.1532575922387; Wed, 25 Jul 2018 20:32:02 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:5742:0:0:0:0:0 with HTTP; Wed, 25 Jul 2018 20:31:41 -0700 (PDT) In-Reply-To: <201807260314.w6Q3Ewhf008665@repo.freebsd.org> References: <201807260314.w6Q3Ewhf008665@repo.freebsd.org> From: Kyle Evans Date: Wed, 25 Jul 2018 22:31:41 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r336730 - projects/bectl/sbin/bectl To: Kyle Evans Cc: src-committers , svn-src-projects@freebsd.org Content-Type: text/plain; charset="UTF-8" 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: Thu, 26 Jul 2018 03:32:04 -0000 On Wed, Jul 25, 2018 at 10:14 PM, Kyle Evans wrote: > Author: kevans > Date: Thu Jul 26 03:14:58 2018 > New Revision: 336730 > URL: https://svnweb.freebsd.org/changeset/base/336730 > > Log: > bectl(8): Support unjailing a boot environment > > The given parameter may either be a jid, jail name, or a BE name. In all > cases, the parameter will be resolved to a jid and bectl(8) will > sanity-check that there's actually a BE mounted at the requested jail root > before invoking jail_remove(2). It was probably also worth mentioning that this will currently leave the mount point hanging around to be unmounted manually. This was a conscious decision- at the moment, `bectl jail` will throw you into a shell inside the jail. Exiting the shell will clean up the jail and the mount appropriately, leaving 'unjail' for edge cases where this cleanup didn't get to happen -- but that won't always be the case. I waffled on whether or not unjail will be useful for removing the mount in the current world, and decided against it for now. The jail command will be getting modified to instead use jail API to create the jail then exec sh inside, at which point I will likely make 'unjail' properly remove the mount as the user will be free to go in and out of jail without worrying about it getting cleaned up upon 'exit'. From owner-svn-src-projects@freebsd.org Thu Jul 26 04:07:38 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 D5C13103A088 for ; Thu, 26 Jul 2018 04:07:37 +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 82D657B629; Thu, 26 Jul 2018 04:07:37 +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 620B223D14; Thu, 26 Jul 2018 04:07:37 +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 w6Q47bYv033952; Thu, 26 Jul 2018 04:07:37 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6Q47biK033951; Thu, 26 Jul 2018 04:07:37 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807260407.w6Q47biK033951@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 26 Jul 2018 04:07:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336731 - projects/bectl/sbin/bectl X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: projects/bectl/sbin/bectl X-SVN-Commit-Revision: 336731 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: Thu, 26 Jul 2018 04:07:38 -0000 Author: kevans Date: Thu Jul 26 04:07:36 2018 New Revision: 336731 URL: https://svnweb.freebsd.org/changeset/base/336731 Log: bectl(8): Redo jail using jail(3) API The jail is created with allow.mount, allow.mount.devfs, and enforce_statfs=1. Upon creation, we immediately attach, chdir to "/", and drop the user into a shell inside the jail. The default IP for this is arbitrarily 10.20.30.40. Modified: projects/bectl/sbin/bectl/bectl.c Modified: projects/bectl/sbin/bectl/bectl.c ============================================================================== --- projects/bectl/sbin/bectl/bectl.c Thu Jul 26 03:14:58 2018 (r336730) +++ projects/bectl/sbin/bectl/bectl.c Thu Jul 26 04:07:36 2018 (r336731) @@ -356,8 +356,7 @@ bectl_cmd_jail(int argc, char *argv[]) { char *bootenv; char mnt_loc[BE_MAXPATHLEN]; - char buf[BE_MAXPATHLEN*2]; - int err; + int err, jid; /* struct jail be_jail = { 0 }; */ @@ -376,39 +375,30 @@ bectl_cmd_jail(int argc, char *argv[]) * XXX TODO: if its already mounted, perhaps there should be a flag to * indicate its okay to proceed?? */ - if ((err = be_mount(be, bootenv, NULL, 0, mnt_loc)) != BE_ERR_SUCCESS) + if ((err = be_mount(be, bootenv, NULL, 0, mnt_loc)) != BE_ERR_SUCCESS) { fprintf(stderr, "could not mount bootenv\n"); + return (1); + } - /* - * NOTE: this is not quite functional: - * see https://github.com/vermaden/beadm/blob/master/HOWTO.htm on - * neccesary modifications to correctly boot the jail - */ + /* XXX TODO: Make the IP/hostname configurable? */ + jid = jail_setv(JAIL_CREATE | JAIL_ATTACH, + "name", bootenv, + "path", mnt_loc, + "host.hostname", bootenv, + "persist", "true", + "ip4.addr", "10.20.30.40", + "allow.mount", "true", + "allow.mount.devfs", "true", + "enforce_statfs", "1", + NULL); + if (jid == -1) { + fprintf(stderr, "unable to create jail. error: %d\n", errno); + return (1); + } - /* - * snprintf(buf, BE_MAXPATHLEN*2, "jail %s %s %s /bin/sh /etc/rc", - * mnt_loc, bootenv, "192.168.1.123"); - */ - snprintf(buf, BE_MAXPATHLEN*2, "jail %s %s %s /bin/sh", mnt_loc, - bootenv, "192.168.1.123"); - system(buf); - - unmount(mnt_loc, 0); - - /* - * be_jail.version = JAIL_API_VERSION; - * be_jail.path = "/tmp/be_mount.hCCk"; - * be_jail.jailname = "sdfs"; - * - * if ((jid = jail(&be_jail)) != -1) { - * printf("jail %d created at %s\n", jid, mnt_loc); - * err = 0; - * } else { - * fprintf(stderr, "unable to create jail. error: %d\n", errno); - * err = errno; - * } - */ - + /* We're attached within the jail... good bye! */ + chdir("/"); + execl("/bin/sh", "/bin/sh", NULL); return (0); } From owner-svn-src-projects@freebsd.org Thu Jul 26 04:12:32 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 01809103A420 for ; Thu, 26 Jul 2018 04:12:32 +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 A33FC7BA5D; Thu, 26 Jul 2018 04:12:31 +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 8459F23EA6; Thu, 26 Jul 2018 04:12:31 +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 w6Q4CVb0038726; Thu, 26 Jul 2018 04:12:31 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6Q4CV96038725; Thu, 26 Jul 2018 04:12:31 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807260412.w6Q4CV96038725@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 26 Jul 2018 04:12:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336732 - projects/bectl/sbin/bectl X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: projects/bectl/sbin/bectl X-SVN-Commit-Revision: 336732 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: Thu, 26 Jul 2018 04:12:32 -0000 Author: kevans Date: Thu Jul 26 04:12:31 2018 New Revision: 336732 URL: https://svnweb.freebsd.org/changeset/base/336732 Log: bectl(8): Remove the jail mount point with unjail Modified: projects/bectl/sbin/bectl/bectl.c Modified: projects/bectl/sbin/bectl/bectl.c ============================================================================== --- projects/bectl/sbin/bectl/bectl.c Thu Jul 26 04:07:36 2018 (r336731) +++ projects/bectl/sbin/bectl/bectl.c Thu Jul 26 04:12:31 2018 (r336732) @@ -619,6 +619,7 @@ bectl_cmd_unjail(int argc, char *argv[]) } jail_remove(jid); + unmount(path, 0); return (0); } From owner-svn-src-projects@freebsd.org Thu Jul 26 13:20:43 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 47C32104EE4D for ; Thu, 26 Jul 2018 13:20:43 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: from mail-wm0-x22b.google.com (mail-wm0-x22b.google.com [IPv6:2a00:1450:400c:c09::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A4A2F8E650 for ; Thu, 26 Jul 2018 13:20:42 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: by mail-wm0-x22b.google.com with SMTP id l2-v6so2120174wme.1 for ; Thu, 26 Jul 2018 06:20:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=QBoX6uiEpR46kaGF7fOtHTUHSKM/13GobL77bFjug0Q=; b=N/ilmvuYIusBLsqLcOwm9d5VDgNJAnwIYnXGj26PgapgfZ+J9D0u5rfZV6dNtaBBvg MhfCOKO+Xj+/coQkxC3xuR4NnZlvpXdrimsOTsXVZeEfzFrhwPs4kk4IDzShOIqtLmAJ 5/xNMYN5PdVy85i6k5sL0weH7ptMFpDskEFcwUBw8E7q6qO0zd9knp9OJuS4CX8NpLWq JonWO0vMxrM8YEd5CufachOEDt7d3gsSV74rQ6S43cdCogjdkq0dd1vZNUDHAWitkW1c L7vk4hamdQURwZyvL3DotTaVhvWTN2tRjPno7WpxO+DUoSeHZ/XcOAd8Z50Otxd8qhbC K4TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=QBoX6uiEpR46kaGF7fOtHTUHSKM/13GobL77bFjug0Q=; b=tVVW2rHF4gDMIC42l+1lMwxx1HLfhrz/soeO73NYb94tjz0Bj15gUKP9/ezNdnIshY CHjfvfhXJFpfKL0rCHSxTKwI6ksjVdggRmRJHsey/6qNfJQskRwRQwEWWyb42NhNTSsk /3PLqW/46Hvk+1giJjfladiZhm7Wyfvw1y+dmtwbyVg9R6T1tRG2/r4X6lk8QUGe+fb6 +eISjXFCSeHkbK2vWgQ+FrvDoM8x5+sUmnc4azKJhEjuH+B7mG7Sxqw6ixkm+G2ZDm3R UlJrDJUY24v7KvFMtBVcLqCyNRHxydLX7MWBmkYoxyWEOveMvw7VjGYvGUEvXAW14B/i 1hZQ== X-Gm-Message-State: AOUpUlEWlKIYlQeienhVeVsClhpAARpzfkK+FZev+yu+T64QRl4Ro/gI rR8OfGYzQZGqkQwZiepBpCvmVzFbQ2M1IA== X-Google-Smtp-Source: AAOMgpcTxwdOKoocy3rM8OTNG2JGWk4qbBBV07fHGhHIX2DmAcRVZuy2nmiOHL1AS6pgQdcb82cqrg== X-Received: by 2002:a1c:d892:: with SMTP id p140-v6mr1682141wmg.76.1532611240817; Thu, 26 Jul 2018 06:20:40 -0700 (PDT) Received: from mutt-hbsd ([185.220.102.7]) by smtp.gmail.com with ESMTPSA id a20-v6sm1886773wmg.23.2018.07.26.06.20.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 06:20:39 -0700 (PDT) Date: Thu, 26 Jul 2018 09:19:59 -0400 From: Shawn Webb To: Kyle Evans Cc: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: Re: svn commit: r336731 - projects/bectl/sbin/bectl Message-ID: <20180726131959.qplqj62fkjzcfyid@mutt-hbsd> References: <201807260407.w6Q47biK033951@repo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ybmzvme6yy3n3dvl" Content-Disposition: inline In-Reply-To: <201807260407.w6Q47biK033951@repo.freebsd.org> X-Operating-System: FreeBSD mutt-hbsd 12.0-CURRENT FreeBSD 12.0-CURRENT X-PGP-Key: http://pgp.mit.edu/pks/lookup?op=vindex&search=0x6A84658F52456EEE User-Agent: NeoMutt/20180622 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: Thu, 26 Jul 2018 13:20:43 -0000 --ybmzvme6yy3n3dvl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 26, 2018 at 04:07:37AM +0000, Kyle Evans wrote: > Author: kevans > Date: Thu Jul 26 04:07:36 2018 > New Revision: 336731 > URL: https://svnweb.freebsd.org/changeset/base/336731 >=20 > Log: > bectl(8): Redo jail using jail(3) API > =20 > The jail is created with allow.mount, allow.mount.devfs, and > enforce_statfs=3D1. Upon creation, we immediately attach, chdir to "/",= and > drop the user into a shell inside the jail. > =20 > The default IP for this is arbitrarily 10.20.30.40. It seems this would only allow working in a single jailed BE at a time, correct? Thanks, --=20 Shawn Webb Cofounder and Security Engineer HardenedBSD Tor-ified Signal: +1 443-546-8752 Tor+XMPP+OTR: lattera@is.a.hacker.sx GPG Key ID: 0x6A84658F52456EEE GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89 3D9E 6A84 658F 5245 6EEE --ybmzvme6yy3n3dvl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEKrq2ve9q9Ia+iT2eaoRlj1JFbu4FAltZynsACgkQaoRlj1JF bu5mNQ//YBFVq38LArHQyP9d+eRldaZZV/U5JpTRNlPK0cy1hroXvJ+7BBpPPGws lODGHEOKpYTwv6mQbBXsgH+IVogGIW0q0Je7OKJs3V6RF0J893Wy+H30K3kNCZY2 m6qf+XI5L2EOCOXmghKktBbUcNWp+VPcp8oZUARmrW2x1kCBB3z53jDO3iyJYb3q EgXpqTpUXQbWZQSmHgTOfhIQms8FcVQ5rEEWdm2CAYXs8kUWRMd8/GxqYsbWddpK sXfva8/4lPqEdAW+7IPnZGOz7JCYeXlc0y0zRUlU9xGEa9O5wZ7NcF4XJiS0IDhc vd9wMhyNhswa4NwZ657OGUPxTxBoD86PybnojGg9dZK3mIxWq+bNoDnlGi6w8I60 BlnckQFBXyi3rB3P6v4+ZPetd2yUz/M4020EnzVxeDH3yyj8IlnchDBd+aHGuYoW nEXoPzm4PMY4FdTVt7cw3x2h6zYDLzr3RsUaZVJ8+WKsFiwPyYzrbRVo/XhMhv+o F6bB8Wnx6JKXk0AsLUopBJZrWvqGneWj21vcbqZ2nK44sQqHxpu0c7MT2deWSiS7 n6KLyGFDKyO1etUKnG/sfPcctoqP9NKB3+t6iG7JDC6MuHXydYWUzXZyUfq1Cy4b ivJ+3g+M+oQaUCROdXwax6SHDMs8Tgg8E+IW8umOTgZ6BwNzYfM= =mdbt -----END PGP SIGNATURE----- --ybmzvme6yy3n3dvl-- From owner-svn-src-projects@freebsd.org Thu Jul 26 13:32: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 7A032104F4C4 for ; Thu, 26 Jul 2018 13:32:49 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EC8F28F025; Thu, 26 Jul 2018 13:32:48 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w6QDWdkK045746; Thu, 26 Jul 2018 06:32:39 -0700 (PDT) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w6QDWdQI045745; Thu, 26 Jul 2018 06:32:39 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201807261332.w6QDWdQI045745@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r336731 - projects/bectl/sbin/bectl In-Reply-To: <20180726131959.qplqj62fkjzcfyid@mutt-hbsd> To: Shawn Webb Date: Thu, 26 Jul 2018 06:32:39 -0700 (PDT) CC: Kyle Evans , src-committers@freebsd.org, svn-src-projects@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII 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: Thu, 26 Jul 2018 13:32:49 -0000 -- Start of PGP signed section. > On Thu, Jul 26, 2018 at 04:07:37AM +0000, Kyle Evans wrote: > > Author: kevans > > Date: Thu Jul 26 04:07:36 2018 > > New Revision: 336731 > > URL: https://svnweb.freebsd.org/changeset/base/336731 > > > > Log: > > bectl(8): Redo jail using jail(3) API > > > > The jail is created with allow.mount, allow.mount.devfs, and > > enforce_statfs=1. Upon creation, we immediately attach, chdir to "/", and > > drop the user into a shell inside the jail. > > > > The default IP for this is arbitrarily 10.20.30.40. > > It seems this would only allow working in a single jailed BE at a > time, correct? Also it is just bad practice to use arbitrary IP's from rfc1918 space. IMHO it would be better to pick a rfc3927 link local address, or one of the rfc5737 test network addresses. Please see RFC5735 page 6, table in section 4, no place in FreeBSD base system should we be shipping stuff that uses rfc1918, that is private space that does not belong to the OS. > Thanks, > Shawn Webb Regards, -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-projects@freebsd.org Thu Jul 26 13:47:53 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 E4CB8104FB66 for ; Thu, 26 Jul 2018 13:47:52 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8D7D18FA76; Thu, 26 Jul 2018 13:47:52 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id 2609326379; Thu, 26 Jul 2018 13:47:52 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-lj1-f169.google.com with SMTP id q127-v6so1557818ljq.11; Thu, 26 Jul 2018 06:47:52 -0700 (PDT) X-Gm-Message-State: AOUpUlEMFwOfWUYUjpdqWs5VYF+PHwMP/3DVdjrGCp3twN9atl/REdia 5EdUVuhnGwAUpditt+MQT7MCFNIhOrI7GYHXg1Q= X-Google-Smtp-Source: AAOMgpf6hiRBlM/IuY7cbn+toKHcBgSfG/mZPAXxYCiEl4cKwmmo+zgDfLDBRS8r5gJ+aS8crI9XzxDjZPWTtPOJ80s= X-Received: by 2002:a2e:4055:: with SMTP id n82-v6mr1633283lja.99.1532612870777; Thu, 26 Jul 2018 06:47:50 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:5742:0:0:0:0:0 with HTTP; Thu, 26 Jul 2018 06:47:30 -0700 (PDT) In-Reply-To: <201807261332.w6QDWdQI045745@pdx.rh.CN85.dnsmgr.net> References: <20180726131959.qplqj62fkjzcfyid@mutt-hbsd> <201807261332.w6QDWdQI045745@pdx.rh.CN85.dnsmgr.net> From: Kyle Evans Date: Thu, 26 Jul 2018 08:47:30 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r336731 - projects/bectl/sbin/bectl To: "Rodney W. Grimes" Cc: Shawn Webb , src-committers , svn-src-projects@freebsd.org Content-Type: text/plain; charset="UTF-8" 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: Thu, 26 Jul 2018 13:47:53 -0000 On Thu, Jul 26, 2018 at 8:32 AM, Rodney W. Grimes wrote: > -- Start of PGP signed section. >> On Thu, Jul 26, 2018 at 04:07:37AM +0000, Kyle Evans wrote: >> > Author: kevans >> > Date: Thu Jul 26 04:07:36 2018 >> > New Revision: 336731 >> > URL: https://svnweb.freebsd.org/changeset/base/336731 >> > >> > Log: >> > bectl(8): Redo jail using jail(3) API >> > >> > The jail is created with allow.mount, allow.mount.devfs, and >> > enforce_statfs=1. Upon creation, we immediately attach, chdir to "/", and >> > drop the user into a shell inside the jail. >> > >> > The default IP for this is arbitrarily 10.20.30.40. >> >> It seems this would only allow working in a single jailed BE at a >> time, correct? > > Also it is just bad practice to use arbitrary IP's from > rfc1918 space. IMHO it would be better to pick a > rfc3927 link local address, or one of the rfc5737 test > network addresses. > > Please see RFC5735 page 6, table in section 4, no > place in FreeBSD base system should we be shipping > stuff that uses rfc1918, that is private space that > does not belong to the OS. > Right on both accounts (Shawn + Rod)... I changed it from an arbitrary IP in 192.168/16 space that was conflicting with my local network (heh... that was fun) with the intent of later changing it to just be configurable rather than hard-coding an IP [1] because I think that no matter what choice I try to go with, someone's going to want something else. I'd rather not make such choices at all and force you to instead specify an IP every time, a la "bectl jail testenv 10.8.0.100". The default remains 10.20.30.40 until that time, though, and it seemed that anyone wanting to test this should be aware. [1] see the "XXX TODO" I dropped in the area, which mentions the former and meant to hint at the latter From owner-svn-src-projects@freebsd.org Thu Jul 26 14:08:38 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 84B611050593 for ; Thu, 26 Jul 2018 14:08:38 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: from mail-wm0-x234.google.com (mail-wm0-x234.google.com [IPv6:2a00:1450:400c:c09::234]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id EF4E790CAB for ; Thu, 26 Jul 2018 14:08:37 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: by mail-wm0-x234.google.com with SMTP id h20-v6so2138573wmb.4 for ; Thu, 26 Jul 2018 07:08:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=N13WNqO9Em3RCzERE8lIaIXM7B49v4b696IoU16B73E=; b=FKzg/H/gPkVXl/ppSXD3NgJXucMNcDsoowWuIJrtNc38v6Lszw+XIh65F72dlTJbYf S7en3trE/v94B/VnVwbXc046EDA1NFAxUkOc8iAo75XKAu/ZWCjkX4/e0FA88Ikc/RJK fVWpuM2MWSDZATiqcIR1geeo4Uizc1SkrKN3E/WZjbIJ16REurhETye/Oz2dw0qbtDCy 7w1g/YPGVCQqy85jOc1J5Cf5s/W8SvMOVgplZ8AA3k4LbBYGn0s69pgwe3Xc62VFmgG7 Ee0jDf9AGmn5IcCE8Mj4xUhJ881mthmJJQOjSx1DHs6Lrzp96SCQXkGmBE/+szlPQutC Rvwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=N13WNqO9Em3RCzERE8lIaIXM7B49v4b696IoU16B73E=; b=CeaeWac3jaMrlp0VPyXjF48UiGjmJ94KvVsvwQvLlO1V9EyPBPQFlxACa5VacR3GzH TThKQT5XDL36H1rej7r92NRbZmfi4NQrrF3DqLAaWVs+cQSQnYOQmUTUT3ZEJ1B4Fg01 hKK1ZCeRupiEcwqRjKt/mbs5KyPGPMGgk/2y7JkYXXqsi1Fkw5I6ICzdnF6XdgrbAhRU Q5nMKpyq5PMFhwHMZGV6y97y1CDwSYu13TfJpi2u9JdzGSVAuMbL8waSSEafGUVcP4js zScWKlbtDqdK15u9phGmvynQEdpVh/55tuGsCARTsKyZrXXjenD6d1AD5cpgy3TFaP7D Mbaw== X-Gm-Message-State: AOUpUlEyUiNcPVd/7QUpK81ud4BQR7qONPZvqHr6FC1z5/7aae6GyN8A qStU3B8Q/o01td5MAnzES1GwsItHJy/7eA== X-Google-Smtp-Source: AAOMgpcmVvK3ENmuuwcc04gr0WI1ryDMsIIVioV3bI8aBqU2mhyD8qXzq+2uMF4bsIfC3N4BXhfD8Q== X-Received: by 2002:a1c:dc41:: with SMTP id t62-v6mr1719715wmg.42.1532614116756; Thu, 26 Jul 2018 07:08:36 -0700 (PDT) Received: from mutt-hbsd (politkovskaja.torservers.net. [77.247.181.165]) by smtp.gmail.com with ESMTPSA id l15-v6sm934170wrt.67.2018.07.26.07.08.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 07:08:35 -0700 (PDT) Date: Thu, 26 Jul 2018 10:07:49 -0400 From: Shawn Webb To: Kyle Evans Cc: "Rodney W. Grimes" , src-committers , svn-src-projects@freebsd.org Subject: Re: svn commit: r336731 - projects/bectl/sbin/bectl Message-ID: <20180726140749.k2zgrtbrmquawbhs@mutt-hbsd> References: <20180726131959.qplqj62fkjzcfyid@mutt-hbsd> <201807261332.w6QDWdQI045745@pdx.rh.CN85.dnsmgr.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jif36glxs4hrvwr2" Content-Disposition: inline In-Reply-To: X-Operating-System: FreeBSD mutt-hbsd 12.0-CURRENT FreeBSD 12.0-CURRENT X-PGP-Key: http://pgp.mit.edu/pks/lookup?op=vindex&search=0x6A84658F52456EEE User-Agent: NeoMutt/20180622 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: Thu, 26 Jul 2018 14:08:38 -0000 --jif36glxs4hrvwr2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 26, 2018 at 08:47:30AM -0500, Kyle Evans wrote: > On Thu, Jul 26, 2018 at 8:32 AM, Rodney W. Grimes > wrote: > > -- Start of PGP signed section. > >> On Thu, Jul 26, 2018 at 04:07:37AM +0000, Kyle Evans wrote: > >> > Author: kevans > >> > Date: Thu Jul 26 04:07:36 2018 > >> > New Revision: 336731 > >> > URL: https://svnweb.freebsd.org/changeset/base/336731 > >> > > >> > Log: > >> > bectl(8): Redo jail using jail(3) API > >> > > >> > The jail is created with allow.mount, allow.mount.devfs, and > >> > enforce_statfs=3D1. Upon creation, we immediately attach, chdir to= "/", and > >> > drop the user into a shell inside the jail. > >> > > >> > The default IP for this is arbitrarily 10.20.30.40. > >> > >> It seems this would only allow working in a single jailed BE at a > >> time, correct? > > > > Also it is just bad practice to use arbitrary IP's from > > rfc1918 space. IMHO it would be better to pick a > > rfc3927 link local address, or one of the rfc5737 test > > network addresses. > > > > Please see RFC5735 page 6, table in section 4, no > > place in FreeBSD base system should we be shipping > > stuff that uses rfc1918, that is private space that > > does not belong to the OS. > > >=20 > Right on both accounts (Shawn + Rod)... I changed it from an arbitrary > IP in 192.168/16 space that was conflicting with my local network > (heh... that was fun) with the intent of later changing it to just be > configurable rather than hard-coding an IP [1] because I think that no > matter what choice I try to go with, someone's going to want something > else. I'd rather not make such choices at all and force you to instead > specify an IP every time, a la "bectl jail testenv 10.8.0.100". Or perhaps to jail the BE without an IP at all. Sometimes all I want to do before rebooting into a new BE is just set an rc.conf value (disable a service, for example). Also, as we look forward to IPv6, it would be nice if IPv6 was supported as well. >=20 > The default remains 10.20.30.40 until that time, though, and it seemed > that anyone wanting to test this should be aware. >=20 > [1] see the "XXX TODO" I dropped in the area, which mentions the > former and meant to hint at the latter --=20 Shawn Webb Cofounder and Security Engineer HardenedBSD Tor-ified Signal: +1 443-546-8752 Tor+XMPP+OTR: lattera@is.a.hacker.sx GPG Key ID: 0x6A84658F52456EEE GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89 3D9E 6A84 658F 5245 6EEE --jif36glxs4hrvwr2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEKrq2ve9q9Ia+iT2eaoRlj1JFbu4FAltZ1bEACgkQaoRlj1JF bu5ITA//XNtk3CdXUk5wGKN/8F9fKYtyuF5TWAwL1l6ucWk6GdZVcXWFe+sgnKaX 0HRJC0Hg1+ixCWcdp7J/2RFx1dfLloDpkvq5gfGF0R6o2fLyE31cLlxYHTrRK6kZ BFvmI4Im4j6vkOOpxgZZioBC9zGBdlM8lsYWXp51Gb3aMCN5Ir9U2VHtZ06bHgs1 c8WUhfut8XyjfKMRlFLfFQ/nvzBNdWWlvrVX4jHA+8l/uq0WnZwVS8XGwVTGhSiH lOaz+as+RE34wowMuiIOwCpQjMtjvT9G9xa1iUI2Rkr9Aq6w4VYuJQ2eXOlBbEw7 +YNLbuEHs7H1UjGXjvTUBewBcuMwQsmBMDrJo0rQv5hGN+vRUys2TGuNFcarddFx vUtL5igV/uKCoZYBKxqz+VL2XPO9/mapgkdZvknAu3ZnlVyNFv1N/ikSomZbqAO+ GwANx5IX1ImQ943rKsTZsr9BTFQTJT2HrLdiJZxloN5sFVgbzxKf+PbwT8FGqLUq 6cFPYgsThQeUUC+xLTzII3zU4OdK5oIA6PDjclXehQIVrxjFA0dL+ZR1ufgau0m1 40gS1owS9AEDSpcjTfyeXUjowpvh1niZVTcu0EDy5b631EA41V+Nz7PeavKsyrYJ de8nWEIdGYgghM876eVZDV78dWL1U10AeHigEr5gjLW3Vh4txLQ= =870x -----END PGP SIGNATURE----- --jif36glxs4hrvwr2-- From owner-svn-src-projects@freebsd.org Thu Jul 26 14:17:07 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 4702310509A6 for ; Thu, 26 Jul 2018 14:17:07 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A76F59135E; Thu, 26 Jul 2018 14:17:06 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w6QEH3XY046033; Thu, 26 Jul 2018 07:17:03 -0700 (PDT) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w6QEH37R046032; Thu, 26 Jul 2018 07:17:03 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201807261417.w6QEH37R046032@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r336731 - projects/bectl/sbin/bectl In-Reply-To: To: Kyle Evans Date: Thu, 26 Jul 2018 07:17:03 -0700 (PDT) CC: "Rodney W. Grimes" , Shawn Webb , src-committers , svn-src-projects@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII 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: Thu, 26 Jul 2018 14:17:07 -0000 > On Thu, Jul 26, 2018 at 8:32 AM, Rodney W. Grimes > wrote: > > -- Start of PGP signed section. > >> On Thu, Jul 26, 2018 at 04:07:37AM +0000, Kyle Evans wrote: > >> > Author: kevans > >> > Date: Thu Jul 26 04:07:36 2018 > >> > New Revision: 336731 > >> > URL: https://svnweb.freebsd.org/changeset/base/336731 > >> > > >> > Log: > >> > bectl(8): Redo jail using jail(3) API > >> > > >> > The jail is created with allow.mount, allow.mount.devfs, and > >> > enforce_statfs=1. Upon creation, we immediately attach, chdir to "/", and > >> > drop the user into a shell inside the jail. > >> > > >> > The default IP for this is arbitrarily 10.20.30.40. > >> > >> It seems this would only allow working in a single jailed BE at a > >> time, correct? > > > > Also it is just bad practice to use arbitrary IP's from > > rfc1918 space. IMHO it would be better to pick a > > rfc3927 link local address, or one of the rfc5737 test > > network addresses. > > > > Please see RFC5735 page 6, table in section 4, no > > place in FreeBSD base system should we be shipping > > stuff that uses rfc1918, that is private space that > > does not belong to the OS. > > > > Right on both accounts (Shawn + Rod)... I changed it from an arbitrary > IP in 192.168/16 space that was conflicting with my local network > (heh... that was fun) with the intent of later changing it to just be > configurable rather than hard-coding an IP [1] because I think that no > matter what choice I try to go with, someone's going to want something > else. I'd rather not make such choices at all and force you to instead > specify an IP every time, a la "bectl jail testenv 10.8.0.100". > > The default remains 10.20.30.40 until that time, though, and it seemed > that anyone wanting to test this should be aware. Can you make it just unconfigured instead? I really am strongly pressing the point that we should never ever commit rfc1918 addresses to the repository. Some address in 192.168/16 conflicted with your network, some address in 10/8 conflicts with my network, and probably others. If you do anything stick a 169.254 on it. That is after all what link locals are for. > [1] see the "XXX TODO" I dropped in the area, which mentions the > former and meant to hint at the latter > -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-projects@freebsd.org Thu Jul 26 14:23:03 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 313491050C6A for ; Thu, 26 Jul 2018 14:23:03 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D931191979; Thu, 26 Jul 2018 14:23:02 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id 76B532679C; Thu, 26 Jul 2018 14:23:02 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-lj1-f178.google.com with SMTP id f1-v6so1664069ljc.9; Thu, 26 Jul 2018 07:23:02 -0700 (PDT) X-Gm-Message-State: AOUpUlE8JloKxzsanA6lWZg8ZMjKpRXWp/mKzOuArmAFQMn49atl521Y Kb/Dp4OyTcdT/TtfBSOT0z8sWDidQYUO68JNMLs= X-Google-Smtp-Source: AAOMgpdIcBZbk92JYtR6QMSo6hLb7SZkk7C3XrWxysWuDUkVMgdEN8T/rtoNHwRz/48cktTPnPh88eDMh0Kme2wR+aY= X-Received: by 2002:a2e:1004:: with SMTP id j4-v6mr2020873lje.2.1532614981025; Thu, 26 Jul 2018 07:23:01 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:5742:0:0:0:0:0 with HTTP; Thu, 26 Jul 2018 07:22:40 -0700 (PDT) In-Reply-To: <201807261417.w6QEH37R046032@pdx.rh.CN85.dnsmgr.net> References: <201807261417.w6QEH37R046032@pdx.rh.CN85.dnsmgr.net> From: Kyle Evans Date: Thu, 26 Jul 2018 09:22:40 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r336731 - projects/bectl/sbin/bectl To: "Rodney W. Grimes" Cc: Shawn Webb , src-committers , svn-src-projects@freebsd.org Content-Type: text/plain; charset="UTF-8" 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: Thu, 26 Jul 2018 14:23:03 -0000 On Thu, Jul 26, 2018 at 9:17 AM, Rodney W. Grimes wrote: >> On Thu, Jul 26, 2018 at 8:32 AM, Rodney W. Grimes >> wrote: >> > -- Start of PGP signed section. >> >> On Thu, Jul 26, 2018 at 04:07:37AM +0000, Kyle Evans wrote: >> >> > Author: kevans >> >> > Date: Thu Jul 26 04:07:36 2018 >> >> > New Revision: 336731 >> >> > URL: https://svnweb.freebsd.org/changeset/base/336731 >> >> > >> >> > Log: >> >> > bectl(8): Redo jail using jail(3) API >> >> > >> >> > The jail is created with allow.mount, allow.mount.devfs, and >> >> > enforce_statfs=1. Upon creation, we immediately attach, chdir to "/", and >> >> > drop the user into a shell inside the jail. >> >> > >> >> > The default IP for this is arbitrarily 10.20.30.40. >> >> >> >> It seems this would only allow working in a single jailed BE at a >> >> time, correct? >> > >> > Also it is just bad practice to use arbitrary IP's from >> > rfc1918 space. IMHO it would be better to pick a >> > rfc3927 link local address, or one of the rfc5737 test >> > network addresses. >> > >> > Please see RFC5735 page 6, table in section 4, no >> > place in FreeBSD base system should we be shipping >> > stuff that uses rfc1918, that is private space that >> > does not belong to the OS. >> > >> >> Right on both accounts (Shawn + Rod)... I changed it from an arbitrary >> IP in 192.168/16 space that was conflicting with my local network >> (heh... that was fun) with the intent of later changing it to just be >> configurable rather than hard-coding an IP [1] because I think that no >> matter what choice I try to go with, someone's going to want something >> else. I'd rather not make such choices at all and force you to instead >> specify an IP every time, a la "bectl jail testenv 10.8.0.100". >> >> The default remains 10.20.30.40 until that time, though, and it seemed >> that anyone wanting to test this should be aware. > > Can you make it just unconfigured instead? I really am strongly > pressing the point that we should never ever commit rfc1918 addresses > to the repository. Right, like I said- force the user to specify on the command-line what they want. > Some address in 192.168/16 conflicted with your network, > some address in 10/8 conflicts with my network, and probably others. > > If you do anything stick a 169.254 on it. That is after all what > link locals are for. > >> [1] see the "XXX TODO" I dropped in the area, which mentions the >> former and meant to hint at the latter >> > > -- > Rod Grimes rgrimes@freebsd.org From owner-svn-src-projects@freebsd.org Thu Jul 26 14:32:07 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 B2FF21050FAB for ; Thu, 26 Jul 2018 14:32:07 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CEB3191FF1; Thu, 26 Jul 2018 14:32:05 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id 6A3BB2689A; Thu, 26 Jul 2018 14:32:03 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-lj1-f180.google.com with SMTP id l15-v6so1701788lji.6; Thu, 26 Jul 2018 07:32:03 -0700 (PDT) X-Gm-Message-State: AOUpUlFzBPdLcFMEhTI+/ZXgJo7WknWOayk2h7ulWN66uJ3Jk944vL1H VBGD4O4BFLCZhU0KT3602M00PophpjMStrrIOa4= X-Google-Smtp-Source: AAOMgpe40HH8Bo52Yy2tGn7W9Fzd7YeID/e6KLcbSkTtvq616Ns6Gy2wuUd/uVJv8YG8BfI607inBMCfxVOhi9Us7xY= X-Received: by 2002:a2e:8616:: with SMTP id a22-v6mr2035719lji.43.1532615521679; Thu, 26 Jul 2018 07:32:01 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a2e:5742:0:0:0:0:0 with HTTP; Thu, 26 Jul 2018 07:31:40 -0700 (PDT) In-Reply-To: <20180726140749.k2zgrtbrmquawbhs@mutt-hbsd> References: <20180726131959.qplqj62fkjzcfyid@mutt-hbsd> <201807261332.w6QDWdQI045745@pdx.rh.CN85.dnsmgr.net> <20180726140749.k2zgrtbrmquawbhs@mutt-hbsd> From: Kyle Evans Date: Thu, 26 Jul 2018 09:31:40 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r336731 - projects/bectl/sbin/bectl To: Shawn Webb Cc: "Rodney W. Grimes" , src-committers , svn-src-projects@freebsd.org Content-Type: text/plain; charset="UTF-8" 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: Thu, 26 Jul 2018 14:32:08 -0000 On Thu, Jul 26, 2018 at 9:07 AM, Shawn Webb wrote: > On Thu, Jul 26, 2018 at 08:47:30AM -0500, Kyle Evans wrote: >> On Thu, Jul 26, 2018 at 8:32 AM, Rodney W. Grimes >> wrote: >> > -- Start of PGP signed section. >> >> On Thu, Jul 26, 2018 at 04:07:37AM +0000, Kyle Evans wrote: >> >> > Author: kevans >> >> > Date: Thu Jul 26 04:07:36 2018 >> >> > New Revision: 336731 >> >> > URL: https://svnweb.freebsd.org/changeset/base/336731 >> >> > >> >> > Log: >> >> > bectl(8): Redo jail using jail(3) API >> >> > >> >> > The jail is created with allow.mount, allow.mount.devfs, and >> >> > enforce_statfs=1. Upon creation, we immediately attach, chdir to "/", and >> >> > drop the user into a shell inside the jail. >> >> > >> >> > The default IP for this is arbitrarily 10.20.30.40. >> >> >> >> It seems this would only allow working in a single jailed BE at a >> >> time, correct? >> > >> > Also it is just bad practice to use arbitrary IP's from >> > rfc1918 space. IMHO it would be better to pick a >> > rfc3927 link local address, or one of the rfc5737 test >> > network addresses. >> > >> > Please see RFC5735 page 6, table in section 4, no >> > place in FreeBSD base system should we be shipping >> > stuff that uses rfc1918, that is private space that >> > does not belong to the OS. >> > >> >> Right on both accounts (Shawn + Rod)... I changed it from an arbitrary >> IP in 192.168/16 space that was conflicting with my local network >> (heh... that was fun) with the intent of later changing it to just be >> configurable rather than hard-coding an IP [1] because I think that no >> matter what choice I try to go with, someone's going to want something >> else. I'd rather not make such choices at all and force you to instead >> specify an IP every time, a la "bectl jail testenv 10.8.0.100". > > Or perhaps to jail the BE without an IP at all. Sometimes all I want > to do before rebooting into a new BE is just set an rc.conf value > (disable a service, for example). > > Also, as we look forward to IPv6, it would be nice if IPv6 was > supported as well. > As I said in the e-mail you guys are replying to, I plan on getting out of the IP game because this game sucks. =) If it's useful, `bectl jail` could grow the ability to specify jail parameters via -o, e.g. `bectl jail -o ip4.addr=... -o ip6.addr=... -o allow.mount=false testenv ...` From owner-svn-src-projects@freebsd.org Thu Jul 26 18:56:51 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 3FFC110573EC for ; Thu, 26 Jul 2018 18:56:51 +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 E5B8C744E2; Thu, 26 Jul 2018 18:56:50 +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 C3F145489; Thu, 26 Jul 2018 18:56:50 +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 w6QIuoY9090935; Thu, 26 Jul 2018 18:56:50 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6QIuo6C090934; Thu, 26 Jul 2018 18:56:50 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807261856.w6QIuo6C090934@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 26 Jul 2018 18:56:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336747 - projects/bectl/sbin/bectl X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: projects/bectl/sbin/bectl X-SVN-Commit-Revision: 336747 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: Thu, 26 Jul 2018 18:56:51 -0000 Author: kevans Date: Thu Jul 26 18:56:50 2018 New Revision: 336747 URL: https://svnweb.freebsd.org/changeset/base/336747 Log: bectl(8): Hack together a more proper `bectl list` Note that the space is currently just the 'used' property of the dataset. Modified: projects/bectl/sbin/bectl/Makefile projects/bectl/sbin/bectl/bectl.c Modified: projects/bectl/sbin/bectl/Makefile ============================================================================== --- projects/bectl/sbin/bectl/Makefile Thu Jul 26 18:34:38 2018 (r336746) +++ projects/bectl/sbin/bectl/Makefile Thu Jul 26 18:56:50 2018 (r336747) @@ -6,6 +6,7 @@ MAN= bectl.8 LIBADD+= be LIBADD+= jail LIBADD+= nvpair +LIBADD+= util CFLAGS+= -I${SRCTOP}/cddl/contrib/opensolaris/lib/libzfs/common CFLAGS+= -I${SRCTOP}/sys/cddl/compat/opensolaris Modified: projects/bectl/sbin/bectl/bectl.c ============================================================================== --- projects/bectl/sbin/bectl/bectl.c Thu Jul 26 18:34:38 2018 (r336746) +++ projects/bectl/sbin/bectl/bectl.c Thu Jul 26 18:56:50 2018 (r336747) @@ -31,16 +31,24 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include +#define HEADER_BE "BE" +#define HEADER_ACTIVE "Active" +#define HEADER_MOUNT "Mountpoint" +#define HEADER_SPACE "Space" +#define HEADER_CREATED "Created" + static int bectl_cmd_activate(int argc, char *argv[]); static int bectl_cmd_create(int argc, char *argv[]); static int bectl_cmd_destroy(int argc, char *argv[]); @@ -406,8 +414,14 @@ bectl_cmd_jail(int argc, char *argv[]) static int bectl_cmd_list(int argc, char *argv[]) { - nvlist_t *props; - int opt; +#define BUFSZ 64 + nvpair_t *cur; + nvlist_t *props, *dsprops; + unsigned long long ctimenum, space; + size_t be_maxcol; + int active_colsz, active_colsz_def, be_colsz, mount_colsz, opt, space_colsz; + char buf[BUFSZ], *creation, *mnt, *spacestr; + boolean_t active_now, active_reboot; bool show_all_datasets, show_space, hide_headers, show_snaps; props = NULL; @@ -450,10 +464,69 @@ bectl_cmd_list(int argc, char *argv[]) return (1); } - dump_nvlist(props, 0); + be_maxcol = strlen(HEADER_BE); + for (cur = nvlist_next_nvpair(props, NULL); cur != NULL; + cur = nvlist_next_nvpair(props, cur)) { + be_maxcol = MAX(be_maxcol, strlen(nvpair_name(cur))); + } + + be_colsz = -be_maxcol; + /* To be made negative after calculating final col sz */ + active_colsz_def = strlen(HEADER_ACTIVE); + mount_colsz = -(int)strlen(HEADER_MOUNT); + space_colsz = -(int)strlen(HEADER_SPACE); + printf("%*s %s %s %s %s\n", be_colsz, HEADER_BE, HEADER_ACTIVE, + HEADER_MOUNT, HEADER_SPACE, HEADER_CREATED); + buf[5] = '\0'; + cur = NULL; + for (cur = nvlist_next_nvpair(props, NULL); cur != NULL; + cur = nvlist_next_nvpair(props, cur)) { + printf("%*s ", be_colsz, nvpair_name(cur)); + // NR + active_colsz = active_colsz_def; + nvpair_value_nvlist(cur, &dsprops); + if (nvlist_lookup_boolean_value(dsprops, "active", + &active_now) == 0 && active_now) { + printf("N"); + active_colsz--; + } + if (nvlist_lookup_boolean_value(dsprops, "nextboot", + &active_reboot) == 0 && active_reboot) { + printf("R"); + active_colsz--; + } + if (active_colsz == active_colsz_def) { + printf("-"); + active_colsz--; + } + printf("%*s ", -active_colsz, " "); + if (nvlist_lookup_string(dsprops, "mountpoint", &mnt) == 0) + printf("%*s ", mount_colsz, mnt); + else + printf("%*s ", mount_colsz, "-"); + // used + if (nvlist_lookup_string(dsprops, "used", &spacestr) == 0) { + space = strtoull(spacestr, NULL, 10); + humanize_number(buf, 6, space, "", HN_AUTOSCALE, + HN_DECIMAL | HN_NOSPACE | HN_B); + printf("%*s ", space_colsz, buf); + } else + printf("%*s ", space_colsz, "-"); + + if (nvlist_lookup_string(dsprops, "creation", &creation) == 0) { + ctimenum = strtoull(creation, NULL, 10); + strftime(buf, BUFSZ, "%Y-%m-%d %H:%M", + localtime((time_t *)&ctimenum)); + printf("%s", buf); + } + + // creation + printf("\n"); + } be_prop_list_free(props); return (0); +#undef BUFSZ } From owner-svn-src-projects@freebsd.org Thu Jul 26 18:57:52 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 1C6D7105744D for ; Thu, 26 Jul 2018 18:57:52 +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 C6D987460F; Thu, 26 Jul 2018 18:57:51 +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 A89EF548A; Thu, 26 Jul 2018 18:57:51 +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 w6QIvp6R091018; Thu, 26 Jul 2018 18:57:51 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6QIvp9U091017; Thu, 26 Jul 2018 18:57:51 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201807261857.w6QIvp9U091017@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 26 Jul 2018 18:57:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336748 - projects/bectl/sbin/bectl X-SVN-Group: projects X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: projects/bectl/sbin/bectl X-SVN-Commit-Revision: 336748 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: Thu, 26 Jul 2018 18:57:52 -0000 Author: kevans Date: Thu Jul 26 18:57:51 2018 New Revision: 336748 URL: https://svnweb.freebsd.org/changeset/base/336748 Log: bectl(8): Remove sneaky comment Modified: projects/bectl/sbin/bectl/bectl.c Modified: projects/bectl/sbin/bectl/bectl.c ============================================================================== --- projects/bectl/sbin/bectl/bectl.c Thu Jul 26 18:56:50 2018 (r336747) +++ projects/bectl/sbin/bectl/bectl.c Thu Jul 26 18:57:51 2018 (r336748) @@ -520,7 +520,6 @@ bectl_cmd_list(int argc, char *argv[]) printf("%s", buf); } - // creation printf("\n"); } be_prop_list_free(props); From owner-svn-src-projects@freebsd.org Fri Jul 27 23:34:12 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 EC955105A634 for ; Fri, 27 Jul 2018 23:34:11 +0000 (UTC) (envelope-from rmacklem@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 A2A748F179; Fri, 27 Jul 2018 23:34:11 +0000 (UTC) (envelope-from rmacklem@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 83D5D1E947; Fri, 27 Jul 2018 23:34:11 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6RNYBk1075769; Fri, 27 Jul 2018 23:34:11 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6RNYB6j075767; Fri, 27 Jul 2018 23:34:11 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201807272334.w6RNYB6j075767@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Fri, 27 Jul 2018 23:34:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336797 - projects/pnfs-planb-server/usr.sbin/nfsd X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: projects/pnfs-planb-server/usr.sbin/nfsd X-SVN-Commit-Revision: 336797 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: Fri, 27 Jul 2018 23:34:12 -0000 Author: rmacklem Date: Fri Jul 27 23:34:10 2018 New Revision: 336797 URL: https://svnweb.freebsd.org/changeset/base/336797 Log: When parsing the "-p" option for nfsd, only use an IPv6 link local address if it is the only address. Link local addresses that are passed from the MDS to a pNFS client for a DS will only work if they are in the same scope zone and the address is unambiguous for the client. Modified: projects/pnfs-planb-server/usr.sbin/nfsd/nfsd.8 projects/pnfs-planb-server/usr.sbin/nfsd/nfsd.c Modified: projects/pnfs-planb-server/usr.sbin/nfsd/nfsd.8 ============================================================================== --- projects/pnfs-planb-server/usr.sbin/nfsd/nfsd.8 Fri Jul 27 23:28:35 2018 (r336796) +++ projects/pnfs-planb-server/usr.sbin/nfsd/nfsd.8 Fri Jul 27 23:34:10 2018 (r336797) @@ -28,7 +28,7 @@ .\" @(#)nfsd.8 8.4 (Berkeley) 3/29/95 .\" $FreeBSD$ .\" -.Dd June 30, 2018 +.Dd July 27, 2018 .Dt NFSD 8 .Os .Sh NAME @@ -156,6 +156,18 @@ data files for and nfsv4-data1 will be used to store data files for .Dq /export2 . .El +.sp +When using IPv6 addresses for DSs +be wary of using link local addresses. +The IPv6 address for the DS is sent to the client and there is no scope +zone in it. +As such, a link local address may not work for a pNFS client to DS +TCP connection. +When parsed, +.Nm +will only use a link local address if it is the only address returned by +.Xr getaddrinfo 3 +for the DS hostname. .It Fl m Ar mirror_level This option is only meaningful when used with the .Fl p Modified: projects/pnfs-planb-server/usr.sbin/nfsd/nfsd.c ============================================================================== --- projects/pnfs-planb-server/usr.sbin/nfsd/nfsd.c Fri Jul 27 23:28:35 2018 (r336796) +++ projects/pnfs-planb-server/usr.sbin/nfsd/nfsd.c Fri Jul 27 23:34:10 2018 (r336797) @@ -1309,7 +1309,17 @@ parse_dsserver(const char *optionarg, struct nfsd_nfsd memcpy(&sin6, res->ai_addr, sizeof(sin6)); ad = inet_ntop(AF_INET6, &sin6.sin6_addr, ip6, sizeof(ip6)); - break; + + /* + * XXX + * Since a link local address will only + * work if the client and DS are in the + * same scope zone, only use it if it is + * the only address. + */ + if (ad != NULL && + !IN6_IS_ADDR_LINKLOCAL(&sin6.sin6_addr)) + break; } } if (ad == NULL)