views:

842

answers:

6

On NTFS there is a nice but mostly unused feature called "Alternate Data Streams" (ADS) which I recently used in a hobby-dev project.

I am thinking of porting this project to Linux, but I do not know if any Filesystem on linux has such a feature?

A: 

Most Linux file systems have extended attributes. I'm not familiar with NTFS streams, so I can't compare the two. Most file systems need to be mounted with flags to enable the extended attributes, so this may not work generically for anyone's system. They are usually abbreviated as xattr or xattrs.

Peter Shinners
A: 

The only thing I know, which goes somewhat into that direction are extended attributes, but from what I read about ADS it's def. not the same thing. What exactly are you using that for?

André
I want to store some meta data of files in it.
Peter Parker
A: 

The commonly used Linux filesystems do not support this. Instead you could use multiple files and a suitable naming scheme (just append the stream index to each filename, perhaps), or an archive containing multiple files; you will find such an approach is better in other ways anyway - for instance, what happens on Windows if someone wants to back up the files Windows to a medium with a non-NTFS filesystem?

moonshadow
You're supposed to use a backup program that uses the backup APIs-- they will package all the metadata on a file (EAs, security descriptor, data streams, encrypted files, etc.) into a single stream to save and later restore.
Chris Smith
+5  A: 

The problem with ADS is that Windows will "lose" those ADS streams the second that it moves to any non-NTFS filesystem. It does not consider those streams important, so oftentimes they are not kept around. You'll find they aren't accessible or disappear when over a network share, when burned to CD, put on a USB drive, etc...

The long and short of it is, unless you have a very narrow focus for your application (always on NTFS), I would avoid ADS streams altogether.

hova
+4  A: 

Extended attributes are supported some filesystems, particularly XFS, and (i think) JFS; but are limited in size (64k in XFS). Reiser4 supports arbitrary sized forks; but it's not supported by any distro i know of. Another option is ZFS, again not very usable.

In the end, it's probably wiser to just use a directory.

Javier
+3  A: 

There are file systems on both Windows and Linux (and other OSes) that support extended attributes (EAs). The Windows support was added for OS/2 compat and does not have any documented interface, except for a hacky method through the backup API (that's what Cygwin does). EAs are designed to store small values only. On Windows, each EA has an ASCII name (whereas almost all other names are Unicode) and the combined size of all EAs on a file can't be larger than 64k. EAs are not files: you can't open a file handle to an EA and read it like a normal file.

Alternate data streams are a separate feature provided by NTFS which allows you to provide alternate subfiles inside of a file. Every file has a default unnamed data stream that is automatically opened unless you specify an alternate one. You can open a handle to an ADS and read (even execute) it like a normal file, with a single (Unicode) filename. An ADS can be as large as any disk file.

There is no exact analog to ADSes on Linux that I know of, but you may be able to use EAs on the Linux port instead if the data values are small.

Chris Smith