bug-xorriso
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sharing files between file systems.


From: Thomas Schmitt
Subject: Re: Sharing files between file systems.
Date: Tue, 08 Dec 2020 09:25:49 +0100

Hi,

Don Cupp wrote:
> is there anyway to
> share the files between the parent iso9660fs and the container fs that makes
> up the El Torito target?

The ISO 9660 (aka ECMA-119) specs do not forbid this. But xorriso does not
offer such an opportunity and you'd need some FAT skills, which i don't
have.

A rough sketch about post-processing the ISO to achieve the goal:
-----------------------------------------------------------------------
Assumptions:

- The EFI boot image (FAT filesystem) for El Torito is named in the ISO:
    /efi.img
- The initrd file in the EFI image is named
    \INITRD
- The initrd file in the ISO filesystem shall be named
    /initrd

-----------------------------------------------------------------------
Procedure for \INITRD being smaller than 4 GiB:

1: Make sure that \INITRD has an offset inside /efi.img which is divisible
   by 2048 without remainder. Other offsets cannot be addressed by
   ISO 9660.
   Divide this offset by 2048 and memorize the result.

2: Create the ISO with EFI boot image as /efi.img
   and an empty file /initrd.

3: Obtain the start block of /efi.img in the ISO image.
   Add it to the memorized offset of \INITRD, (which is already divided
   by 2048). Memorize it as "LBA".

4: Find the byte address of the ISO 9660 directory record of /initrd.

5: At byte offset 2 relative to that address write the LBA as 32 bit
   little endian number. At byte offset 6 write LBA as big-endian.

6: At byte offset 10 write the file size in bytes of \INITRD as
   little-endian. At byte offset 14 as big-endian.

Now /initrd points to the same byte range as \INITRD does.

-----------------------------------------------------------------------
Implementation issues:

Step 1 is completely out of my scope.

Step 2 is trivial (at least if compared to the others).

Step 3 can be done by this xorriso command applied to the ISO:
  xorrriso -indev "$ISO" -find /efi.img -exec report_lba --
which will report on stdout something like:
  Report layout: xt , Startlba ,   Blocks , Filesize , ISO image path
  File data lba:  0 ,     1234 ,   524288 , 1073741824 , '/efi.img'
We want the value under "Startlba", in this example: 1234.

Step 4 is tricky. xorriso does not tell byte offsets of directory records.
Program isodump might be able to tell desired the number. But i am not
smart enough to decode its output.
The quickest way i can imagine for now is to mount the ISO by Linux and to
obtain its inode number.
This number is the result of dividing the desired address by 32.
(See fs/isofs/isofs.h function isofs_get_ino()).
>From inode_number * 32 begin searching for the byte sequence
  "INITRD"
and when found, subtract 33 from the byte address of the first "I".
(See ECMA-119, 9.1 Format of a Directory Record. Byte offset is BP - 1.)

Step 5 and 6 are quite easy in a programming language that can address
bytes in a file and write binary numbers to it.

-----------------------------------------------------------------------

The main obstacle for an implementation in xorriso is step 1.
The content of EFI images is currently completely opaque to xorriso and
libisofs.

If initrd is 4 GiB or larger, then you will have to patch more than one
directory record with partial sizes <= 4 GiB - 2048 and with LBA offsets
which take into account the sizes of the previous file parts.


Have a nice day :)

Thomas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]