1

I've heard that NTFS supports having multiple datastreams in a single file. Where you can specify a stream to read or write from other than the main one.

I see quite a bit of potential here, for different reasons.

Is there a filesystem for linux that achieves the same? Have attempts been made at making one? Why or why not would one be a good idea? What would it take for a filesystem to have this kind of feature?

5
  • I was about to create a snarky comment to the effect of "yes, there is one, it's called NTFS", since NTFS is, of course, supported by the Linux kernel. I don't know the extent of ADS support, but there seems to be some (this is an almost ten years old Stackexchange question about the NTFS Fuse driver). Feb 23, 2021 at 1:31
  • Since the purpose of Stackexchange is to answer specific questions rather than leading general discussions, you may want to elaborate on the potential you see and ask questions like "is NTFS-ADS feature ABC123 supported by Linux, and how?". In other words, which Streams features do you find appealing and would like to see implemented? Perhaps they are implemented already. Feb 23, 2021 at 1:32
  • NTFS alternate data streams are more of a solution in search of a problem than they are something useful. A chunk of data with a different name is a solved problem: it's a different file. If you look at the history, they're more of a reimplementation of what in Linux/POSIX/UNIX systems would be called extended attributes. Feb 24, 2021 at 12:20
  • 1
    @AndrewHenle that's not true. ADS is a "reimplementation" of forks which is a classic Mac thing. Mac wasn't POSIX until version X, and POSIX didn't have anything like that until the 2000s
    – phuclv
    Jun 4, 2022 at 9:46
  • 1
    @phuclv And Mac OS created resource forks because early versions of MFS didn't support directories. HFS even uses separate files now for resource forks. When the inventor abandons a concept... Jun 4, 2022 at 12:50

1 Answer 1

3

Files in NTFS only have a single main data stream, but they can have additional streams called Alternate data stream (ADS). ADS was introduced for classic Mac interoperability because Apple used resource forks to store additional data which is a kind of data fork

ADS has limited used and was mainly abused by viruses and malware. Besides using forks make it prone to data loss when copying using normal tools or copying to a non-supported file system. Therefore *nix didn't quite catch up on that. Even MS tried to use it for thumbnails in Windows 2000 but then abandoned the idea in XP. And when they introduced ReFS (which is the successor to NTFS) initially they dropped ADS support completely

The only common valid use of ADS nowadays is to store zone information to indicate where the file was downloaded from, in order to protect users from attacks from the internet. This needs little space so it was gaining popularity in other platforms. In the *nix world extended file attributes, which is additional data but with limited size, was starting to be added to most *nix file systems during the booming of the internet era in the 2000s. For example FreeBSD started supporting extended attributes since version 5.x in 2003

In Linux, the ext2, ext3, ext4, JFS, Squashfs, UBIFS, Yaffs2, ReiserFS, Reiser4, XFS, Btrfs, OrangeFS, Lustre, OCFS2 1.6, ZFS, and F2FS filesystems support extended attributes (abbreviated xattr) when enabled in the kernel configuration. Any regular file or directory may have extended attributes consisting of a name and associated data. The name must be a null-terminated string prefixed by a namespace identifier and a dot character. Currently, four namespaces exist: user, trusted, security and system. The user namespace has no restrictions with regard to naming or contents. The system namespace is primarily used by the kernel for access control lists. The security namespace is used by SELinux, for example.

Support for the extended attribute concept from a POSIX.1e draft[citation needed] that had been withdrawn in 1997 was added to Linux around 2002. As of 2016, they are not yet in widespread use by user-space Linux programs, but are used by Beagle, OpenStack Swift, Dropbox, KDE's semantic metadata framework (Baloo), Chromium, Wget and cURL.

The Linux kernel allows extended attribute to have names of up to 255 bytes and values of up to 64 KiB, as do XFS and ReiserFS, but ext2/3/4 and btrfs impose much smaller limits, requiring all the attributes (names and values) of one file to fit in one "filesystem block" (usually 4 KiB). Per POSIX.1e,[citation needed] the names are required to start with one of security, system, trusted, and user plus a period. This defines the four namespaces of extended attributes.

https://en.wikipedia.org/wiki/Extended_file_attributes#Linux

As noted previously, ReFS originally didn't support ADS but ADS with limited length was added back to newer ReFS versions but which makes it essentially extended attributes

Solaris 9 in 2002 is the first Unix to have forks, therefore Solaris' ZFS is probably the only Unix file system with forks, although confusingly they call it "extended attributes"

You must log in to answer this question.

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