From de27460e2ee5a892dac4f740fba98136878f3db3 Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Wed, 18 Apr 2012 00:04:28 +0200 Subject: [PATCH] libutil: let opendisk(3) try /dev If a device node is given without path, and opening the node fails initially, prepend "/dev/" to the node name and try opening again. This is more in line with NetBSD behavior. Change-Id: Ib544aec52abe43132510f0e4b173b00fb3dbaab8 --- lib/libutil/opendisk.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/libutil/opendisk.c b/lib/libutil/opendisk.c index 18a314f4f..25daa348c 100644 --- a/lib/libutil/opendisk.c +++ b/lib/libutil/opendisk.c @@ -54,6 +54,14 @@ __opendisk(const char *path, int flags, char *buf, size_t buflen, int iscooked, int f; #endif +#ifdef __minix + /* + * MINIX does not have the cooked/raw distinction. Do not prepend 'r' + * to the device name when generating a full path. + */ + iscooked = 1; +#endif + if (buf == NULL) { errno = EFAULT; return (-1); @@ -80,6 +88,7 @@ __opendisk(const char *path, int flags, char *buf, size_t buflen, int iscooked, f = ofn(buf, flags, 0); if (f != -1 || errno != ENOENT) return (f); +#endif if (strchr(path, '/') != NULL) return (-1); @@ -89,6 +98,7 @@ __opendisk(const char *path, int flags, char *buf, size_t buflen, int iscooked, if (f != -1 || errno != ENOENT) return (f); +#ifndef __minix snprintf(buf, buflen, "%s%s%s%c", _PATH_DEV, iscooked ? "" : "r", path, 'a' + rawpart); f = ofn(buf, flags, 0); -- 2.44.0