From owner-freebsd-fs@FreeBSD.ORG Tue Apr 21 17:01:43 2009 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7E8F7106567A; Tue, 21 Apr 2009 17:01:43 +0000 (UTC) (envelope-from avg@freebsd.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 7F29F8FC25; Tue, 21 Apr 2009 17:01:42 +0000 (UTC) (envelope-from avg@freebsd.org) Received: from odyssey.starpoint.kiev.ua (alpha-e.starpoint.kiev.ua [212.40.38.101]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id TAA19084; Tue, 21 Apr 2009 19:51:34 +0300 (EEST) (envelope-from avg@freebsd.org) Message-ID: <49EDF995.2050508@freebsd.org> Date: Tue, 21 Apr 2009 19:51:33 +0300 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.21 (X11/20090406) MIME-Version: 1.0 To: Ivan Voras References: <49EDCA21.70908@icyb.net.ua> <49EDF80F.3070105@icyb.net.ua> In-Reply-To: <49EDF80F.3070105@icyb.net.ua> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: freebsd-fs@freebsd.org, freebsd-geom@freebsd.org Subject: Re: glabel for ufs: size check is overzealous? X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Apr 2009 17:01:43 -0000 on 21/04/2009 19:45 Andriy Gapon said the following: > Maybe this is a check against disk space being re-used for some other fs and > super-block staying sufficiently intact. But, OTOH, fs_fsize and fs_size could > still match the raw media in this case too. > If some extra sanity checks are needed in addition to magic then > fs_bmask/fs_fmask/fs_bshift/fs_fshift and/or any other derived fields could be used. > BTW, right now I put this in my local tree: diff --git a/sys/geom/label/g_label_ufs.c b/sys/geom/label/g_label_ufs.c index 8510fc0..0cffb8d 100644 --- a/sys/geom/label/g_label_ufs.c +++ b/sys/geom/label/g_label_ufs.c @@ -83,10 +83,10 @@ g_label_ufs_taste_common(struct g_consumer *cp, char *label, size_t size, int wh continue; /* Check for magic and make sure things are the right size */ if (fs->fs_magic == FS_UFS1_MAGIC && fs->fs_fsize > 0 && - pp->mediasize / fs->fs_fsize == fs->fs_old_size) { + pp->mediasize / fs->fs_fsize >= fs->fs_old_size) { /* Valid UFS1. */ } else if (fs->fs_magic == FS_UFS2_MAGIC && fs->fs_fsize > 0 && - pp->mediasize / fs->fs_fsize == fs->fs_size) { + pp->mediasize / fs->fs_fsize >= fs->fs_size) { /* Valid UFS2. */ } else { g_free(fs); -- Andriy Gapon