bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] drive completion when network available


From: KB Sriram
Subject: [PATCH] drive completion when network available
Date: Mon, 22 Sep 2003 14:06:15 -0700 (PDT)

I'd like to offer this patch to address the "bug
in drive completion when network drive is
available" issue.

An example of the symptom is even when grub is
compiled without network support, on a machine
with one hard drive:

"root (n<TAB>" expands into

"root (nd" and offers
" Possible disks are: fd0 hd0"

and on the same machine with grub compiled with
network support, and an initialized network,

"root (hd0<TAB>" does not expand, and offers
" Possible disks are: hd0 nd"

In addition to checks whether "nd" is an
appropriate completion, the patch allows the "nd"
option only when the network is initialized, and
also includes the "nd" related checks only when
network support is compiled in. I'm afraid this
resulted in a few more #ifdefs in the code.

BTW, this is a small patch, but if it looks
acceptable and should there be any issues on the
copyrights, I'd be happy to do what's necessary to
transfer it to the FSF.

Regards,
-kb


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
--- grub.orig/stage2/disk_io.c  Wed Jan 15 13:44:19 2003
+++ grub/stage2/disk_io.c       Mon Sep 22 11:57:15 2003
@@ -948,8 +948,12 @@
       if (*device != ',' && *device != ')')
        {
          char ch = *device;
-
-         if (*device == 'f' || *device == 'h' || *device == 'n')
+#ifdef SUPPORT_NETBOOT
+         if (*device == 'f' || *device == 'h' ||
+             (*device == 'n' && network_ready))
+#else
+         if (*device == 'f' || *device == 'h')
+#endif /* SUPPORT_NETBOOT */
            {
              /* user has given '([fhn]', check for resp. add 'd' and
                 let disk_choice handle what disks we have */
@@ -964,13 +968,20 @@
                return device + 2;
            }
 
-         if ((*device == 'f' || *device == 'h' || *device == 'n')
+#ifdef SUPPORT_NETBOOT
+         if ((*device == 'f' || *device == 'h' ||
+              (*device == 'n' && network_ready))
+#else
+         if ((*device == 'f' || *device == 'h')
+#endif /* SUPPORT_NETBOOT */
              && (device += 2, (*(device - 1) != 'd')))
            errnum = ERR_NUMBER_PARSING;
 
-         if (ch == 'n')
+#ifdef SUPPORT_NETBOOT
+         if (ch == 'n' && network_ready)
            current_drive = NETWORK_DRIVE;
          else
+#endif /* SUPPORT_NETBOOT */
            {
              safe_parse_maxint (&device, (int *) &current_drive);
              
@@ -1326,26 +1337,33 @@
              if (! is_completion)
                grub_printf (" Possible disks are: ");
 
-             for (i = (ptr && (*(ptr-2) == 'h' && *(ptr-1) == 'd') ? 1 : 0);
-                  i < (ptr && (*(ptr-2) == 'f' && *(ptr-1) == 'd') ? 1 : 2);
-                  i++)
+#ifdef SUPPORT_NETBOOT
+             if (!ptr || *(ptr-1) != 'd' || *(ptr-2) != 'n')
+#endif /* SUPPORT_NETBOOT */
                {
-                 for (j = 0; j < 8; j++)
+                 for (i = (ptr && (*(ptr-1) == 'd' && *(ptr-2) == 'h') ? 1:0);
+                      i < (ptr && (*(ptr-1) == 'd' && *(ptr-2) == 'f') ? 1:2);
+                      i++)
                    {
-                     disk_no = (i * 0x80) + j;
-                     if ((disk_choice || disk_no == current_drive)
-                         && ! get_diskinfo (disk_no, &geom))
+                     for (j = 0; j < 8; j++)
                        {
-                         char dev_name[8];
-
-                         grub_sprintf (dev_name, "%cd%d", i ? 'h' : 'f', j);
-                         print_a_completion (dev_name);
+                         disk_no = (i * 0x80) + j;
+                         if ((disk_choice || disk_no == current_drive)
+                             && ! get_diskinfo (disk_no, &geom))
+                           {
+                             char dev_name[8];
+
+                             grub_sprintf (dev_name, "%cd%d", i ? 'h':'f', j);
+                             print_a_completion (dev_name);
+                           }
                        }
                    }
                }
-
 # ifdef SUPPORT_NETBOOT
-             if (network_ready)
+             if (network_ready &&
+                 (disk_choice || NETWORK_DRIVE == current_drive) &&
+                 (!ptr || *(ptr-1) == '(' ||
+                  (*(ptr-1) == 'd' && *(ptr-2) == 'n')))
                print_a_completion ("nd");
 # endif /* SUPPORT_NETBOOT */
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]