Hacker News new | ask | show | jobs
by sockboy 358 days ago
Emulating extended attributes for a filesystem is a fascinating approach. It can significantly streamline lightweight OS customization without needing a full port of the filesystem driver. Has anyone experimented with this in open-source projects? Would love to hear about practical results or challenges.
1 comments

Linux has supported xattrs for many years; there's no need to emulate them.
Linux's xattrs appear to only be an array of bytes, while Haiku's extended attributes are typed (string, mime, int, llong, float, double, bool, icon, or raw). This means a compatibility layer is probably needed to handle encoding types into the value of the xattr. Xattr(7) says there is a limit of 64kb for the value. Some haiku programs allegedly use more, but i dont have an example handy. Further, specific file systems may impose additional restrictions. For instance ext4 requires all xattrs to fit in a single file system block (assuming that the man page I'm reading is not out of date).
For compressed files, HFS+ puts the entire contents in an (xattr né resource fork).
macOS resource forks values are "file-like" with position-based "block" read/write, Linux xattrs is a key-value map with atomic get/set operations on the whole value only.