Skip to content

iso9660: write images that strict readers accept - #460

Merged
deitch merged 1 commit into
diskfs:masterfrom
haklein:iso9660-strict-readers
Nov 19, 2026
Merged

deitch merged 1 commit into
diskfs:masterfrom
haklein:iso9660-strict-readers

Conversation

@haklein

@haklein haklein commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

This change makes Finalize write ISO 9660 images that strict readers accept.

pycdlib 1.22.0 rejects a bootable Rock Ridge image from go-diskfs when the workspace contains the boot catalog file, for example isolinux/boot.cat. Tolerant readers such as xorriso and isoinfo accept the image.

Defects

PX file serial number. The Rock Ridge PX entry stored the file serial number as one 64-bit little-endian value. RRIP 1.12 section 4.1.1 defines a 32-bit value in both byte orders. pycdlib reports PX record big and little-endian file serial number do not agree.

Second boot catalog record. Finalize appended a directory record for the boot catalog when the workspace already contained a file with the same name. The directory then had two records with the identifier BOOT.CAT;1. pycdlib reports Failed adding duplicate name to parent.

Order of directory records. Finalize wrote directory records in the order of the workspace walk. ECMA-119 section 9.3 requires the order of the file identifiers. A workspace with EFI, coreos, images and isolinux gave the order EFI, COREOS, IMAGES, ISOLINUX.

Changes

  • The writer stores the PX serial number as two 32-bit halves. The reader reads the little-endian half. The type of the serial number is now uint32.
  • Finalize uses the existing directory record for the generated catalog. With HideBootCatalog, Finalize removes the existing file from the image.
  • Finalize sorts the records of each directory by file identifier. The Joliet tree sorts its records by the UCS-2 bytes of the names.

New rules for the boot catalog path

  • If a different file has the same ISO 9660 identifier as the catalog, the catalog gets a free identifier (BOOT0.CAT for BOOT.CAT).
  • If the path of a visible catalog is a directory or a symlink, Finalize returns an error.
  • If the path of the catalog is also the path of a boot image, Finalize returns an error.

Tests

The unit tests are in finalize_catalog_internal_test.go and rockridge_internal_test.go.

I also built one image from master and one image from this branch. The workspace was the content of a bootable ISO with isolinux/boot.cat, Rock Ridge, a BIOS boot entry and an EFI boot entry. Each reader extracted all files, and I compared the sha256 of each file with the source.

Reader master This branch
pycdlib 1.22.0 fails (PX serial number) reads all files
isoparser (Python) fails (both-endian value) reads all files
xorriso 1.5 warns about a name collision no warning, reads all files
isoinfo, libcdio, libarchive, 7z two boot.cat records one record, reads all files
Linux kernel isofs not tested reads all files
QEMU with SeaBIOS not tested ISOLINUX starts and loads the kernel
QEMU with OVMF not tested GRUB starts

golangci-lint v2.14.0 reports no issues.

@deitch

deitch commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

This is some good work, thank you for this. I ran CI, it is all clean.

ECMA-119 section 9.3 requires the order of the file identifiers. A workspace with EFI, coreos, images and isolinux gave the order EFI, COREOS, IMAGES, ISOLINUX

The most recent 6th edition of ecma-119 section 9.3 describes volume set terminator. Did you mean a different section? Section 7.8 is directory structure, and 7.9 is path table, specifically 7.9.2 is path table ordering.

7.9.2 has this fun tidbit:

The records in a path table shall be ordered by the following criteria in descending order of significance:
— in ascending order according to the level in the directory hierarchy;
— in ascending order according to the directory number of the parent directory of the directory identified by
the record;
— in ascending order according to the relative value of the directory identifier field in the record, where the
directory identifiers shall be valued as follows. 
  - If two directory identifiers do not contain the same number of byte positions, the shorter directory
identifier shall be treated as if it were padded on the right with all padding bytes set to filler (see 8.4.3.2),
and as if both directory identifiers contained the identical number of byte positions;
  - After any padding necessary to treat the directory identifiers as if they were of equal length, the
characters in the corresponding byte positions (starting with the first position) of the directory identifiers
are compared until a byte position is found that does not contain the same character in both directory
identifiers. The greater directory identifier is the one that contains the character with the higher code
position value in the coded graphic character sets used to interpret the directory identifier of the path
table record

In any case, yes, the order is prescribed, and not just according to the walk. It would be cool if you could tell the walk func "order it this way", but it doesn't work like that.

I assume this is addressed in lessISOIdentifier(), will look there.

@deitch deitch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions.

Comment thread filesystem/iso9660/rockridge.go Resolved
Comment thread filesystem/iso9660/finalize.go Resolved
@haklein

haklein commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

The most recent 6th edition of ecma-119 section 9.3 describes volume set terminator. Did you mean a different section? Section 7.8 is directory structure, and 7.9 is path table, specifically 7.9.2 is path table ordering.

right, my reference to 9.3 was from older numbering. Funny enough the annex C.4.8.1 of the 6th edition still uses that number.

Finalize wrote three structures that a strict reader such as pycdlib
rejects. Tolerant readers such as xorriso and isoinfo accept them.

The Rock Ridge PX entry stored the file serial number as one 64-bit
little-endian value. RRIP 1.12 section 4.1.1 defines a 32-bit value in
both byte orders. The writer now stores the two halves, and the reader
reads the little-endian half.

Finalize appended a second directory record for the boot catalog when
the workspace already contained a file with the same name. Finalize now
uses the existing record for the generated catalog. With
HideBootCatalog, Finalize removes the existing file from the image.

Finalize wrote directory records in the order of the workspace walk.
ECMA-119 section 9.3 requires the order of the file identifiers.
Finalize now sorts the records of each directory. The Joliet tree sorts
its records by the UCS-2 bytes of the names.

The boot catalog path has these new rules:

- If a different file has the same ISO 9660 identifier as the catalog,
  the catalog gets a free identifier (BOOT0.CAT for BOOT.CAT).
- If the path of a visible catalog is a directory or a symlink,
  Finalize returns an error.
- If the path of the catalog is also the path of a boot image,
  Finalize returns an error.

Co-Authored-By: Claude <noreply@anthropic.com>
@haklein
haklein force-pushed the iso9660-strict-readers branch from e63ba59 to f1b1bd1 Compare November 19, 2026 14:30
@deitch
deitch merged commit caaa5de into diskfs:master Nov 19, 2026
20 checks passed
@haklein
haklein deleted the iso9660-strict-readers branch November 19, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants