From: kn Date: Fri, 26 Aug 2022 21:47:16 +0000 (+0000) Subject: Backout "Only return file descriptors to block or character devices" X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=531ea1fd1f29d4262dcc911182a2c7056587eb1f;p=openbsd Backout "Only return file descriptors to block or character devices" mount_mfs(8) no monger mounts "/build" with the following fstab(5) entry: /dev/sd0b /build mfs rw,noperm,nodev,nosuid,-s=2064348,noauto as found out by bluhm the hard way. --- diff --git a/lib/libutil/opendev.3 b/lib/libutil/opendev.3 index ae6ce343007..0046d052e9c 100644 --- a/lib/libutil/opendev.3 +++ b/lib/libutil/opendev.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: opendev.3,v 1.23 2022/08/25 17:09:54 kn Exp $ +.\" $OpenBSD: opendev.3,v 1.24 2022/08/26 21:47:16 kn Exp $ .\" .\" Copyright (c) 2000, Todd C. Miller. All rights reserved. .\" Copyright (c) 1996, Jason Downs. All rights reserved. @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: August 25 2022 $ +.Dd $Mdocdate: August 26 2022 $ .Dt OPENDEV 3 .Os .Sh NAME @@ -90,12 +90,10 @@ is not .Dv NULL , it is modified to point at the fully expanded device name. .Sh RETURN VALUES -If successful, +The .Fn opendev -returns a file descriptor. -Otherwise, a value of -1 is returned and -.Va errno -is set to indicate the error. +return value and errors are the same as the return value and errors of +.Xr open 2 . .Sh SEE ALSO .Xr open 2 , .Xr getrawpartition 3 , diff --git a/lib/libutil/opendev.c b/lib/libutil/opendev.c index 2afbe8d6586..dfb60248986 100644 --- a/lib/libutil/opendev.c +++ b/lib/libutil/opendev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: opendev.c,v 1.16 2022/08/25 17:09:54 kn Exp $ */ +/* $OpenBSD: opendev.c,v 1.17 2022/08/26 21:47:16 kn Exp $ */ /* * Copyright (c) 2000, Todd C. Miller. All rights reserved. @@ -38,7 +38,6 @@ #include #include #include -#include #include "util.h" @@ -64,23 +63,8 @@ opendev(const char *path, int oflags, int dflags, char **realpath) prefix = "r"; /* character device */ if ((slash = strchr(path, '/'))) { - struct stat sb; - strlcpy(namebuf, path, sizeof(namebuf)); fd = open(namebuf, oflags); - - if (fd != -1) { - if (fstat(fd, &sb) == -1) { - close(fd); - fd = -1; - } else if ((dflags & OPENDEV_BLCK) ? - !S_ISBLK(sb.st_mode) : - !S_ISCHR(sb.st_mode)) { - close(fd); - fd = -1; - errno = ENOTBLK; - } - } } else if (isduid(path, dflags)) { strlcpy(namebuf, path, sizeof(namebuf)); if ((fd = open("/dev/diskmap", oflags)) != -1) {