github / libprojfs

Linux projected filesystem library
GNU Lesser General Public License v2.1
92 stars 14 forks source link

Implement pre-modification state flag for hydrated files #65

Closed chrisd8088 closed 5 years ago

chrisd8088 commented 5 years ago

Per our design, we need a third state for files which have been hydrated with their contents, but not modified by the user. We can implement this by setting our user.projection.empty flag to n, and then only removing the xattr if the file is opened for writing.

This will allow us to detect and send events at the "convert to full (i.e., modified)" state transition (when the file is opened for writing), akin to how the VFSForGit Mac kext sends PreConvertToFull events when it receives a KAUTH_VNODE_WRITE_DATA authorization request on a file which has been hydrated but still has a org.vfsforgit.xattr.file xattr. After sending this event, the Mac user-space library then removes the xattr.

We don't need a second xattr, because unlike the VFSForGit kext, which uses a spare BSD file flag to mark un-hydrated empty files, we're already using an xattr for that purpose, and can simply give it a different value (n) upon hydration, and then only remove it if the file is ever opened for writing.

chrisd8088 commented 5 years ago

Closed by #66.