1
/* grub-probefs.c - probe a filesystem module for a given path */
3
* GRUB -- GRand Unified Bootloader
4
* Copyright (C) 2005 Free Software Foundation, Inc.
6
* GRUB is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with GRUB; if not, write to the Free Software
18
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
#include <grub/types.h>
23
#include <grub/util/misc.h>
24
#include <grub/device.h>
25
#include <grub/disk.h>
27
#include <grub/partition.h>
28
#include <grub/pc_partition.h>
29
#include <grub/machine/util/biosdisk.h>
30
#include <grub/util/getroot.h>
41
/* NetBSD uses /boot for its boot block. */
42
# define DEFAULT_DIRECTORY "/grub"
44
# define DEFAULT_DIRECTORY "/boot/grub"
47
#define DEFAULT_DEVICE_MAP DEFAULT_DIRECTORY "/device.map"
61
probe (const char *path)
67
device_name = grub_guess_root_device (path);
70
fprintf (stderr, "cannot find a GRUB device for %s.\n", path);
74
grub_util_info ("opening %s", device_name);
75
dev = grub_device_open (device_name);
77
grub_util_error ("%s", grub_errmsg);
79
fs = grub_fs_probe (dev);
81
grub_util_error ("%s", grub_errmsg);
83
printf ("%s\n", fs->name);
85
grub_device_close (dev);
89
static struct option options[] =
91
{"device-map", required_argument, 0, 'm'},
92
{"help", no_argument, 0, 'h'},
93
{"version", no_argument, 0, 'V'},
94
{"verbose", no_argument, 0, 'v'},
103
"Try ``grub-probefs --help'' for more information.\n");
106
Usage: grub-probefs [OPTION]... PATH\n\
108
Probe a filesystem module for a given path.\n\
110
-m, --device-map=FILE use FILE as the device map [default=%s]\n\
111
-h, --help display this message and exit\n\
112
-V, --version print version information and exit\n\
113
-v, --verbose print verbose messages\n\
115
Report bugs to <%s>.\n\
117
DEFAULT_DEVICE_MAP, PACKAGE_BUGREPORT);
123
main (int argc, char *argv[])
128
progname = "grub-probefs";
130
/* Check for options. */
133
int c = getopt_long (argc, argv, "m:hVv", options, 0);
144
dev_map = xstrdup (optarg);
152
printf ("%s (%s) %s\n", progname, PACKAGE_NAME, PACKAGE_VERSION);
168
fprintf (stderr, "No path is specified.\n");
172
if (optind + 1 != argc)
174
fprintf (stderr, "Unknown extra argument `%s'.\n", argv[optind + 1]);
180
/* Initialize the emulated biosdisk driver. */
181
grub_util_biosdisk_init (dev_map ? : DEFAULT_DEVICE_MAP);
182
grub_pc_partition_map_init ();
184
/* Initialize filesystems. */
195
/* Free resources. */
203
grub_pc_partition_map_fini ();
204
grub_util_biosdisk_fini ();