+2008-08-06 Bean <bean123ch@gmail.com>
+
+ * fs/i386/pc/pxe.c (curr_file): new variable.
+ (grub_pxefs_open): Simply the handling of pxe file system. Don't
+ require the dummy internal file system anymore.
+ (grub_pxefs_read): Removed.
+ (grub_pxefs_close): Likewise.
+ (grub_pxefs_fs_int): Likewise.
+ (grub_pxefs_read_int): Renamed to grub_pxefs_read. Reinitialize tftp
+ connection when we switch file.
+ (grub_pxefs_close_int): Renamed to grub_pxefs_close.
+
2008-08-06 Robert Millan <rmh@aybabtu.com>
* conf/i386-coreboot.rmk (pkglib_MODULES): Add `reboot.mod' and
* commands/i386/pc/pxecmd.c: New file.
- * disk/i386/pc/pxe.c: Likewise.
+ * fs/i386/pc/pxe.c: Likewise.
* include/grub/i386/pc/pxe.h: Likewise.
grub_uint32_t grub_pxe_gateway_ip;
int grub_pxe_blksize = GRUB_PXE_MIN_BLKSIZE;
+static grub_file_t curr_file = 0;
+
struct grub_pxe_data
{
grub_uint32_t packet_number;
return grub_errno;
}
- file_int->data = data;
- file_int->offset = 0;
- file_int->device = 0;
- file_int->size = file->size;
- file_int->read_hook = 0;
- file_int->fs = &grub_pxefs_fs_int;
+ file->data = data;
+ grub_memcpy (file_int, file, sizeof (struct grub_file));
+ curr_file = file_int;
bufio = grub_bufio_open (file_int, grub_pxe_blksize);
if (! bufio)
return grub_errno;
}
- file->data = bufio;
+ grub_memcpy (file, bufio, sizeof (struct grub_file));
return GRUB_ERR_NONE;
}
static grub_ssize_t
grub_pxefs_read (grub_file_t file, char *buf, grub_size_t len)
-{
- grub_file_t bufio;
-
- bufio = file->data;
- bufio->offset = file->offset;
-
- return bufio->fs->read (bufio, buf, len);
-}
-
-static grub_ssize_t
-grub_pxefs_close (grub_file_t file)
-{
- grub_file_close ((grub_file_t) file->data);
-
- return grub_errno;
-}
-
-static grub_ssize_t
-grub_pxefs_read_int (grub_file_t file, char *buf, grub_size_t len)
{
struct grub_pxenv_tftp_read c;
struct grub_pxe_data *data;
return grub_error (GRUB_ERR_BAD_FS,
"read access must be aligned to packet size");
- if (data->packet_number > pn)
+ if ((curr_file != file) || (data->packet_number > pn))
{
struct grub_pxenv_tftp_open o;
if (o.status)
return grub_error (GRUB_ERR_BAD_FS, "open fails");
data->packet_number = 0;
+ curr_file = file;
}
c.buffer = SEGOFS (GRUB_MEMORY_MACHINE_SCRATCH_ADDR);
}
static grub_err_t
-grub_pxefs_close_int (grub_file_t file)
+grub_pxefs_close (grub_file_t file)
{
struct grub_pxenv_tftp_close c;
.next = 0
};
-static struct grub_fs grub_pxefs_fs_int =
- {
- .name = "pxefs",
- .read = grub_pxefs_read_int,
- .close = grub_pxefs_close_int,
- };
-
static void
grub_pxe_detect (void)
{