CIFS File and DFS Path Names

CIFS file names may be in short or long formats. A client indicates support for long file name formats by setting bit2 in the Flags2 field of the CIFS packet header. The wildcard characters "?" and "*" are supported in file names.

File names in the CIFS protocol consist of components separated by a backslash ('\').

In legacy dialects of SMB, file name components are in an 8.3 format composed of a basename of no more than 8 characters, and an extension of no more than 3 characters. The basename and extension are separated by a period '.'. All characters are legal in the basename and extension except the space character (0x20) and the following characters:

" . / \[]:+|<>=;,*?

If the client has indicated long name support, a server may return file names that have a total length of up to 255 characters. This capability was introduced with the LM1.2X002 protocol dialect.

DFS Path Names

A DFS (Distributed File System) path name is in the same format as a file name. A client accessing a DFS share sets bit12 in the Flags2 field of the request packet header to indicate that the server is to resolve the enclosed path name in the DFS namespace. The path name should always have the full file name, including the server and share names.

Wildcard Characters

Using wildcards in a file name allows a client to request that a number of files be operated on as a unit, without having to separately enumerate the files.

The ? character is a wildcard for a single character. If a file name component begins with one or more "?"s, then exactly that number of characters are matched by the wildcards: for example, "??x" equals "abx" but not "abcx" or "ax". When a file name component has trailing "?"s, then file name matches are matched by the specified number of characters or less: for example, "x??" matches "xab", "xa" and "x", but not "xabc". If only "?"s are present in the file name component, then it is handled as for trailing "?"s.

The * character matches an entire component of the name, as does an empty specification for that component. A component consisting of * means that the rest of the component should be filled with ? and the search should be performed with this wildcard character. For example, "*.abc" or ".abc" match any file with an extension of "abc". "*.*", "*" or "null" match all files in a directory.

If the client is using 8.3 format names, the basename and extension are treated separately. For long file names, the '.' in the name is significant even though there is no longer a restriction on the size of each of the components.

If the negotiated dialect is "NTLM 0.12" or later, and the client requires MS-DOS wildcard matching semantics, UNICODE wildcards should be translated according to the following rules:

  • Translate the ? literal to >
  • Translate the . literal to " if it is followed by a ? or a *
  • Translate the * literal to < if it is followed by a .

The translation can be performed in place.

See Also

Royalty-Free CIFS Technical Reference License Agreement