diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1996-06-17 06:36:30 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1996-06-17 06:36:30 +0000 |
commit | 7a7ebc7c4a71fbb4370e6f4e74a5af44ebdabdaf (patch) | |
tree | 3a567c30796b80229ceb8fc2d3a8b7f41a366cb2 /bin/mt | |
parent | cf9425b1a58581ea4090150152b41a4034373dcd (diff) |
Changed to use the opendev(3) in libutil
Diffstat (limited to 'bin/mt')
-rw-r--r-- | bin/mt/Makefile | 3 | ||||
-rw-r--r-- | bin/mt/mt.c | 47 |
2 files changed, 7 insertions, 43 deletions
diff --git a/bin/mt/Makefile b/bin/mt/Makefile index 297471469d3..c7458f7262c 100644 --- a/bin/mt/Makefile +++ b/bin/mt/Makefile @@ -1,8 +1,11 @@ +# $OpenBSD: Makefile,v 1.4 1996/06/17 06:36:27 downsj Exp $ # $NetBSD: Makefile,v 1.5 1996/03/06 06:22:04 scottr Exp $ # @(#)Makefile 8.1 (Berkeley) 6/6/93 PROG= mt SRCS= mt.c mtrmt.c +DPADD= ${LIBUTIL} +LDADD= -lutil BINOWN= root BINMODE=4555 diff --git a/bin/mt/mt.c b/bin/mt/mt.c index 1497773a75b..ac74077b5a6 100644 --- a/bin/mt/mt.c +++ b/bin/mt/mt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mt.c,v 1.8 1996/06/17 02:21:53 downsj Exp $ */ +/* $OpenBSD: mt.c,v 1.9 1996/06/17 06:36:29 downsj Exp $ */ /* $NetBSD: mt.c,v 1.14.2.1 1996/05/27 15:12:11 mrg Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)mt.c 8.2 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$NetBSD: mt.c,v 1.14.2.1 1996/05/27 15:12:11 mrg Exp $"; +static char rcsid[] = "$OpenBSD: mt.c,v 1.9 1996/06/17 06:36:29 downsj Exp $"; #endif #endif /* not lint */ @@ -62,6 +62,7 @@ static char rcsid[] = "$NetBSD: mt.c,v 1.14.2.1 1996/05/27 15:12:11 mrg Exp $"; #include <err.h> #include <errno.h> #include <fcntl.h> +#include <opendev.h> #include <paths.h> #include <stdio.h> #include <stdlib.h> @@ -94,7 +95,6 @@ struct commands { }; #define COM_EJECT 9 /* element in the above array */ -int opendev __P((char *, int, mode_t, char **)); void printreg __P((char *, u_int, char *)); void status __P((struct mtget *)); void usage __P((void)); @@ -185,6 +185,7 @@ main(argc, argv) flags = comp->c_ronly ? O_RDONLY : O_WRONLY | O_CREAT; if ((mtfd = host ? rmtopen(tape, flags) : opendev(tape, flags, + OPENDEV_PART | OPENDEV_DRCT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, &realtape)) < 0) err(2, "%s", host ? tape : realtape); @@ -217,46 +218,6 @@ main(argc, argv) /* NOTREACHED */ } -int -opendev(path, flags, mode, realpath) - char *path; - int flags; - mode_t mode; - char **realpath; -{ - int fd; - static char namebuf[256]; - - *realpath = path; - - fd = open(path, flags, mode); - if (fd < 0) { - if (path[0] != '/') { - /* first try raw partition (for removable drives) */ - (void)snprintf(namebuf, sizeof(namebuf), "%sr%s%c", - _PATH_DEV, path, 'a' + RAW_PART); - fd = open(namebuf, flags, mode); - - if ((fd < 0) && (errno == ENOENT)) { - /* ..and now no partition (for tapes) */ - namebuf[strlen(namebuf) - 1] = '\0'; - fd = open(namebuf, flags, mode); - } - - *realpath = namebuf; - } - } - if ((fd < 0) && (errno == ENOENT) && (path[0] != '/')) { - (void)snprintf(namebuf, sizeof(namebuf), "%sr%s", - _PATH_DEV, path); - fd = open(namebuf, flags, mode); - - *realpath = namebuf; - } - - return (fd); -} - #ifdef sun #include <sundev/tmreg.h> #include <sundev/arreg.h> |