Drop path prefix workaround
Canonicalization, the source of the trouble, was disabled in 9000a9f
.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Sterling Jensen <sterlingjensen@users.noreply.github.com>
Closes #11295
This commit is contained in:
parent
ab4fb9b74e
commit
1e4667af32
|
@ -43,53 +43,30 @@
|
||||||
libzfs_handle_t *g_zfs;
|
libzfs_handle_t *g_zfs;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the pool/dataset to mount given the name passed to mount. This
|
* Opportunistically convert a target string into a pool name. If the
|
||||||
* is expected to be of the form pool/dataset, however may also refer to
|
* string does not represent a block device with a valid zfs label
|
||||||
* a block device if that device contains a valid zfs label.
|
* then it is passed through without modification.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
parse_dataset(const char *target, char **dataset)
|
parse_dataset(const char *target, char **dataset)
|
||||||
{
|
{
|
||||||
/*
|
/* Assume pool/dataset is more likely */
|
||||||
* We expect a pool/dataset to be provided, however if we're
|
strlcpy(*dataset, target, PATH_MAX);
|
||||||
* given a device which is a member of a zpool we attempt to
|
|
||||||
* extract the pool name stored in the label. Given the pool
|
int fd = open(target, O_RDONLY | O_CLOEXEC);
|
||||||
* name we can mount the root dataset.
|
if (fd < 0)
|
||||||
*/
|
return;
|
||||||
int fd = open(target, O_RDONLY);
|
|
||||||
if (fd >= 0) {
|
nvlist_t *cfg = NULL;
|
||||||
nvlist_t *config = NULL;
|
if (zpool_read_label(fd, &cfg, NULL) == 0) {
|
||||||
if (zpool_read_label(fd, &config, NULL) != 0)
|
char *nm = NULL;
|
||||||
config = NULL;
|
if (!nvlist_lookup_string(cfg, ZPOOL_CONFIG_POOL_NAME, &nm))
|
||||||
|
strlcpy(*dataset, nm, PATH_MAX);
|
||||||
|
nvlist_free(cfg);
|
||||||
|
}
|
||||||
|
|
||||||
if (close(fd))
|
if (close(fd))
|
||||||
perror("close");
|
perror("close");
|
||||||
|
|
||||||
if (config) {
|
|
||||||
char *name = NULL;
|
|
||||||
if (!nvlist_lookup_string(config,
|
|
||||||
ZPOOL_CONFIG_POOL_NAME, &name))
|
|
||||||
(void) strlcpy(*dataset, name, PATH_MAX);
|
|
||||||
nvlist_free(config);
|
|
||||||
if (name)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If a file or directory in your current working directory is
|
|
||||||
* named 'dataset' then mount(8) will prepend your current working
|
|
||||||
* directory to the dataset. There is no way to prevent this
|
|
||||||
* behavior so we simply check for it and strip the prepended
|
|
||||||
* patch when it is added.
|
|
||||||
*/
|
|
||||||
char cwd[PATH_MAX];
|
|
||||||
if (getcwd(cwd, PATH_MAX) != NULL) {
|
|
||||||
int len = strlen(cwd);
|
|
||||||
/* Do not add one when cwd already ends in a trailing '/' */
|
|
||||||
if (strncmp(cwd, target, len) == 0)
|
|
||||||
target += len + (cwd[len-1] != '/');
|
|
||||||
}
|
|
||||||
strlcpy(*dataset, target, PATH_MAX);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -25,15 +25,15 @@
|
||||||
verify_runnable "both"
|
verify_runnable "both"
|
||||||
|
|
||||||
set -A vdevs $(get_disklist_fullpath $TESTPOOL)
|
set -A vdevs $(get_disklist_fullpath $TESTPOOL)
|
||||||
vdev=${vdevs[0]}
|
typeset -r mntpoint=$(get_prop mountpoint $TESTPOOL)
|
||||||
mntpoint=$TESTDIR/$TESTPOOL
|
typeset -r helper="mount.zfs -o zfsutil"
|
||||||
helper="mount.zfs -o zfsutil"
|
typeset -r fs=$TESTPOOL/$TESTFS
|
||||||
fs=$TESTPOOL/$TESTFS
|
|
||||||
|
|
||||||
function cleanup
|
function cleanup
|
||||||
{
|
{
|
||||||
log_must force_unmount $vdev
|
cd $STF_SUITE
|
||||||
[[ -d $mntpoint ]] && log_must rm -rf $mntpoint
|
[[ -d $TESTDIR/$$ ]] && (rm -rf $TESTDIR/$$ || log_fail)
|
||||||
|
mounted && zfs $mountcmd $TESTPOOL
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
log_onexit cleanup
|
log_onexit cleanup
|
||||||
|
@ -41,18 +41,21 @@ log_onexit cleanup
|
||||||
log_note "Verify zfs mount helper functions for both devices and pools"
|
log_note "Verify zfs mount helper functions for both devices and pools"
|
||||||
|
|
||||||
# Ensure that the ZFS filesystem is unmounted
|
# Ensure that the ZFS filesystem is unmounted
|
||||||
force_unmount $fs
|
force_unmount $TESTPOOL
|
||||||
log_must mkdir -p $mntpoint
|
|
||||||
|
|
||||||
log_note "Verify '<dataset> <path>'"
|
log_note "Verify '<dataset> <path>'"
|
||||||
log_must $helper $fs $mntpoint
|
log_must $helper $fs $mntpoint
|
||||||
log_must ismounted $fs
|
log_must ismounted $fs
|
||||||
force_unmount $fs
|
force_unmount $fs
|
||||||
|
|
||||||
log_note "Verify '\$PWD/<pool> <path>' prefix workaround"
|
log_note "Verify mount(8) does not canonicalize before calling helper"
|
||||||
log_must $helper $PWD/$fs $mntpoint
|
# Canonicalization is confused by files in PWD matching [device|mountpoint]
|
||||||
log_must ismounted $fs
|
mkdir -p $TESTDIR/$$/$TESTPOOL && cd $TESTDIR/$$ || log_fail
|
||||||
force_unmount $fs
|
# The env flag directs zfs to exec /bin/mount, which then calls helper
|
||||||
|
log_must eval ZFS_MOUNT_HELPER=1 zfs $mountcmd -v $TESTPOOL
|
||||||
|
# mount (2.35.2) still suffers from a cosmetic PWD prefix bug
|
||||||
|
log_must mounted $TESTPOOL
|
||||||
|
force_unmount $TESTPOOL
|
||||||
|
|
||||||
log_note "Verify '-f <dataset> <path>' fakemount"
|
log_note "Verify '-f <dataset> <path>' fakemount"
|
||||||
log_must $helper -f $fs $mntpoint
|
log_must $helper -f $fs $mntpoint
|
||||||
|
@ -63,14 +66,13 @@ log_must ${helper},ro -v $fs $mntpoint
|
||||||
log_must ismounted $fs
|
log_must ismounted $fs
|
||||||
force_unmount $fs
|
force_unmount $fs
|
||||||
|
|
||||||
log_note "Verify '<device> <path>'"
|
|
||||||
log_must $helper $vdev $mntpoint
|
|
||||||
log_must ismounted $mntpoint
|
|
||||||
log_must umount $TESTPOOL
|
|
||||||
|
|
||||||
log_note "Verify '-o abc -s <device> <path>' sloppy option"
|
log_note "Verify '-o abc -s <device> <path>' sloppy option"
|
||||||
log_must ${helper},abc -s $vdev $mntpoint
|
log_must ${helper},abc -s ${vdevs[0]} $mntpoint
|
||||||
log_must ismounted $mntpoint
|
log_must mounted $mntpoint
|
||||||
log_must umount $TESTPOOL
|
force_unmount $TESTPOOL
|
||||||
|
|
||||||
|
log_note "Verify '<device> <path>'"
|
||||||
|
log_must $helper ${vdevs[0]} $mntpoint
|
||||||
|
log_must mounted $mntpoint
|
||||||
|
|
||||||
log_pass "zfs mount helper correctly handles both device and pool strings"
|
log_pass "zfs mount helper correctly handles both device and pool strings"
|
Loading…
Reference in New Issue