mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-12-26 13:05:18 +01:00
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
This commit is contained in:
parent
9c65c7fb48
commit
709b553cd0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/projects/bectl/; revision=337406
@ -172,10 +172,13 @@ prop_list_builder_cb(zfs_handle_t *zfs_hdl, void *data_p)
|
|||||||
nvlist_add_string(props, "name", name);
|
nvlist_add_string(props, "name", name);
|
||||||
|
|
||||||
mounted = zfs_is_mounted(zfs_hdl, &mountpoint);
|
mounted = zfs_is_mounted(zfs_hdl, &mountpoint);
|
||||||
nvlist_add_boolean_value(props, "mounted", mounted);
|
|
||||||
|
|
||||||
if (mounted)
|
if (mounted)
|
||||||
nvlist_add_string(props, "mountpoint", mountpoint);
|
nvlist_add_string(props, "mounted", mountpoint);
|
||||||
|
|
||||||
|
if (zfs_prop_get(zfs_hdl, ZFS_PROP_MOUNTPOINT, buf, 512,
|
||||||
|
NULL, NULL, 0, 1) == 0)
|
||||||
|
nvlist_add_string(props, "mountpoint", buf);
|
||||||
|
|
||||||
if (zfs_prop_get(zfs_hdl, ZFS_PROP_ORIGIN, buf, 512,
|
if (zfs_prop_get(zfs_hdl, ZFS_PROP_ORIGIN, buf, 512,
|
||||||
NULL, NULL, 0, 1) == 0)
|
NULL, NULL, 0, 1) == 0)
|
||||||
@ -282,12 +285,32 @@ bool
|
|||||||
be_exists(libbe_handle_t *lbh, char *be)
|
be_exists(libbe_handle_t *lbh, char *be)
|
||||||
{
|
{
|
||||||
char buf[BE_MAXPATHLEN];
|
char buf[BE_MAXPATHLEN];
|
||||||
|
nvlist_t *dsprops;
|
||||||
|
char *mntpoint;
|
||||||
|
bool valid;
|
||||||
|
|
||||||
be_root_concat(lbh, be, buf);
|
be_root_concat(lbh, be, buf);
|
||||||
|
|
||||||
/*
|
if (!zfs_dataset_exists(lbh->lzh, buf, ZFS_TYPE_DATASET))
|
||||||
* XXX TODO: check mountpoint prop and see if its /, AND that result
|
return (false);
|
||||||
* with below expression.
|
|
||||||
*/
|
/* Also check if it's mounted at / */
|
||||||
return (zfs_dataset_exists(lbh->lzh, buf, ZFS_TYPE_DATASET));
|
if (be_prop_list_alloc(&dsprops) != 0) {
|
||||||
|
set_error(lbh, BE_ERR_UNKNOWN);
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (be_get_dataset_props(lbh, buf, dsprops) != 0) {
|
||||||
|
nvlist_free(dsprops);
|
||||||
|
return (false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nvlist_lookup_string(dsprops, "mountpoint", &mntpoint) == 0) {
|
||||||
|
valid = (strcmp(mntpoint, "/") == 0);
|
||||||
|
nvlist_free(dsprops);
|
||||||
|
return (valid);
|
||||||
|
}
|
||||||
|
|
||||||
|
nvlist_free(dsprops);
|
||||||
|
return (false);
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ print_info(const char *name, nvlist_t *dsprops, struct printc *pc)
|
|||||||
const char *oname;
|
const char *oname;
|
||||||
char *dsname, *propstr;
|
char *dsname, *propstr;
|
||||||
int active_colsz;
|
int active_colsz;
|
||||||
boolean_t active_now, active_reboot, mounted;
|
boolean_t active_now, active_reboot;
|
||||||
|
|
||||||
dsname = NULL;
|
dsname = NULL;
|
||||||
originprops = NULL;
|
originprops = NULL;
|
||||||
@ -228,10 +228,7 @@ print_info(const char *name, nvlist_t *dsprops, struct printc *pc)
|
|||||||
active_colsz--;
|
active_colsz--;
|
||||||
}
|
}
|
||||||
print_padding(NULL, active_colsz, pc);
|
print_padding(NULL, active_colsz, pc);
|
||||||
if (nvlist_lookup_boolean_value(dsprops, "mounted", &mounted) != 0)
|
if (nvlist_lookup_string(dsprops, "mounted", &propstr) == 0) {
|
||||||
mounted = false;
|
|
||||||
if (mounted && nvlist_lookup_string(dsprops, "mountpoint",
|
|
||||||
&propstr) == 0) {
|
|
||||||
printf("%s", propstr);
|
printf("%s", propstr);
|
||||||
print_padding(propstr, pc->mount_colsz, pc);
|
print_padding(propstr, pc->mount_colsz, pc);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user