summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2010-06-05 07:36:24 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2010-06-05 07:36:24 +0000
commita2f7c79d0a135d45e2d0572d29b4ccbc96a13f15 (patch)
tree78b80849f11be23e1d75193c13354921dca4c073
parent7c13fd24dc96ef7c6e39c867ba601a1d9b1cb3cf (diff)
Switch fsck_ffs(8) and fsdb(8) to opendev(3) so that they will soon be able
to operate with disklabel UIDs. ok marco@ krw@ otto@
-rw-r--r--sbin/fsck_ffs/Makefile4
-rw-r--r--sbin/fsck_ffs/setup.c28
-rw-r--r--sbin/fsdb/Makefile6
3 files changed, 22 insertions, 16 deletions
diff --git a/sbin/fsck_ffs/Makefile b/sbin/fsck_ffs/Makefile
index 3481017d397..aceda8d6d67 100644
--- a/sbin/fsck_ffs/Makefile
+++ b/sbin/fsck_ffs/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.6 2010/01/04 17:50:38 deraadt Exp $
+# $OpenBSD: Makefile,v 1.7 2010/06/05 07:36:23 jsing Exp $
PROG= fsck_ffs
MAN= fsck_ffs.8
@@ -6,5 +6,7 @@ SRCS= dir.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c pass4.c \
pass5.c fsutil.c setup.c utilities.c ffs_subr.c ffs_tables.c
.PATH: ${.CURDIR}/../../sys/ufs/ffs ${.CURDIR}/../fsck
CFLAGS+= -I${.CURDIR}/../fsck
+DPADD+= ${LIBUTIL}
+LDADD+= -lutil
.include <bsd.prog.mk>
diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c
index eca21dd8628..4b50a664f9e 100644
--- a/sbin/fsck_ffs/setup.c
+++ b/sbin/fsck_ffs/setup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: setup.c,v 1.42 2010/05/18 04:41:14 dlg Exp $ */
+/* $OpenBSD: setup.c,v 1.43 2010/06/05 07:36:23 jsing Exp $ */
/* $NetBSD: setup.c,v 1.27 1996/09/27 22:45:19 christos Exp $ */
/*
@@ -80,26 +80,30 @@ setup(char *dev)
int doskipclean;
int32_t maxsymlinklen, nindir, inopb;
u_int64_t maxfilesize;
+ char *realdev;
havesb = 0;
fswritefd = fsreadfd = -1;
doskipclean = skipclean;
- if (stat(dev, &statb) < 0) {
- printf("Can't stat %s: %s\n", dev, strerror(errno));
+ if ((fsreadfd = opendev(dev, O_RDONLY, 0, &realdev)) < 0) {
+ printf("Can't open %s: %s\n", dev, strerror(errno));
+ return (0);
+ }
+ if (fstat(fsreadfd, &statb) < 0) {
+ printf("Can't stat %s: %s\n", realdev, strerror(errno));
+ close(fsreadfd);
return (0);
}
if (!S_ISCHR(statb.st_mode)) {
- pfatal("%s is not a character device", dev);
- if (reply("CONTINUE") == 0)
+ pfatal("%s is not a character device", realdev);
+ if (reply("CONTINUE") == 0) {
+ close(fsreadfd);
return (0);
- }
- if ((fsreadfd = open(dev, O_RDONLY)) < 0) {
- printf("Can't open %s: %s\n", dev, strerror(errno));
- return (0);
+ }
}
if (preen == 0)
- printf("** %s", dev);
- if (nflag || (fswritefd = open(dev, O_WRONLY)) < 0) {
+ printf("** %s", realdev);
+ if (nflag || (fswritefd = opendev(dev, O_WRONLY, 0, NULL)) < 0) {
fswritefd = -1;
if (preen)
pfatal("NO WRITE ACCESS");
@@ -123,7 +127,7 @@ setup(char *dev)
* Read in the superblock, looking for alternates if necessary
*/
if (readsb(1) == 0) {
- if (bflag || preen || calcsb(dev, fsreadfd, &proto) == 0)
+ if (bflag || preen || calcsb(realdev, fsreadfd, &proto) == 0)
return(0);
if (reply("LOOK FOR ALTERNATE SUPERBLOCKS") == 0)
return (0);
diff --git a/sbin/fsdb/Makefile b/sbin/fsdb/Makefile
index 49c840190de..25b67164619 100644
--- a/sbin/fsdb/Makefile
+++ b/sbin/fsdb/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.7 2002/05/11 00:20:20 espie Exp $
+# $OpenBSD: Makefile,v 1.8 2010/06/05 07:36:23 jsing Exp $
PROG= fsdb
MAN= fsdb.8
@@ -6,8 +6,8 @@ SRCS= fsdb.c fsdbutil.c fsutil.c \
dir.c inode.c pass1.c pass1b.c pass2.c pass3.c pass4.c \
pass5.c preen.c setup.c utilities.c ffs_subr.c ffs_tables.c
CFLAGS+= -I${.CURDIR}/../../sbin/fsck -I${.CURDIR}/../../sbin/fsck_ffs
-LDADD+= -ledit -lcurses
-DPADD+= ${LIBEDIT} ${LIBCURSES}
+LDADD+= -ledit -lcurses -lutil
+DPADD+= ${LIBEDIT} ${LIBCURSES} ${LIBUTIL}
.PATH: ${.CURDIR}/../../sbin/fsck ${.CURDIR}/../../sbin/fsck_ffs ${.CURDIR}/../../sys/ufs/ffs
.include <bsd.prog.mk>