Does OpenZFS support File IDs?

Developer discussions.

Does OpenZFS support File IDs?

Postby ball » Mon Dec 14, 2015 6:26 pm

I looked in the wiki and all over the various OpenZFS/ZFS web sites, and they all come from a UNIX perspective which I don't honestly care too much about (despite the fact I started with UNIX). One question which is important from a Mac perspective is if ZFS volumes support FileIDs.

Back in the day (System 7), files and folders on a Mac were referred to by volume and a 32bit value, not a file path. This means that things wouldn't break when moving or renaming files or folders, including aliases.

In case you come from a UNIX background, I'll clue you in on something: aliases are not symlinks or hard links. They are an arbitrary description on how to find a file, and on HFS filesystems could have the volume and ID of a file as opposed to merely the equivalent to a file path. On UFS filesystems they were basically symlinks which are fragile.

(for a long time Cocoa apps couldn't handle files being renamed or moved while open until they started using File IDs internally, although I don't think Apple ever exposed the mechanism in FoundationKit because they're idiots)

Anyway, this is a really nice human interface solution to a problem which won't be fully solved until someone develops an OS that doesn't have files to begin with, and I don't see any mass adoption of ZFS without such a feature.

I undertand that the HFS method for implementing this feature (a catalog file) may be impossible to achieve and the knee-jerk reaction to this may be to dismiss me completely based on that alone, but I would prefer a more constructive conversation than what I've typically experienced in open source projects.

I don't know enough specifics about ZFS to suggest an implementation method, but basically it's a file reference that isn't supposed to break unless the file is deleted. If you hard-link a file (assuming one would ever want to implement hard-links), each hard link has its own file ID in MacOS and behave much like a file path except they don't change.

I honestly don't care as much about case sensitivity, although it's nice to disallow similarly named files to avoid confusion (which I'm sure was the original intent).
Posts: 1
Joined: Mon Dec 14, 2015 6:03 pm

Re: Does OpenZFS support File IDs?

Postby lundman » Tue Dec 15, 2015 5:26 pm

We have been trading emails about this for a while, and I think we have reached an understanding :)

FileID, as in being able to lookup a file based only on volume+fileid will work in ZFS, it was required for Spotlight to work etc. You can test it by using the ".vol" lookup.

For example, find the mount ID number:

Code: Select all
# stat /Volumes/BOOM/
754974723 2 drwxr-xr-x 30 lundman wheel 0 30 "Dec  4 15:05:00 2015" "Dec 13 13:38:00 2015" "Dec 13 13:38:00 2015" "Oct 13 09:53:32 2015" 3072 17 0 /Volumes/BOOM/

In this case, "754974723". Presumably there are ways to look this up from something more persistent, like Volume UUID. Using this you can lookup a file based on its FileID:

Code: Select all
# stat /.vol/754974723/12
754974723 12 -rw-r--r-- 1 root wheel 0 8192 "Nov  6 15:35:52 2015" "Nov  6 15:35:52 2015" "Nov  6 15:35:52 2015" "Nov  6 15:35:52 2015" 8192 17 0 /.vol/754974723/12

In this case, "12" is persistent, and maps to ZFS' z_id. And will keep its FileID if renamed and moved:

Code: Select all
# ls -li /Volumes/BOOM/ROGER
12 -rw-r--r--  1 root  wheel  8192 Nov  6 15:35 /Volumes/BOOM/ROGER

# mv /Volumes/BOOM/ROGER /Volumes/BOOM/mydir/MOORE

# ~/FSMegaInfo getattrlist -ATTR_CMN_NAME  /.vol/754974723/12
getattrlist -ATTR_CMN_NAME /.vol/754974723/12

But as we discussed, HARDLINKS are not persistent. Yes, they will get a unique "LinkID" as expected by Finder, and you can query each hardlink by its LinkID (vget or ".vol" as above), but the LinkIDs are not retained across re-mounts/reboots. We could potentially extend ZFS to also store hardlink LinkIDs on disk, if there is a need.
User avatar
Posts: 490
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan

Re: Does OpenZFS support File IDs?

Postby bhagaban » Wed Jan 06, 2016 12:55 am


how thw zfs file system contacts with the block storage driver in MAC osx. How the filr system buffer goes to Block storage layer any comman api between filesyem and block storage layer in osx ?

Posts: 22
Joined: Mon Nov 30, 2015 6:31 am

Return to OpenZFS on OS X Development

Who is online

Users browsing this forum: No registered users and 1 guest