Changeset View
Changeset View
Standalone View
Standalone View
sys/contrib/openzfs/cmd/mount_zfs/mount_zfs.c
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Opportunistically convert a target string into a pool name. If the | * Opportunistically convert a target string into a pool name. If the | ||||
* string does not represent a block device with a valid zfs label | * string does not represent a block device with a valid zfs label | ||||
* then it is passed through without modification. | * 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) | ||||
{ | { | ||||
/* | |||||
* Prior to util-linux 2.36.2, if a file or directory in the | |||||
* current working directory was named 'dataset' then mount(8) | |||||
* would prepend the current working directory to the dataset. | |||||
* Check for it and strip the prepended path when it is added. | |||||
*/ | |||||
char cwd[PATH_MAX]; | |||||
if (getcwd(cwd, PATH_MAX) == NULL) { | |||||
perror("getcwd"); | |||||
return; | |||||
} | |||||
int len = strlen(cwd); | |||||
if (strncmp(cwd, target, len) == 0) | |||||
target += len; | |||||
/* Assume pool/dataset is more likely */ | /* Assume pool/dataset is more likely */ | ||||
strlcpy(*dataset, target, PATH_MAX); | strlcpy(*dataset, target, PATH_MAX); | ||||
int fd = open(target, O_RDONLY | O_CLOEXEC); | int fd = open(target, O_RDONLY | O_CLOEXEC); | ||||
if (fd < 0) | if (fd < 0) | ||||
return; | return; | ||||
nvlist_t *cfg = NULL; | nvlist_t *cfg = NULL; | ||||
▲ Show 20 Lines • Show All 312 Lines • Show Last 20 Lines |