-.\" $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.
.\" 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
.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 ,
-/* $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.
#include <sys/limits.h>
#include <sys/disk.h>
#include <sys/dkio.h>
-#include <sys/stat.h>
#include "util.h"
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) {