From 2a5858225fa1e8a26b001017b14e87554b6a5193 Mon Sep 17 00:00:00 2001 From: krw Date: Thu, 22 May 2014 14:38:48 +0000 Subject: [PATCH] Nuke pointless dev_bsize variable which is always set to 512, and just use DEV_BSIZE. Replace lseek+read with pread(). --- sbin/badsect/badsect.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/sbin/badsect/badsect.c b/sbin/badsect/badsect.c index 62686952b74..197d85d5920 100644 --- a/sbin/badsect/badsect.c +++ b/sbin/badsect/badsect.c @@ -1,4 +1,4 @@ -/* $OpenBSD: badsect.c,v 1.23 2014/05/21 16:32:08 krw Exp $ */ +/* $OpenBSD: badsect.c,v 1.24 2014/05/22 14:38:48 krw Exp $ */ /* $NetBSD: badsect.c,v 1.10 1995/03/18 14:54:28 cgd Exp $ */ /* @@ -71,7 +71,6 @@ static union { static struct fs *fs; static int fsi; static int errs; -static long dev_bsize = 1; int main(int argc, char *argv[]) @@ -124,7 +123,6 @@ main(int argc, char *argv[]) fs = &sblock; rdfs(SBOFF, SBSIZE, (char *)fs); - dev_bsize = fs->fs_fsize / fsbtodb(fs, 1); for (argc -= 2, argv += 2; argc > 0; argc--, argv++) { number = strtonum(*argv, 0, QUAD_MAX, NULL); if (chkuse(number, 1)) @@ -185,14 +183,7 @@ chkuse(daddr_t blkno, int cnt) static void rdfs(daddr_t bno, int size, char *bf) { - int n; - - if (lseek(fsi, (off_t)bno * dev_bsize, SEEK_SET) < 0) { - fprintf(stderr, "seek error: %lld\n", (long long)bno); - err(1, "rdfs"); - } - n = read(fsi, bf, size); - if (n != size) { + if (pread(fsi, bf, size, bno * DEV_BSIZE) != size) { fprintf(stderr, "read error: %lld\n", (long long)bno); err(1, "rdfs"); } -- 2.20.1