This change decouples the two usages of "str" filesystem: "pseudo" filesystems, and tmpfs. The difference between them is that in "pseudo" filesystems, the file data is stored directly in handle.
Instead of str_* functions, there is a simpler set of mem_file_* functions that do not operate on handles or dentries, just on its own buffer.
The decoupling makes both use-cases simpler: there is no structure "inheritance" and no extra layer of reference counting.
Next steps
I converted file position from a pointer to file_off_t, so it brings us a step closer to pushing the file position upwards (so that it's not handled by individual filesystems).
I got rid of the reference counting here, which unblocks fix to dentry lifecycle (I made a first attempt in #2499 but got blocked by this).
Instead of a bit field, the dentry state can be an enum; something like "new -> negative (file doesn't exist yet) -> valid -> deleted (after unlink)".
The last filesystem I want to rewrite is chroot, but it turns out that it has some more advanced handling of deleted files, so I'll be trying to include that in dentry lifecycle.
To be more specific, the chroot filesystem allows you to have a handle to "old" deleted file, and a dentry to the "new" one; this is done using a version field. Instead, I want these files to be described by two separate dentries.
Description of the changes
This change decouples the two usages of "str" filesystem: "pseudo" filesystems, and
tmpfs
. The difference between them is that in "pseudo" filesystems, the file data is stored directly in handle.Instead of
str_*
functions, there is a simpler set ofmem_file_*
functions that do not operate on handles or dentries, just on its own buffer.The decoupling makes both use-cases simpler: there is no structure "inheritance" and no extra layer of reference counting.
Next steps
file_off_t
, so it brings us a step closer to pushing the file position upwards (so that it's not handled by individual filesystems).chroot
, but it turns out that it has some more advanced handling of deleted files, so I'll be trying to include that in dentry lifecycle.chroot
filesystem allows you to have a handle to "old" deleted file, and a dentry to the "new" one; this is done using aversion
field. Instead, I want these files to be described by two separate dentries.How to test this PR?
The existing tests should be enough.
This change is