2008-05-30 Robert Millan <rmh@aybabtu.com>

* commands/search.c (options): Add --fs_uuid option.
        (search_fs_uuid): New function.
        (grub_cmd_search): Fix --set argument passing.
        Use search_fs_uuid() when requested via --fs_uuid.
        (grub_search_init): Update help message.
        * fs/ext2.c (struct grub_ext2_sblock): Rename `unique_id' to `uuid'
        and redeclare it as an array of 16-bit words.
        (grub_ext2_uuid): New function.
        (grub_ext2_fs): Reference grub_ext2_uuid() in `uuid' struct member.
        * include/grub/fs.h (struct grub_fs): Add `uuid' struct member.
        * util/update-grub.in (GRUB_DEVICE_UUID, GRUB_DEVICE_BOOT)
        (GRUB_DEVICE_BOOT_UUID): New variables.
        (GRUB_DRIVE. GRUB_DRIVE_BOOT. GRUB_DRIVE_BOOT_GRUB): Remove.
        * util/grub.d/00_header.in: Set root using `search --fs_uuid' command
        whenever possible.
        * util/grub.d/10_hurd.in: Avoid explicit use of root drive.  Instead,
        just assume `root' variable has the right value.
        * util/grub.d/10_linux.in: Likewise.
        * util/grub-probe.c (probe): Probe for filesystem UUID when requested
        via PRINT_FS_UUID.
        (main): Recognise `-t fs_uuid' argument.
This commit is contained in:
robertmh 2008-05-30 11:04:08 +00:00
parent 01b73ec8eb
commit 6219127445
9 changed files with 159 additions and 37 deletions

View file

@ -44,6 +44,7 @@
enum {
PRINT_FS,
PRINT_FS_UUID,
PRINT_DRIVE,
PRINT_DEVICE,
PRINT_PARTMAP,
@ -110,6 +111,7 @@ probe (const char *path, char *device_name)
char *filebuf_via_grub = NULL, *filebuf_via_sys = NULL;
int abstraction_type;
grub_device_t dev = NULL;
grub_fs_t fs;
if (path == NULL)
{
@ -185,10 +187,13 @@ probe (const char *path, char *device_name)
goto end;
}
fs = grub_fs_probe (dev);
if (! fs)
grub_util_error ("%s", grub_errmsg);
if (print == PRINT_FS)
{
struct stat st;
grub_fs_t fs;
stat (path, &st);
@ -210,19 +215,21 @@ probe (const char *path, char *device_name)
if (memcmp (filebuf_via_grub, filebuf_via_sys, file->size))
grub_util_error ("files differ");
fs = file->fs;
}
else
{
fs = grub_fs_probe (dev);
if (! fs)
grub_util_error ("%s", grub_errmsg);
}
printf ("%s\n", fs->name);
}
if (print == PRINT_FS_UUID)
{
char *uuid;
if (! fs->uuid)
grub_util_error ("%s does not support UUIDs", fs->name);
fs->uuid (dev, &uuid);
printf ("%s\n", uuid);
}
end:
if (dev)
grub_device_close (dev);
@ -257,7 +264,7 @@ Probe device information for a given path (or device, if the -d option is given)
\n\
-d, --device given argument is a system device, not a path\n\
-m, --device-map=FILE use FILE as the device map [default=%s]\n\
-t, --target=(fs|drive|device|partmap|abstraction)\n\
-t, --target=(fs|fs_uuid|drive|device|partmap|abstraction)\n\
print filesystem module, GRUB drive, system device, partition map module or abstraction module [default=fs]\n\
-h, --help display this message and exit\n\
-V, --version print version information and exit\n\
@ -302,6 +309,8 @@ main (int argc, char *argv[])
case 't':
if (!strcmp (optarg, "fs"))
print = PRINT_FS;
else if (!strcmp (optarg, "fs_uuid"))
print = PRINT_FS_UUID;
else if (!strcmp (optarg, "drive"))
print = PRINT_DRIVE;
else if (!strcmp (optarg, "device"))