diff options
author | Klemens Nanni <kn@cvs.openbsd.org> | 2022-08-26 21:47:17 +0000 |
---|---|---|
committer | Klemens Nanni <kn@cvs.openbsd.org> | 2022-08-26 21:47:17 +0000 |
commit | 643a03d5ac6ec220f395c8d21dff456190abd253 (patch) | |
tree | e21b99b650832765dacf618630b10e7f8501bde4 /lib | |
parent | 23509175c606068b2cd0d904271d811ca20c826e (diff) |
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libutil/opendev.3 | 12 | ||||
-rw-r--r-- | lib/libutil/opendev.c | 18 |
2 files changed, 6 insertions, 24 deletions
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 <sys/limits.h> #include <sys/disk.h> #include <sys/dkio.h> -#include <sys/stat.h> #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) { |