Changeset View
Changeset View
Standalone View
Standalone View
sys/contrib/openzfs/cmd/mount_zfs/mount_zfs.c
Context not available. | |||||
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); | ||||
Context not available. |