Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/dumplfs Read the padded superblocks to avoid proble...
details: https://anonhg.NetBSD.org/src/rev/a2ed5b77675c
branches: trunk
changeset: 752135:a2ed5b77675c
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Tue Feb 16 18:57:53 2010 +0000
description:
Read the padded superblocks to avoid problems with disks that have
larger sectors than 512 Bytes.
diffstat:
usr.sbin/dumplfs/dumplfs.c | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
diffs (68 lines):
diff -r 2a25fb559c80 -r a2ed5b77675c usr.sbin/dumplfs/dumplfs.c
--- a/usr.sbin/dumplfs/dumplfs.c Tue Feb 16 16:56:29 2010 +0000
+++ b/usr.sbin/dumplfs/dumplfs.c Tue Feb 16 18:57:53 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dumplfs.c,v 1.37 2008/07/21 13:36:58 lukem Exp $ */
+/* $NetBSD: dumplfs.c,v 1.38 2010/02/16 18:57:53 mlelstv Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -40,7 +40,7 @@
#if 0
static char sccsid[] = "@(#)dumplfs.c 8.5 (Berkeley) 5/24/95";
#else
-__RCSID("$NetBSD: dumplfs.c,v 1.37 2008/07/21 13:36:58 lukem Exp $");
+__RCSID("$NetBSD: dumplfs.c,v 1.38 2010/02/16 18:57:53 mlelstv Exp $");
#endif
#endif /* not lint */
@@ -136,6 +136,7 @@
struct lfs lfs_sb1, lfs_sb2, *lfs_master;
daddr_t seg_addr, idaddr, sbdaddr;
int ch, do_allsb, do_ientries, do_segentries, fd, segnum;
+ void *sbuf;
do_allsb = 0;
do_ientries = 0;
@@ -178,9 +179,14 @@
if ((fd = open(special, O_RDONLY, 0)) < 0)
err(1, "%s", special);
+ sbuf = malloc(LFS_SBPAD);
+ if (sbuf == NULL)
+ err(1, "malloc");
+
if (sbdaddr == 0x0) {
/* Read the proto-superblock */
- get(fd, LFS_LABELPAD, &(lfs_sb1.lfs_dlfs), sizeof(struct dlfs));
+ get(fd, LFS_LABELPAD, sbuf, LFS_SBPAD);
+ memcpy(&(lfs_sb1.lfs_dlfs), sbuf, sizeof(struct dlfs));
/* If that wasn't the real first sb, get the real first sb */
if (lfs_sb1.lfs_version > 1 &&
@@ -194,7 +200,8 @@
*/
get(fd,
fsbtobyte(&lfs_sb1, lfs_sb1.lfs_sboffs[1]),
- &(lfs_sb2.lfs_dlfs), sizeof(struct dlfs));
+ sbuf, LFS_SBPAD);
+ memcpy(&(lfs_sb2.lfs_dlfs), sbuf, sizeof(struct dlfs));
lfs_master = &lfs_sb1;
if (lfs_sb1.lfs_version > 1) {
@@ -212,11 +219,13 @@
}
} else {
/* Read the first superblock */
- get(fd, dbtob((off_t)sbdaddr), &(lfs_sb1.lfs_dlfs),
- sizeof(struct dlfs));
+ get(fd, dbtob((off_t)sbdaddr), sbuf, LFS_SBPAD);
+ memcpy(&(lfs_sb1.lfs_dlfs), sbuf, sizeof(struct dlfs));
lfs_master = &lfs_sb1;
}
+ free(sbuf);
+
/* Compatibility */
if (lfs_master->lfs_version == 1) {
lfs_master->lfs_sumsize = LFS_V1_SUMMARY_SIZE;
Home |
Main Index |
Thread Index |
Old Index