Skip to content

Commit

Permalink
libbe(3)/bectl(8): Kill off the 'add' functionality for now
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kevans91 committed Aug 11, 2018
1 parent c4b7f80 commit 92afc1f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
12 changes: 9 additions & 3 deletions lib/libbe/be.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ __FBSDID("$FreeBSD$");
#include "be.h"
#include "be_impl.h"

#if SOON
static int be_create_child_noent(libbe_handle_t *lbh, const char *active,
const char *child_path);
static int be_create_child_cloned(libbe_handle_t *lbh, const char *active);
#endif

/*
* Iterator function for locating the rootfs amongst the children of the
Expand Down Expand Up @@ -725,6 +727,7 @@ be_import(libbe_handle_t *lbh, const char *bootenv, int fd)
return (be_destroy(lbh, nbuf, 0));
}

#if SOON
static int
be_create_child_noent(libbe_handle_t *lbh, const char *active,
const char *child_path)
Expand Down Expand Up @@ -778,7 +781,7 @@ be_create_child_noent(libbe_handle_t *lbh, const char *active,
static int
be_create_child_cloned(libbe_handle_t *lbh, const char *active)
{
char buf[BE_MAXPATHLEN];
char buf[BE_MAXPATHLEN], tmp[BE_MAXPATHLEN];;
zfs_handle_t *zfs;
int err;

Expand All @@ -788,10 +791,12 @@ be_create_child_cloned(libbe_handle_t *lbh, const char *active)
* Establish if the existing path is a zfs dataset or just
* the subdirectory of one
*/
strlcpy(buf, "/tmp/be_snap.XXXXX", sizeof(buf));
if (mktemp(buf) == NULL)
strlcpy(tmp, "tmp/be_snap.XXXXX", sizeof(tmp));
if (mktemp(tmp) == NULL)
return (set_error(lbh, BE_ERR_UNKNOWN));

be_root_concat(lbh, tmp, buf);
printf("Here %s?\n", buf);
if ((err = zfs_snapshot(lbh->lzh, buf, false, NULL)) != 0) {
switch (err) {
case EZFS_INVALIDNAME:
Expand Down Expand Up @@ -865,6 +870,7 @@ be_add_child(libbe_handle_t *lbh, const char *child_path, bool cp_if_exists)
return (be_create_child_cloned(lbh, active));
return (set_error(lbh, BE_ERR_EXISTS));
}
#endif /* SOON */

static int
be_set_nextboot(libbe_handle_t *lbh, nvlist_t *config, uint64_t pool_guid,
Expand Down
2 changes: 2 additions & 0 deletions lib/libbe/be.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ bool be_exists(libbe_handle_t *, char *);
int be_export(libbe_handle_t *, const char *, int fd);
int be_import(libbe_handle_t *, const char *, int fd);

#if SOON
int be_add_child(libbe_handle_t *, const char *, bool);
#endif
void be_nicenum(uint64_t num, char *buf, size_t buflen);

#endif /* _LIBBE_H */
10 changes: 8 additions & 2 deletions sbin/bectl/bectl.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ static int bectl_cmd_create(int argc, char *argv[]);
static int bectl_cmd_destroy(int argc, char *argv[]);
static int bectl_cmd_export(int argc, char *argv[]);
static int bectl_cmd_import(int argc, char *argv[]);
#if SOON
static int bectl_cmd_add(int argc, char *argv[]);
#endif
static int bectl_cmd_mount(int argc, char *argv[]);
static int bectl_cmd_rename(int argc, char *argv[]);
static int bectl_cmd_unmount(int argc, char *argv[]);
Expand All @@ -72,7 +74,9 @@ usage(bool explicit)
"\tbectl destroy [-F] beName | beName@snapshot⟩\n"
"\tbectl export sourceBe\n"
"\tbectl import targetBe\n"
#if SOON
"\tbectl add (path)*\n"
#endif
"\tbectl jail [ -o key=value | -u key ]... bootenv\n"
"\tbectl list [-a] [-D] [-H] [-s]\n"
"\tbectl mount beName [mountpoint]\n"
Expand Down Expand Up @@ -100,7 +104,9 @@ static struct command_map_entry command_map[] =
{ "destroy", bectl_cmd_destroy },
{ "export", bectl_cmd_export },
{ "import", bectl_cmd_import },
#if SOON
{ "add", bectl_cmd_add },
#endif
{ "jail", bectl_cmd_jail },
{ "list", bectl_cmd_list },
{ "mount", bectl_cmd_mount },
Expand Down Expand Up @@ -295,7 +301,7 @@ bectl_cmd_import(int argc, char *argv[])
return (err);
}


#if SOON
static int
bectl_cmd_add(int argc, char *argv[])
{
Expand All @@ -313,7 +319,7 @@ bectl_cmd_add(int argc, char *argv[])

return (0);
}

#endif

static int
bectl_cmd_destroy(int argc, char *argv[])
Expand Down

0 comments on commit 92afc1f

Please sign in to comment.