[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: grub-mkrescue hfsplus GPT partition is not mountable on Linux
From: |
Thomas Schmitt |
Subject: |
Re: grub-mkrescue hfsplus GPT partition is not mountable on Linux |
Date: |
Sat, 26 Dec 2015 12:39:05 +0100 |
Hi,
i hopefully identified the cause of the i/o error with kernel
message
[ 359.020970] hfsplus: walked past end of dir
It seems to be an original mistake by Vladimir (who normally
makes much less mistakes than i do).
Since Andrei is surely more familiar with Vladimir's coding habits
and quite surely has more clue about HFS+, i post my analysis for
review.
--------------------------------------------------------------------
In libisofs/hfsplus.c there is a function create_tree() :
http://bazaar.launchpad.net/~libburnia-team/libisofs/scdbackup/view/1249/libisofs/hfsplus.c#L299
It converts file objects from the libisofs tree model into objects
of the HFS+ tree model. The function returns 0 without creating
a new HFS+ tree object for files which it deems to be ignorable.
In case of error the return value is < 0.
In case of successful creation of HFS+ object and sub objects
it returns ISO_SUCCESS, which is > 0.
The two callers of create_tree() return error, if they receive
a return value < 0.
But they increment the directory children counter without
regarding return value 0.
This happens in the loop for populating the root directory
http://bazaar.launchpad.net/~libburnia-team/libisofs/scdbackup/view/1249/libisofs/hfsplus.c#L1660
and in the loop for recursively populating other directories
http://bazaar.launchpad.net/~libburnia-team/libisofs/scdbackup/view/1249/libisofs/hfsplus.c#L400
In my test runs, two files get ignored in the root directory:
/boot.catalog ... because it is not a data file in the libisofs
model but rather a boot catalog.
(For HFS+ this difference would not matter.)
/efi.img ......... because it is explicitely hidden from HFS+.
(Not so clear why libisofs/eltorito.c hides
the first EFI boot image from HFS+. Shrug.)
So the HFS+ root directory gets a .nchildren count of 6, but only 4
HFS+ file objects get registered for populating the root directory.
The remedy is to increment .nchildren only if create_tree() returned
a value > 0.
After i changed both loops, i get from grub-mkrescue an ISO, where
i can mount and explore /dev/sdb3 (via GPT) without i/o error.
http://bazaar.launchpad.net/~libburnia-team/libisofs/scdbackup/revision/1298/libisofs/hfsplus.c
--------------------------------------------------------------------
Have a nice day :)
Thomas