Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/clri Calculate sector size from superblock and use that...
details: https://anonhg.NetBSD.org/src/rev/e860d092a347
branches: trunk
changeset: 340282:e860d092a347
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sun Aug 30 05:23:17 2015 +0000
description:
Calculate sector size from superblock and use that instead of DEV_BSIZE.
diffstat:
sbin/clri/clri.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diffs (45 lines):
diff -r 3acc31307b08 -r e860d092a347 sbin/clri/clri.c
--- a/sbin/clri/clri.c Sun Aug 30 05:12:00 2015 +0000
+++ b/sbin/clri/clri.c Sun Aug 30 05:23:17 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: clri.c,v 1.23 2013/06/23 02:06:04 dholland Exp $ */
+/* $NetBSD: clri.c,v 1.24 2015/08/30 05:23:17 mlelstv Exp $ */
/*
* Copyright (c) 1990, 1993
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)clri.c 8.3 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: clri.c,v 1.23 2013/06/23 02:06:04 dholland Exp $");
+__RCSID("$NetBSD: clri.c,v 1.24 2015/08/30 05:23:17 mlelstv Exp $");
#endif
#endif /* not lint */
@@ -84,6 +84,7 @@
char *fs, sblock[SBLOCKSIZE];
int needswap = 0, is_ufs2 = 0;
int i, imax;
+ long dev_bsize;
if (argc < 3) {
(void)fprintf(stderr, "usage: clri filesystem inode ...\n");
@@ -151,6 +152,9 @@
if (needswap)
ffs_sb_swap(sbp, sbp);
+ /* compute disk block size from superblock parameters */
+ dev_bsize = sbp->fs_fsize / FFS_FSBTODB(sbp, 1);
+
bsize = sbp->fs_bsize;
ibuf = malloc(bsize);
if (ibuf == NULL) {
@@ -166,7 +170,7 @@
/* read in the appropriate block. */
offset = ino_to_fsba(sbp, inonum); /* inode to fs blk */
offset = FFS_FSBTODB(sbp, offset); /* fs blk disk blk */
- offset *= DEV_BSIZE; /* disk blk to bytes */
+ offset *= dev_bsize; /* disk blk to bytes */
/* seek and read the block */
if (lseek(fd, offset, SEEK_SET) < 0)
Home |
Main Index |
Thread Index |
Old Index