From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Myv7w-0007cn-G6 for mharc-grub-devel@gnu.org; Fri, 16 Oct 2009 18:18:24 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Myv7u-0007ci-Pq for grub-devel@gnu.org; Fri, 16 Oct 2009 18:18:22 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Myv7q-0007bt-4N for grub-devel@gnu.org; Fri, 16 Oct 2009 18:18:22 -0400 Received: from [199.232.76.173] (port=38778 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Myv7p-0007bm-W0 for grub-devel@gnu.org; Fri, 16 Oct 2009 18:18:18 -0400 Received: from mail-fx0-f228.google.com ([209.85.220.228]:35335) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Myv7o-0006We-UV for grub-devel@gnu.org; Fri, 16 Oct 2009 18:18:17 -0400 Received: by fxm28 with SMTP id 28so2966456fxm.42 for ; Fri, 16 Oct 2009 15:18:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type; bh=Kv5/fRbgQHlCRqOyZFt1oPiK3EHY2577YFLhJx4uqeQ=; b=hbBxX85fjpjOxvDhm4y3tVjNpKAEK00cRKWx/Pp62GcEfIEPJ/s2RUG9k3D2WZAzPy e+R8cEq81UY/4U+JRlzlG5G97H+OyKP/woN6bXq1MWnlrNCpHfMOoH8c/kaqm7HvxM6l q9IQNTZvY2dh+Vg6Ve06WpW9PQimgrp8UQkp4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; b=fpPgeM25yn4Z2ZhM5I4Kbz61xqOWPY78/ygt+KsnO9xqnTOvIagqggvBTBohjd7PF/ rFtpKA/88V/heE+UO9TnZvb2Peda0eTLhQXdjWyiSnhCP/9xsPFjtA0/NAG4hvmhyuqc 7IpmCBIaznEwyIk5OO2YK+xLeWrifkeM8FJek= Received: by 10.204.34.194 with SMTP id m2mr1874482bkd.53.1255731495512; Fri, 16 Oct 2009 15:18:15 -0700 (PDT) Received: from debian.bg45.phnet (190-234.203-62.cust.bluewin.ch [62.203.234.190]) by mx.google.com with ESMTPS id 14sm279266bwz.13.2009.10.16.15.18.09 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 16 Oct 2009 15:18:14 -0700 (PDT) Message-ID: <4AD8F11D.1030007@gmail.com> Date: Sat, 17 Oct 2009 00:18:05 +0200 From: Vladimir 'phcoder' Serbinenko User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090701) MIME-Version: 1.0 To: The development of GRUB 2 References: <4AD8514E.2040304@gmail.com> <4AD87D15.7060408@gmail.com> <20091016160156.GA4986@nubol.oskuro.net> <20091016183805.GE7037@thorin> <4AD8D305.5000806@gmail.com> <20091016205258.GA8496@thorin> <4AD8E0CF.9080509@gmail.com> <20091016215343.GA9378@thorin> In-Reply-To: <20091016215343.GA9378@thorin> Content-Type: multipart/mixed; boundary="------------070008060009000800070808" X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: Re: [PATCH] Refuse to install on XFS destroying its superblock X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Oct 2009 22:18:23 -0000 This is a multi-part message in MIME format. --------------070008060009000800070808 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Robert Millan wrote: > On Fri, Oct 16, 2009 at 11:08:31PM +0200, Vladimir 'phcoder' Serbinenko wrote: > >> Robert Millan wrote: >> >>> On Fri, Oct 16, 2009 at 10:09:41PM +0200, Vladimir 'phcoder' Serbinenko wrote: >>> >>> >>>> Robert Millan wrote: >>>> >>>> >>>>> On Fri, Oct 16, 2009 at 06:01:56PM +0200, Jordi Mallach wrote: >>>>> >>>>> >>>>> >>>>>> On Fri, Oct 16, 2009 at 04:03:01PM +0200, Vladimir 'phcoder' Serbinenko wrote: >>>>>> >>>>>> >>>>>> >>>>>>> + if (memcmp (tmp_img, "XFSB", 4) == 0) >>>>>>> + grub_util_error ("Can't install on XFS."); >>>>>>> >>>>>>> >>>>>>> >>>>>> Can this error message give some more detail on what the problem is? >>>>>> >>>>>> >>>>>> >>>>> I suggest something like: >>>>> >>>>> grub_util_warn ("Refusing to overwrite XFS meta-data."); >>>>> >>>>> This is more informative, and with grub_util_warn() user has an opportunity to >>>>> override it if she knows what she's doing. >>>>> >>>>> >>>>> >>>>> >>>> Installing with blocklists/to partition is considered >>>> backward-compatibility feature. We never supported a config with XFS why >>>> we would want bw-compat for it? >>>> >>>> >>> Because we can't reliably tell if it's a config with XFS, only the user can. >>> This is an issue for both MBR or PBR installs. >>> >>> Maybe "XFSB" is only a remnant from one of this disk / partition former >>> lifes. Maybe it's a valid XFS but user no longer cares about it. Or >>> maybe a DOS-style label was created on top of it, without overwriting the first >>> 440 bytes. Or maybe another filesystem had overwritten most XFS metadata >>> but preserved the first block (this is conceivable since other filesystems >>> tend to avoid using the first block). >>> >>> If user has to workaround GRUB heuristics by dd'ing zeros into a partition >>> before running grub-install, this is a sign GRUB isn't doing the right thing. >>> >>> >>> >> Well, ok. But then I would ask to use a separate --force e.g. >> --force-destroy-xfs since users and distributions tend to use --force >> too much >> > > Ok. > > -- Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git --------------070008060009000800070808 Content-Type: text/x-patch; name="xfs.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="xfs.diff" diff --git a/ChangeLog b/ChangeLog index 960fc06..cc225a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2009-10-16 Vladimir Serbinenko + * util/i386/pc/grub-setup.c (setup): Refuse to overwrite XFS superblock. + (options): New option --destroy-xfs. + (main): Handle --destroy-xfs. + +2009-10-16 Vladimir Serbinenko + Let user specify OpenBSD root device. * loader/i386/bsd.c (openbsd_root): New variable. diff --git a/util/i386/pc/grub-setup.c b/util/i386/pc/grub-setup.c index ccfbd1d..4ef746b 100644 --- a/util/i386/pc/grub-setup.c +++ b/util/i386/pc/grub-setup.c @@ -86,7 +86,8 @@ grub_refresh (void) static void setup (const char *dir, const char *boot_file, const char *core_file, - const char *root, const char *dest, int must_embed, int force) + const char *root, const char *dest, int must_embed, int force, + int destroy_xfs) { char *boot_path, *core_path, *core_path_dev; char *boot_img, *core_img; @@ -251,6 +252,13 @@ setup (const char *dir, if (grub_disk_read (dest_dev->disk, 0, 0, GRUB_DISK_SECTOR_SIZE, tmp_img)) grub_util_error ("%s", grub_errmsg); + if (memcmp (tmp_img, "XFSB", 4) == 0) + { + grub_util_warn ("This install would require destroying XFS."); + if (! destroy_xfs) + grub_util_error ("If you really want to destroy it use --destroy-xfs."); + } + /* Copy the possible DOS BPB. */ memcpy (boot_img + GRUB_BOOT_MACHINE_BPB_START, tmp_img + GRUB_BOOT_MACHINE_BPB_START, @@ -556,6 +564,7 @@ static struct option options[] = {"device-map", required_argument, 0, 'm'}, {"root-device", required_argument, 0, 'r'}, {"force", no_argument, 0, 'f'}, + {"destroy-xfs", no_argument, 0, 'X'}, {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'V'}, {"verbose", no_argument, 0, 'v'}, @@ -580,6 +589,7 @@ DEVICE must be a GRUB device (e.g. ``(hd0,1)'').\n\ -m, --device-map=FILE use FILE as the device map [default=%s]\n\ -r, --root-device=DEV use DEV as the root device [default=guessed]\n\ -f, --force install even if problems are detected\n\ + --destroy-xfs install even destroying XFS superblock\n\ -h, --help display this message and exit\n\ -V, --version print version information and exit\n\ -v, --verbose print verbose messages\n\ @@ -614,6 +624,7 @@ main (int argc, char *argv[]) char *root_dev = 0; char *dest_dev; int must_embed = 0, force = 0; + int destroy_xfs = 0; progname = "grub-setup"; @@ -666,6 +677,10 @@ main (int argc, char *argv[]) force = 1; break; + case 'X': + destroy_xfs = 1; + break; + case 'h': usage (0); break; @@ -767,7 +782,8 @@ main (int argc, char *argv[]) setup (dir ? : DEFAULT_DIRECTORY, boot_file ? : DEFAULT_BOOT_FILE, core_file ? : DEFAULT_CORE_FILE, - root_dev, grub_util_get_grub_dev (devicelist[i]), 1, force); + root_dev, grub_util_get_grub_dev (devicelist[i]), 1, force, + destroy_xfs); } } else @@ -776,7 +792,7 @@ main (int argc, char *argv[]) setup (dir ? : DEFAULT_DIRECTORY, boot_file ? : DEFAULT_BOOT_FILE, core_file ? : DEFAULT_CORE_FILE, - root_dev, dest_dev, must_embed, force); + root_dev, dest_dev, must_embed, force, destroy_xfs); /* Free resources. */ grub_fini_all (); --------------070008060009000800070808--