Skip to content

Commit

Permalink
libbe(3)/bectl(8): Make consistent with beadm
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
kevans91 committed Aug 24, 2018
1 parent 729ef97 commit 51650c5
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
2 changes: 2 additions & 0 deletions ObsoleteFiles.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/libbe/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

PACKAGE= lib${LIB}
LIB= be
SHLIBDIR?= /lib
SHLIB_MAJOR= 1
SHLIB_MINOR= 0

Expand Down
14 changes: 3 additions & 11 deletions lib/libbe/be.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));

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

Expand Down
9 changes: 7 additions & 2 deletions lib/libbe/libbe.3
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd August 16, 2018
.Dd August 24, 2018
.Dt LIBBE 3
.Os
.Sh NAME
Expand Down Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions sbin/bectl/bectl.8
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd August 22, 2018
.Dd August 24, 2018
.Dt BECTL 8
.Os
.Sh NAME
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions sbin/bectl/bectl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
2 changes: 1 addition & 1 deletion tools/build/mk/OptionalObsoleteFiles.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 51650c5

Please sign in to comment.