From 8369ba427a9a4db4c4886fb2a6d7a7dae00de707 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Fri, 24 Aug 2018 20:44:58 +0000 Subject: [PATCH] libbe(3)/bectl(8): Make consistent with beadm vermaden (maintainer of beadm) points out the following inconsistencies: - "missing command" is not printed prior to usage if the error is simply a missing command; this should be obvious from the context - "bectl rename" isn't using the "don't unmount" flag (zfs rename -u), so the active BE can't be renamed. It doesn't make sense in our context to *not* use -u, so use it. Documentation updates reflect the above and note an inconsistency with the 'destroy' command that is consistent with other parts of the base system. A fix for libbe(3) not properly being installed to /lib is included. SHLIBDIR should have been added when it was moved in r337995. Approved by: re (kib) --- ObsoleteFiles.inc | 2 ++ lib/libbe/Makefile | 1 + lib/libbe/be.c | 14 +++----------- lib/libbe/libbe.3 | 9 +++++++-- sbin/bectl/bectl.8 | 8 +++++--- sbin/bectl/bectl.c | 4 +--- tools/build/mk/OptionalObsoleteFiles.inc | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index 414be14d1fe7..53e3c6104ce5 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -38,6 +38,8 @@ # xargs -n1 | sort | uniq -d; # done +# 20180824: libbe(3) SHLIBDIR fixed to reflect correct location +OLD_LIBS+=usr/lib/libbe.so.1 # 20180819: Remove deprecated arc4random(3) stir/addrandom interfaces OLD_FILES+=usr/share/man/man3/arc4random_addrandom.3.gz OLD_FILES+=usr/share/man/man3/arc4random_stir.3.gz diff --git a/lib/libbe/Makefile b/lib/libbe/Makefile index dad908d2945f..5fada3204fb9 100644 --- a/lib/libbe/Makefile +++ b/lib/libbe/Makefile @@ -2,6 +2,7 @@ PACKAGE= lib${LIB} LIB= be +SHLIBDIR?= /lib SHLIB_MAJOR= 1 SHLIB_MINOR= 0 diff --git a/lib/libbe/be.c b/lib/libbe/be.c index 5b5015612646..16a64f24ca3f 100644 --- a/lib/libbe/be.c +++ b/lib/libbe/be.c @@ -623,10 +623,6 @@ be_rename(libbe_handle_t *lbh, const char *old, const char *new) if ((err = be_root_concat(lbh, new, full_new)) != 0) return (set_error(lbh, err)); - /* Check if old is active BE */ - if (strcmp(full_old, be_active_path(lbh)) == 0) - return (set_error(lbh, BE_ERR_MOUNTED)); - if (!zfs_dataset_exists(lbh->lzh, full_old, ZFS_TYPE_DATASET)) return (set_error(lbh, BE_ERR_NOENT)); @@ -637,14 +633,10 @@ be_rename(libbe_handle_t *lbh, const char *old, const char *new) ZFS_TYPE_FILESYSTEM)) == NULL) return (set_error(lbh, BE_ERR_ZFSOPEN)); - /* XXX TODO: Allow a force flag */ - if (zfs_is_mounted(zfs_hdl, NULL)) { - zfs_close(zfs_hdl); - return (set_error(lbh, BE_ERR_MOUNTED)); - } - /* recurse, nounmount, forceunmount */ - struct renameflags flags = { 0, 0, 0 }; + struct renameflags flags = { + .nounmount = 1, + }; err = zfs_rename(zfs_hdl, NULL, full_new, flags); diff --git a/lib/libbe/libbe.3 b/lib/libbe/libbe.3 index 2e1b8cd699ef..02c14d809946 100644 --- a/lib/libbe/libbe.3 +++ b/lib/libbe/libbe.3 @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 16, 2018 +.Dd August 24, 2018 .Dt LIBBE 3 .Os .Sh NAME @@ -222,7 +222,12 @@ snapshot. .Pp The .Fn be_rename -function renames a boot environment. +function renames a boot environment without unmounting it, as if renamed with +the +.Fl u +argument were passed to +.Nm zfs +.Cm rename .Pp The .Fn be_activate diff --git a/sbin/bectl/bectl.8 b/sbin/bectl/bectl.8 index e853126b6614..56ff28c71e13 100644 --- a/sbin/bectl/bectl.8 +++ b/sbin/bectl/bectl.8 @@ -18,7 +18,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 22, 2018 +.Dd August 24, 2018 .Dt BECTL 8 .Os .Sh NAME @@ -132,7 +132,8 @@ Destroys the given .Ar beName boot environment or .Ar beName@snapshot -snapshot. +snapshot without confirmation, unlike in +.Nm beadm . Specifying .Fl F will automatically unmount without confirmation. @@ -239,10 +240,11 @@ Mount at the specified .Ar mountpoint if provided. .It Cm rename Ar origBeName newBeName -Renames the given nonactive +Renames the given .Ar origBeName to the given .Ar newBeName . +The boot environment will not be unmounted in order for this rename to occur. .It Cm unjail Brq Ar jailID | jailName | beName Destroys the jail created from the given boot environment. .It Xo diff --git a/sbin/bectl/bectl.c b/sbin/bectl/bectl.c index 5a121fda8089..89a90e4af02f 100644 --- a/sbin/bectl/bectl.c +++ b/sbin/bectl/bectl.c @@ -491,10 +491,8 @@ main(int argc, char *argv[]) const char *command; int command_index, rc; - if (argc < 2) { - fprintf(stderr, "missing command\n"); + if (argc < 2) return (usage(false)); - } command = argv[1]; diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index ac0f86f3d581..5d05ddfab6d1 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -1288,7 +1288,7 @@ OLD_FILES+=usr/bin/ztest OLD_FILES+=usr/lib/libbe.a OLD_FILES+=usr/lib/libbe_p.a OLD_FILES+=usr/lib/libbe.so -OLD_LIBS+=usr/lib/libbe.so.1 +OLD_LIBS+=lib/libbe.so.1 OLD_FILES+=usr/lib/libzfs.a OLD_LIBS+=usr/lib/libzfs.so OLD_FILES+=usr/lib/libzfs_core.a