Hook network protocols
This commit is contained in:
parent
975cffff74
commit
9a9852df79
6 changed files with 87 additions and 16 deletions
|
@ -26,6 +26,8 @@
|
|||
#include <grub/env.h>
|
||||
#include <grub/partition.h>
|
||||
|
||||
grub_net_t (*grub_net_open) (const char *name) = NULL;
|
||||
|
||||
grub_device_t
|
||||
grub_device_open (const char *name)
|
||||
{
|
||||
|
@ -46,15 +48,16 @@ grub_device_open (const char *name)
|
|||
if (! dev)
|
||||
goto fail;
|
||||
|
||||
dev->net = NULL;
|
||||
/* Try to open a disk. */
|
||||
disk = grub_disk_open (name);
|
||||
if (! disk)
|
||||
goto fail;
|
||||
dev->disk = grub_disk_open (name);
|
||||
if (dev->disk)
|
||||
return dev;
|
||||
if (grub_net_open)
|
||||
dev->net = grub_net_open (name);
|
||||
|
||||
dev->disk = disk;
|
||||
dev->net = 0; /* FIXME */
|
||||
|
||||
return dev;
|
||||
if (dev->net)
|
||||
return dev;
|
||||
|
||||
fail:
|
||||
if (disk)
|
||||
|
@ -71,6 +74,12 @@ grub_device_close (grub_device_t device)
|
|||
if (device->disk)
|
||||
grub_disk_close (device->disk);
|
||||
|
||||
if (device->net)
|
||||
{
|
||||
grub_free (device->net->name);
|
||||
grub_free (device->net);
|
||||
}
|
||||
|
||||
grub_free (device);
|
||||
|
||||
return grub_errno;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue