6

It's possible to mount both Apple HFS+ and Microsoft NTFS filesystems under Linux.

Both filesystems support multiple content streams per file, though this is not widely used.

Are there (semi) standard ways to access these filesystem features from Linux? If so are the methods uniform between the two filesystems or are only arcane ad-hoc methods available? (Perhaps something with ioctls?)

hippietrail
  • 350
  • 1
  • 2
  • 14

1 Answers1

7

ntfs-3g can read alternate data streams in NTFS. From its manpage:

Alternate Data Streams (ADS)

NTFS stores all data in streams. Every file has exactly one unnamed data stream and can have many named data streams. The size of a file is the size of its unnamed data stream. By default, ntfs-3g will only read the unnamed data stream.

By using the options "streams_interface=windows", with the ntfs-3g driver (not possible with lowntfs-3g), you will be able to read any named data streams, simply by specifying the stream's name after a colon. For example:

 cat some.mp3:artist

Named data streams act like normal files, so you can read from them, write to them and even delete them (using rm). You can list all the named data streams a file has by getting the "ntfs.streams.list" extended attribute.

For hfs+ I couldn't find anything conclusive (e.g. kernel documentation), but this question at Super User points to a suggestion:

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 a file called destfile. All command-line functions work this way. I haven't tested it with anything graphical.

Renan
  • 16,976
  • 8
  • 69
  • 88
  • 1
    Thanks for a very complete answer! One thing, apparently HFS+ now supports an arbitrary number of forks per file like NTFS and not just two. Of course just like on NTFS the feature is almost never used. It seems there's little hope of a standardized way to access them to make them useful for caching non-critical or metadata ... – hippietrail Dec 09 '12 at 22:56
  • 1
    At some point Apple changed the syntax to access the resource fork from `cp somefile/rsrc destfile` to `cp somefile/..namedfork/rsrc destfile` - the new syntax suggests that you could access any Named Fork (Apple's actual name for ADS) that way. But at least since Mountain Lion you've only been able to access the resource fork this way. I don't know the exact history of the changes but I asked a question about it the other day: https://apple.stackexchange.com/questions/416039 – hippietrail Mar 20 '21 at 01:40