merge mainline into arm

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-05-11 10:24:24 +02:00
commit 8e71d87482
490 changed files with 29659 additions and 8612 deletions

View file

@ -211,6 +211,9 @@ grub_net_configure_by_dhcp_ack (const char *name,
grub_print_error ();
}
if (is_def)
grub_env_set ("net_default_interface", name);
if (device && !*device && bp->server_ip)
{
*device = grub_xasprintf ("tftp,%d.%d.%d.%d",

View file

@ -79,7 +79,7 @@ send_card_buffer (struct grub_net_card *dev, struct grub_net_buff *pack)
grub_memcpy (dev->txbuf, pack->data, len);
status = grub_ieee1275_write (data->handle, dev->txbuf,
pack->tail - pack->data, &actual);
len, &actual);
if (status)
return grub_error (GRUB_ERR_IO, N_("couldn't send network packet"));
@ -97,10 +97,7 @@ get_card_packet (struct grub_net_card *dev)
nb = grub_netbuff_alloc (dev->mtu + 64 + 2);
if (!nb)
{
grub_netbuff_free (nb);
return NULL;
}
return NULL;
/* Reserve 2 bytes so that 2 + 14/18 bytes of ethernet header is divisible
by 4. So that IP header is aligned on 4 bytes. */
grub_netbuff_reserve (nb, 2);
@ -281,6 +278,9 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
card->txbuf = grub_zalloc (card->txbufsize);
if (!card->txbuf)
{
grub_free (ofdata->path);
grub_free (ofdata);
grub_free (card);
grub_print_error ();
return 0;
}

View file

@ -157,9 +157,10 @@ http_err (grub_net_tcp_socket_t sock __attribute__ ((unused)),
if (data->sock)
grub_net_tcp_close (data->sock, GRUB_NET_TCP_ABORT);
data->sock = 0;
if (data->current_line)
grub_free (data->current_line);
grub_free (data);
data->current_line = 0;
file->device->net->eof = 1;
file->device->net->stall = 1;
if (file->size == GRUB_FILE_SIZE_UNKNOWN)
@ -175,6 +176,12 @@ http_receive (grub_net_tcp_socket_t sock __attribute__ ((unused)),
http_data_t data = file->data;
grub_err_t err;
if (!data->sock)
{
grub_netbuff_free (nb);
return GRUB_ERR_NONE;
}
while (1)
{
char *ptr = (char *) nb->data;
@ -432,7 +439,8 @@ http_seek (struct grub_file *file, grub_off_t off)
grub_err_t err;
old_data = file->data;
/* FIXME: Reuse socket? */
grub_net_tcp_close (old_data->sock, GRUB_NET_TCP_ABORT);
if (old_data->sock)
grub_net_tcp_close (old_data->sock, GRUB_NET_TCP_ABORT);
old_data->sock = 0;
while (file->device->net->packs.first)
@ -529,7 +537,8 @@ http_packets_pulled (struct grub_file *file)
if (!file->device->net->eof)
file->device->net->stall = 0;
grub_net_tcp_unstall (data->sock);
if (data && data->sock)
grub_net_tcp_unstall (data->sock);
return 0;
}

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2010,2011 Free Software Foundation, Inc.
* Copyright (C) 2010,2011,2012,2013 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -813,6 +813,69 @@ defserver_get_env (struct grub_env_var *var __attribute__ ((unused)),
return grub_net_default_server ? : "";
}
static const char *
defip_get_env (struct grub_env_var *var __attribute__ ((unused)),
const char *val __attribute__ ((unused)))
{
const char *intf = grub_env_get ("net_default_interface");
const char *ret = NULL;
if (intf)
{
char *buf = grub_xasprintf ("net_%s_ip", intf);
if (buf)
ret = grub_env_get (buf);
grub_free (buf);
}
return ret;
}
static char *
defip_set_env (struct grub_env_var *var __attribute__ ((unused)),
const char *val)
{
const char *intf = grub_env_get ("net_default_interface");
if (intf)
{
char *buf = grub_xasprintf ("net_%s_ip", intf);
if (buf)
grub_env_set (buf, val);
grub_free (buf);
}
return NULL;
}
static const char *
defmac_get_env (struct grub_env_var *var __attribute__ ((unused)),
const char *val __attribute__ ((unused)))
{
const char *intf = grub_env_get ("net_default_interface");
const char *ret = NULL;
if (intf)
{
char *buf = grub_xasprintf ("net_%s_mac", intf);
if (buf)
ret = grub_env_get (buf);
grub_free (buf);
}
return ret;
}
static char *
defmac_set_env (struct grub_env_var *var __attribute__ ((unused)),
const char *val)
{
const char *intf = grub_env_get ("net_default_interface");
if (intf)
{
char *buf = grub_xasprintf ("net_%s_mac", intf);
if (buf)
grub_env_set (buf, val);
grub_free (buf);
}
return NULL;
}
static void
grub_net_network_level_interface_register (struct grub_net_network_level_interface *inter)
@ -1180,6 +1243,7 @@ grub_net_open_real (const char *name)
grub_net_app_level_t proto;
const char *protname, *server;
grub_size_t protnamelen;
int try;
if (grub_strncmp (name, "pxe:", sizeof ("pxe:") - 1) == 0)
{
@ -1217,32 +1281,53 @@ grub_net_open_real (const char *name)
return NULL;
}
FOR_NET_APP_LEVEL (proto)
{
if (grub_memcmp (proto->name, protname, protnamelen) == 0
&& proto->name[protnamelen] == 0)
for (try = 0; try < 2; try++)
{
FOR_NET_APP_LEVEL (proto)
{
grub_net_t ret = grub_zalloc (sizeof (*ret));
if (!ret)
return NULL;
ret->protocol = proto;
if (server)
if (grub_memcmp (proto->name, protname, protnamelen) == 0
&& proto->name[protnamelen] == 0)
{
ret->server = grub_strdup (server);
if (!ret->server)
grub_net_t ret = grub_zalloc (sizeof (*ret));
if (!ret)
return NULL;
ret->protocol = proto;
if (server)
{
grub_free (ret);
return NULL;
ret->server = grub_strdup (server);
if (!ret->server)
{
grub_free (ret);
return NULL;
}
}
else
ret->server = NULL;
ret->fs = &grub_net_fs;
ret->offset = 0;
ret->eof = 0;
return ret;
}
else
ret->server = NULL;
ret->fs = &grub_net_fs;
ret->offset = 0;
ret->eof = 0;
return ret;
}
}
if (try == 0)
{
if (sizeof ("http") - 1 == protnamelen
&& grub_memcmp ("http", protname, protnamelen) == 0)
{
grub_dl_load ("http");
grub_errno = GRUB_ERR_NONE;
continue;
}
if (sizeof ("tftp") - 1 == protnamelen
&& grub_memcmp ("tftp", protname, protnamelen) == 0)
{
grub_dl_load ("tftp");
grub_errno = GRUB_ERR_NONE;
continue;
}
}
break;
}
/* Restore original error. */
grub_error (GRUB_ERR_UNKNOWN_DEVICE, N_("disk `%s' not found"),
@ -1560,6 +1645,10 @@ GRUB_MOD_INIT(net)
defserver_set_env);
grub_register_variable_hook ("pxe_default_server", defserver_get_env,
defserver_set_env);
grub_register_variable_hook ("net_default_ip", defip_get_env,
defip_set_env);
grub_register_variable_hook ("net_default_mac", defmac_get_env,
defmac_set_env);
cmd_addaddr = grub_register_command ("net_add_addr", grub_cmd_addaddr,
/* TRANSLATORS: HWADDRESS stands for