[ipxe-devel] [PATCH] wimboot syslinux kludge 2/4: provide common read_mem_file cpio handler

Friedemann Gerold f.gerold at b-c-s.de
Mon Mar 11 10:52:50 UTC 2019


VladikSS informed me that the patch was accidentally pasted twice:
"wimboot syslinux kludge 2/4: provide common read_mem_file cpio handler"

Attached are all the changes again as diffs which can be applied in order
with patch -p2 in the wimboot/src directory.

Submitting the broken patch in question again for reference:
--
For the next patch that will add cpio support for efi,
we want to use a common read_mem_file() as cpio handler.
This patch moves the private read_file() from main.c to
vdisk.c as read_mem_file() so it can shared.

Signed-off-by: Friedemann Gerold <f.gerold at b-c-s.de>
--- wimbootorig/src/vdisk.h	2018-11-02 12:29:14.343297008 +0100
+++ wimboot/src/vdisk.h	2018-11-02 12:28:48.071166732 +0100
@@ -610,11 +610,15 @@

  extern struct vdisk_file vdisk_files[VDISK_MAX_FILES];

+
  extern void vdisk_read ( uint64_t lba, unsigned int count, void *data );
  extern struct vdisk_file *
  vdisk_add_file ( const char *name, void *opaque, size_t len,
  		 void ( * read ) ( struct vdisk_file *file, void *data,
  				   size_t offset, size_t len ) );
+
+extern void read_mem_file ( struct vdisk_file *file, void *data, size_t offset, size_t len );
+
  extern void
  vdisk_patch_file ( struct vdisk_file *file,
  		   void ( * patch ) ( struct vdisk_file *file, void *data,
--- wimbootorig/src/vdisk.c	2018-11-02 12:29:14.343297008 +0100
+++ wimboot/src/vdisk.c	2018-11-02 12:28:48.071166732 +0100
@@ -614,6 +614,19 @@
  }

  /**
+ * Read from file
+ *
+ * @v file              Virtual file
+ * @v data              Data buffer
+ * @v offset            Offset
+ * @v len               Length
+ */
+void read_mem_file ( struct vdisk_file *file, void *data, size_t offset, size_t len ) {
+        memcpy ( data, ( file->opaque + offset ), len );
+}
+
+
+/**
   * Add file to virtual disk
   *
   * @v name		Name
--- wimbootorig/src/main.c	2018-11-02 12:29:14.343297008 +0100
+++ wimboot/src/main.c	2018-11-02 12:28:48.071166732 +0100
@@ -197,20 +197,6 @@
  }

  /**
- * Read from file
- *
- * @v file		Virtual file
- * @v data		Data buffer
- * @v offset		Offset
- * @v len		Length
- */
-static void read_file ( struct vdisk_file *file, void *data, size_t offset,
-			size_t len ) {
-
-	memcpy ( data, ( file->opaque + offset ), len );
-}
-
-/**
   * Add embedded bootmgr.exe extracted from bootmgr
   *
   * @v data		File data
@@ -305,8 +291,7 @@
  		decompress ( compressed, compressed_len, initrd );

  		/* Add decompressed image */
-		return vdisk_add_file ( "bootmgr.exe", initrd,
-					decompressed_len, read_file );
+		return vdisk_add_file ( "bootmgr.exe", initrd, decompressed_len, read_mem_file );
  	}

  	DBG ( "...no embedded bootmgr.exe found\n" );
@@ -325,7 +310,7 @@
  	struct vdisk_file *file;

  	/* Store file */
-	file = vdisk_add_file ( name, data, len, read_file );
+	file = vdisk_add_file ( name, data, len, read_mem_file );

  	/* Check for special-case files */
  	if ( strcasecmp ( name, "bootmgr.exe" ) == 0 ) {
@@ -378,7 +363,7 @@
  	/* Read bootmgr.exe into memory */
  	if ( ! bootmgr )
  		die ( "FATAL: no bootmgr.exe\n" );
-	if ( bootmgr->read == read_file ) {
+	if ( bootmgr->read == read_mem_file ) {
  		raw_pe = bootmgr->opaque;
  	} else {
  		padded_len = ( ( bootmgr->len + PAGE_SIZE - 1 ) &
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 01-efihandover.diff
Type: text/x-diff
Size: 2306 bytes
Desc: not available
URL: <http://lists.ipxe.org/pipermail/ipxe-devel/attachments/20190311/84558f3a/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 02-readmemfile.diff
Type: text/x-diff
Size: 2627 bytes
Desc: not available
URL: <http://lists.ipxe.org/pipermail/ipxe-devel/attachments/20190311/84558f3a/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 03-eficpio.diff
Type: text/x-diff
Size: 4243 bytes
Desc: not available
URL: <http://lists.ipxe.org/pipermail/ipxe-devel/attachments/20190311/84558f3a/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 04-initrdcmdline.diff
Type: text/x-diff
Size: 544 bytes
Desc: not available
URL: <http://lists.ipxe.org/pipermail/ipxe-devel/attachments/20190311/84558f3a/attachment-0003.bin>


More information about the ipxe-devel mailing list