From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1SfOnZ-00041H-Md for mharc-grub-devel@gnu.org; Fri, 15 Jun 2012 01:10:17 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33406) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfOnW-00041A-V5 for grub-devel@gnu.org; Fri, 15 Jun 2012 01:10:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SfOnV-0005dA-3g for grub-devel@gnu.org; Fri, 15 Jun 2012 01:10:14 -0400 Received: from qmta09.westchester.pa.mail.comcast.net ([76.96.62.96]:46471) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfOnU-0005cz-V9 for grub-devel@gnu.org; Fri, 15 Jun 2012 01:10:13 -0400 Received: from omta17.westchester.pa.mail.comcast.net ([76.96.62.89]) by qmta09.westchester.pa.mail.comcast.net with comcast id NUYW1j0021vXlb859VAAyF; Fri, 15 Jun 2012 05:10:10 +0000 Received: from [192.168.1.101] ([24.63.69.222]) by omta17.westchester.pa.mail.comcast.net with comcast id NVA71j00N4nkFao3dVA8yr; Fri, 15 Jun 2012 05:10:08 +0000 Message-ID: <4FDAC3B1.3010303@comcast.net> Date: Fri, 15 Jun 2012 01:10:09 -0400 From: Robert Mabee User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: grub-devel@gnu.org Subject: [PATCH] Don't look for a partition map on a floppy Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 76.96.62.96 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2012 05:10:16 -0000 "echo *" takes about 12 seconds on my system (PC, BIOS, empty floppy drive) because grub_partition_iterate tries to enumerate the partitions on the floppy. "search --no-floppy" probably hits the same delay (not verified) since it has to generate the partition names before it can discard fd[0-9]. I suggest skipping tiny devices (ie < 4 MB) rather than looking at the name so it won't affect various 100 MB super floppies that might appear as BIOS floppies and therefore get indistinguishable names in fd[0-9]. Arguably these drives should continue to support partition maps, at the expense of long timeouts if they don't handle missing media any better than plain-old floppy drives do. === modified file 'ChangeLog' --- old/ChangeLog 2012-06-09 17:58:38 +0000 +++ new/ChangeLog 2012-06-15 04:34:50 +0000 @@ -1,3 +1,15 @@ +2012-06-15 Bob Mabee + + * kern/partition.c (grub_partition_is_plausible): New function to + decide drive is too small (like floppy) to support partitioning. + * (grub_partition_iterate): Use above so search and (*) avoid long + timeouts trying to read partmap from a missing floppy. + 2012-06-09 Vladimir Serbinenko * tests/grub_script_expansion.in: Explicitly tell grep that we handle === modified file 'grub-core/kern/partition.c' --- old/grub-core/kern/partition.c 2012-02-08 19:19:44 +0000 +++ new/grub-core/kern/partition.c 2012-06-14 05:30:02 +0000 @@ -162,12 +162,23 @@ return part; } +/* Very unlikely to find a partmap on a tiny floppy, but looking for a + map costs a long timeout if drive is empty, so skip device < 4 MB. + (Allowing for a lower-overhead format on biggest media, 2.88 MB.) */ +static int +grub_partition_is_plausible (struct grub_disk *disk) +{ + grub_uint64_t n_bytes = grub_disk_get_size (disk) << GRUB_DISK_SECTOR_BITS; + return n_bytes >= 4 << 20; +} + int grub_partition_iterate (struct grub_disk *disk, int (*hook) (grub_disk_t disk, const grub_partition_t partition)) { int ret = 0; + if (!grub_partition_is_plausible (disk)) return ret; auto int part_iterate (grub_disk_t dsk, const grub_partition_t p);