summaryrefslogtreecommitdiff
path: root/sbin/dump
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2014-05-24 21:49:10 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2014-05-24 21:49:10 +0000
commit3ad8b33cbfd68868ab48b52d61b2f9ca2bb8e5e2 (patch)
treeb389de9a370e89e528f43d94f1f5d3f1e8d57712 /sbin/dump
parent21ba3d0ed24f3aa90117bad879127a8463d3c8eb (diff)
Nuke last of the illusionary 'dev_bsize' and 'dev_bshift' variables in
favour of DEV_BSIZE. No-op on 512-byte sector devices.
Diffstat (limited to 'sbin/dump')
-rw-r--r--sbin/dump/dump.h4
-rw-r--r--sbin/dump/main.c7
-rw-r--r--sbin/dump/tape.c4
-rw-r--r--sbin/dump/traverse.c29
4 files changed, 20 insertions, 24 deletions
diff --git a/sbin/dump/dump.h b/sbin/dump/dump.h
index 401722d4f3c..3c172247c92 100644
--- a/sbin/dump/dump.h
+++ b/sbin/dump/dump.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dump.h,v 1.18 2014/05/21 17:38:30 krw Exp $ */
+/* $OpenBSD: dump.h,v 1.19 2014/05/24 21:49:09 krw Exp $ */
/* $NetBSD: dump.h,v 1.11 1997/06/05 11:13:20 lukem Exp $ */
/*-
@@ -79,8 +79,6 @@ time_t tstart_writing; /* when started writing the first tape block */
long xferrate; /* averaged transfer rate of all volumes */
struct fs *sblock; /* the file system super block */
char sblock_buf[MAXBSIZE];
-long dev_bsize; /* block size of underlying disk device */
-int dev_bshift; /* log2(dev_bsize) */
int tp_bshift; /* log2(TP_BSIZE) */
/* operator interface functions */
diff --git a/sbin/dump/main.c b/sbin/dump/main.c
index feb245b3675..c985a132ce1 100644
--- a/sbin/dump/main.c
+++ b/sbin/dump/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.46 2013/04/16 18:17:39 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.47 2014/05/24 21:49:09 krw Exp $ */
/* $NetBSD: main.c,v 1.14 1997/06/05 11:13:24 lukem Exp $ */
/*-
@@ -61,7 +61,6 @@ int tapeno = 0; /* current tape number */
int density = 0; /* density in bytes/0.1" */
int ntrec = NTREC; /* # tape blocks in each tape record */
int cartridge = 0; /* Assume non-cartridge tape */
-long dev_bsize = 1; /* recalculated below */
long blocksperfile; /* output blocks per file */
char *host = NULL; /* remote host (if any) */
int maxbsize = 64*1024; /* XXX MAXBSIZE from sys/param.h */
@@ -396,10 +395,6 @@ main(int argc, char *argv[])
}
if (sblock_try[i] == -1)
quit("Cannot find filesystem superblock\n");
- dev_bsize = sblock->fs_fsize / fsbtodb(sblock, 1);
- dev_bshift = ffs(dev_bsize) - 1;
- if (dev_bsize != (1 << dev_bshift))
- quit("dev_bsize (%d) is not a power of 2\n", dev_bsize);
tp_bshift = ffs(TP_BSIZE) - 1;
if (TP_BSIZE != (1 << tp_bshift))
quit("TP_BSIZE (%d) is not a power of 2\n", TP_BSIZE);
diff --git a/sbin/dump/tape.c b/sbin/dump/tape.c
index 2b001f38da2..a64bd6b9fbf 100644
--- a/sbin/dump/tape.c
+++ b/sbin/dump/tape.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tape.c,v 1.38 2013/11/12 04:59:02 deraadt Exp $ */
+/* $OpenBSD: tape.c,v 1.39 2014/05/24 21:49:09 krw Exp $ */
/* $NetBSD: tape.c,v 1.11 1997/06/05 11:13:26 lukem Exp $ */
/*-
@@ -182,7 +182,7 @@ dumpblock(daddr_t blkno, int size)
spcl.c_tapea += avail;
if (trecno >= ntrec)
flushtape();
- dblkno += avail << (tp_bshift - dev_bshift);
+ dblkno += avail << (tp_bshift - (ffs(DEV_BSIZE) - 1));
tpblks -= avail;
}
}
diff --git a/sbin/dump/traverse.c b/sbin/dump/traverse.c
index 7aa52bef0d9..74dcc34a565 100644
--- a/sbin/dump/traverse.c
+++ b/sbin/dump/traverse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: traverse.c,v 1.30 2014/05/21 17:38:30 krw Exp $ */
+/* $OpenBSD: traverse.c,v 1.31 2014/05/24 21:49:09 krw Exp $ */
/* $NetBSD: traverse.c,v 1.17 1997/06/05 11:13:27 lukem Exp $ */
/*-
@@ -801,25 +801,27 @@ int breaderrors = 0;
void
bread(daddr_t blkno, char *buf, int size)
{
+ off_t offset;
int cnt, i;
+ offset = blkno * DEV_BSIZE;
+
loop:
- if ((cnt = pread(diskfd, buf, size, (off_t)blkno << dev_bshift)) ==
- size)
+ if ((cnt = pread(diskfd, buf, size, offset)) == size)
return;
- if (blkno + (size / dev_bsize) >
+ if (blkno + (size / DEV_BSIZE) >
fsbtodb(sblock, sblock->fs_ffs1_size)) {
/*
* Trying to read the final fragment.
*
* NB - dump only works in TP_BSIZE blocks, hence
- * rounds `dev_bsize' fragments up to TP_BSIZE pieces.
+ * rounds `DEV_BSIZE' fragments up to TP_BSIZE pieces.
* It should be smarter about not actually trying to
* read more than it can get, but for the time being
* we punt and scale back the read only when it gets
* us into trouble. (mkm 9/25/83)
*/
- size -= dev_bsize;
+ size -= DEV_BSIZE;
goto loop;
}
if (cnt == -1)
@@ -843,17 +845,18 @@ loop:
* Zero buffer, then try to read each sector of buffer separately.
*/
memset(buf, 0, size);
- for (i = 0; i < size; i += dev_bsize, buf += dev_bsize, blkno++) {
- if ((cnt = pread(diskfd, buf, dev_bsize,
- (off_t)blkno << dev_bshift)) == dev_bsize)
+ for (i = 0; i < size; i += DEV_BSIZE, buf += DEV_BSIZE) {
+ if ((cnt = pread(diskfd, buf, DEV_BSIZE, offset + i)) ==
+ DEV_BSIZE)
continue;
if (cnt == -1) {
msg("read error from %s: %s: [sector %lld]: "
- "count=%ld\n", disk, strerror(errno), blkno,
- dev_bsize);
+ "count=%d\n", disk, strerror(errno),
+ (long long)(offset + i) / DEV_BSIZE, DEV_BSIZE);
continue;
}
- msg("short read error from %s: [sector %lld]: count=%ld, "
- "got=%d\n", disk, blkno, dev_bsize, cnt);
+ msg("short read error from %s: [sector %lld]: count=%d, "
+ "got=%d\n", disk, (long long)(offset + i) / DEV_BSIZE,
+ DEV_BSIZE, cnt);
}
}