Add /dev/mapper/ to search path

When creating pools short device names may be used when those
devices appear in certain well known locations under /dev/.
This change adds /dev/mapper/ to that list.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
This commit is contained in:
Brian Behlendorf 2012-05-25 14:52:56 -07:00
parent 821b683436
commit b04c9fc009
1 changed files with 13 additions and 1 deletions

View File

@ -824,14 +824,26 @@ zfs_resolve_shortname(const char *name, char *path, size_t pathlen)
char dirs[6][9] = {"by-id", "by-label", "by-path", "by-uuid", "zpool", char dirs[6][9] = {"by-id", "by-label", "by-path", "by-uuid", "zpool",
"by-vdev"}; "by-vdev"};
/* /dev/ */
(void) snprintf(path, pathlen, "%s/%s", DISK_ROOT, name); (void) snprintf(path, pathlen, "%s/%s", DISK_ROOT, name);
err = access(path, F_OK); err = access(path, F_OK);
if (err == 0)
return (err);
/* /dev/mapper/ */
(void) snprintf(path, pathlen, "%s/mapper/%s", DISK_ROOT, name);
err = access(path, F_OK);
if (err == 0)
return (err);
/* /dev/disk/<dirs>/ */
for (i = 0; i < 6 && err < 0; i++) { for (i = 0; i < 6 && err < 0; i++) {
(void) snprintf(path, pathlen, "%s/%s/%s", (void) snprintf(path, pathlen, "%s/%s/%s",
UDISK_ROOT, dirs[i], name); UDISK_ROOT, dirs[i], name);
err = access(path, F_OK); err = access(path, F_OK);
} }
return err;
return (err);
} }
/* /*