[PATCH 3/4] ntdll: Implement storing DOS attributes in NtSetInformationFile.

cdavis5x at gmail.com cdavis5x at gmail.com
Thu Dec 18 14:23:53 CST 2014


> On Dec 18, 2014, at 10:16 AM, Erich E. Hoover <erich.e.hoover at gmail.com> wrote:
> This patch implements storing DOS attributes in the Samba format
> "user.DOSATTRIB" extended attribute using fsetxattr and fremovexattr.
> FILE_ATTRIBUTE_NORMAL is masked out since that attribute is
> unnecessary, and leaving it out avoids having to store an attribute
> for every file on the system.
Only NORMAL?

There are quite a few DOS attributes. Here’s a list from <winnt.h>:

#define FILE_ATTRIBUTE_READONLY            0x00000001
#define FILE_ATTRIBUTE_HIDDEN              0x00000002
#define FILE_ATTRIBUTE_SYSTEM              0x00000004
#define FILE_ATTRIBUTE_DIRECTORY           0x00000010
#define FILE_ATTRIBUTE_ARCHIVE             0x00000020
#define FILE_ATTRIBUTE_DEVICE              0x00000040
#define FILE_ATTRIBUTE_NORMAL              0x00000080
#define FILE_ATTRIBUTE_TEMPORARY           0x00000100
#define FILE_ATTRIBUTE_SPARSE_FILE         0x00000200
#define FILE_ATTRIBUTE_REPARSE_POINT       0x00000400
#define FILE_ATTRIBUTE_COMPRESSED          0x00000800
#define FILE_ATTRIBUTE_OFFLINE             0x00001000
#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
#define FILE_ATTRIBUTE_ENCRYPTED           0x00004000

(Yes, all of those are in Microsoft’s public headers. I checked.)

Of those, these are the ones that Samba lets clients set:

FILE_ATTRIBUTE_READONLY
FILE_ATTRIBUTE_HIDDEN
FILE_ATTRIBUTE_SYSTEM
FILE_ATTRIBUTE_ARCHIVE
FILE_ATTRIBUTE_OFFLINE

and these are the ones that Samba returns:

FILE_ATTRIBUTE_READONLY
FILE_ATTRIBUTE_HIDDEN
FILE_ATTRIBUTE_SYSTEM
FILE_ATTRIBUTE_DIRECTORY
FILE_ATTRIBUTE_ARCHIVE
FILE_ATTRIBUTE_SPARSE_FILE

(Weird. They let people set OFFLINE, but never return it…)

These are the ones that MSDN says Windows lets programs set with SetFileAttributes() (but I can’t vouch for MSDN’s accuracy, so this really needs to be demonstrated with a test):

FILE_ATTRIBUTE_READONLY
FILE_ATTRIBUTE_HIDDEN
FILE_ATTRIBUTE_SYSTEM
FILE_ATTRIBUTE_NORMAL
FILE_ATTRIBUTE_ARCHIVE
FILE_ATTRIBUTE_TEMPORARY
FILE_ATTRIBUTE_OFFLINE
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED

and these are the ones that CreateFile() is supposed to let programs set:

FILE_ATTRIBUTE_READONLY
FILE_ATTRIBUTE_HIDDEN
FILE_ATTRIBUTE_SYSTEM
FILE_ATTRIBUTE_NORMAL
FILE_ATTRIBUTE_ARCHIVE
FILE_ATTRIBUTE_TEMPORARY
FILE_ATTRIBUTE_OFFLINE
FILE_ATTRIBUTE_ENCRYPTED

I definitely think we shouldn’t be letting people set the DEVICE attribute (this is, I suspect, the attribute you get from a device handle), or the REPARSE_POINT attribute (this is what Windows returns for e.g. symlinks and junctions); MSDN says that the SET_REPARSE_POINT FSCTL is supposed to be able to set this attribute, though.

Samba also forcibly sets the DIRECTORY attribute according to whether the file is or is not actually a directory; we should do this, too.

MSDN also says the COMPRESSED attribute is supposed to be set by the SET_COMPRESSION FSCTL, the ENCRYPTED attribute is supposed to be set by advapi32.EncryptFile() (which I suspect just makes a SET_ENCRYPTION FSCTL) or when the file is created, and the SPARSE_FILE attribute is supposed to be set by the SET_SPARSE FSCTL, so we should mask all those out too. (Or error out, depending on what native does; as always, the tests are your friends here.)

Also, NORMAL is only supposed to be valid by itself, so if any attributes are set along with NORMAL, we may need to error out.

We REALLY need tests for all this. ;) (We have some tests for setting file attributes, but not enough IMO.)

Chip


More information about the wine-devel mailing list