6

I thought extended file attributes existed in NTFS which Windows supports. I cannot find a cmd for accessing/updating attributes.

Is there a flavor of Windows (and its file system) that supports this?

I tried getfattr, setfattr, and a number of other commands. attrib is not it either.

If extended attributes are to remain portable across filesystems (even virtual ones implemented in FUSE) then all target platforms need to present an api in userspace (a cmd or set of cmds).

Mario
  • 6,572
  • 3
  • 42
  • 74
  • Hi, evidently I'm not as familiar with extended attributes as the answer below, so I'll add this is a comment to test the waters. Using powershell it's possible to dip into COM and grab attributes: https://blogs.technet.microsoft.com/heyscriptingguy/2014/02/06/use-powershell-to-find-metadata-from-photograph-files/ – Alex KeySmith Dec 21 '17 at 17:18
  • Also, have you considered using xattr via bash in the new linux subsystem in windows (of course this will depend on your use case). – Alex KeySmith Dec 21 '17 at 17:19
  • I think that NTFS Alternate Data Streams https://stackoverflow.com/questions/1809725/ntfs-alternate-data-streams/1819063 are the closest thing to extended attributes – Oren Kishon Oct 08 '18 at 06:40

3 Answers3

1

The closest thing to UNIX attribs are EAs: NTFS stores partition metadata called Extended Attributes (EA), which allow data to be stored as an attribute of a file or folder.

EAs, for instance, are used by IE to identify a file as having been "downloaded from the web".

From Wikipedia:

On Windows NT, limited-length extended attributes are supported by FAT, HPFS, and NTFS. This was implemented as part of the OS/2 subsystem. They are notably used by the NFS server of the Interix POSIX subsystem in order to implement Unix-like permissions. The Windows Subsystem for Linux added in the Windows 10 Anniversary Update uses them for similar purposes, storing the Linux file mode, owner, device ID (if applicable), and file times in the extended attributes. Additionally, NTFS can store infinite-length extended attributes in the form of alternate data streams (ADS), a type of resource fork. Plugins for the file manager Total Commander, like NTFS Descriptions and QuickSearch eXtended support filtering the file list by or searching for metadata contained in ADS Streams. Ref.

If you want to do something security related you want to take a look at the Discretionary Access Control List (DACL) functionality; http://www.windowsecurity.com/articles/Understanding-Windows-NTFS-Permissions.html

Powershell can help setting the mode and extended file and folder attributes - but this does, unfortunately, only apply to regular attributes (not EAs).

I found something related to NTFS attribs in the 3G-Fuse source that might be helpful. However, I doubt that's truly portable.

wp78de
  • 18,207
  • 7
  • 43
  • 71
1

Here's a GitHub repo containing a tool that allows to manipulate EAs: https://github.com/jschicht/EaTools - this apparently uses NtCreateFile and NtSetEaFile to set and modify them.

(I also asked specifically about .NET APIs to maybe implement a cross-platform tool: .NET: How to set "extended file attributes" in a cross-platform way? - currently there is no such API.)

Heinrich Ulbricht
  • 10,064
  • 4
  • 54
  • 85
0

You can also try using the Alternate Data Streams APIs for NTFS which network file servers like samba use to store the extended attributes for exported shares.

Take a look at this: https://www.codeproject.com/Articles/2670/Accessing-alternative-data-streams-of-files-on-an

Waleed
  • 3,105
  • 2
  • 24
  • 31