summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2006-02-18 10:59:47 +0000
committerpjd <pjd@FreeBSD.org>2006-02-18 10:59:47 +0000
commit55a384575ff2b5988a6f6b74a41333f91eddf6b5 (patch)
tree46c5c93be59c03a3dcaf5957a86ec39224242cd2
parent748737a8af54bcdc13e93e17e6d0ea0e4b3ff210 (diff)
downloadFreeBSD-src-55a384575ff2b5988a6f6b74a41333f91eddf6b5.zip
FreeBSD-src-55a384575ff2b5988a6f6b74a41333f91eddf6b5.tar.gz
- Do not depend on fact that file system covers entire provider.
It won't work for file systems created with -s option. Use better file system verfication. - Add myself to the copyright. MFC after: 3 days
-rw-r--r--sys/geom/label/g_label_ufs.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/sys/geom/label/g_label_ufs.c b/sys/geom/label/g_label_ufs.c
index 0af23bc..f2f29ce 100644
--- a/sys/geom/label/g_label_ufs.c
+++ b/sys/geom/label/g_label_ufs.c
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 2002, 2003 Gordon Tetlow
+ * Copyright (c) 2006 Pawel Jakub Dawidek <pjd@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -11,10 +12,10 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -77,26 +78,19 @@ g_label_ufs_taste(struct g_consumer *cp, char *label, size_t size)
if (fs == NULL)
continue;
/* Check for magic and make sure things are the right size */
- if (fs->fs_magic == FS_UFS1_MAGIC) {
- G_LABEL_DEBUG(1, "UFS1 file system detected on %s.",
- pp->name);
- if (fs->fs_old_size * fs->fs_fsize !=
- (int32_t)pp->mediasize) {
- g_free(fs);
- continue;
- }
- } else if (fs->fs_magic == FS_UFS2_MAGIC) {
- G_LABEL_DEBUG(1, "UFS2 file system detected on %s.",
- pp->name);
- if (fs->fs_fsize <= 0 ||
- pp->mediasize / fs->fs_fsize != fs->fs_size) {
- g_free(fs);
- continue;
- }
- } else {
+ if (fs->fs_magic != FS_UFS1_MAGIC &&
+ fs->fs_magic != FS_UFS2_MAGIC) {
g_free(fs);
continue;
}
+ if (fs->fs_sblockloc != superblock || fs->fs_ncg < 1 ||
+ fs->fs_bsize < MINBSIZE ||
+ fs->fs_bsize < sizeof(struct fs)) {
+ g_free(fs);
+ continue;
+ }
+ G_LABEL_DEBUG(1, "%s file system detected on %s.",
+ fs->fs_magic == FS_UFS1_MAGIC ? "UFS1" : "UFS2", pp->name);
/* Check for volume label */
if (fs->fs_volname[0] == '\0') {
g_free(fs);
OpenPOWER on IntegriCloud