how to access resource fork of hfs+ filesystem on linux

5

I have an HFS+ filesystem image recovered from a failing Mac harddrive and can loopback mount it on my Linux machine. How can I access the resource forks for the files in this filesystem from the Linux machine?

(I do not have a Mac with the capacity to store an image this large.)

retracile

Posted 2011-12-01T19:06:52.557

Reputation: 2 586

FYI, modern Mac OS stores resources in the data fork for files that are resource-only, ie have no need to store data in the data fork. Font suitcases are one example. – Neil Mayhew – 2017-01-30T17:07:32.287

If the image is too large to fit on your Macs, you could share it over the network from Linux and loop-mount it on a Mac. Or you could put it on an external drive of some kind. – Neil Mayhew – 2018-02-17T01:08:52.157

Answers

1

Add /rsrc to the end of the file name to access the resource fork. I have no I idea where that's documented if anywhere.

Edit: Just to clarify I was referring to command-line usage; for example cp somefile/rsrc destfile will copy the resouce fork of somefile to a file called destfile. All command-line functions work this way. I haven't tested it with anything graphical.

This mechanism existed in 2.xx kernels but was removed at some later point. seec https://evilpiepirate.org/git/linux-bcache.git/plain/fs/hfsplus/inode.c

*hfsplus_file_lookup contained the fallowing:

if (HFSPLUS_IS_RSRC(dir) || strcmp(dentry->d_name.name, "rsrc"))
        goto out;

This was later removed. It was never documented and may not have worked for all systems. At any rate as noted by "Neil Mayhew" current kernel mainline source no longer does this. Further since OS X apple has stopped creating new resource forks so only legacy files will have them.

wheredidthatnamecomefrom

Posted 2011-12-01T19:06:52.557

Reputation: 198

Appears this no longer works, at least not for .textClipping files. – Jeff Burdges – 2015-06-05T08:13:52.527

I'll look into it there was never any offical documentation that I could find. Apple has been moving away from resource forks since OS X came out. – wheredidthatnamecomefrom – 2015-06-07T17:48:09.597

I couldn't get this to work. – Neil Mayhew – 2017-01-30T16:37:18.240

That worked; thanks. Files without a resource fork on the hfs+ filesystem would give a 'permission denied' error when I tried to access /rsrc, which let me determine which files had resource forks and which didn't. – retracile – 2012-03-18T11:50:40.273

3

I don't think this is possible with the default kernel driver (fs/hfsplus in the kernel sources).

I have an HFS+ volume mounted in Linux and files that have a resource fork. I tried both the commonly-used special filename syntaxes FILENAME/rsrc and FILENAME/..namedfork/rsrc. The former used to work on Mac OS, and the latter works on Mac OS now, but neither works on Linux. They return the error ENOTDIR, "Not a directory". I tried this with files that have a resource fork and no data fork, and files that have both.

I looked through the driver sources and I can see no sign of it being possible to access a resource fork explicitly, either with a special filename syntax or with an ioctl call. The driver does concern itself with resource forks, but only for the purpose of keeping them together with the rest of the file when a file is moved, and deleting them when a file is deleted.

I would love to be proved wrong on this, but I wasn't able to find any information to the contrary.

Neil Mayhew

Posted 2011-12-01T19:06:52.557

Reputation: 776

1

This won't help you now, but for future reference, there's a utility in the Apple developer tools called SplitForks that turns a single file with a resource fork into two files. The second, hidden, file has ._ prepended to the original filename. It's in AppleDouble format and also contains Finder metadata such as the file's type and creator codes. This is the same format that's used to store Mac-specific data in archive formats like zip and tar, and for transfer using rsync.

SplitForks can work hierarchically on entire directory trees, which can then be transferred to a non-Mac filesystem without loss of data. There's also a companion utility called FixupResourceForks that puts split files back together again if the directory tree is later moved to another Mac.

Neil Mayhew

Posted 2011-12-01T19:06:52.557

Reputation: 776