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)
This commit is contained in:
Kyle Evans 2018-08-24 20:44:58 +00:00
parent 306abf0f35
commit 8369ba427a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=338303
7 changed files with 20 additions and 20 deletions

View file

@ -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

View file

@ -2,6 +2,7 @@
PACKAGE= lib${LIB}
LIB= be
SHLIBDIR?= /lib
SHLIB_MAJOR= 1
SHLIB_MINOR= 0

View file

@ -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);

View file

@ -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

View file

@ -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

View file

@ -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];

View file

@ -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