~hamo/ubuntu/precise/grub2/grub2.hi_res

« back to all changes in this revision

Viewing changes to util/grub-probe.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Millan
  • Date: 2007-11-01 13:18:51 UTC
  • mto: (17.3.1 squeeze) (1.9.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: james.westby@ubuntu.com-20071101131851-63uqsb4dax2h1cbm
Tags: upstream-1.95+20071101
ImportĀ upstreamĀ versionĀ 1.95+20071101

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *  GRUB  --  GRand Unified Bootloader
4
4
 *  Copyright (C) 2005,2006,2007 Free Software Foundation, Inc.
5
5
 *
6
 
 *  GRUB is free software; you can redistribute it and/or modify
 
6
 *  GRUB is free software: you can redistribute it and/or modify
7
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
 
8
 *  the Free Software Foundation, either version 3 of the License, or
9
9
 *  (at your option) any later version.
10
10
 *
11
 
 *  This program is distributed in the hope that it will be useful,
 
11
 *  GRUB is distributed in the hope that it will be useful,
12
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
14
 *  GNU General Public License for more details.
15
15
 *
16
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.
 
17
 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
19
18
 */
20
19
 
21
20
#include <config.h>
30
29
#include <grub/util/getroot.h>
31
30
#include <grub/term.h>
32
31
 
 
32
#include <grub_probe_init.h>
 
33
 
33
34
#include <stdio.h>
34
35
#include <unistd.h>
35
36
#include <string.h>
38
39
#define _GNU_SOURCE     1
39
40
#include <getopt.h>
40
41
 
41
 
#ifdef __NetBSD__
42
 
/* NetBSD uses /boot for its boot block.  */
43
 
# define DEFAULT_DIRECTORY      "/grub"
44
 
#else
45
 
# define DEFAULT_DIRECTORY      "/boot/grub"
46
 
#endif
47
 
 
48
 
#define DEFAULT_DEVICE_MAP      DEFAULT_DIRECTORY "/device.map"
49
 
 
50
42
#define PRINT_FS        0
51
43
#define PRINT_DRIVE     1
52
44
#define PRINT_DEVICE    2
81
73
probe (const char *path)
82
74
{
83
75
  char *device_name;
84
 
  char *drive_name = 0;
 
76
  char *drive_name = NULL;
85
77
  grub_device_t dev;
86
78
  grub_fs_t fs;
87
79
  
88
80
  device_name = grub_guess_root_device (path);
89
81
  if (! device_name)
90
 
    {
91
 
      fprintf (stderr, "cannot find a device for %s.\n", path);
92
 
      goto end;
93
 
    }
 
82
    grub_util_error ("cannot find a device for %s.\n", path);
94
83
 
95
84
  if (print == PRINT_DEVICE)
96
85
    {
100
89
 
101
90
  drive_name = grub_util_get_grub_dev (device_name);
102
91
  if (! drive_name)
103
 
    {
104
 
      fprintf (stderr, "cannot find a GRUB drive for %s.\n", device_name);
105
 
      goto end;
106
 
    }
 
92
    grub_util_error ("cannot find a GRUB drive for %s.\n", device_name);
107
93
  
108
94
  if (print == PRINT_DRIVE)
109
95
    {
259
245
  
260
246
  /* Initialize the emulated biosdisk driver.  */
261
247
  grub_util_biosdisk_init (dev_map ? : DEFAULT_DEVICE_MAP);
262
 
  grub_pc_partition_map_init ();
263
 
  grub_gpt_partition_map_init ();
264
 
  grub_apple_partition_map_init ();
265
 
  grub_raid_init ();
266
 
  grub_lvm_init ();
267
248
  
268
 
  /* Initialize filesystems.  */
269
 
  grub_fat_init ();
270
 
  grub_ext2_init ();
271
 
  grub_ufs_init ();
272
 
  grub_minix_init ();
273
 
  grub_jfs_init ();
274
 
  grub_xfs_init ();
 
249
  /* Initialize all modules. */
 
250
  grub_init_all ();
275
251
 
276
252
  /* Do it.  */
277
253
  probe (path);
278
254
  
279
255
  /* Free resources.  */
280
 
  grub_ext2_fini ();
281
 
  grub_fat_fini ();
282
 
  grub_ufs_fini ();
283
 
  grub_minix_fini ();
284
 
  grub_jfs_fini ();
285
 
  grub_xfs_fini ();
286
 
  
287
 
  grub_lvm_fini ();
288
 
  grub_raid_fini ();
289
 
  grub_gpt_partition_map_fini ();
290
 
  grub_apple_partition_map_fini ();
291
 
  grub_pc_partition_map_fini ();
 
256
  grub_fini_all ();
292
257
  grub_util_biosdisk_fini ();
293
258
  
294
259
  free (dev_map);