History log of /freebsd-current/lib/libbe/libbe.3
Revision Date Author Comments
# 763f5da9 04-Oct-2023 Graham Perrin <grahamperrin@gmail.com>

libbe(3): history: fix

'bectl(8) and libbe' (not 'libbe and libbe(3)').

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/857


# 04610d66 04-Oct-2023 Graham Perrin <grahamperrin@gmail.com>

libbe(3): consistency, and authors

Consistency with the manual page for bectl(8), including addition of an
AUTHORS section.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/857


# ad99fea9 18-Mar-2024 Dag-Erling Smørgrav <des@FreeBSD.org>

libbe: Fix some markup issues.

MFC after: 3 days
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D44407


# f446c948 12-Jan-2024 Cheng-Yuan Wu <nthu112062583@gapp.nthu.edu.tw>

libbe(3): Fix typo and grammar

Event: Advanced UNIX Programming Course (Fall’23) at NTHU.
Pull Request: https://github.com/freebsd/freebsd-src/pull/1039


# fa9896e0 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: two-line nroff pattern

Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 513bd2fc 18-Oct-2020 Kyle Evans <kevans@FreeBSD.org>

libbe(3): document be_snapshot()

While toying around with lua bindings for libbe(3), I discovered that I
apparently never documented this, despite having documented
be_is_auto_snapshot_name that references it.

MFC after: 1 week


# 5773e924 18-Oct-2020 Kyle Evans <kevans@FreeBSD.org>

libbe(3): const'ify a couple arguments

libbe will never need to mutate these as we either process them into a local
buffer or we just don't touch them and write to a separate out argument.

MFC after: 1 week


# e307eb94 21-Sep-2020 Toomas Soome <tsoome@FreeBSD.org>

loader: zfs should support bootonce an nextboot

bootonce feature is temporary, one time boot, activated by
"bectl activate -t BE", "bectl activate -T BE" will reset the bootonce flag.

By default, the bootonce setting is reset on attempt to boot and the next
boot will use previously active BE.

By setting zfs_bootonce_activate="YES" in rc.conf, the bootonce BE will
be set permanently active.

bootonce dataset name is recorded in boot pool labels, bootenv area.

in case of nextboot, the nextboot_enable boolean variable is recorded in
freebsd:nvstore nvlist, also stored in boot pool label bootenv area.
On boot, the loader will process /boot/nextboot.conf if nextboot_enable
is "YES", and will set nextboot_enable to "NO", preventing /boot/nextboot.conf
processing on next boot.

bootonce and nextboot features are usable in both UEFI and BIOS boot.

To use bootonce/nextboot features, the boot loader needs to be updated on disk;
if loader.efi is stored on ESP, then ESP needs to be updated and
for BIOS boot, stage2 (zfsboot or gptzfsboot) needs to be updated
(gpart or other tools).

At this time, only lua loader is updated.

Sponsored by: Netflix, Klara Inc.
Differential Revision: https://reviews.freebsd.org/D25512


# 6966ac05 23-Jan-2020 Kyle Evans <kevans@FreeBSD.org>

Drop "All Rights Reserved" from all libbe/bectl files

I sent out an e-mail on 2020/01/21 with a plan to do this to Kyle, Rob, and
Wes; all parties have responded in the affirmative that it's OK to drop it
from these files.


# 455d8009 16-Oct-2019 Kyle Evans <kevans@FreeBSD.org>

libbe(3): add needed bits for be_destroy to auto-destroy some origins

New BEs can be created from either an existing snapshot or an existing BE.
If an existing BE is chosen (either implicitly via 'bectl create' or
explicitly via 'bectl create -e foo bar', for instance), then bectl will
create a snapshot of the current BE or "foo" with be_snapshot, with a name
formatted like: strftime("%F-%T") and a serial added to it.

This commit adds the needed bits for libbe or consumers to determine if a
snapshot names matches one of these auto-created snapshots (with some light
validation of the date/time/serial), and also a be_destroy flag to specify
that the origin should be automatically destroyed if possible.

A future commit to bectl will specify BE_DESTROY_AUTOORIGIN by default so we
clean up the origin in the most common case, non-user-managed snapshots.


# fa30d9ed 22-Apr-2019 Kyle Evans <kevans@FreeBSD.org>

libbe(3): allow creation of arbitrary depth boot environments

libbe currently only provides an API to create a recursive boot environment,
without any formal support for intentionally limiting the depth. This
changeset adds an API, be_create_depth, that may be used to arbitrarily
restrict the depth of the new BE.

Submitted by: Rob Fairbanks <rob.fx907 gmail com>
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D18564


# be7dd423 12-Feb-2019 Kyle Evans <kevans@FreeBSD.org>

libbe(3): Fix be_destroy behavior w.r.t. deep BE snapshots and -o

be_destroy is documented to recursively destroy a boot environment. In the
case of snapshots, one would take this to mean that these are also
recursively destroyed. However, this was previously not the case.
be_destroy would descend into the be_destroy callback and attempt to
zfs_iter_children on the top-level snapshot, which is bogus.

Our alternative approach is to take note of the snapshot name and iterate
through all of fs children of the BE to try destruction in the children.

The -o option is also fixed to work properly with deep BEs. If the BE was
created with `bectl create -e otherDeepBE newDeepBE`, for instance, then a
recursive snapshot of otherDeepBE would have been taken for construction of
newDeepBE but a subsequent destroy with BE_DESTROY_ORIGIN set would only
clean up the snapshot at the root of otherDeepBE: ${BEROOT}/otherDeepBE@...

The most recent iteration instead pretends not to know how these things
work, verifies that the origin is another BE and then passes that back
through be_destroy to DTRT when snapshots and deep BEs may be in play.

MFC after: 1 week


# 446ae812 11-Feb-2019 Kyle Evans <kevans@FreeBSD.org>

libbe(3): Belatedly note the BE_DESTROY_ORIGIN option added in r343977

X-MFC-With: r343977


# f5c8cb4c 20-Nov-2018 Mateusz Piotrowski <0mp@FreeBSD.org>

Cross-reference libbe(3) and bectl(8).

Those two manual pages are already referencing each other in the HISTORY
sections, which people might skip. Mention those manual pages explicitly in
the SEE ALSO sections. Also, remove a reference to be(1) from libbe(3).

Reviewed by: bcr
Approved by: krion (mentor, implicit), mat (mentor, implicit)
Differential Revision: https://reviews.freebsd.org/D18136


# cc58f749 21-Nov-2018 Mateusz Piotrowski <0mp@FreeBSD.org>

libbe(3): Put each error value in separate line.

As requested by a TODO in the source code.

Reviewed by: bcr
Approved by: krion (mentor, implicit), mat (mentor, implicit)
Differential Revision: https://reviews.freebsd.org/D18063


# cc624025 18-Nov-2018 Kyle Evans <kevans@FreeBSD.org>

bectl(3)/libbe(3): Allow BE root to be specified

Add an undocumented -r option preceding the bectl subcommand to specify a BE
root to operate out of. This will remain undocumented for now, as some
caveats apply:

- BEs cannot be activated in the pool that doesn't contain the rootfs
- bectl create cannot work out of the box without the -e option right now,
since it defaults to the rootfs and cross-pool cloning doesn't work like
that (IIRC)

Plumb the BE root through to libbe(3) so that some things -can- be done to
it, e.g.

bectl -r tank/ROOT create -e default upgrade
bectl -r tank/ROOT mount upgrade /mnt

this aides in some upgrade setups where rootfs is not necessarily ZFS, and
also makes it easier/possible to regression-test bectl when combined with a
file-backed zpool.

MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D18029


# 162ec569 31-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

libbe(3): Fix error handling with respect to be_exists

Some paths through be_exists will set the error state, others will not
There are multiple reasons that a call can fail, so clean it up a bit: all
paths now return an appropriate error code so the caller can attempt to
distinguish between a BE legitimately not existing and just having the wrong
mountpoint. The caller is expected to bubble the error through to the
internal error handler as needed.

This fixes some unfriendliness with bectl(8)'s activate subcommand, where
it might fail due to a bad mountpoint but the only message output is a
generic "failed to activate" message.

Approved by: re (gjb)


# 8369ba42 24-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

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)


# 5b7803a9 16-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

libbe(3): Impose dataset length restrictions on boot env name validation

Previously, we only validated names for character restrictions. This is
helpful, but we should've also checked length restrictions- dataset names
must be restricted to MAXNAMELEN.

While here, move validation before doing a bunch of concatenations and fix
error handling in be_rename. It was previously setting the error state based
on return value from a libzfs function, which is wrong: libzfs errors don't
necessarily match cleanly to libbe errors. This would cause the assertion in
be_error to hit when the error was printed.


# a8e44f4d 16-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

libbe(3): Prefer safer versions of strcat/strcpy

Or, in the activate case, just use snprintf since that's effectively what
we're doing anyways.


# 1b057aac 12-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

libbe(3): Fix be_import to delete temp snapshot

Deleting the temp snapshot isn't immediately possible because it's the
origin of the newly imported boot environment. However, this is trivially
solved by opening the new boot environment and promoting it. The roles are
now reversed and the temp snapshot/dataset may be completely destroyed.

Remove the BUGS from libbe(3) and bectl(8).


# d2a6bc9f 10-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

libbe(3): Document the import bug...


# 7c2cc9b2 10-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

libbe(3): Brain dump...


# 84e61219 10-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

libbe(3)/bectl(8): Make igor and mandoc -Tlint a little happier


# 11f2a123 10-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

libbe(3): Bring man page back into reality


# b179da01 07-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

libbe(3)/bectl(8): Standardize copyright headers

- File names don't necessarily need to be repeated
- Add SPDX tags
- Add a missing copyright for Kyle Kneitinger in bectl.8, originally written
by him in GSoC 2017; his standard copyright notice has been copied from
other files within the same directory to remain consistent with how he
clearly wished to portray it


# f1ca70d3 06-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

libbe(3): Return some more proper error codes


# 96c5db58 05-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

bectl(8): Implement `bectl list -s`

be_get_dataset_snapshots has been added to libbe(3), effectively returning
the same information as be_get_bootenv_props but for snapshots of the given
dataset. The assumption is that one will have the BE dataset name before
wanting to grab snapshots.


# 9b1662e6 04-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

bectl: Implement -D ("space if origin datasets were deleted")

This also accomplishes the following:

- Proxy through zfs_nicenum as be_nicenum, because it looks better than
humanize_number and would presumably be useful to other libbe consumers.

- Rename be_get_snapshot_props to be_get_dataset_props, make it more useful


# 4146029b 02-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

bectl(8): Take origin snapshot into account when calculating used space

This more closely matches the behavior for beadm. The associated libbe(3)
API is still getting worked out a little bit.


# 843e39ce 25-Jul-2018 Kyle Evans <kevans@FreeBSD.org>

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.


# 734e362f 25-Jul-2018 Kyle Evans <kevans@FreeBSD.org>

libbe(3)/bectl(8): Provide and use proper alloc/free for property lists


# b29bf2f8 25-Jul-2018 Kyle Evans <kevans@FreeBSD.org>

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


# 28f16a0f 24-Jul-2018 Kyle Evans <kevans@FreeBSD.org>

Import libbe(3)/be(1) from socsvn/soc2017/kneitinger/libbe-head