All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Don't look for a partition map on a floppy
@ 2012-06-15  5:10 Robert Mabee
  2012-06-15  5:15 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 3+ messages in thread
From: Robert Mabee @ 2012-06-15  5:10 UTC (permalink / raw)
  To: grub-devel

"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 <rmabee@comcast.net>
+
+    * 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 <phcoder@gmail.com>

      * 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);





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Don't look for a partition map on a floppy
  2012-06-15  5:10 Robert Mabee
@ 2012-06-15  5:15 ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 0 replies; 3+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2012-06-15  5:15 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 2784 bytes --]

On 15.06.2012 07:10, Robert Mabee wrote:

> "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].
> 

search -s stops when it finds first matching device and floppies are
checked in the last place.

> 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.

Minix floppies are partitioned.

> 
> === 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 <rmabee@comcast.net>
> +
> +    * 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 <phcoder@gmail.com>
> 
>      * 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);
> 
> 
> 
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 



-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 294 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Don't look for a partition map on a floppy
       [not found] <mailman.79.1339776014.12100.grub-devel@gnu.org>
@ 2012-06-16  4:58 ` Robert Mabee
  0 siblings, 0 replies; 3+ messages in thread
From: Robert Mabee @ 2012-06-16  4:58 UTC (permalink / raw)
  To: grub-devel

> Minix floppies are partitioned.
>
Facts are such inconvenient things.

I'm still looking for a way to iterate through partitions without incurring
the floppy timeout, something like this:
   for dev in *; do
     if ! regexp "\(fd[0-9]\)" $dev; then
       for part in ($dev,*); do

I can see how to change the *-expansion logic so * wouldn't read partmaps
(since it only matches devices anyway) and so (hd0,*) would only access hd0.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-06-16  4:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.79.1339776014.12100.grub-devel@gnu.org>
2012-06-16  4:58 ` [PATCH] Don't look for a partition map on a floppy Robert Mabee
2012-06-15  5:10 Robert Mabee
2012-06-15  5:15 ` Vladimir 'φ-coder/phcoder' Serbinenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.