1 /* misc.c - miscellaneous functions */
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2005,2007,2008 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 3 of the License, or
9 * (at your option) any later version.
11 * GRUB 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, see <http://www.gnu.org/licenses/>.
20 #include <grub/normal.h>
21 #include <grub/disk.h>
24 #include <grub/misc.h>
26 #include <grub/datetime.h>
28 /* Print the information on the device NAME. */
30 grub_normal_print_device_info (const char *name
)
35 p
= grub_strchr (name
, ',');
37 grub_printf ("\tPartition %s: ", name
);
39 grub_printf ("Device %s: ", name
);
41 dev
= grub_device_open (name
);
43 grub_printf ("Filesystem cannot be accessed");
48 fs
= grub_fs_probe (dev
);
49 /* Ignore all errors. */
54 grub_printf ("Filesystem type %s", fs
->name
);
58 (fs
->label
) (dev
, &label
);
59 if (grub_errno
== GRUB_ERR_NONE
)
61 if (label
&& grub_strlen (label
))
62 grub_printf (", Label %s", label
);
65 grub_errno
= GRUB_ERR_NONE
;
70 struct grub_datetime datetime
;
71 (fs
->mtime
) (dev
, &tm
);
72 if (grub_errno
== GRUB_ERR_NONE
)
74 grub_unixtime2datetime (tm
, &datetime
);
75 grub_printf (", Last modification time %d-%02d-%02d "
77 datetime
.year
, datetime
.month
, datetime
.day
,
78 datetime
.hour
, datetime
.minute
, datetime
.second
,
79 grub_get_weekday_name (&datetime
));
82 grub_errno
= GRUB_ERR_NONE
;
87 (fs
->uuid
) (dev
, &uuid
);
88 if (grub_errno
== GRUB_ERR_NONE
)
90 if (uuid
&& grub_strlen (uuid
))
91 grub_printf (", UUID %s", uuid
);
94 grub_errno
= GRUB_ERR_NONE
;
97 else if (! dev
->disk
->has_partitions
|| dev
->disk
->partition
)
98 grub_printf ("Unknown filesystem");
100 grub_printf ("Partition table");
102 grub_device_close (dev
);