From: David van Moolenbroek Date: Tue, 17 Apr 2012 22:04:28 +0000 (+0200) Subject: libutil: let opendisk(3) try /dev X-Git-Tag: v3.3.0~590 X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=de27460e2ee5a892dac4f740fba98136878f3db3;p=minix.git 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 --- 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);