diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-02-19 00:57:15 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-02-19 00:57:15 +0000 |
commit | 47eacfbac1d5bf400ae4b59db8baa6b999965883 (patch) | |
tree | 72ddc31aa0085de50d71ac8368da791214d7171e | |
parent | c13e171d14c8c16a6ed3cc1a8a1d55ec7cc5c285 (diff) |
Use pread/pwrite where sensible; also remove some bogus casts in
printf to long and long long for things that are int32_t.
-rw-r--r-- | sbin/newfs/mkfs.c | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index 920a160d126..670fb41251a 100644 --- a/sbin/newfs/mkfs.c +++ b/sbin/newfs/mkfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkfs.c,v 1.22 2002/06/09 08:13:08 todd Exp $ */ +/* $OpenBSD: mkfs.c,v 1.23 2003/02/19 00:57:14 millert Exp $ */ /* $NetBSD: mkfs.c,v 1.25 1995/06/18 21:35:38 cgd Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)mkfs.c 8.3 (Berkeley) 2/3/94"; #else -static char rcsid[] = "$OpenBSD: mkfs.c,v 1.22 2002/06/09 08:13:08 todd Exp $"; +static char rcsid[] = "$OpenBSD: mkfs.c,v 1.23 2003/02/19 00:57:14 millert Exp $"; #endif #endif /* not lint */ @@ -371,9 +371,8 @@ recalc: if (mincpc == 1 || sblock.fs_frag == 1 || sblock.fs_bsize == MINBSIZE) break; - printf("With a block size of %ld %s %ld\n", - (long)sblock.fs_bsize, - "minimum bytes per inode is", + printf("With a block size of %d %s %ld\n", + sblock.fs_bsize, "minimum bytes per inode is", (mincpg * bpcg - used) / MAXIPG(&sblock) + 1); sblock.fs_bsize >>= 1; sblock.fs_frag >>= 1; @@ -1187,22 +1186,14 @@ rdfs(bno, size, bf) void *bf; { int n; - off_t offset; if (mfs) { memcpy(bf, membase + bno * sectorsize, size); return; } - offset = bno; - offset *= sectorsize; - if (lseek(fsi, offset, SEEK_SET) < 0) { - printf("seek error: %lld\n", (long long)bno); - perror("rdfs"); - exit(33); - } - n = read(fsi, bf, size); + n = pread(fsi, bf, size, (off_t)bno * sectorsize); if (n != size) { - printf("read error: %lld\n", (long long)bno); + printf("read error: %d\n", bno); perror("rdfs"); exit(34); } @@ -1218,7 +1209,6 @@ wtfs(bno, size, bf) void *bf; { int n; - off_t offset; if (mfs) { memcpy(membase + bno * sectorsize, bf, size); @@ -1226,16 +1216,9 @@ wtfs(bno, size, bf) } if (Nflag) return; - offset = bno; - offset *= sectorsize; - if (lseek(fso, offset, SEEK_SET) < 0) { - printf("seek error: %lld\n", (long long)bno); - perror("wtfs"); - exit(35); - } - n = write(fso, bf, size); + n = pwrite(fso, bf, size, (off_t)bno * sectorsize); if (n != size) { - printf("write error: %lld\n", (long long)bno); + printf("write error: %d\n", bno); perror("wtfs"); exit(36); } |