Added support to netdisk specified in the form (net,protocol,server_ip,username,password)

an to list its information with command ls.

* fs/ieee1275/ofnet.c (grub_ofnet_open): parse parameters to determine netdisk data
* fs/ieee1275/ofnet.c (grub_ofnet_close): dealloc netdisk data
* include/grub/disk.h: added struct grub_netdisk_data
* include/grub/ieee1275/ofnet.h: added newline
* kern/disk.c (grub_disk_open): ignore partition check for netdisk
* normal/misc.c (grub_normal_print_device_info): added support to list netdisk information
This commit is contained in:
Paulo de Rezende Pinatti 2010-07-13 11:22:35 -03:00
parent 3ec6213b17
commit f8795693f1
5 changed files with 213 additions and 7 deletions

View file

@ -32,8 +32,47 @@ grub_err_t
grub_normal_print_device_info (const char *name)
{
grub_device_t dev;
grub_netdisk_data_t data;
char *p;
if ((! grub_strcmp(name, "net")) || (! grub_strncmp(name, "net,", 4)))
{
grub_printf_ (N_("Device network:"));
grub_putchar (' ');
dev = grub_device_open (name);
if (! dev || ! dev->disk || ! dev->disk->data)
grub_printf ("%s", _("Network information not available"));
else
{
data = dev->disk->data;
grub_putchar ('\n');
grub_putchar ('\t');
if (data->protocol == GRUB_NETDISK_PROTOCOL_TFTP)
grub_printf_(N_("Protocol: %s"), "TFTP");
else
grub_printf_(N_("Protocol: %s"), "Unknown");
grub_putchar ('\n');
grub_putchar ('\t');
grub_printf_(N_("Server IP: %d.%d.%d.%d"), data->server_ip & 0xff, data->server_ip >> 8 & 0xff, data->server_ip >> 16 & 0xff, data->server_ip >> 24 & 0xff);
if (data->username)
{
grub_putchar ('\n');
grub_putchar ('\t');
grub_printf_(N_("Username: %s"), data->username);
if (data->password)
{
grub_putchar ('\n');
grub_putchar ('\t');
grub_printf_(N_("Password: %s"), data->password);
}
}
}
grub_putchar ('\n');
return GRUB_ERR_NONE;
}
p = grub_strchr (name, ',');
if (p)
{