diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2010-11-17 12:31:12 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2010-11-17 12:31:12 +0000 |
commit | 47b2876666405eec8c3fe3fb8b4b8c0eb5079e31 (patch) | |
tree | cabea6a5cb535f1fbbb6a1ddaa9942113c0fb127 /sbin | |
parent | bc2fee9859e80ab6e36fa8cba79dff4374c81eab (diff) |
Switch fsck_msdos(8) to opendev(3) so that it can handle disklabel UIDs.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fsck_msdos/Makefile | 6 | ||||
-rw-r--r-- | sbin/fsck_msdos/check.c | 27 |
2 files changed, 19 insertions, 14 deletions
diff --git a/sbin/fsck_msdos/Makefile b/sbin/fsck_msdos/Makefile index 8592f7e37d1..0d0f8e8a02a 100644 --- a/sbin/fsck_msdos/Makefile +++ b/sbin/fsck_msdos/Makefile @@ -1,9 +1,11 @@ -# $OpenBSD: Makefile,v 1.4 1997/09/21 11:36:40 deraadt Exp $ +# $OpenBSD: Makefile,v 1.5 2010/11/17 12:31:11 jsing Exp $ PROG= fsck_msdos MAN= fsck_msdos.8 SRCS= main.c check.c boot.c fat.c dir.c fsutil.c -CFLAGS+= -I${.CURDIR}/../fsck .PATH: ${.CURDIR}/../fsck +CFLAGS+= -I${.CURDIR}/../fsck +DPADD+= ${LIBUTIL} +LDADD+= -lutil .include <bsd.prog.mk> diff --git a/sbin/fsck_msdos/check.c b/sbin/fsck_msdos/check.c index 73bfe5368cc..f9e149f264a 100644 --- a/sbin/fsck_msdos/check.c +++ b/sbin/fsck_msdos/check.c @@ -1,4 +1,4 @@ -/* $OpenBSD: check.c,v 1.12 2009/10/27 23:59:33 deraadt Exp $ */ +/* $OpenBSD: check.c,v 1.13 2010/11/17 12:31:11 jsing Exp $ */ /* $NetBSD: check.c,v 1.8 1997/10/17 11:19:29 ws Exp $ */ /* @@ -33,6 +33,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <sys/param.h> #include <stdlib.h> #include <string.h> #include <ctype.h> @@ -48,29 +49,31 @@ checkfilesys(const char *fname) int dosfs; struct bootblock boot; struct fatEntry *fat = NULL; + char *realdev; int i; int mod = 0; rdonly = alwaysno; - if (!preen) - printf("** %s", fname); - dosfs = open(fname, rdonly ? O_RDONLY : O_RDWR, 0); + dosfs = opendev(fname, rdonly ? O_RDONLY : O_RDWR, 0, &realdev); if (dosfs < 0 && !rdonly) { - dosfs = open(fname, O_RDONLY, 0); - if (dosfs >= 0) - pwarn(" (NO WRITE)\n"); - else if (!preen) - printf("\n"); + dosfs = opendev(fname, O_RDONLY, 0, &realdev); rdonly = 1; - } else if (!preen) - printf("\n"); - + } if (dosfs < 0) { xperror("Can't open"); return (8); } + if (!preen) { + printf("** %s", realdev); + if (strncmp(fname, realdev, PATH_MAX) != 0) + printf(" (%s)", fname); + if (rdonly) + printf(" (NO WRITE)"); + printf("\n"); + } + if (readboot(dosfs, &boot) != FSOK) { (void)close(dosfs); return (8); |