]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2005-08-20 Yoshinori K. Okuji <okuji@enbug.org>
authorokuji <okuji@localhost>
Sat, 20 Aug 2005 07:49:02 +0000 (07:49 +0000)
committerokuji <okuji@localhost>
Sat, 20 Aug 2005 07:49:02 +0000 (07:49 +0000)
        * partmap/pc.c (pc_partition_map_iterate): Include the value of an
        invalid magic in thre error.

        * commands/search.c: New file.

        * util/grub-emu.c (main): Call grub_search_init and
        grub_search_fini.

        * kern/rescue.c (grub_rescue_print_disks): Removed.
        (grub_rescue_print_devices): New function.
        (grub_rescue_cmd_ls): Use grub_device_iterate with
        grub_rescue_print_devices instead of grub_disk_dev_iterate with
        grub_rescue_print_disks.

        * kern/partition.c (grub_partition_iterate): Return the result of
        PARTMAP->ITERATE instead of GRUB_ERRNO.

        * kern/device.c: Include grub/partition.h.
        (grub_device_iterate): New function.

        * include/grub/partition.h (grub_partition_iterate): Return int
        instead of grub_err_t.

        * include/grub/normal.h [GRUB_UTIL] (grub_search_init): New
        prototype.
        [GRUB_UTIL] (grub_search_fini): Likewise.

        * include/grub/device.h (grub_device_iterate): New prototype.

        * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Added
        commands/search.c.
        (pkgdata_MODULES): Added search.mod.
        (search_mod_SOURCES): New variable.
        (search_mod_CFLAGS): Likewise.

        * conf/i386-pc.rmk (grub_emu_SOURCES): Added commands/search.c.
        (pkgdata_MODULES): Added search.mod.
        (search_mod_SOURCES): New variable.
        (search_mod_CFLAGS): Likewise.

        * commands/ls.c (grub_ls_list_disks): Renamed to ...
        (grub_ls_list_devices): ... this, and use grub_device_iterate.
        All callers changed.

        * DISTLIST: Added commands/search.c.

17 files changed:
ChangeLog
DISTLIST
NEWS
commands/ls.c
commands/search.c [new file with mode: 0644]
conf/i386-pc.mk
conf/i386-pc.rmk
conf/powerpc-ieee1275.mk
conf/powerpc-ieee1275.rmk
include/grub/device.h
include/grub/normal.h
include/grub/partition.h
kern/device.c
kern/partition.c
kern/rescue.c
partmap/pc.c
util/grub-emu.c

index 0e1ebcede7c31e4ed4ae741d6a6eb0cacea22d11..23f8ea877c806368266b4e3f7e2dfb8d48817d87 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,51 @@
+2005-08-20  Yoshinori K. Okuji  <okuji@enbug.org>
+
+       * partmap/pc.c (pc_partition_map_iterate): Include the value of an
+       invalid magic in thre error.
+
+       * commands/search.c: New file.
+       
+       * util/grub-emu.c (main): Call grub_search_init and
+       grub_search_fini.
+
+       * kern/rescue.c (grub_rescue_print_disks): Removed.
+       (grub_rescue_print_devices): New function.
+       (grub_rescue_cmd_ls): Use grub_device_iterate with
+       grub_rescue_print_devices instead of grub_disk_dev_iterate with
+       grub_rescue_print_disks.
+
+       * kern/partition.c (grub_partition_iterate): Return the result of
+       PARTMAP->ITERATE instead of GRUB_ERRNO.
+
+       * kern/device.c: Include grub/partition.h.
+       (grub_device_iterate): New function.
+
+       * include/grub/partition.h (grub_partition_iterate): Return int
+       instead of grub_err_t.
+
+       * include/grub/normal.h [GRUB_UTIL] (grub_search_init): New
+       prototype.
+       [GRUB_UTIL] (grub_search_fini): Likewise.
+
+       * include/grub/device.h (grub_device_iterate): New prototype.
+
+       * conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Added
+       commands/search.c.
+       (pkgdata_MODULES): Added search.mod.
+       (search_mod_SOURCES): New variable.
+       (search_mod_CFLAGS): Likewise.
+
+       * conf/i386-pc.rmk (grub_emu_SOURCES): Added commands/search.c.
+       (pkgdata_MODULES): Added search.mod.
+       (search_mod_SOURCES): New variable.
+       (search_mod_CFLAGS): Likewise.
+
+       * commands/ls.c (grub_ls_list_disks): Renamed to ...
+       (grub_ls_list_devices): ... this, and use grub_device_iterate.
+       All callers changed.
+
+       * DISTLIST: Added commands/search.c.
+
 2005-08-20  Yoshinori K. Okuji  <okuji@enbug.org>
 
        * kern/term.c (grub_putchar): Use grub_utf8_to_ucs4 for the
index 92ce2c3ed713a94921d2db77f0d4721daa044369..732441e59abe6598d1672a02a0df7048a3bc6a15 100644 (file)
--- a/DISTLIST
+++ b/DISTLIST
@@ -44,6 +44,7 @@ commands/configfile.c
 commands/default.c
 commands/help.c
 commands/ls.c
+commands/search.c
 commands/terminal.c
 commands/timeout.c
 conf/i386-pc.mk
diff --git a/NEWS b/NEWS
index e7c0cd40666bd8f1560cfcd297cd8532246d89a1..4f20f1610703b8edadc2aacb5bce68fb5a037dd4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ New in 1.91:
 
 * Add VBE support.
 
+* New commands, "search", "vbetest" and "vbeinfo".
+
 
 New in 1.90 - 2005-08-07:
 
index 5b1b5a70afd5947b04e03df6bdbc6e50fe788494..51c8fef0cea748b800624ed637b08fb6ea7f4df9 100644 (file)
@@ -42,60 +42,20 @@ static const struct grub_arg_option options[] =
 static const char grub_human_sizes[] = {' ', 'K', 'M', 'G', 'T'};
 
 static grub_err_t
-grub_ls_list_disks (int longlist)
+grub_ls_list_devices (int longlist)
 {
-  auto int grub_ls_print_disks (const char *name);
-  int grub_ls_print_disks (const char *name)
+  auto int grub_ls_print_devices (const char *name);
+  int grub_ls_print_devices (const char *name)
     {
-      grub_device_t dev;
-      auto int print_partition (grub_disk_t disk, const grub_partition_t p);
-      
-      int print_partition (grub_disk_t disk __attribute__ ((unused)),
-                          const grub_partition_t p)
-       {
-         char *pname = grub_partition_get_name (p);
-
-         if (pname)
-           {
-             if (longlist)
-               {
-                 char device_name[grub_strlen (name) + 1
-                                  + grub_strlen (pname) + 1];
-                 grub_sprintf (device_name, "%s,%s", name, pname);
-                 grub_normal_print_device_info (device_name);
-               }
-             else
-               grub_printf ("(%s,%s) ", name, pname);
-
-             grub_free (pname);
-           }
-
-         return 0;
-       }
-      
-      dev = grub_device_open (name);
-      grub_errno = GRUB_ERR_NONE;
-      
-      if (dev)
-       {
-         if (longlist)
-           grub_normal_print_device_info (name);
-         else
-           grub_printf ("(%s) ", name);
-
-         if (dev->disk && dev->disk->has_partitions)
-           {
-             grub_partition_iterate (dev->disk, print_partition);
-             grub_errno = GRUB_ERR_NONE;
-           }
-
-         grub_device_close (dev);
-       }
+      if (longlist)
+       grub_normal_print_device_info (name);
+      else
+       grub_printf ("(%s) ", name);
   
       return 0;
     }
   
-  grub_disk_dev_iterate (grub_ls_print_disks);
+  grub_device_iterate (grub_ls_print_devices);
   grub_putchar ('\n');
   grub_refresh ();
 
@@ -260,7 +220,7 @@ static grub_err_t
 grub_cmd_ls (struct grub_arg_list *state, int argc, char **args)
 {
   if (argc == 0)
-    grub_ls_list_disks (state[0].set);
+    grub_ls_list_devices (state[0].set);
   else
     grub_ls_list_files (args[0], state[0].set, state[2].set,
                        state[1].set);
diff --git a/commands/search.c b/commands/search.c
new file mode 100644 (file)
index 0000000..e07f137
--- /dev/null
@@ -0,0 +1,186 @@
+/* search.c - search devices based on a file or a filesystem label */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2005  Free Software Foundation, Inc.
+ *
+ *  GRUB is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA.
+ */
+
+#include <grub/types.h>
+#include <grub/misc.h>
+#include <grub/mm.h>
+#include <grub/err.h>
+#include <grub/dl.h>
+#include <grub/normal.h>
+#include <grub/arg.h>
+#include <grub/device.h>
+#include <grub/file.h>
+#include <grub/env.h>
+
+static const struct grub_arg_option options[] =
+  {
+    {"file", 'f', 0, "search devices by a file (default)", 0, 0},
+    {"label", 'l', 0, "search devices by a filesystem label", 0, 0},
+    {"set", 's', GRUB_ARG_OPTION_OPTIONAL, "set a variable to the first device found", "VAR", ARG_TYPE_STRING},
+    {0, 0, 0, 0, 0, 0}
+  };
+
+static void
+search_label (const char *key, const char *var)
+{
+  int count = 0;
+  auto int iterate_device (const char *name);
+
+  int iterate_device (const char *name)
+    {
+      grub_device_t dev;
+      
+      dev = grub_device_open (name);
+      if (dev)
+       {
+         grub_fs_t fs;
+         
+         fs = grub_fs_probe (dev);
+         if (fs && fs->label)
+           {
+             char *label;
+             
+             (fs->label) (dev, &label);
+             if (grub_errno == GRUB_ERR_NONE && label)
+               {
+                 if (grub_strcmp (label, key) == 0)
+                   {
+                     /* Found!  */
+                     grub_printf (" %s", name);
+                     if (count++ == 0 && var)
+                       grub_env_set (var, name);
+                   }
+                 
+                 grub_free (label);
+               }
+           }
+         
+         grub_device_close (dev);
+       }
+
+      grub_errno = GRUB_ERR_NONE;
+      return 0;
+    }
+  
+  grub_device_iterate (iterate_device);
+  
+  if (count == 0)
+    grub_error (GRUB_ERR_FILE_NOT_FOUND, "no such device: %s", key);
+}
+
+static void
+search_file (const char *key, const char *var)
+{
+  int count = 0;
+  char *buf = 0;
+  auto int iterate_device (const char *name);
+
+  int iterate_device (const char *name)
+    {
+      grub_size_t len;
+      char *p;
+      grub_file_t file;
+      
+      len = grub_strlen (name) + 2 + grub_strlen (key) + 1;
+      p = grub_realloc (buf, len);
+      if (! p)
+       return 1;
+
+      buf = p;
+      grub_sprintf (buf, "(%s)%s", name, key);
+      
+      file = grub_file_open (buf);
+      if (file)
+       {
+         /* Found!  */
+         grub_printf (" %s", name);
+         if (count++ == 0 && var)
+           grub_env_set (var, name);
+
+         grub_file_close (file);
+       }
+      
+      grub_errno = GRUB_ERR_NONE;
+      return 0;
+    }
+  
+  grub_device_iterate (iterate_device);
+  
+  grub_free (buf);
+  
+  if (grub_errno == GRUB_ERR_NONE && count == 0)
+    grub_error (GRUB_ERR_FILE_NOT_FOUND, "no such device");
+}
+
+static grub_err_t
+grub_cmd_search (struct grub_arg_list *state, int argc, char **args)
+{
+  const char *var = 0;
+  
+  if (argc == 0)
+    return grub_error (GRUB_ERR_INVALID_COMMAND, "no argument specified");
+
+  if (state[2].set)
+    var = state[2].arg ? : "root";
+  
+  if (state[1].set)
+    search_label (args[0], var);
+  else
+    search_file (args[0], var);
+
+  return grub_errno;
+}
+
+#ifdef GRUB_UTIL
+void
+grub_search_init (void)
+{
+  grub_register_command ("search", grub_cmd_search, GRUB_COMMAND_FLAG_BOTH,
+                        "search [-f|-l|-s] NAME",
+                        "Search devices by a file or a filesystem label."
+                        " If --set is specified, the first device found is"
+                        " set to a variable. If no variable name is"
+                        " specified, \"root\" is used.",
+                        options);
+}
+
+void
+grub_search_fini (void)
+{
+  grub_unregister_command ("search");
+}
+#else /* ! GRUB_UTIL */
+GRUB_MOD_INIT
+{
+  (void) mod;                  /* To stop warning. */
+  grub_register_command ("search", grub_cmd_search, GRUB_COMMAND_FLAG_BOTH,
+                        "search [-f|-l|-s] NAME",
+                        "Search devices by a file or a filesystem label."
+                        " If --set is specified, the first device found is"
+                        " set to a variable. If no variable name is"
+                        " specified, \"root\" is used.",
+                        options);
+}
+
+GRUB_MOD_FINI
+{
+  grub_unregister_command ("search");
+}
+#endif /* ! GRUB_UTIL */
index bdfbe540af7b053564890a61640052807fb5aef7..9e0f00dfe2ff20b7a80fa60798822bc8a0db6f00 100644 (file)
@@ -674,7 +674,8 @@ grub_probefs-fs_fshelp.d: fs/fshelp.c
 # For grub-emu.
 grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c       \
        commands/configfile.c commands/default.c commands/help.c        \
-       commands/terminal.c commands/ls.c commands/timeout.c            \
+       commands/terminal.c commands/ls.c commands/search.c             \
+       commands/timeout.c                                              \
        commands/i386/pc/halt.c commands/i386/pc/reboot.c               \
        disk/loopback.c                                                 \
        fs/ext2.c fs/fat.c fs/fshelp.c fs/hfs.c fs/iso9660.c fs/jfs.c   \
@@ -689,10 +690,10 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c  \
        util/console.c util/grub-emu.c util/misc.c                      \
        util/i386/pc/biosdisk.c util/i386/pc/getroot.c                  \
        util/i386/pc/misc.c
-CLEANFILES += grub-emu grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_default.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_timeout.o grub_emu-commands_i386_pc_halt.o grub_emu-commands_i386_pc_reboot.o grub_emu-disk_loopback.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_ufs.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_context.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_i386_pc_misc.o
-MOSTLYCLEANFILES += grub_emu-commands_boot.d grub_emu-commands_cat.d grub_emu-commands_cmp.d grub_emu-commands_configfile.d grub_emu-commands_default.d grub_emu-commands_help.d grub_emu-commands_terminal.d grub_emu-commands_ls.d grub_emu-commands_timeout.d grub_emu-commands_i386_pc_halt.d grub_emu-commands_i386_pc_reboot.d grub_emu-disk_loopback.d grub_emu-fs_ext2.d grub_emu-fs_fat.d grub_emu-fs_fshelp.d grub_emu-fs_hfs.d grub_emu-fs_iso9660.d grub_emu-fs_jfs.d grub_emu-fs_minix.d grub_emu-fs_ufs.d grub_emu-kern_device.d grub_emu-kern_disk.d grub_emu-kern_dl.d grub_emu-kern_env.d grub_emu-kern_err.d grub_emu-kern_file.d grub_emu-kern_fs.d grub_emu-kern_loader.d grub_emu-kern_main.d grub_emu-kern_misc.d grub_emu-kern_partition.d grub_emu-kern_rescue.d grub_emu-kern_term.d grub_emu-normal_arg.d grub_emu-normal_cmdline.d grub_emu-normal_command.d grub_emu-normal_completion.d grub_emu-normal_context.d grub_emu-normal_main.d grub_emu-normal_menu.d grub_emu-normal_menu_entry.d grub_emu-normal_misc.d grub_emu-partmap_amiga.d grub_emu-partmap_apple.d grub_emu-partmap_pc.d grub_emu-partmap_sun.d grub_emu-util_console.d grub_emu-util_grub_emu.d grub_emu-util_misc.d grub_emu-util_i386_pc_biosdisk.d grub_emu-util_i386_pc_getroot.d grub_emu-util_i386_pc_misc.d
+CLEANFILES += grub-emu grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_default.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_search.o grub_emu-commands_timeout.o grub_emu-commands_i386_pc_halt.o grub_emu-commands_i386_pc_reboot.o grub_emu-disk_loopback.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_ufs.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_context.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_i386_pc_misc.o
+MOSTLYCLEANFILES += grub_emu-commands_boot.d grub_emu-commands_cat.d grub_emu-commands_cmp.d grub_emu-commands_configfile.d grub_emu-commands_default.d grub_emu-commands_help.d grub_emu-commands_terminal.d grub_emu-commands_ls.d grub_emu-commands_search.d grub_emu-commands_timeout.d grub_emu-commands_i386_pc_halt.d grub_emu-commands_i386_pc_reboot.d grub_emu-disk_loopback.d grub_emu-fs_ext2.d grub_emu-fs_fat.d grub_emu-fs_fshelp.d grub_emu-fs_hfs.d grub_emu-fs_iso9660.d grub_emu-fs_jfs.d grub_emu-fs_minix.d grub_emu-fs_ufs.d grub_emu-kern_device.d grub_emu-kern_disk.d grub_emu-kern_dl.d grub_emu-kern_env.d grub_emu-kern_err.d grub_emu-kern_file.d grub_emu-kern_fs.d grub_emu-kern_loader.d grub_emu-kern_main.d grub_emu-kern_misc.d grub_emu-kern_partition.d grub_emu-kern_rescue.d grub_emu-kern_term.d grub_emu-normal_arg.d grub_emu-normal_cmdline.d grub_emu-normal_command.d grub_emu-normal_completion.d grub_emu-normal_context.d grub_emu-normal_main.d grub_emu-normal_menu.d grub_emu-normal_menu_entry.d grub_emu-normal_misc.d grub_emu-partmap_amiga.d grub_emu-partmap_apple.d grub_emu-partmap_pc.d grub_emu-partmap_sun.d grub_emu-util_console.d grub_emu-util_grub_emu.d grub_emu-util_misc.d grub_emu-util_i386_pc_biosdisk.d grub_emu-util_i386_pc_getroot.d grub_emu-util_i386_pc_misc.d
 
-grub-emu: grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_default.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_timeout.o grub_emu-commands_i386_pc_halt.o grub_emu-commands_i386_pc_reboot.o grub_emu-disk_loopback.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_ufs.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_context.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_i386_pc_misc.o
+grub-emu: grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_default.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_search.o grub_emu-commands_timeout.o grub_emu-commands_i386_pc_halt.o grub_emu-commands_i386_pc_reboot.o grub_emu-disk_loopback.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_ufs.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_context.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_i386_pc_misc.o
        $(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(grub_emu_LDFLAGS)
 
 grub_emu-commands_boot.o: commands/boot.c
@@ -759,6 +760,14 @@ grub_emu-commands_ls.d: commands/ls.c
 
 -include grub_emu-commands_ls.d
 
+grub_emu-commands_search.o: commands/search.c
+       $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
+
+grub_emu-commands_search.d: commands/search.c
+       set -e;           $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $<    | sed 's,search\.o[ :]*,grub_emu-commands_search.o $@ : ,g' > $@;       [ -s $@ ] || rm -f $@
+
+-include grub_emu-commands_search.d
+
 grub_emu-commands_timeout.o: commands/timeout.c
        $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
 
@@ -1150,7 +1159,7 @@ pkgdata_MODULES = _chain.mod _linux.mod linux.mod fat.mod ufs.mod \
        terminal.mod fshelp.mod chain.mod multiboot.mod amiga.mod       \
        apple.mod pc.mod sun.mod loopback.mod reboot.mod halt.mod       \
        help.mod default.mod timeout.mod configfile.mod vbe.mod         \
-       vesafb.mod vbetest.mod vbeinfo.mod
+       vesafb.mod vbetest.mod vbeinfo.mod search.mod
 
 # For _chain.mod.
 _chain_mod_SOURCES = loader/i386/pc/chainloader.c
@@ -3180,6 +3189,56 @@ fs-vbetest.lst: commands/i386/pc/vbetest.c genfslist.sh
 
 
 vbetest_mod_CFLAGS = $(COMMON_CFLAGS)
+
+# For search.mod.
+search_mod_SOURCES = commands/search.c
+CLEANFILES += search.mod mod-search.o mod-search.c pre-search.o search_mod-commands_search.o def-search.lst und-search.lst
+MOSTLYCLEANFILES += search_mod-commands_search.d
+DEFSYMFILES += def-search.lst
+UNDSYMFILES += und-search.lst
+
+search.mod: pre-search.o mod-search.o
+       -rm -f $@
+       $(LD) -r -d -o $@ $^
+       $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
+
+pre-search.o: search_mod-commands_search.o
+       -rm -f $@
+       $(LD) -r -d -o $@ $^
+
+mod-search.o: mod-search.c
+       $(CC) $(CPPFLAGS) $(CFLAGS) $(search_mod_CFLAGS) -c -o $@ $<
+
+mod-search.c: moddep.lst genmodsrc.sh
+       sh $(srcdir)/genmodsrc.sh 'search' $< > $@ || (rm -f $@; exit 1)
+
+def-search.lst: pre-search.o
+       $(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 search/' > $@
+
+und-search.lst: pre-search.o
+       echo 'search' > $@
+       $(NM) -u -P -p $< | cut -f1 -d' ' >> $@
+
+search_mod-commands_search.o: commands/search.c
+       $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(search_mod_CFLAGS) -c -o $@ $<
+
+search_mod-commands_search.d: commands/search.c
+       set -e;           $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(search_mod_CFLAGS) -M $<          | sed 's,search\.o[ :]*,search_mod-commands_search.o $@ : ,g' > $@;     [ -s $@ ] || rm -f $@
+
+-include search_mod-commands_search.d
+
+CLEANFILES += cmd-search.lst fs-search.lst
+COMMANDFILES += cmd-search.lst
+FSFILES += fs-search.lst
+
+cmd-search.lst: commands/search.c gencmdlist.sh
+       set -e;           $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(search_mod_CFLAGS) -E $<          | sh $(srcdir)/gencmdlist.sh search > $@ || (rm -f $@; exit 1)
+
+fs-search.lst: commands/search.c genfslist.sh
+       set -e;           $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(search_mod_CFLAGS) -E $<          | sh $(srcdir)/genfslist.sh search > $@ || (rm -f $@; exit 1)
+
+
+search_mod_CFLAGS = $(COMMON_CFLAGS)
 CLEANFILES += moddep.lst command.lst fs.lst
 pkgdata_DATA += moddep.lst command.lst fs.lst
 moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep
index da1769d2d9ce5acf4291d3b6e669d04cb5a3b25f..4e7e41493e38b7141893895e9f1ff35fd6f888f6 100644 (file)
@@ -78,7 +78,8 @@ grub_probefs_SOURCES = util/i386/pc/grub-probefs.c    \
 # For grub-emu.
 grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c       \
        commands/configfile.c commands/default.c commands/help.c        \
-       commands/terminal.c commands/ls.c commands/timeout.c            \
+       commands/terminal.c commands/ls.c commands/search.c             \
+       commands/timeout.c                                              \
        commands/i386/pc/halt.c commands/i386/pc/reboot.c               \
        disk/loopback.c                                                 \
        fs/ext2.c fs/fat.c fs/fshelp.c fs/hfs.c fs/iso9660.c fs/jfs.c   \
@@ -112,7 +113,7 @@ pkgdata_MODULES = _chain.mod _linux.mod linux.mod fat.mod ufs.mod   \
        terminal.mod fshelp.mod chain.mod multiboot.mod amiga.mod       \
        apple.mod pc.mod sun.mod loopback.mod reboot.mod halt.mod       \
        help.mod default.mod timeout.mod configfile.mod vbe.mod         \
-       vesafb.mod vbetest.mod vbeinfo.mod
+       vesafb.mod vbetest.mod vbeinfo.mod search.mod
 
 # For _chain.mod.
 _chain_mod_SOURCES = loader/i386/pc/chainloader.c
@@ -269,3 +270,7 @@ vbeinfo_mod_CFLAGS = $(COMMON_CFLAGS)
 # For vbetest.mod.
 vbetest_mod_SOURCES = commands/i386/pc/vbetest.c
 vbetest_mod_CFLAGS = $(COMMON_CFLAGS)
+
+# For search.mod.
+search_mod_SOURCES = commands/search.c
+search_mod_CFLAGS = $(COMMON_CFLAGS)
index 04da8ecf5b2c05025857132ac004b4a2c30f9104..d128e8d89b72c519d9700d832f65424996a0712b 100644 (file)
@@ -65,7 +65,8 @@ grub_mkimage-util_resolve.d: util/resolve.c
 # For grub-emu
 grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c       \
        commands/configfile.c commands/default.c commands/help.c        \
-       commands/terminal.c commands/ls.c commands/timeout.c            \
+       commands/search.c commands/terminal.c commands/ls.c             \
+       commands/timeout.c                                              \
        commands/ieee1275/halt.c commands/ieee1275/reboot.c             \
        disk/loopback.c                                                 \
        fs/ext2.c fs/fat.c fs/fshelp.c fs/hfs.c fs/iso9660.c fs/jfs.c   \
@@ -80,10 +81,10 @@ grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c    \
        util/console.c util/grub-emu.c util/misc.c                      \
        util/i386/pc/biosdisk.c util/i386/pc/getroot.c                  \
        util/powerpc/ieee1275/misc.c
-CLEANFILES += grub-emu grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_default.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_timeout.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_ufs.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_context.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_powerpc_ieee1275_misc.o
-MOSTLYCLEANFILES += grub_emu-commands_boot.d grub_emu-commands_cat.d grub_emu-commands_cmp.d grub_emu-commands_configfile.d grub_emu-commands_default.d grub_emu-commands_help.d grub_emu-commands_terminal.d grub_emu-commands_ls.d grub_emu-commands_timeout.d grub_emu-commands_ieee1275_halt.d grub_emu-commands_ieee1275_reboot.d grub_emu-disk_loopback.d grub_emu-fs_ext2.d grub_emu-fs_fat.d grub_emu-fs_fshelp.d grub_emu-fs_hfs.d grub_emu-fs_iso9660.d grub_emu-fs_jfs.d grub_emu-fs_minix.d grub_emu-fs_ufs.d grub_emu-kern_device.d grub_emu-kern_disk.d grub_emu-kern_dl.d grub_emu-kern_env.d grub_emu-kern_err.d grub_emu-kern_file.d grub_emu-kern_fs.d grub_emu-kern_loader.d grub_emu-kern_main.d grub_emu-kern_misc.d grub_emu-kern_partition.d grub_emu-kern_rescue.d grub_emu-kern_term.d grub_emu-normal_arg.d grub_emu-normal_cmdline.d grub_emu-normal_command.d grub_emu-normal_completion.d grub_emu-normal_context.d grub_emu-normal_main.d grub_emu-normal_menu.d grub_emu-normal_menu_entry.d grub_emu-normal_misc.d grub_emu-partmap_amiga.d grub_emu-partmap_apple.d grub_emu-partmap_pc.d grub_emu-partmap_sun.d grub_emu-util_console.d grub_emu-util_grub_emu.d grub_emu-util_misc.d grub_emu-util_i386_pc_biosdisk.d grub_emu-util_i386_pc_getroot.d grub_emu-util_powerpc_ieee1275_misc.d
+CLEANFILES += grub-emu grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_default.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_timeout.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_ufs.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_context.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_powerpc_ieee1275_misc.o
+MOSTLYCLEANFILES += grub_emu-commands_boot.d grub_emu-commands_cat.d grub_emu-commands_cmp.d grub_emu-commands_configfile.d grub_emu-commands_default.d grub_emu-commands_help.d grub_emu-commands_search.d grub_emu-commands_terminal.d grub_emu-commands_ls.d grub_emu-commands_timeout.d grub_emu-commands_ieee1275_halt.d grub_emu-commands_ieee1275_reboot.d grub_emu-disk_loopback.d grub_emu-fs_ext2.d grub_emu-fs_fat.d grub_emu-fs_fshelp.d grub_emu-fs_hfs.d grub_emu-fs_iso9660.d grub_emu-fs_jfs.d grub_emu-fs_minix.d grub_emu-fs_ufs.d grub_emu-kern_device.d grub_emu-kern_disk.d grub_emu-kern_dl.d grub_emu-kern_env.d grub_emu-kern_err.d grub_emu-kern_file.d grub_emu-kern_fs.d grub_emu-kern_loader.d grub_emu-kern_main.d grub_emu-kern_misc.d grub_emu-kern_partition.d grub_emu-kern_rescue.d grub_emu-kern_term.d grub_emu-normal_arg.d grub_emu-normal_cmdline.d grub_emu-normal_command.d grub_emu-normal_completion.d grub_emu-normal_context.d grub_emu-normal_main.d grub_emu-normal_menu.d grub_emu-normal_menu_entry.d grub_emu-normal_misc.d grub_emu-partmap_amiga.d grub_emu-partmap_apple.d grub_emu-partmap_pc.d grub_emu-partmap_sun.d grub_emu-util_console.d grub_emu-util_grub_emu.d grub_emu-util_misc.d grub_emu-util_i386_pc_biosdisk.d grub_emu-util_i386_pc_getroot.d grub_emu-util_powerpc_ieee1275_misc.d
 
-grub-emu: grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_default.o grub_emu-commands_help.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_timeout.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_ufs.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_context.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_powerpc_ieee1275_misc.o
+grub-emu: grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_default.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_ls.o grub_emu-commands_timeout.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_ufs.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_partition.o grub_emu-kern_rescue.o grub_emu-kern_term.o grub_emu-normal_arg.o grub_emu-normal_cmdline.o grub_emu-normal_command.o grub_emu-normal_completion.o grub_emu-normal_context.o grub_emu-normal_main.o grub_emu-normal_menu.o grub_emu-normal_menu_entry.o grub_emu-normal_misc.o grub_emu-partmap_amiga.o grub_emu-partmap_apple.o grub_emu-partmap_pc.o grub_emu-partmap_sun.o grub_emu-util_console.o grub_emu-util_grub_emu.o grub_emu-util_misc.o grub_emu-util_i386_pc_biosdisk.o grub_emu-util_i386_pc_getroot.o grub_emu-util_powerpc_ieee1275_misc.o
        $(BUILD_CC) -o $@ $^ $(BUILD_LDFLAGS) $(grub_emu_LDFLAGS)
 
 grub_emu-commands_boot.o: commands/boot.c
@@ -134,6 +135,14 @@ grub_emu-commands_help.d: commands/help.c
 
 -include grub_emu-commands_help.d
 
+grub_emu-commands_search.o: commands/search.c
+       $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
+
+grub_emu-commands_search.d: commands/search.c
+       set -e;           $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -M $<    | sed 's,search\.o[ :]*,grub_emu-commands_search.o $@ : ,g' > $@;       [ -s $@ ] || rm -f $@
+
+-include grub_emu-commands_search.d
+
 grub_emu-commands_terminal.o: commands/terminal.c
        $(BUILD_CC) -Icommands -I$(srcdir)/commands $(BUILD_CPPFLAGS) $(BUILD_CFLAGS) -DGRUB_UTIL=1 $(grub_emu_CFLAGS) -c -o $@ $<
 
@@ -738,7 +747,7 @@ pkgdata_MODULES = _linux.mod linux.mod fat.mod ufs.mod ext2.mod minix.mod \
        hfs.mod jfs.mod normal.mod hello.mod font.mod ls.mod \
        boot.mod cmp.mod cat.mod terminal.mod fshelp.mod amiga.mod apple.mod \
        pc.mod suspend.mod loopback.mod help.mod reboot.mod halt.mod sun.mod \
-       default.mod timeout.mod configfile.mod
+       default.mod timeout.mod configfile.mod search.mod
 
 # For fshelp.mod.
 fshelp_mod_SOURCES = fs/fshelp.c
@@ -2368,6 +2377,56 @@ fs-configfile.lst: commands/configfile.c genfslist.sh
 
 
 configfile_mod_CFLAGS = $(COMMON_CFLAGS)
+
+# For search.mod.
+search_mod_SOURCES = commands/search.c
+CLEANFILES += search.mod mod-search.o mod-search.c pre-search.o search_mod-commands_search.o def-search.lst und-search.lst
+MOSTLYCLEANFILES += search_mod-commands_search.d
+DEFSYMFILES += def-search.lst
+UNDSYMFILES += und-search.lst
+
+search.mod: pre-search.o mod-search.o
+       -rm -f $@
+       $(LD) -r -d -o $@ $^
+       $(STRIP) --strip-unneeded -K grub_mod_init -K grub_mod_fini -R .note -R .comment $@
+
+pre-search.o: search_mod-commands_search.o
+       -rm -f $@
+       $(LD) -r -d -o $@ $^
+
+mod-search.o: mod-search.c
+       $(CC) $(CPPFLAGS) $(CFLAGS) $(search_mod_CFLAGS) -c -o $@ $<
+
+mod-search.c: moddep.lst genmodsrc.sh
+       sh $(srcdir)/genmodsrc.sh 'search' $< > $@ || (rm -f $@; exit 1)
+
+def-search.lst: pre-search.o
+       $(NM) -g --defined-only -P -p $< | sed 's/^\([^ ]*\).*/\1 search/' > $@
+
+und-search.lst: pre-search.o
+       echo 'search' > $@
+       $(NM) -u -P -p $< | cut -f1 -d' ' >> $@
+
+search_mod-commands_search.o: commands/search.c
+       $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(search_mod_CFLAGS) -c -o $@ $<
+
+search_mod-commands_search.d: commands/search.c
+       set -e;           $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(search_mod_CFLAGS) -M $<          | sed 's,search\.o[ :]*,search_mod-commands_search.o $@ : ,g' > $@;     [ -s $@ ] || rm -f $@
+
+-include search_mod-commands_search.d
+
+CLEANFILES += cmd-search.lst fs-search.lst
+COMMANDFILES += cmd-search.lst
+FSFILES += fs-search.lst
+
+cmd-search.lst: commands/search.c gencmdlist.sh
+       set -e;           $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(search_mod_CFLAGS) -E $<          | sh $(srcdir)/gencmdlist.sh search > $@ || (rm -f $@; exit 1)
+
+fs-search.lst: commands/search.c genfslist.sh
+       set -e;           $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(search_mod_CFLAGS) -E $<          | sh $(srcdir)/genfslist.sh search > $@ || (rm -f $@; exit 1)
+
+
+search_mod_CFLAGS = $(COMMON_CFLAGS)
 CLEANFILES += moddep.lst command.lst fs.lst
 pkgdata_DATA += moddep.lst command.lst fs.lst
 moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep
index a7fa2f53c8707e2f702d00931af9f191d4024afe..9b9026a1e462da173ca3c6681c29366f3d3f0ed8 100644 (file)
@@ -35,7 +35,8 @@ grub_mkimage_SOURCES = util/powerpc/ieee1275/grub-mkimage.c util/misc.c \
 # For grub-emu
 grub_emu_SOURCES = commands/boot.c commands/cat.c commands/cmp.c       \
        commands/configfile.c commands/default.c commands/help.c        \
-       commands/terminal.c commands/ls.c commands/timeout.c            \
+       commands/search.c commands/terminal.c commands/ls.c             \
+       commands/timeout.c                                              \
        commands/ieee1275/halt.c commands/ieee1275/reboot.c             \
        disk/loopback.c                                                 \
        fs/ext2.c fs/fat.c fs/fshelp.c fs/hfs.c fs/iso9660.c fs/jfs.c   \
@@ -74,7 +75,7 @@ pkgdata_MODULES = _linux.mod linux.mod fat.mod ufs.mod ext2.mod minix.mod \
        hfs.mod jfs.mod normal.mod hello.mod font.mod ls.mod \
        boot.mod cmp.mod cat.mod terminal.mod fshelp.mod amiga.mod apple.mod \
        pc.mod suspend.mod loopback.mod help.mod reboot.mod halt.mod sun.mod \
-       default.mod timeout.mod configfile.mod
+       default.mod timeout.mod configfile.mod search.mod
 
 # For fshelp.mod.
 fshelp_mod_SOURCES = fs/fshelp.c
@@ -199,3 +200,7 @@ timeout_mod_CFLAGS =  $(COMMON_CFLAGS)
 # For configfile.mod
 configfile_mod_SOURCES = commands/configfile.c
 configfile_mod_CFLAGS = $(COMMON_CFLAGS)
+
+# For search.mod.
+search_mod_SOURCES = commands/search.c
+search_mod_CFLAGS = $(COMMON_CFLAGS)
index 642689d00ab874688b004d1bf753ba0e23daa4dc..d4a44a6e33131e0323504b277aa4bb4bfec88c6d 100644 (file)
@@ -37,5 +37,6 @@ typedef struct grub_device *grub_device_t;
 
 grub_device_t EXPORT_FUNC(grub_device_open) (const char *name);
 grub_err_t EXPORT_FUNC(grub_device_close) (grub_device_t device);
+int EXPORT_FUNC(grub_device_iterate) (int (*hook) (const char *name));
 
 #endif /* ! GRUB_DEVICE_HEADER */
index b6814e9516373606f0f473b842e0329dd8d25549..5e0a2a9b32c10d1107565898fadc56e5c8f9e59c 100644 (file)
@@ -221,6 +221,8 @@ void grub_timeout_init (void);
 void grub_timeout_fini (void);
 void grub_configfile_init (void);
 void grub_configfile_fini (void);
+void grub_search_init (void);
+void grub_search_fini (void);
 #endif
 
 #endif /* ! GRUB_NORMAL_HEADER */
index 4cd1eb15a446c733844b19866e87a7b153ed9ca2..92f533704641c406150f9f5f53ecd0499e776cfc 100644 (file)
@@ -72,8 +72,9 @@ struct grub_partition
 
 grub_partition_t EXPORT_FUNC(grub_partition_probe) (struct grub_disk *disk,
                                                    const char *str);
-grub_err_t EXPORT_FUNC(grub_partition_iterate) (struct grub_disk *disk,
-                                               int (*hook) (struct grub_disk *disk, const grub_partition_t partition));
+int EXPORT_FUNC(grub_partition_iterate) (struct grub_disk *disk,
+                                        int (*hook) (struct grub_disk *disk,
+                                                     const grub_partition_t partition));
 char *EXPORT_FUNC(grub_partition_get_name) (const grub_partition_t partition);
 
 int EXPORT_FUNC(grub_partition_map_iterate) (int (*hook) (const grub_partition_map_t partmap));
index b47618aa2ca8f32364859d302496d6efe5ea809e..a8a2506c902b1ee4f616bd5c196ad152a8ff4f3a 100644 (file)
@@ -25,6 +25,7 @@
 #include <grub/mm.h>
 #include <grub/misc.h>
 #include <grub/env.h>
+#include <grub/partition.h>
 
 grub_device_t
 grub_device_open (const char *name)
@@ -78,3 +79,62 @@ grub_device_close (grub_device_t device)
 
   return grub_errno;
 }
+
+int
+grub_device_iterate (int (*hook) (const char *name))
+{
+  auto int iterate_disk (const char *disk_name);
+  auto int iterate_partition (grub_disk_t disk,
+                             const grub_partition_t partition);
+  
+  int iterate_disk (const char *disk_name)
+    {
+      grub_device_t dev;
+
+      if (hook (disk_name))
+       return 1;
+      
+      dev = grub_device_open (disk_name);
+      if (! dev)
+       return 1;
+      
+      if (dev->disk && dev->disk->has_partitions)
+       if (grub_partition_iterate (dev->disk, iterate_partition))
+         {
+           grub_device_close (dev);
+           return 1;
+         }
+
+      grub_device_close (dev);
+      return 0;
+    }
+  
+  int iterate_partition (grub_disk_t disk, const grub_partition_t partition)
+    {
+      char *partition_name;
+      char *device_name;
+      int ret;
+      
+      partition_name = grub_partition_get_name (partition);
+      if (! partition_name)
+       return 1;
+      
+      device_name = grub_malloc (grub_strlen (disk->name) + 1
+                                + grub_strlen (partition_name) + 1);
+      if (! device_name)
+       {
+         grub_free (partition_name);
+         return 1;
+       }
+
+      grub_sprintf (device_name, "%s,%s", disk->name, partition_name);
+      grub_free (partition_name);
+
+      ret = hook (device_name);
+      grub_free (device_name);
+      return ret;
+    }
+
+  /* Only disk devices are supported at the moment.  */
+  return grub_disk_dev_iterate (iterate_disk);
+}
index 3eea7ae0dac68f2fe0cab9ab6b5c44c91cd2b657..af0c95de7ad7b4344568094104f9f8460cd85777 100644 (file)
@@ -83,13 +83,14 @@ grub_partition_probe (struct grub_disk *disk, const char *str)
   return part;
 }
 
-grub_err_t
+int
 grub_partition_iterate (struct grub_disk *disk,
                        int (*hook) (grub_disk_t disk,
                                     const grub_partition_t partition))
 {
   grub_partition_map_t partmap = 0;
-
+  int ret = 0;
+  
   auto int part_map_iterate (const grub_partition_map_t p);
   auto int part_map_iterate_hook (grub_disk_t d,
                                  const grub_partition_t partition);
@@ -117,9 +118,9 @@ grub_partition_iterate (struct grub_disk *disk,
 
   grub_partition_map_iterate (part_map_iterate);
   if (partmap)
-    partmap->iterate (disk, hook);
+    ret = partmap->iterate (disk, hook);
   
-  return grub_errno;
+  return ret;
 }
 
 char *
index fa1ee80f039f587223364ab762187a03c3466283..981fe5c2bc1be6ea06cdf6873648eb18a7b7f805 100644 (file)
@@ -168,40 +168,9 @@ grub_rescue_cmd_cat (int argc, char *argv[])
 }
 
 static int
-grub_rescue_print_disks (const char *name)
+grub_rescue_print_devices (const char *name)
 {
-  grub_device_t dev;
-  auto int print_partition (grub_disk_t disk, const grub_partition_t p);
-
-  int print_partition (grub_disk_t disk __attribute__ ((unused)),
-                      const grub_partition_t p)
-    {
-      char *pname = grub_partition_get_name (p);
-
-      if (pname)
-       {
-         grub_printf ("(%s,%s) ", name, pname);
-         grub_free (pname);
-       }
-
-      return 0;
-    }
-
-  dev = grub_device_open (name);
-  grub_errno = GRUB_ERR_NONE;
-  
-  if (dev)
-    {
-      grub_printf ("(%s) ", name);
-
-      if (dev->disk && dev->disk->has_partitions)
-       {
-         grub_partition_iterate (dev->disk, print_partition);
-         grub_errno = GRUB_ERR_NONE;
-       }
-
-      grub_device_close (dev);
-    }
+  grub_printf ("(%s) ", name);
   
   return 0;
 }
@@ -220,7 +189,7 @@ grub_rescue_cmd_ls (int argc, char *argv[])
 {
   if (argc < 1)
     {
-      grub_disk_dev_iterate (grub_rescue_print_disks);
+      grub_device_iterate (grub_rescue_print_devices);
       grub_putchar ('\n');
       grub_refresh ();
     }
index 2f96dc4c7f39add9cc19c9c7167760c60d0a05e1..abcd8df37482fedd34c2ce310aa5e9d68638f338 100644 (file)
@@ -170,7 +170,8 @@ pc_partition_map_iterate (grub_disk_t disk,
                  if (label.magic
                      != grub_cpu_to_le32 (GRUB_PC_PARTITION_BSD_LABEL_MAGIC))
                    return grub_error (GRUB_ERR_BAD_PART_TABLE,
-                                      "invalid disk label magic");
+                                      "invalid disk label magic 0x%x",
+                                      label.magic);
 
                  for (pcdata.bsd_part = 0;
                       pcdata.bsd_part < grub_cpu_to_le16 (label.num_partitions);
index 7bf07877bc4229189403f29b15db92ae2fea30e3..fe679ad3b2c79c95a76b757377ee4612bc21b283 100644 (file)
@@ -214,6 +214,7 @@ main (int argc, char *argv[])
   grub_default_init ();
   grub_timeout_init ();
   grub_configfile_init ();
+  grub_search_init ();
   
   /* XXX: Should normal mode be started by default?  */
   grub_normal_init ();
@@ -222,6 +223,7 @@ main (int argc, char *argv[])
   if (setjmp (main_env) == 0)
     grub_main ();
 
+  grub_search_fini ();
   grub_configfile_fini ();
   grub_timeout_fini ();
   grub_default_fini ();