0

I always knew that Mac operating systems had a concept of "resource forks" but have just learned that this feature has in fact been deprecated since the arrival of OS X.

I also just discovered the mdls terminal command that lists metadata.

Does some or any of this metadata come from resource forks? If not, where is the metadata stored? Or is the metadata generated each time it's needed?

1 Answer 1

2

Some of the meta data comes from the file's ordinary metadata (e.g. creation date, and similar), other parts of the meta data comes from so called extended file attributes, and some again are from other sources (such as the file's data fork).

On HFS+ a file's basic meta data is stored inside the catalog record (creation date, content modification date, etc.). HFS+ also supports attributes, which can be stored in a special file known as the "attributes file" that holds key/value records. The attributes file itself consists of a single fork.

Only smaller attributes are stored inline. Medium sized attributes are stored in up to 8 extents pointed to by a fork data attribute record. Larger attributes (known as extension attributes) have a list of extents managed exactly like a resource fork.

The naming here can be a bit confusing. Initial versions of HFS referred to this same structure in the file system as "named forks". Only later were they renamed to "extended attributes". The main difference being the type of API used by applications to access the data.

So in essence forks are still very much used on OS X. However, the specific "resource fork" as managed by the Resource Manager API is deprecated, as you describe.

For macOS, we have moved away from HFS+ to APFS. With APFS, resouce forks are stored as an extended attribute named "com.apple.ResourceFork". However, they are still treated specially by the file system, as inodes on APFS (similar to catalog records on HFS?) have a specific flag to state that a resource fork exists. Other extended attributes do not have such a flag.

Note that other parts of the metadata can come from a wide range of data sources - some stored on disk, others generated upon import (for example by consulting cloud services when dealing with files stored in iCloud or similar service).

mdls uses the Spotlight API in order to retrieve the metadata for display. The Spotlight API draws upon sources such as file system data, file system meta data, extended attributes, and many other places. In particular it has a system of importer plugins that are responsible for parsing various file types, contacting various cloud services, etc.

5
  • Extended attributes are not a named fork. They're a separate feature of the file system. In fact, under APFS, the resource fork is stored as an extended attribute named com.apple.ResourceFork!
    – user101978
    Feb 7, 2018 at 21:47
  • 2
    @duskwuff The answer was written before APFS was a thing. On HFS+ extended attributes are in fact stored in a named fork. However, resource forks and named forks are not the same thing.
    – jksoegaard
    Feb 8, 2018 at 8:55
  • @jksoegaard: What was the name of that named fork? Or if it is not a single unchanging name like the resource fork, how was the name derived? Mar 8, 2021 at 2:26
  • Resource forks and named forks are "kind of" the same thing. When named forks were added the resource fork was just a special case of one of those, but resource forks were around before named forks and live on, though moribund, after named forks have gone. I've tried writing code for named forks on the oldest Mac available to me and tried to scan my whole system for forks other than resource forks and found nothing. Any additional info would be greatly appreciated. Apr 23, 2023 at 1:48
  • I tried to explain how their relationship is in my answer. You are right that you can see them as "kind of" the same thing - but still, it's really not the same thing. In general, the contents of resource forks follow a specific set of rules (a format) - that is not generally the case for named forks.
    – jksoegaard
    Apr 23, 2023 at 11:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .