26
28
#include <grub/fs.h>
27
29
#include <grub/partition.h>
28
30
#include <grub/msdos_partition.h>
29
#include <grub/util/hostdisk.h>
30
#include <grub/util/getroot.h>
31
#include <grub/emu/hostdisk.h>
32
#include <grub/emu/getroot.h>
31
33
#include <grub/term.h>
32
34
#include <grub/env.h>
33
35
#include <grub/raid.h>
34
36
#include <grub/i18n.h>
36
#include <grub_probe_init.h>
39
39
#include <unistd.h>
40
40
#include <string.h>
58
59
int print = PRINT_FS;
59
60
static unsigned int argument_is_device = 0;
73
struct grub_handler_class grub_term_input_class;
74
struct grub_handler_class grub_term_output_class;
83
63
probe_partmap (grub_disk_t disk)
65
grub_partition_t part;
85
67
if (disk->partition == NULL)
87
69
grub_util_info ("no partition map found for %s", disk->name);
91
printf ("%s\n", disk->partition->partmap->name);
73
for (part = disk->partition; part; part = part->parent)
74
printf ("%s\n", part->partmap->name);
117
100
if (path == NULL)
119
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
102
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
120
103
if (! grub_util_check_char_device (device_name))
121
104
grub_util_error ("%s is not a character device", device_name);
244
228
if (print == PRINT_FS)
252
if (S_ISREG (st.st_mode))
254
/* Regular file. Verify that we can read it properly. */
258
grub_util_info ("reading %s via OS facilities", path);
259
filebuf_via_sys = grub_util_read_image (path);
261
rel_path = make_system_path_relative_to_its_root (path);
262
grub_path = xasprintf ("(%s)%s", drive_name, rel_path);
264
grub_util_info ("reading %s via GRUB facilities", grub_path);
265
file = grub_file_open (grub_path);
267
grub_util_error ("cannot open %s via GRUB facilities", grub_path);
268
filebuf_via_grub = xmalloc (file->size);
269
grub_file_read (file, filebuf_via_grub, file->size);
271
grub_util_info ("comparing");
273
if (memcmp (filebuf_via_grub, filebuf_via_sys, file->size))
274
grub_util_error ("files differ");
278
230
printf ("%s\n", fs->name);
281
if (print == PRINT_FS_UUID)
232
else if (print == PRINT_FS_UUID)
285
236
grub_util_error ("%s does not support UUIDs", fs->name);
287
fs->uuid (dev, &uuid);
238
if (fs->uuid (dev, &uuid) != GRUB_ERR_NONE)
239
grub_util_error ("%s", grub_errmsg);
289
241
printf ("%s\n", uuid);
243
else if (print == PRINT_FS_LABEL)
247
grub_util_error ("%s does not support labels", fs->name);
249
if (fs->label (dev, &label) != GRUB_ERR_NONE)
250
grub_util_error ("%s", grub_errmsg);
252
printf ("%s\n", label);
324
287
-d, --device given argument is a system device, not a path\n\
325
288
-m, --device-map=FILE use FILE as the device map [default=%s]\n\
326
-t, --target=(fs|fs_uuid|drive|device|partmap|abstraction)\n\
289
-t, --target=(fs|fs_uuid|fs_label|drive|device|partmap|abstraction)\n\
327
290
print filesystem module, GRUB drive, system device, partition map module or abstraction module [default=fs]\n\
328
291
-h, --help display this message and exit\n\
329
292
-V, --version print version information and exit\n\
372
335
print = PRINT_FS;
373
336
else if (!strcmp (optarg, "fs_uuid"))
374
337
print = PRINT_FS_UUID;
338
else if (!strcmp (optarg, "fs_label"))
339
print = PRINT_FS_LABEL;
375
340
else if (!strcmp (optarg, "drive"))
376
341
print = PRINT_DRIVE;
377
342
else if (!strcmp (optarg, "device"))