diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2010-06-05 07:36:24 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2010-06-05 07:36:24 +0000 |
commit | a2f7c79d0a135d45e2d0572d29b4ccbc96a13f15 (patch) | |
tree | 78b80849f11be23e1d75193c13354921dca4c073 /sbin/fsck_ffs/setup.c | |
parent | 7c13fd24dc96ef7c6e39c867ba601a1d9b1cb3cf (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@
Diffstat (limited to 'sbin/fsck_ffs/setup.c')
-rw-r--r-- | sbin/fsck_ffs/setup.c | 28 |
1 files changed, 16 insertions, 12 deletions
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); |