fix several bugs in netboot and one bug in the command geometry.
This commit is contained in:
parent
bfbcbe125e
commit
687f54b6b8
7 changed files with 123 additions and 24 deletions
30
ChangeLog
30
ChangeLog
|
@ -1,3 +1,33 @@
|
||||||
|
2000-02-12 OKUJI Yoshinori <okuji@gnu.org>
|
||||||
|
|
||||||
|
* stage2/builtins.c (geometry_func): Attempt to read the first
|
||||||
|
sector to examine if LBA mode is really supported.
|
||||||
|
|
||||||
|
* netboot/fsys_tftp.c (buf_fill) [TFTP_DEBUG]: Added some debug
|
||||||
|
messages.
|
||||||
|
(send_rrq) [TFTP_DEBUG]: Likewise.
|
||||||
|
(tftp_read) [TFTP_DEBUG]: Likewise.
|
||||||
|
(tftp_dir) [TFTP_DEBUG]: Likewise.
|
||||||
|
(tftp_close) [TFTP_DEBUG]: Likewise.
|
||||||
|
(tftp_read): Call buf_fill with the argument 1 first, if FILEPOS
|
||||||
|
has been moved backwards, and use grub_memmove for copying
|
||||||
|
SAVED_TP to TP instead of a direct assignment.
|
||||||
|
If send_rrq fails, set ERRNUM to ERR_WRITE instead of ERR_READ.
|
||||||
|
Check if BUF_READ is zero instead of if BUF_EOF is non-zero at
|
||||||
|
the end of the loop.
|
||||||
|
(tftp_dir): Set ERRNUM to ERR_WRITE instead of ERR_READ, if
|
||||||
|
send_rrq fails.
|
||||||
|
Save TP and LEN in SAVED_TP and SAVED_LEN respectively before
|
||||||
|
buf_fill instead of after it, because it destroys the contents
|
||||||
|
of TP.
|
||||||
|
* netboot/main.c (print_network_configuration): The order of the
|
||||||
|
arguments for grub_sprintf in the local function sprint_ip_addr
|
||||||
|
is reversed.
|
||||||
|
|
||||||
|
* configure.in (--enable-packet_retransmission): Renamed to ...
|
||||||
|
(--disable-packet-retransmission): ... this. Assume that a
|
||||||
|
network is congested by default.
|
||||||
|
|
||||||
2000-02-11 OKUJI Yoshinori <okuji@gnu.org>
|
2000-02-11 OKUJI Yoshinori <okuji@gnu.org>
|
||||||
|
|
||||||
From Pavel Roskin:
|
From Pavel Roskin:
|
||||||
|
|
6
configure
vendored
6
configure
vendored
|
@ -35,8 +35,8 @@ ac_arg_enable_help="$ac_arg_enable_help
|
||||||
ac_arg_enable_help="$ac_arg_enable_help
|
ac_arg_enable_help="$ac_arg_enable_help
|
||||||
--disable-gunzip disable decompression in Stage 2"
|
--disable-gunzip disable decompression in Stage 2"
|
||||||
ac_arg_enable_help="$ac_arg_enable_help
|
ac_arg_enable_help="$ac_arg_enable_help
|
||||||
--enable-packet-retransmission
|
--disable-packet-retransmission
|
||||||
turn on packet retransmission"
|
turn off packet retransmission"
|
||||||
ac_arg_enable_help="$ac_arg_enable_help
|
ac_arg_enable_help="$ac_arg_enable_help
|
||||||
--enable-pci-direct access PCI directly instead of using BIOS"
|
--enable-pci-direct access PCI directly instead of using BIOS"
|
||||||
ac_arg_enable_help="$ac_arg_enable_help
|
ac_arg_enable_help="$ac_arg_enable_help
|
||||||
|
@ -2425,7 +2425,7 @@ if test "${enable_packet_retransmission+set}" = set; then
|
||||||
:
|
:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "x$enable_packet_retransmission" = xyes; then
|
if test "x$enable_packet_retransmission" != xno; then
|
||||||
NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCONGESTED=1"
|
NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCONGESTED=1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -217,9 +217,9 @@ fi
|
||||||
dnl The netboot support.
|
dnl The netboot support.
|
||||||
dnl General options.
|
dnl General options.
|
||||||
AC_ARG_ENABLE(packet-retransmission,
|
AC_ARG_ENABLE(packet-retransmission,
|
||||||
[ --enable-packet-retransmission
|
[ --disable-packet-retransmission
|
||||||
turn on packet retransmission])
|
turn off packet retransmission])
|
||||||
if test "x$enable_packet_retransmission" = xyes; then
|
if test "x$enable_packet_retransmission" != xno; then
|
||||||
NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCONGESTED=1"
|
NET_EXTRAFLAGS="$NET_EXTRAFLAGS -DCONGESTED=1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ The URL is <http://www.slug.org.au/etherboot/>.
|
||||||
These below are common options for configure. Perhaps you may not need
|
These below are common options for configure. Perhaps you may not need
|
||||||
to specify them.
|
to specify them.
|
||||||
|
|
||||||
--enable-packet-retransmission
|
--disable-packet-retransmission
|
||||||
Turns on packet retransmission. Use it on a congested network, where
|
Turns off packet retransmission. Use it on an empty network, where
|
||||||
the normal operation can't boot the image.
|
no packet collision can happen.
|
||||||
|
|
||||||
--enable-pci-direct
|
--enable-pci-direct
|
||||||
Define this for PCI BIOSes that do not implement BIOS32 or not
|
Define this for PCI BIOSes that do not implement BIOS32 or not
|
||||||
|
|
|
@ -26,6 +26,8 @@ Author: Martin Renters
|
||||||
|
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
|
/* #define TFTP_DEBUG 1 */
|
||||||
|
|
||||||
#include <filesys.h>
|
#include <filesys.h>
|
||||||
|
|
||||||
#include <etherboot.h>
|
#include <etherboot.h>
|
||||||
|
@ -47,6 +49,10 @@ static char *buf;
|
||||||
static int
|
static int
|
||||||
buf_fill (int abort)
|
buf_fill (int abort)
|
||||||
{
|
{
|
||||||
|
#ifdef TFTP_DEBUG
|
||||||
|
grub_printf ("buf_fill (%d)\n", abort);
|
||||||
|
#endif
|
||||||
|
|
||||||
while (! buf_eof && (buf_read + packetsize <= FSYS_BUFLEN))
|
while (! buf_eof && (buf_read + packetsize <= FSYS_BUFLEN))
|
||||||
{
|
{
|
||||||
struct tftp_t *tr;
|
struct tftp_t *tr;
|
||||||
|
@ -63,6 +69,9 @@ buf_fill (int abort)
|
||||||
if (! block && retry++ < MAX_TFTP_RETRIES)
|
if (! block && retry++ < MAX_TFTP_RETRIES)
|
||||||
{
|
{
|
||||||
/* Maybe initial request was lost. */
|
/* Maybe initial request was lost. */
|
||||||
|
#ifdef TFTP_DEBUG
|
||||||
|
grub_printf ("Maybe initial request was lost.\n");
|
||||||
|
#endif
|
||||||
rfc951_sleep (retry);
|
rfc951_sleep (retry);
|
||||||
if (! udp_transmit (arptable[ARP_SERVER].ipaddr.s_addr,
|
if (! udp_transmit (arptable[ARP_SERVER].ipaddr.s_addr,
|
||||||
++isocket, TFTP, len, (char *) &tp))
|
++isocket, TFTP, len, (char *) &tp))
|
||||||
|
@ -75,7 +84,7 @@ buf_fill (int abort)
|
||||||
if (block && ((retry += TFTP_REXMT) < TFTP_TIMEOUT))
|
if (block && ((retry += TFTP_REXMT) < TFTP_TIMEOUT))
|
||||||
{
|
{
|
||||||
/* We resend our last ack. */
|
/* We resend our last ack. */
|
||||||
# ifdef MDEBUG
|
# ifdef TFTP_DEBUG
|
||||||
grub_printf ("<REXMT>\n");
|
grub_printf ("<REXMT>\n");
|
||||||
# endif
|
# endif
|
||||||
udp_transmit (arptable[ARP_SERVER].ipaddr.s_addr,
|
udp_transmit (arptable[ARP_SERVER].ipaddr.s_addr,
|
||||||
|
@ -101,6 +110,9 @@ buf_fill (int abort)
|
||||||
{
|
{
|
||||||
char *p = tr->u.oack.data, *e;
|
char *p = tr->u.oack.data, *e;
|
||||||
|
|
||||||
|
#ifdef TFTP_DEBUG
|
||||||
|
grub_printf ("OACK ");
|
||||||
|
#endif
|
||||||
/* Shouldn't happen. */
|
/* Shouldn't happen. */
|
||||||
if (prevblock)
|
if (prevblock)
|
||||||
/* Ignore it. */
|
/* Ignore it. */
|
||||||
|
@ -118,6 +130,9 @@ buf_fill (int abort)
|
||||||
p += 8;
|
p += 8;
|
||||||
if ((packetsize = getdec (&p)) < TFTP_DEFAULTSIZE_PACKET)
|
if ((packetsize = getdec (&p)) < TFTP_DEFAULTSIZE_PACKET)
|
||||||
goto noak;
|
goto noak;
|
||||||
|
#ifdef TFTP_DEBUG
|
||||||
|
grub_printf ("blksize = %d\n", packetsize);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if (! grub_strcmp ("tsize", p))
|
else if (! grub_strcmp ("tsize", p))
|
||||||
{
|
{
|
||||||
|
@ -127,10 +142,16 @@ buf_fill (int abort)
|
||||||
filemax = -1;
|
filemax = -1;
|
||||||
goto noak;
|
goto noak;
|
||||||
}
|
}
|
||||||
|
#ifdef TFTP_DEBUG
|
||||||
|
grub_printf ("tsize = %d\n", filemax);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
noak:
|
noak:
|
||||||
|
#ifdef TFTP_DEBUG
|
||||||
|
grub_printf ("NOAK\n");
|
||||||
|
#endif
|
||||||
tp.opcode = htons (TFTP_ERROR);
|
tp.opcode = htons (TFTP_ERROR);
|
||||||
tp.u.err.errcode = 8;
|
tp.u.err.errcode = 8;
|
||||||
len = (grub_sprintf ((char *) tp.u.err.errmsg,
|
len = (grub_sprintf ((char *) tp.u.err.errmsg,
|
||||||
|
@ -158,6 +179,9 @@ buf_fill (int abort)
|
||||||
}
|
}
|
||||||
else if (tr->opcode == ntohs (TFTP_DATA))
|
else if (tr->opcode == ntohs (TFTP_DATA))
|
||||||
{
|
{
|
||||||
|
#ifdef TFTP_DEBUG
|
||||||
|
grub_printf ("DATA ");
|
||||||
|
#endif
|
||||||
len = ntohs (tr->udp.len) - sizeof (struct udphdr) - 4;
|
len = ntohs (tr->udp.len) - sizeof (struct udphdr) - 4;
|
||||||
|
|
||||||
/* Shouldn't happen. */
|
/* Shouldn't happen. */
|
||||||
|
@ -179,6 +203,9 @@ buf_fill (int abort)
|
||||||
tp.opcode = abort ? htons (TFTP_ERROR) : htons (TFTP_ACK);
|
tp.opcode = abort ? htons (TFTP_ERROR) : htons (TFTP_ACK);
|
||||||
osocket = ntohs (tr->udp.src);
|
osocket = ntohs (tr->udp.src);
|
||||||
|
|
||||||
|
#ifdef TFTP_DEBUG
|
||||||
|
grub_printf ("ACK\n");
|
||||||
|
#endif
|
||||||
/* Ack. */
|
/* Ack. */
|
||||||
udp_transmit (arptable[ARP_SERVER].ipaddr.s_addr, isocket,
|
udp_transmit (arptable[ARP_SERVER].ipaddr.s_addr, isocket,
|
||||||
osocket, TFTP_MIN_PACKET, (char *) &tp);
|
osocket, TFTP_MIN_PACKET, (char *) &tp);
|
||||||
|
@ -225,6 +252,9 @@ send_rrq (void)
|
||||||
buf_read = 0;
|
buf_read = 0;
|
||||||
saved_filepos = 0;
|
saved_filepos = 0;
|
||||||
|
|
||||||
|
#ifdef TFTP_DEBUG
|
||||||
|
grub_printf ("send_rrq ()\n");
|
||||||
|
#endif
|
||||||
/* Send the packet. */
|
/* Send the packet. */
|
||||||
return udp_transmit (arptable[ARP_SERVER].ipaddr.s_addr, ++isocket, TFTP,
|
return udp_transmit (arptable[ARP_SERVER].ipaddr.s_addr, ++isocket, TFTP,
|
||||||
len, (char *) &tp);
|
len, (char *) &tp);
|
||||||
|
@ -253,14 +283,34 @@ tftp_read (char *addr, int size)
|
||||||
/* How many bytes is read? */
|
/* How many bytes is read? */
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
#ifdef TFTP_DEBUG
|
||||||
|
grub_printf ("tftp_read (0x%x, %d)\n", (int) addr, size);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (filepos < saved_filepos)
|
if (filepos < saved_filepos)
|
||||||
{
|
{
|
||||||
/* Uggh.. FILEPOS has been moved backwards. So reopen the file. */
|
/* Uggh.. FILEPOS has been moved backwards. So reopen the file. */
|
||||||
tp = saved_tp;
|
buf_fill (1);
|
||||||
|
grub_memmove ((char *) &tp, (char *) &saved_tp, saved_len);
|
||||||
len = saved_len;
|
len = saved_len;
|
||||||
|
#ifdef TFTP_DEBUG
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
grub_printf ("opcode = 0x%x, rrq = ", (unsigned long) tp.opcode);
|
||||||
|
for (i = 0; i < TFTP_DEFAULTSIZE_PACKET; i++)
|
||||||
|
{
|
||||||
|
if (tp.u.rrq[i] >= ' ' && tp.u.rrq[i] <= '~')
|
||||||
|
grub_putchar (tp.u.rrq[i]);
|
||||||
|
else
|
||||||
|
grub_putchar ('*');
|
||||||
|
}
|
||||||
|
grub_putchar ('\n');
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (! send_rrq ())
|
if (! send_rrq ())
|
||||||
{
|
{
|
||||||
errnum = ERR_READ;
|
errnum = ERR_WRITE;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,7 +352,8 @@ tftp_read (char *addr, int size)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size > 0 && buf_eof)
|
/* Sanity check. */
|
||||||
|
if (size > 0 && buf_read == 0)
|
||||||
{
|
{
|
||||||
errnum = ERR_READ;
|
errnum = ERR_READ;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -319,6 +370,10 @@ tftp_dir (char *dirname)
|
||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
|
#ifdef TFTP_DEBUG
|
||||||
|
grub_printf ("tftp_dir (%s)\n", dirname);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* In TFTP, there is no way to know what files exis. */
|
/* In TFTP, there is no way to know what files exis. */
|
||||||
if (print_possibilities)
|
if (print_possibilities)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -338,9 +393,12 @@ tftp_dir (char *dirname)
|
||||||
+ TFTP_MIN_PACKET + 1);
|
+ TFTP_MIN_PACKET + 1);
|
||||||
/* Restore the original DIRNAME. */
|
/* Restore the original DIRNAME. */
|
||||||
dirname[grub_strlen (dirname)] = ch;
|
dirname[grub_strlen (dirname)] = ch;
|
||||||
|
/* Save the TFTP packet so that we can reopen the file later. */
|
||||||
|
grub_memmove ((char *) &saved_tp, (char *) &tp, len);
|
||||||
|
saved_len = len;
|
||||||
if (! send_rrq ())
|
if (! send_rrq ())
|
||||||
{
|
{
|
||||||
errnum = ERR_READ;
|
errnum = ERR_WRITE;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,10 +435,6 @@ tftp_dir (char *dirname)
|
||||||
goto reopen;
|
goto reopen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save the TFTP packet so that we can reopen the file later. */
|
|
||||||
saved_tp = tp;
|
|
||||||
saved_len = len;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,6 +442,10 @@ tftp_dir (char *dirname)
|
||||||
void
|
void
|
||||||
tftp_close (void)
|
tftp_close (void)
|
||||||
{
|
{
|
||||||
|
#ifdef TFTP_DEBUG
|
||||||
|
grub_printf ("tftp_close ()\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
buf_read = 0;
|
buf_read = 0;
|
||||||
buf_fill (1);
|
buf_fill (1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,8 +129,8 @@ print_network_configuration (void)
|
||||||
static void sprint_ip_addr (char *buf, unsigned long addr)
|
static void sprint_ip_addr (char *buf, unsigned long addr)
|
||||||
{
|
{
|
||||||
grub_sprintf (buf, "%d.%d.%d.%d",
|
grub_sprintf (buf, "%d.%d.%d.%d",
|
||||||
addr >> 24, (addr >> 16) & 0xFF,
|
addr & 0xFF, (addr >> 8) & 0xFF,
|
||||||
(addr >> 8) & 0xFF, addr & 0xFF);
|
(addr >> 16) & 0xFF, addr >> 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! eth_probe ())
|
if (! eth_probe ())
|
||||||
|
|
|
@ -979,16 +979,27 @@ geometry_func (char *arg, int flags)
|
||||||
char *ptr;
|
char *ptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Get the device number. */
|
||||||
set_device (device);
|
set_device (device);
|
||||||
if (errnum)
|
if (errnum)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
/* Check for the geometry. */
|
||||||
if (get_diskinfo (current_drive, &geom))
|
if (get_diskinfo (current_drive, &geom))
|
||||||
{
|
{
|
||||||
errnum = ERR_NO_DISK;
|
errnum = ERR_NO_DISK;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Attempt to read the first sector, because some BIOSes turns out not
|
||||||
|
to support LBA even though they set the bit 0 in the support
|
||||||
|
bitmap, only after reading something actually. */
|
||||||
|
if (biosdisk (BIOSDISK_READ, current_drive, &geom, 0, 1, SCRATCHSEG))
|
||||||
|
{
|
||||||
|
errnum = ERR_READ;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef GRUB_UTIL
|
#ifdef GRUB_UTIL
|
||||||
ptr = skip_to (0, device);
|
ptr = skip_to (0, device);
|
||||||
if (*ptr)
|
if (*ptr)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue