Module Name: src Committed By: mlelstv Date: Tue Feb 16 23:13:13 UTC 2010
Modified Files: src/libexec/lfs_cleanerd: lfs_cleanerd.c Log Message: Read the padded superblocks to avoid problems with disks that have larger sectors than 512 Bytes. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/libexec/lfs_cleanerd/lfs_cleanerd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/libexec/lfs_cleanerd/lfs_cleanerd.c diff -u src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.22 src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.23 --- src/libexec/lfs_cleanerd/lfs_cleanerd.c:1.22 Fri Oct 9 16:35:17 2009 +++ src/libexec/lfs_cleanerd/lfs_cleanerd.c Tue Feb 16 23:13:13 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_cleanerd.c,v 1.22 2009/10/09 16:35:17 pooka Exp $ */ +/* $NetBSD: lfs_cleanerd.c,v 1.23 2010/02/16 23:13:13 mlelstv Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -203,6 +203,7 @@ struct statvfs sf; int rootfd; int i; + void *sbuf; /* * Get the raw device from the block device. @@ -233,10 +234,20 @@ return -4; kops.ko_close(rootfd); + sbuf = malloc(LFS_SBPAD); + if (sbuf == NULL) { + syslog(LOG_ERR, "couldn't malloc superblock buffer"); + return -1; + } + /* Load in the superblock */ - if (kops.ko_pread(fs->clfs_devfd, &(fs->lfs_dlfs), sizeof(struct dlfs), - LFS_LABELPAD) < 0) + if (kops.ko_pread(fs->clfs_devfd, sbuf, LFS_SBPAD, LFS_LABELPAD) < 0) { + free(sbuf); return -1; + } + + memcpy(&(fs->lfs_dlfs), sbuf, sizeof(struct dlfs)); + free(sbuf); /* If this is not a version 2 filesystem, complain and exit */ if (fs->lfs_version != 2) {