2008-02-28 Fabian Greffrath <greffrath@leat.rub.de>
* include/grub/util/getroot.h (grub_util_check_block_device): Export new function. * util/getroot.c (grub_util_check_block_device): New function that returns the given argument if it is a block device and returns NULL else. * util/grub-probe.c (argument_is_device): New variable. (probe): Promote device_name from a variable to an argument. Receive device_name from grub_util_check_block_device() if path is NULL and from grub_guess_root_device() else. Do not free() device_name anymore. (options): Introduce new parameter '-d, --device'. (main): Add description of the new parameter to the help screen. Rename path variable to argument. Set argument_is_device if the '-d' option is given. Pass argument to probe() depending on argument_is_device.
This commit is contained in:
parent
0d16e571f1
commit
79ca2d78d4
4 changed files with 58 additions and 12 deletions
|
@ -332,3 +332,17 @@ grub_util_get_grub_dev (const char *os_dev)
|
|||
|
||||
return grub_dev;
|
||||
}
|
||||
|
||||
char *
|
||||
grub_util_check_block_device (const char *blk_dev)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat (blk_dev, &st) < 0)
|
||||
grub_util_error ("Cannot stat `%s'", blk_dev);
|
||||
|
||||
if (S_ISBLK (st.st_mode))
|
||||
return (blk_dev);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue