NTFS Documentation: File Name Attribute

Interest

Name of the file. This file attribute is always resident.

NTFS has an advantage: as you can have several file name attributes for one file, you can easily implement POSIX hard links as a file with multiple file name attributes. When you delete a POSIX hard link, only the corresponding file name attribute is deleted. If there is no file name attribute left, then the file is really deleted.

One lightly different application of that is the automatic generation of a DOS® file name based on the Win32 file name, which occurs when you give a name to a file that doesn't fit into the DOS® filename space. Then, both names are real synonyms (in particular, you can really delete the file using anyone of the two names), allowing to old DOS® clients to have an access to all the files of a Windows NT® server. The generation algorithm is:

  1. Remove all Unicode characters
  2. Remove all '.' but the last one if it is not the first character
  3. Uppercase all letters
  4. Remove forbidden characters
  5. Truncate everything before the potential '.' to 6 characters, and add the string "~1"
  6. Truncate everything after the potential '.' to 3 characters
  7. While the name already exists, increment the string "~1"

    Note: Step 7 means that although the generated DOS® name is unique, it is impossible to deduce it from the Win32 name only.

Layout of the stream

Offset to the beginning of the stream Length Description
0 8 File reference to the base FILE record of the directory containing this name
8 20 File modification times
28 8 Allocated size of the file
30 8 Real size of the file
38 8 Flags
40 1 L=Length of the file name
41 1 File name space
42 2*L File name in Unicode

Flags
This is a superset of the standard attribute DOS® file permissions

Bit Signification
00 00 00 00 10 00 00 00 Directory
00 00 00 00 00 00 08 00 Compressed
00 00 00 00 00 00 00 20 Archive
00 00 00 00 00 00 00 04 System
00 00 00 00 00 00 00 02 Hidden
00 00 00 00 00 00 00 01 Read-only

Filename space
This specifies to which filename space the file name belongs.

Value Signification
0 POSIX space: any Unicode character but 0 (null) and '/'. Names are case sensitive.
1 Win32 space: sub-space of the POSIX space, characters '"' '*' '/' ':' '<' '>' '?' '\' '|' are forbidden. Names can't end with a '.' or a ' ' and are case insensitive.
2 DOS® space: sub-space of the Win32 space, allowing only 8 bit characters greater than ' ' and different from '"' '*' '+' ',' ':' ';' '<' '=' '>' '?' '\'. Names must match the following pattern: 1 to 8 characters, then '.', then 1 to 3 characters. Letters must be in uppercase.
3 Both Win32 and DOS® spaces: The provided Win32 name already belongs to the DOS® space, so there is no need to generate an additional DOS® name.

Note:

Questions


Regis Duchesne at VIA, ECP, France
Last modified: Mon Feb 15 07:06:41 PST 1999