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

Re: Tool for blessing HFS+ filesystems required



Hi,

John Paul Adrian Glaubitz wrote:
> - Use HFS+ with hfsprogs and write a blessing tool based on libisofs [2]

The code was contributed by Vladimir Serbinenko in 2012, when he was
the active maintainer of GRUB. See:
  https://dev.lovelyhq.com/libburnia/libisofs/raw/branch/master/libisofs/hfsplus.c

I myself have few clue what it does overall. But i can tell for what
to look in the code.

The libisofs user (a programmer) calls
  int iso_image_hfsplus_bless(IsoImage *img,
                              enum IsoHfsplusBlessings blessing,
                              IsoNode *node, int flag);
to attribute a blessing to a file (here: node).
Defined blessings are
  enum IsoHfsplusBlessings {
    /* The blessing that is issued by mkisofs option -hfs-bless. */
    ISO_HFSPLUS_BLESS_PPC_BOOTDIR,

    /* To be applied to a data file */
    ISO_HFSPLUS_BLESS_INTEL_BOOTFILE,

    /* Further blessings for directories */
    ISO_HFSPLUS_BLESS_SHOWFOLDER,
    ISO_HFSPLUS_BLESS_OS9_FOLDER,
    ISO_HFSPLUS_BLESS_OSX_FOLDER,

    /* Not a blessing, but telling the number of blessings in this list */
    ISO_HFSPLUS_BLESS_MAX
  };

A pointer to the blessed IsoNode object is stored in
IsoImage.hfsplus_blessed[blessing] and copied over to
Ecma119Image.hfsplus_blessed[blessing] before the ISO output stream
gets produced.
Ecma119Image.hfsplus_blessed[] is the input to HFS+ production in
libisofs/hfsplus.c .

create_tree() uses the hfsplus_blessed[] array to watch out for the
IsoNode objects which are to be blessed. Ecma119Image.hfsp_bless_id[]
then memorizes the respective HFS+ cat_id which has been attributed to
the found IsoNode.

write_sb() copies the .hfsp_bless_id[] array to this sequence of
struct hfsplus_volheader elements
  uint32_t ppc_bootdir;
  uint32_t intel_bootfile;
  uint32_t showfolder;
  uint32_t os9folder;
  uint32_t unused;
  uint32_t osxfolder;
skipping "unused".
struct hfsplus_volheader is defined in
  https://dev.lovelyhq.com/libburnia/libisofs/raw/branch/master/libisofs/hfsplus.h
This struct gets written flatly to the ISO.

So the job with an existing HFS+ fileystem image would be to find out
the cat_id numbers of the intended files and to write them into the
32 bit slots of the HFS+ entity which is represented by struct
hfsplus_volheader.

The code gives hints that the specs are called "TN1150". In the web i find
  https://developer.apple.com/library/archive/technotes/tn/tn1150.html
It tells
  The volume header is always located at 1024 bytes from the start
  of the volume.
So together with the layout of the libisofs struct, this tells where
to store the numbers.

Either the specs or the code of HFS+ capable tools will probably tell
how to find a file by name and how to obtain its "cat_id", which i guess
is called "catalog node ID" in the specs.


Have a nice day :)

Thomas


Reply to: