Windows cli equivalent of Mac `xattr`?
Asked Answered
C

4

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).

Christner answered 27/9, 2017 at 22:48 Comment(3)
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: blogs.technet.microsoft.com/heyscriptingguy/2014/02/06/…Burmese
Also, have you considered using xattr via bash in the new linux subsystem in windows (of course this will depend on your use case).Burmese
I think that NTFS Alternate Data Streams https://mcmap.net/q/189524/-ntfs-alternate-data-streams/… are the closest thing to extended attributesHarleyharli
N
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.

Neighboring answered 17/12, 2017 at 6:22 Comment(2)
The code sample seems to only work for setting the standard attributes, not extended attributes. I'm looking for a way to do the latter.Octangle
I've removed the code sample and clarified that part.Neighboring
P
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.)

Parochial answered 17/5, 2021 at 9:18 Comment(0)
S
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

Smyrna answered 27/2, 2023 at 22:35 Comment(0)
K
0

Sysinternals (available on Windows Store) has a program called streams that would query or delete the Alternate Data Streams (useful if you need to transfer files to a file system that does not support it)

Kurdish answered 10/1 at 19:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.