diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2014-05-22 14:04:42 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2014-05-22 14:04:42 +0000 |
commit | fa8ea6bf66873fadb0d460758bcab79c49c3cd24 (patch) | |
tree | 7573bebfdb44fd21c4d7ad1d3e45e96ff442bb4b /sbin | |
parent | 2008e9964f6902eeac39711b03d90a8fefdc0627 (diff) |
Nuke pointless dev_bsize variable which is always set to 512, and just
use DEV_BSIZE.
Write sizes need to be secsize and not DEV_BSIZE, just like reads.
Equivalent to changes made in fsck_ffs.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/fsck_ext2fs/fsck.h | 3 | ||||
-rw-r--r-- | sbin/fsck_ext2fs/setup.c | 12 | ||||
-rw-r--r-- | sbin/fsck_ext2fs/utilities.c | 26 |
3 files changed, 19 insertions, 22 deletions
diff --git a/sbin/fsck_ext2fs/fsck.h b/sbin/fsck_ext2fs/fsck.h index 8b469c925b1..3cb1eebfa25 100644 --- a/sbin/fsck_ext2fs/fsck.h +++ b/sbin/fsck_ext2fs/fsck.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fsck.h,v 1.10 2011/03/12 17:50:47 deraadt Exp $ */ +/* $OpenBSD: fsck.h,v 1.11 2014/05/22 14:04:41 krw Exp $ */ /* $NetBSD: fsck.h,v 1.1 1997/06/11 11:21:47 bouyer Exp $ */ /* @@ -161,7 +161,6 @@ struct inoinfo { } **inphead, **inpsort; long numdirs, listmax, inplast; -long dev_bsize; /* computed value of DEV_BSIZE */ long secsize; /* actual disk sector size */ char nflag; /* assume a no response */ char yflag; /* assume a yes response */ diff --git a/sbin/fsck_ext2fs/setup.c b/sbin/fsck_ext2fs/setup.c index 01b2d0de9a1..c99e0ce7895 100644 --- a/sbin/fsck_ext2fs/setup.c +++ b/sbin/fsck_ext2fs/setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setup.c,v 1.19 2013/11/22 04:38:02 guenther Exp $ */ +/* $OpenBSD: setup.c,v 1.20 2014/05/22 14:04:41 krw Exp $ */ /* $NetBSD: setup.c,v 1.1 1997/06/11 11:22:01 bouyer Exp $ */ /* @@ -107,9 +107,9 @@ setup(char *dev) if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL) errexit("cannot allocate space for superblock\n"); if ((lp = getdisklabel((char *)NULL, fsreadfd)) != NULL) - dev_bsize = secsize = lp->d_secsize; + secsize = lp->d_secsize; else - dev_bsize = secsize = DEV_BSIZE; + secsize = DEV_BSIZE; /* * Read in the superblock, looking for alternates if necessary */ @@ -253,7 +253,7 @@ badsblabel: static int readsb(int listerr) { - daddr32_t super = bflag ? bflag : SBOFF / dev_bsize; + daddr32_t super = bflag ? bflag : SBOFF / DEV_BSIZE; if (bread(fsreadfd, (char *)sblk.b_un.b_fs, super, (long)SBSIZE) != 0) return (0); @@ -294,9 +294,7 @@ readsb(int listerr) * according to fsbtodb, and adjust superblock block number * so we can tell if this is an alternate later. */ - super *= dev_bsize; - dev_bsize = sblock.e2fs_bsize / fsbtodb(&sblock, 1); - sblk.b_bno = super / dev_bsize; + sblk.b_bno = super / DEV_BSIZE; if (sblock.e2fs_ncg == 1) { /* no alternate superblock; assume it's okey */ diff --git a/sbin/fsck_ext2fs/utilities.c b/sbin/fsck_ext2fs/utilities.c index 3fe2436fcec..81ec619edf3 100644 --- a/sbin/fsck_ext2fs/utilities.c +++ b/sbin/fsck_ext2fs/utilities.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utilities.c,v 1.20 2014/05/20 21:11:16 krw Exp $ */ +/* $OpenBSD: utilities.c,v 1.21 2014/05/22 14:04:41 krw Exp $ */ /* $NetBSD: utilities.c,v 1.6 2001/02/04 21:19:34 christos Exp $ */ /* @@ -200,7 +200,7 @@ flush(int fd, struct bufarea *bp) return; if (bp->b_errs != 0) pfatal("WRITING %sZERO'ED BLOCK %d TO DISK\n", - (bp->b_errs == bp->b_size / dev_bsize) ? "" : "PARTIALLY ", + (bp->b_errs == bp->b_size / DEV_BSIZE) ? "" : "PARTIALLY ", bp->b_bno); bp->b_dirty = 0; bp->b_errs = 0; @@ -237,9 +237,9 @@ ckfini(int markclean) return; } flush(fswritefd, &sblk); - if (havesb && sblk.b_bno != SBOFF / dev_bsize && + if (havesb && sblk.b_bno != SBOFF / DEV_BSIZE && !preen && reply("UPDATE STANDARD SUPERBLOCKS")) { - sblk.b_bno = SBOFF / dev_bsize; + sblk.b_bno = SBOFF / DEV_BSIZE; sbdirty(); flush(fswritefd, &sblk); copyback_sb(&asblk); @@ -285,7 +285,7 @@ bread(int fd, char *buf, daddr32_t blk, long size) off_t offset; offset = blk; - offset *= dev_bsize; + offset *= DEV_BSIZE; if (pread(fd, buf, size, offset) == size) return (0); rwerror("READ", blk); @@ -294,12 +294,12 @@ bread(int fd, char *buf, daddr32_t blk, long size) printf("THE FOLLOWING DISK SECTORS COULD NOT BE READ:"); for (cp = buf, i = 0; i < size; i += secsize, cp += secsize) { if (pread(fd, cp, secsize, offset + i) != secsize) { - if (secsize != dev_bsize && dev_bsize != 1) + if (secsize != DEV_BSIZE) printf(" %ld (%ld),", - (blk * dev_bsize + i) / secsize, - blk + i / dev_bsize); + (blk * DEV_BSIZE + i) / secsize, + blk + i / DEV_BSIZE); else - printf(" %ld,", blk + i / dev_bsize); + printf(" %ld,", blk + i / DEV_BSIZE); errs++; } } @@ -317,16 +317,16 @@ bwrite(int fd, char *buf, daddr32_t blk, long size) if (fd < 0) return; offset = blk; - offset *= dev_bsize; + offset *= DEV_BSIZE; if (pwrite(fd, buf, size, offset) == size) { fsmodified = 1; return; } rwerror("WRITE", blk); printf("THE FOLLOWING SECTORS COULD NOT BE WRITTEN:"); - for (cp = buf, i = 0; i < size; i += dev_bsize, cp += dev_bsize) - if (pwrite(fd, cp, dev_bsize, offset + i) != dev_bsize) { - printf(" %ld,", blk + i / dev_bsize); + for (cp = buf, i = 0; i < size; i += secsize, cp += secsize) + if (pwrite(fd, cp, secsize, offset + i) != secsize) { + printf(" %ld,", blk + i / DEV_BSIZE); } printf("\n"); return; |