7

I just opened help for ATTRIB command on Windows 10.0.15063, and found out that there are new attributes I didn't know about.

>attrib /?
Displays or changes file attributes.

ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] [+O | -O] [+I | -I] [+P | -P] [+U | -U]
       [drive:][path][filename] [/S [/D]] [/L]

  +   Sets an attribute.
  -   Clears an attribute.
  R   Read-only file attribute.
  A   Archive file attribute.
  S   System file attribute.
  H   Hidden file attribute.
  O   Offline attribute.
  I   Not content indexed file attribute.
  X   No scrub file attribute.
  V   Integrity attribute.
  P   Pinned attribute.
  U   Unpinned attribute.
  [drive:][path][filename]
      Specifies a file or files for attrib to process.
  /S  Processes matching files in the current folder
      and all subfolders.
  /D  Processes folders as well.
  /L  Work on the attributes of the Symbolic Link versus
      the target of the Symbolic Link

(specifically, X, V, P, U)

And I can set +X via ATTRIB command, even though it's not listed as modifiable.

I don't know what they do or used for though. And I didn't manage to google out anything useful except lists not much more useful than the help itself. Even Microsoft' own help does not help.I tried googling. Really!

5

There are new attributes I didn't know about.

V Integrity attribute.

This is related to checking for file corruption:

Integrity-streams - ReFS uses checksums for metadata and optionally for file data, giving ReFS the ability to reliably detect corruptions.

Source Resilient File System (ReFS) overview

FILE_ATTRIBUTE_INTEGRITY_STREAM

The directory or user data stream is configured with integrity (only supported on ReFS volumes). It is not included in an ordinary directory listing. The integrity setting persists with the file if it's renamed. If a file is copied the destination file will have integrity set if either the source file or destination directory have integrity set.

Source File Attribute Constants


X No scrub file attribute.

This is related to error correction:

Proactive error correction - In addition to validating data before reads and writes, ReFS introduces a data integrity scanner, known as a scrubber. This scrubber periodically scans the volume, identifying latent corruptions and proactively triggering a repair of corrupt data.

Source Resilient File System (ReFS) overview

FILE_ATTRIBUTE_NO_SCRUB_DATA

The user data stream not to be read by the background data integrity scanner (AKA scrubber). When set on a directory it only provides inheritance. This flag is only supported on Storage Spaces and ReFS volumes. It is not included in an ordinary directory listing.

Source File Attribute Constants


P Pinned attribute.

This indicates that the file is a Sparse File:

A sparse file has an attribute that causes the I/O subsystem to allocate only meaningful (nonzero) data. Nonzero data is allocated on disk, and non-meaningful data (large strings of data composed of zeros) is not. When a sparse file is read, allocated data is returned as it was stored; non-allocated data is returned, by default, as zeros.

NTFS deallocates sparse data streams and only maintains other data as allocated. When a program accesses a sparse file, the file system yields allocated data as actual data and deallocated data as zeros.

NTFS includes full sparse file support for both compressed and uncompressed files. NTFS handles read operations on sparse files by returning allocated data and sparse data. It is possible to read a sparse file as allocated data and a range of data without retrieving the entire data set, although NTFS returns the entire data set by default.

With the sparse file attribute set, the file system can deallocate data from anywhere in the file and, when an application calls, yield the zero data by range instead of storing and returning the actual data. File system application programming interfaces (APIs) allow for the file to be copied or backed as actual bits and sparse stream ranges. The net result is efficient file system storage and access. Next figure shows how data is stored with and without the sparse file attribute set.

Source NTFS Sparse Files

FILE_ATTRIBUTE_SPARSE_FILE

A file that is a sparse file.

Source File Attribute Constants


Further Reading

  • hm how did you link "Pinned" to sparse? Also, how it's possible that "Sparse" attribute can be set or removed via ATTRIB command? And one more: there's «Unpinned» attribute, which is mutually exclusive with "Pinned", but both Pinned and Unpinned can be unset simultaneously (so there is no explanation what is it?). – LogicDaemon May 31 '17 at 11:42
  • @LogicDaemon Because p was sparse in previous versions of Windows. There is no indication that the file attributes API has changed for this version of Windows 10. – DavidPostill May 31 '17 at 12:14
  • @LogicDaemon Note also sparse has disappeared from the list. – DavidPostill May 31 '17 at 12:15
  • okay, but can you just mark any file sparse? You can mark any file pinned though. No elevation required imgur.com/aotouix – LogicDaemon Jun 1 '17 at 5:24
  • 2
    Note that in the latest SDK headers there is FILE_ATTRIBUTE_PINNED. This refers to the "Always available on this device" setting for OneDrive files. – Jonathan Potter Oct 26 '17 at 8:35
5

There are actually more new attributes found in C:\Program Files (x86)\Windows Kits\10\Include\10.0.16299.0\um\winnt.h:

FILE_ATTRIBUTE_UNPINNED              = 0x00100000
FILE_ATTRIBUTE_PINNED                = 0x00080000
FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x00400000

Only the last one is documented at https://msdn.microsoft.com/en-us/library/windows/desktop/gg258117%28v=vs.85%29.aspx

Based on https://techcommunity.microsoft.com/t5/OneDrive-for-Business/Files-on-demand-difference-in-locally-available-and-always/m-p/118203#M2781 my guess is that the "Pinned" flag is used to prevent that the file is purged from local storage when running low on disk space. The "Unpinned" attribute, OTOH, seems to be used to indicate that you want to force that the file is not stored locally.

I'm currently investigating how these attributes are used by the new "OneDrive Files On Demand" feature (https://support.office.com/en-us/article/Learn-about-OneDrive-Files-On-Demand-0E6860D3-D9F3-4971-B321-7092438FB38E).

See https://social.technet.microsoft.com/Forums/windows/en-US/375f3933-fcab-450c-bb9c-da54155549e2/how-do-i-getset-onedrive-files-on-demand-status-from-powershell?forum=ITCG if you want to learn from these investigations.

1

It is correct to be able to set NO SCRUB(X) with NTFS.
NTFS does check readable and recovers if needed.
Since there is no checksum, NTFS do not check whether the data is correct.
It makes sense only on the redundant Storage Spaces.
This is one of information sources.
(see slide #30)

P is not sparse attribute.
Because "Get-Item | Format-List Attributes" in Powershell will print "Sparse" when sparse attribute.
But Pinned attribute will be hex value, not meaningful string.
Sorry, I don't know what is pinnd/unpinned.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.