Commit Graph

44 Commits

Author SHA1 Message Date
Kyle Evans
9491dcf564 bectl(8): Appease clang-scan
Use strlcpy instead of a plain strcpy
2018-08-16 17:59:49 +00:00
Kyle Evans
55b0e92b89 libbe(3)/bectl(8): Hit rewind on a bunch of off-by-ones
While here, use sizeof() in some places that it makes sense to reduce room
for error and prefer strlcpy to strncpy
2018-08-16 17:56:03 +00:00
Kyle Evans
4c5d19fda4 bectl(8): Check jailparam_* return values
Previous iteration of this assumed that these won't fail because we've
already setup the jail param to this point, but the allocations could still
fail in pretty bad conditions.

Admit that it's possible and return (ENOENT, EINVAL, ENOMEM, or 0) when
deleting arguments. EINVAL shouldn't happen since we're passing optarg;
which may satisfy *optarg == '\0' but never optarg == NULL.

CID:		1394885, 1394901
2018-08-14 18:35:33 +00:00
Kyle Evans
f2fdf2a1dc libbe(3)/bectl(8): Remove now-redundant include paths
These were previously necessary because the libnvpair and libzfs_core
includes were not installed into the SYSROOT, being a part of the copies
target in include/Makefile rather than being installed with the library.

This was fixed in r337696 and the headers are now installed properly, so we
may let go of the cruft.
2018-08-13 05:01:19 +00:00
Kyle Evans
1b057aac2b 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).
2018-08-13 03:42:14 +00:00
Kyle Evans
9fe5b5bf13 bectl(8): Use strcmp, rather than trying to directly compare 2018-08-12 00:09:52 +00:00
Kyle Evans
e903601824 bectl(8): Rename "index" variable, which shadows a global in some lands 2018-08-12 00:00:13 +00:00
Kyle Evans
35d2028fb8 libbe(3)/bectl(8): More SYSROOT/GCC build fixes
- Missing include path
- Fully specify libzfs's dependencies (except for deps pulled in by other
  deps) in Makefile.inc1
- Drop WARNS back down to 2 for libbe(3). I do this with much hesitation,
  but the libzfs headers are apparently a hot warning-filled mess as far as
  GCC 4.2 is concerned.
2018-08-11 22:45:39 +00:00
Kyle Evans
efa70a5614 bectl(8): Add missing include path 2018-08-11 20:47:35 +00:00
Kyle Evans
6eeb282e00 bectl(8): Also document the import bug. 2018-08-11 04:11:34 +00:00
Kyle Evans
216d435975 bectl(8): Swap the order of ujail/umount documentation...
"Despite my inconsistency, consistency is king." -Anonymous
2018-08-11 04:03:05 +00:00
Kyle Evans
34761e8423 bectl(8): Document export/import 2018-08-11 04:01:24 +00:00
Kyle Evans
84e6121955 libbe(3)/bectl(8): Make igor and mandoc -Tlint a little happier 2018-08-11 01:40:24 +00:00
Kyle Evans
3d1a1f2caf libbe(3)/bectl(8): Kill off the 'add' functionality for now
The mostly-undocumented 'add' functionality, from initial read-through, is
intended for construction of deep ("bdrewery style") boot environments.
However, it's mostly broken at this point. `#if SOON` it out on both sides
so that we're not exposing a broken API/feature.

Work will resume on it in due time.
2018-08-11 01:02:27 +00:00
Kyle Evans
b6e7c421b7 libbe(3)/bectl(8): Standardize $FreeBSD$ IDs 2018-08-07 14:02:41 +00:00
Kyle Evans
b179da0111 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
2018-08-07 13:46:06 +00:00
Kyle Evans
709b553cd0 libbe(3): Check that dataset is to be mounted at / for be_exists
This makes the be_exists behavior match the comments that assert that we've
already checked that the dataset derived from the BE name is set to mount at
/.

Other changes of note:
- bectl_list sees another change; changing mountpoint based on mount status
  turns out to be a bad idea, so instead make the mounted property of the
  returned nvlist the path that it's mounted at

- Always return the "mountpoint" property in "mountpoint" if it's ste
2018-08-07 03:07:54 +00:00
Kyle Evans
9c65c7fb48 bectl(8): Only show mountpoint if the dataset is actually mounted
This is to accomodate a later change in libbe(3) that will always return the
mountpoint, whether it be the directory the dataset is actively mounted at
or the "mountpoint" property.
2018-08-07 03:01:04 +00:00
Kyle Evans
2a0b8dc2cb bectl(8): Provide -u option to unset jail parameters
All but name, host.hostname, and path may be completely unset.
2018-08-06 15:21:46 +00:00
Kyle Evans
526ad58e80 bectl(8): Split list functionality out into its own file as well 2018-08-06 03:41:52 +00:00
Kyle Evans
d694059f1e bectl(8): bectl jail improvements
- Support passing arbitrary jail arguments via -o
- Split the related (and rewritten since the GSoC) jail bits out into a new
  bectl_jail.c file, to reduce clutter in bectl.c
- Don't use RFC 1918 IP space [0]; we'll instead set no default IPv4 and let
  the user pass in any address options they wish via -o

Reported by:	rgrimes [0], Shawn Webb [0]
2018-08-06 03:32:25 +00:00
Kyle Evans
9a460e6fd2 bectl(8): Some light cleanup and commenting 2018-08-05 20:03:05 +00:00
Kyle Evans
96c5db5854 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.
2018-08-05 19:38:56 +00:00
Kyle Evans
9b1662e67b 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
2018-08-05 04:40:13 +00:00
Kyle Evans
f97b318f7d bectl(8): Take -H parameter to list into account
-H is for a scripted format, where all fields are tab-delimited and the
headers go away. We accomplish this by splitting out pad printing to a
separate function that'll take into account whether we're supposed to be
scripted or not.

This has the nice side effect of maintaining positive column sizes again.
2018-08-05 04:16:00 +00:00
Kyle Evans
3443420646 bectl(8): Sort BEs lightly by active (now or later) BE, then others
While it could be preferred to do this at insert in libbe(3), there's no
convenient way to insert at the head of an nvlist. Instead, we'll make two
passes over- once to print anything active either now or at nextboot, and
another to print everything else.

This doesn't actually impact performance in a significant way here, so we'll
worry about further optimizations if the need actually arises.
2018-08-04 06:29:46 +00:00
Kyle Evans
77d5a868a0 bectl(8): Add some relevant bectl list -a information
bectl list -a should show the boot environment, its relevant dataset, and
the snapshot it was created from. The header also changes to indicate the
rough order in which these things will show.

While here, start doing a little bit of spring cleaning and splitting
different bits out.
2018-08-04 06:14:54 +00:00
Kyle Evans
4146029bb3 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.
2018-08-03 02:04:57 +00:00
Kyle Evans
74c55b3d38 bectl(8): Just use a single pointer for all string props 2018-08-03 01:51:44 +00:00
Kyle Evans
970fd6543a bectl(8): Move dataset printing out into its own function
This may later get reused for printing snapshot and/or origin snapshot
information.
2018-08-03 01:46:46 +00:00
Kyle Evans
4503a8b6c7 bectl(8): Remove sneaky comment 2018-07-26 18:57:51 +00:00
Kyle Evans
83244ec1ec bectl(8): Hack together a more proper bectl list
Note that the space is currently just the 'used' property of the dataset.
2018-07-26 18:56:50 +00:00
Kyle Evans
2e355bd3ff bectl(8): Remove the jail mount point with unjail 2018-07-26 04:12:31 +00:00
Kyle Evans
a2d93d3c98 bectl(8): Redo jail using jail(3) API
The jail is created with allow.mount, allow.mount.devfs, and
enforce_statfs=1. Upon creation, we immediately attach, chdir to "/", and
drop the user into a shell inside the jail.

The default IP for this is arbitrarily 10.20.30.40.
2018-07-26 04:07:36 +00:00
Kyle Evans
ad765da4e8 bectl(8): Support unjailing a boot environment
The given parameter may either be a jid, jail name, or a BE name.  In all
cases, the parameter will be resolved to a jid and bectl(8) will
sanity-check that there's actually a BE mounted at the requested jail root
before invoking jail_remove(2).
2018-07-26 03:14:58 +00:00
Kyle Evans
734e362fa1 libbe(3)/bectl(8): Provide and use proper alloc/free for property lists 2018-07-25 16:00:48 +00:00
Kyle Evans
b29bf2f84e 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
2018-07-25 15:14:35 +00:00
Kyle Evans
3682d5e902 bectl(8): Start dumping out BE information with bectl list
For the moment, this is a primitive nvlist dump of what we get back from
be_get_bootenv_props as a proof-of-concept and to make sure that we're
getting back the kind of information we want to see from list.
2018-07-25 14:30:47 +00:00
Kyle Evans
16a10da86c bectl(8): Consistent style 2018-07-25 04:06:09 +00:00
Kyle Evans
2c8489579a bectl(8): Rename error messages 2018-07-25 03:57:28 +00:00
Kyle Evans
9e004b219e bectl.c: Chase rename 2018-07-25 01:04:50 +00:00
Kyle Evans
268af06d3e Normalize bectl(8)/libbe(3) Makefiles, remove Makefile copyright/license
Approved by:	hselaskey
2018-07-24 19:55:02 +00:00
Kyle Evans
edbfe3bcb5 bectl(8): Chase rename in manpage 2018-07-24 13:24:30 +00:00
Kyle Evans
5952343e02 Rename be(1) to bectl(8); continues to live in /sbin
Discussed with:	rpokala, allanjude
2018-07-24 13:21:44 +00:00