libbe(3): Properly account for altroot when creating new BEs
Previously we would blindly copy the 'mountpoint' property, which includes the altroot. The altroot needs to be snipped off prior to setting it on the new BE, though, or you'll end up with a new BE and a mountpoint of /mnt with altroot=/mnt MFC after: 3 days
This commit is contained in:
parent
cc624025b4
commit
af43c24d3d
@ -305,6 +305,7 @@ be_deep_clone_prop(int prop, void *cb)
|
||||
zprop_source_t src;
|
||||
char pval[BE_MAXPATHLEN];
|
||||
char source[BE_MAXPATHLEN];
|
||||
char *val;
|
||||
|
||||
dccb = cb;
|
||||
/* Skip some properties we don't want to touch */
|
||||
@ -324,7 +325,15 @@ be_deep_clone_prop(int prop, void *cb)
|
||||
if (src != ZPROP_SRC_LOCAL)
|
||||
return (ZPROP_CONT);
|
||||
|
||||
nvlist_add_string(dccb->props, zfs_prop_to_name(prop), (char *)pval);
|
||||
/* Augment mountpoint with altroot, if needed */
|
||||
val = pval;
|
||||
if (prop == ZFS_PROP_MOUNTPOINT && *dccb->altroot != '\0') {
|
||||
if (pval[strlen(dccb->altroot)] == '\0')
|
||||
strlcpy(pval, "/", sizeof(pval));
|
||||
else
|
||||
val = pval + strlen(dccb->altroot);
|
||||
}
|
||||
nvlist_add_string(dccb->props, zfs_prop_to_name(prop), val);
|
||||
|
||||
return (ZPROP_CONT);
|
||||
}
|
||||
@ -367,6 +376,10 @@ be_deep_clone(zfs_handle_t *ds, void *data)
|
||||
|
||||
dccb.zhp = ds;
|
||||
dccb.props = props;
|
||||
if (zpool_get_prop(isdc->lbh->active_phandle, ZPOOL_PROP_ALTROOT,
|
||||
dccb.altroot, sizeof(dccb.altroot), NULL, true) != 0 ||
|
||||
strcmp(dccb.altroot, "-") == 0)
|
||||
*dccb.altroot = '\0';
|
||||
if (zprop_iter(be_deep_clone_prop, &dccb, B_FALSE, B_FALSE,
|
||||
ZFS_TYPE_FILESYSTEM) == ZPROP_INVAL)
|
||||
return (-1);
|
||||
|
@ -55,6 +55,7 @@ struct libbe_deep_clone {
|
||||
struct libbe_dccb {
|
||||
zfs_handle_t *zhp;
|
||||
nvlist_t *props;
|
||||
char altroot[MAXPATHLEN];
|
||||
};
|
||||
|
||||
typedef struct prop_data {
|
||||
|
Loading…
x
Reference in New Issue
Block a user