aboutsummaryrefslogtreecommitdiff
path: root/lib/libbe
Commit message (Collapse)AuthorAgeFilesLines
* libbe: Fix some markup issues.Dag-Erling Smørgrav2024-03-221-10/+17
| | | | | | | | MFC after: 3 days Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D44407 (cherry picked from commit ad99fea9045dd3daaeca3d2dd60fffecd2311826)
* libbe: Avoid double printing cloning errors.John Grafton2024-02-191-5/+5
| | | | | | | | | | | | | | be_clone calls be_clone_cb and both call set_error on the return error path. set_error prints the error resulting in a double print. be_clone_cb should just return the error code and allow be_clone to print it. PR: 265248 Reported by: Graham Perrin Reviewed by: imp, kevans Pull Request: https://github.com/freebsd/freebsd-src/pull/685 (cherry picked from commit 8e933d9c598ec847081c322e7ae9a46bf7897886)
* Remove $FreeBSD$: two-line nroff patternWarner Losh2023-08-231-2/+0
| | | | | | | Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/ Similar commit in main: (cherry picked from commit fa9896e082a1)
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-234-4/+0
| | | | | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/ Similar commit in main: (cherry picked from commit d0b2dbfa0ecf)
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-235-10/+0
| | | | | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/ Similar commit in main: (cherry picked from commit 1d386b48a555)
* Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-232-4/+0
| | | | | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/ Similar commit in main: (cherry picked from commit b3e7694832e8)
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-07-259-9/+9
| | | | | | | | | | | 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 (cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
* libbe: bail out early if the zfs kmod isn't loadedKyle Evans2023-07-111-0/+11
| | | | | | | | | | | | | As noted in the comment, we already know the rest of libbe_init() will fail because there's no pool imported. Avoid the side effect by checking beforehand and bailing out early. With this, freebsd-update(8) should no longer trigger a load of the zfs kmod just because it runs `bectl check`. Reviewed by: jwmaag_gmail.com, rew (cherry picked from commit 2f700ca965a04c4a03b6f760da6a210b6ca4df4b)
* pkgbase: Put zfs utilities and lib in their own packageEmmanuel Vadot2023-02-021-1/+1
| | | | | | | | | | | It is useful to have zfs utilities and lib in a separate package as it allow users to create image that can support ZFS (i.e. not with WITHOUT_ZFS in src.conf set) without bloating the default image with all zfs tools (for example for jails). Differential Revision: https://reviews.freebsd.org/D36225 (cherry picked from commit a71ea7bea0d2a8ba86373377c3c1443acbeab5d2)
* bectl: push space-in-name check down into libbeKyle Evans2022-04-061-0/+11
| | | | | | | | | | | | | This check was previously in `create` only, not applying to renames. It should really be applied at the libbe level, so that we can avoid writing about this restriction over and over again. While we're here: `bectl rename` always succeeds, even when it doesn't. Start returning the error. Reported By: Christian McDonald <cmcdonald netgate com> (cherry picked from commit dadb9c70938c4ae2c260f6af65752c67ac752284)
* libbe: fix be_mounted_at() with props after bootonceKyle Evans2022-04-061-0/+1
| | | | | | | propinfo.bootonce was filled with garbage, leading to a segfault later during prop building. Initialize it to NULL. (cherry picked from commit d155d8e138563c0b39c658684e6a4fe6e2e36f8a)
* libbe: pull props for the correct dataset in be_mounted_at()Kyle Evans2022-04-061-1/+1
| | | | | | | | | | | | | | The props feature to this API was added as a "just in case", with no planned consumer. It turns out that it was implemented incorrectly, tapping out props for the BE root (BE's parent) rather than the BE itself in all cases. Fetch properties for the dataset that's actually mounted at the queried path. Reported by: Christian McDonald <cmcdonald netgate com> (cherry picked from commit 31190aa02eef05b1b58ba89212dc8c8738770e37)
* When be_activate() turns on a new boot environment, it always deactivatesGleb Smirnoff2021-01-081-1/+2
| | | | | | | | | the current one first. And if it fails to do so, it abandons activation. However, with the new bootonce feature, there is a legitimate case when a pool doesn't have "bootfs" property set. Check for this case before calling be_deactivate(). Reviewed by: kevans
* pkgbase: Move bectl to the runtime packageEmmanuel Vadot2021-01-041-0/+1
| | | | | | | runtime contain what is needed to boot in single user and repair a system, bectl could be handy to have in this situation. Differential Revision: https://reviews.freebsd.org/D27708
* libbe(3): install MLINKS for all of the functions providedKyle Evans2020-10-181-0/+35
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=366821
* libbe(3): document be_snapshot()Kyle Evans2020-10-181-0/+27
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=366820
* libbe(3): const'ify a couple argumentsKyle Evans2020-10-184-11/+11
| | | | | | | | | | 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 Notes: svn path=/head/; revision=366819
* loader: zfs should support bootonce an nextbootToomas Soome2020-09-216-59/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=365938
* Skip armv7 bectl tests on CI; they deadlock (""KSTACK_PAGES is 2").Edward Tomasz Napierala2020-09-141-0/+5
| | | | | | | | PR: 249229 Sponsored by: DARPA Notes: svn path=/head/; revision=365713
* ZFS: MFV 2.0-rc1-gfd20a8Matt Macy2020-09-041-2/+5
| | | | | | | | | | - fixes jail delegation - fixes raw kstat unsupported complaints - exposes dbgmsg, dbuf, and checksum benchmark stats - restore rename -u support Notes: svn path=/head/; revision=365347
* Temporarily skip tests panic i386 kernel in CILi-Wen Hsu2020-09-021-0/+5
| | | | | | | | | | | lib.libbe.be_create.libbe_create sbin.bectl.bectl_test.bectl_create PR: 249055 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=365271
* libbe: lift the WARNS post-OpenZFS mergeKyle Evans2020-08-251-3/+0
| | | | | | | | | | | | | | | | | sys/ccompile.h no longer uses #pragma ident, so we no longer need to worry about unknown pragmas. I fixed one WARNS issue in r363409 by annotating be_is_auto_snapshot_name's lbh parameter __unused, then upstreamed the following changes to OpenZFS that rode in with the merge: - zfs_path_to_zhandle now takes a const char *path rather than a char *path, since it won't be mutating the string it receives and I had no reason to believe it will need to in the future. [OpenZFS PR #10605] - Annotated some unused parameters on definitions inlined into headers as such. [OpenZFS PR #10606] Notes: svn path=/head/; revision=364775
* Merge OpenZFS support in to HEAD.Matt Macy2020-08-253-23/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The primary benefit is maintaining a completely shared code base with the community allowing FreeBSD to receive new features sooner and with less effort. I would advise against doing 'zpool upgrade' or creating indispensable pools using new features until this change has had a month+ to soak. Work on merging FreeBSD support in to what was at the time "ZFS on Linux" began in August 2018. I first publicly proposed transitioning FreeBSD to (new) OpenZFS on December 18th, 2018. FreeBSD support in OpenZFS was finally completed in December 2019. A CFT for downstreaming OpenZFS support in to FreeBSD was first issued on July 8th. All issues that were reported have been addressed or, for a couple of less critical matters there are pull requests in progress with OpenZFS. iXsystems has tested and dogfooded extensively internally. The TrueNAS 12 release is based on OpenZFS with some additional features that have not yet made it upstream. Improvements include: project quotas, encrypted datasets, allocation classes, vectorized raidz, vectorized checksums, various command line improvements, zstd compression. Thanks to those who have helped along the way: Ryan Moeller, Allan Jude, Zack Welch, and many others. Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D25872 Notes: svn path=/head/; revision=364746
* libbe: annotate lbh as __unused in be_is_auto_snapshot_nameKyle Evans2020-07-221-1/+1
| | | | | | | | | | | | lbh is included for consistency with other functions and in case future work needs to use it, but it is currently unused. Mark it, and a post-OpenZFS-import world will be able to raise WARNS of libbe to the default (pending some minor changes to openzfs libzfs). MFC after: 3 days Notes: svn path=/head/; revision=363409
* Drop "All Rights Reserved" from all libbe/bectl filesKyle Evans2020-01-248-8/+0
| | | | | | | | | 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. Notes: svn path=/head/; revision=357067
* libbe: use the new zfs_mount_at()Kyle Evans2020-01-191-4/+1
| | | | | | | | | | | More background is available in r356876, but this new interface is more portable across ZFS implementations and cleaner for what libbe is attempting to achieve anyways. MFC after: 3 days Notes: svn path=/head/; revision=356877
* libbe(3): promote dependent clones when destroying an environmentKyle Evans2020-01-023-26/+232
| | | | | | | | | | | | | | | | | When removing a boot environment iterate over the dependents and process the snapshots by grabbing any clones. Promote the clones we found and then remove the target environment. This fixes the ability to destroy a boot environment when it has been used to spawn one or more other boot environments. PR: 242592 Submitted by: Wes Maag <jwmaag gmail com> (with changes by myself) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D22953 Notes: svn path=/head/; revision=356279
* Update Makefile.depend filesSimon J. Gerraty2019-12-111-0/+20
| | | | | | | | | | | | | Update a bunch of Makefile.depend files as a result of adding Makefile.depend.options files Reviewed by: bdrewery MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22494 Notes: svn path=/head/; revision=355617
* libbe: fix build against sysutils/openzfs, part 1Kyle Evans2019-12-063-1/+8
| | | | | | | | | | | | This is the half of the changes required that work as-is with both in-tree ZFS and the new hotness, sysutils/openzfs. Highlights are less dependency on header pollution (from somewhere) and using 'mnttab' instead of 'extmnttab'. In the in-tree ZFS, the latter is a #define for the former, but in the port extmnttab is actually a distinct struct that's a super-set of mnttab. We really want mnttab here anyways, so just use it. Notes: svn path=/head/; revision=355460
* Commit missing file from r354116Alan Somers2019-10-261-1/+2
| | | | | | | | | | Pointy-hat-to: Me Reported by: Dan Mack MFC after: 2 weeks MFC-With: 354116 Notes: svn path=/head/; revision=354120
* libbe(3): Fix destroy of imported BE w/ AUTOORIGINKyle Evans2019-10-161-4/+5
| | | | | | | | | | | | | | | | | | | Imported BE, much like the activated BE, will not have an origin that we can fetch/examine for destruction. be_destroy should not return BE_ERR_NOORIGIN for failure to get the origin property for BE_DESTROY_AUTOORIGIN, because we don't really know going into it that there's even an origin to be destroyed. BE_DESTROY_NEEDORIGIN has been renamed to BE_DESTROY_WANTORIGIN because only a subset of it *needs* the origin, so 'need' is too strong of verbiage. This was caught by jenkins and the bectl tests, but kevans failed to run the bectl tests prior to commit. Reported by: lwhsu Notes: svn path=/head/; revision=353663
* libbe(3): add needed bits for be_destroy to auto-destroy some originsKyle Evans2019-10-163-2/+53
| | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=353644
* fixup up fallout from r352447 in libbeAndriy Gapon2019-09-171-1/+2
| | | | | | | | | | I totally forgot that we now have another in-tree consumer of libzfs. MFC after: 3 days X-MFC with: r352447 Notes: svn path=/head/; revision=352449
* pkgbase: Create a FreeBSD-utilities package and make it the default oneEmmanuel Vadot2019-09-051-1/+0
| | | | | | | | | | | | | The default package use to be FreeBSD-runtime but it should only contain binaries and libs enough to boot to single user and repair the system, it is also very handy to have a package that can be tranform to a small mfsroot. So create a new package named FreeBSD-utilities and make it the default one. Also move a few binaries and lib into this package when it make sense. Reviewed by: bapt, gjb Differential Revision: https://reviews.freebsd.org/D21506 Notes: svn path=/head/; revision=351858
* libbe(3): restructure be_mount, skip canmount check for BE datasetKyle Evans2019-06-251-13/+19
| | | | | | | | | | | | Further cleanup after r349380; loader and kernel will both ignore canmount on the root dataset as well, so we should not be so strict about it when mounting it. be_mount is restructured to make it more clear that depth==0 is special, and to not try fetching these properties that we won't care about. MFC after: 3 days Notes: svn path=/head/; revision=349383
* libbe(3): mount: the BE dataset is mounted at /Kyle Evans2019-06-251-1/+1
| | | | | | | | | | | | | | | | Other parts of libbe(3) were fairly strict on the mountpoint property of the BE dataset, and be_mount was not much better. It was improved in r347027 to allow mountpoint=none for depth==0, but this bit was still sensitive to mountpoint != / and mountpoint != none. Given that other parts of libbe(3) no longer restrict the mountpoint property here, and the rest of the base system is generally OK and will assume that a BE is mounted at /, let's do the same. Reported by: ler MFC after: 3 days Notes: svn path=/head/; revision=349380
* libbe(3): Descend into children of datasets w/ mountpoint=noneKyle Evans2019-05-161-5/+5
| | | | | | | | | | | | | These datasets will generally be canmount=noauto,mountpoint=none (e.g. zroot/var) but have children that may need to be mounted. Instead of skipping that segment for no good reason, descend. Submitted by: Wes Maag Reported by: Wes Maag MFC after: 3 days Notes: svn path=/head/; revision=347640
* libbe: set mountpoint=none in be_importKyle Evans2019-05-021-1/+1
| | | | | | | | | | If we're going to set a mountpoint at all, mountpoint=none makes more sense than mountpoint=/. MFC after: 3 days Notes: svn path=/head/; revision=347028
* libbe(3): Properly mount BEs with mountpoint=noneKyle Evans2019-05-021-20/+39
| | | | | | | | | | | | Instead of pretending to successfully mount them while not actually mounting anything, we'll now actually mount them *and* claim we mounted them successfully. Reported by: ler MFC after: 3 days Notes: svn path=/head/; revision=347027
* libbe(3): Fix libcompat buildKyle Evans2019-04-251-1/+2
| | | | | | | | | | | | | SHLIBDIR should still be optionally set, just before src.opts.mk is included so that libcompat can properly override it. This fixes lib32 failures reported by both Jenkins and Michael Butler. Reported by: Michael Butler <imb@protected-networks.net> MFC after: 3 days X-MFC-With: r346546 Notes: svn path=/head/; revision=346705
* libbe(3): Fix mis-application of patch (SHLIBDIR)Kyle Evans2019-04-251-1/+1
| | | | | | | | | | | | | | Rob's patch in D18564 cemented the SHLIBDIR because bsd.own.mk (included by src.opts.mk) sets it to /usr/lib. r346546 did somehow not apply this part of the patch, leaving it to get installed to the wrong place and subsequently removed via ObsoleteFiles. Reported by: jkim MFC after: 3 days X-MFC-With: r346546 Notes: svn path=/head/; revision=346700
* libbe(3): Copy received properties as wellKyle Evans2019-04-251-2/+6
| | | | | | | | | | This was inherently broken on send|recv datasets. Reported and tested by: Wes Maag <jwmaag gmail com> MFC after: 3 days Notes: svn path=/head/; revision=346680
* libbe(3): Add a test for be creationKyle Evans2019-04-224-0/+257
| | | | | | | | | Submitted by: Rob Fairbanks <rob.fx907 gmail com> MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D18564 Notes: svn path=/head/; revision=346546
* libbe(3): allow creation of arbitrary depth boot environmentsKyle Evans2019-04-224-64/+134
| | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=346545
* libbe(3): use libzfs name validation for datasets/snapshot namesKyle Evans2019-04-101-6/+7
| | | | | | | | | | | Our home-rolled solution didn't quite capture all of the details, and we didn't actually validate snapshot names at all. zfs_name_valid captures the important details, but it doesn't necessarily expose the errors that we're wanting to see in the be_validate_* functions. Validating lengths independently, then the names, should make this a non-issue. Notes: svn path=/head/; revision=346082
* libbe(3): Add a serial to the generated snapshot namesKyle Evans2019-04-031-6/+26
| | | | | | | | | | | | | | | | | | | To use bectl in an example, when one creates a new boot environment with either `bectl create <be>` or `bectl create -e <otherbe> <be>`, libbe will take a snapshot of the original boot environment to clone. Previously, this used %F-%T date format as the snapshot name, but this has some limitations- attempting to create multiple boot environments in quick succession may collide if done within the same second. Tack a serial onto it to reduce the chances of a collision... we could still collide if multiple processes/threads are creating boot environments at the same time, but this is likely not a big concern as this has only been reported as occurring in freebsd-ci setup. MFC after: 3 days Notes: svn path=/head/; revision=345848
* libbe: Fix zfs_is_mounted check w/ snapshotsKyle Evans2019-04-011-10/+10
| | | | | | | | | | | | | | 'be_destroy' can destroy a boot environment (by name) or a given snapshot. If the target to be destroyed is a dataset, check if it's mounted. We don't want to check if the origin dataset is mounted when destroying a snapshot. PR: 236043 Submitted by: Rob Fairbanks <rob.fx907 gmail com> MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D19650 Notes: svn path=/head/; revision=345769
* libbe(3): Fix be_destroy behavior w.r.t. deep BE snapshots and -oKyle Evans2019-02-134-25/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=344084
* libbe(3): Belatedly note the BE_DESTROY_ORIGIN option added in r343977Kyle Evans2019-02-121-1/+8
| | | | | | | X-MFC-With: r343977 Notes: svn path=/head/; revision=344034
* libbe(3): Add a destroy option for removing the originKyle Evans2019-02-102-7/+24
| | | | | | | | | | | | | | | | | | Currently origin snapshots are left behind when a BE is destroyed, whether it was an auto-created snapshot or explicitly specified via, for example, `bectl create -e be@mysnap ...`. Removing it automatically could be argued as a POLA violation in some circumstances, so provide a flag to be_destroy for it. An accompanying option will be added to bectl(8) to utilize this. Some minor style/consistency nits in the affected areas also addressed. Reported by: Shawn Webb MFC after: 1 week Notes: svn path=/head/; revision=343977