~ubuntu-branches/ubuntu/trusty/grub2/trusty-updates

« back to all changes in this revision

Viewing changes to normal/misc.c

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2006-01-05 15:20:40 UTC
  • mto: (17.3.1 squeeze) (1.9.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20060105152040-b72i5pq1a82z22yi
Tags: upstream-1.92
ImportĀ upstreamĀ versionĀ 1.92

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* misc.c - miscellaneous functions */
 
2
/*
 
3
 *  GRUB  --  GRand Unified Bootloader
 
4
 *  Copyright (C) 2005  Free Software Foundation, Inc.
 
5
 *
 
6
 *  This program 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.
 
10
 *
 
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.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
19
 */
 
20
 
 
21
#include <grub/normal.h>
 
22
#include <grub/disk.h>
 
23
#include <grub/fs.h>
 
24
#include <grub/err.h>
 
25
#include <grub/misc.h>
 
26
#include <grub/mm.h>
 
27
 
 
28
/* Print the information on the device NAME.  */
 
29
grub_err_t
 
30
grub_normal_print_device_info (const char *name)
 
31
{
 
32
  grub_device_t dev;
 
33
  char *p;
 
34
 
 
35
  p = grub_strchr (name, ',');
 
36
  if (p)
 
37
    grub_printf ("\tPartition %s: ", name);
 
38
  else
 
39
    grub_printf ("Device %s: ", name);
 
40
  
 
41
  dev = grub_device_open (name);
 
42
  if (! dev)
 
43
    grub_printf ("Filesystem cannot be accessed");
 
44
  else if (! dev->disk || ! dev->disk->has_partitions || dev->disk->partition)
 
45
    {
 
46
      char *label;
 
47
      grub_fs_t fs;
 
48
 
 
49
      fs = grub_fs_probe (dev);
 
50
      /* Ignore all errors.  */
 
51
      grub_errno = 0;
 
52
 
 
53
      grub_printf ("Filesystem type %s", fs ? fs->name : "unknown");
 
54
          
 
55
      if (fs && fs->label)
 
56
        {
 
57
          (fs->label) (dev, &label);
 
58
          if (grub_errno == GRUB_ERR_NONE)
 
59
            {
 
60
              if (label && grub_strlen (label))
 
61
                grub_printf (", Label %s", label);
 
62
              grub_free (label);
 
63
            }
 
64
          grub_errno = GRUB_ERR_NONE;
 
65
        }
 
66
      grub_device_close (dev);
 
67
    }
 
68
 
 
69
  grub_printf ("\n");
 
70
  return grub_errno;
 
71
}