Why do we apply XATTR_ATTRIBS_MASK when setting file attributes, but not getting them? Admittedly it's not quite clear to me whether to do one or the other, but the inconsistency is confusing.
You have that backwards, we store everything when setting (`FILE_ATTRIBUTE_NORMAL` is 0, the absence of other attributes, so `flags & ~0` gives everything) and mask out the values for Wine when reading (`XATTR_ATTRIBS_MASK` is for the attributes Wine will pay attention to).
I will note however that this will presumably set FILE_ATTRIBUTE_DIRECTORY on directories, which probably isn't what we want. We may also want to mask out FILE_ATTRIBUTE_REPARSE_POINT if Windows isn't going to handle it correctly.
I would suggest that, for correctness, we wish to store all attributes and on reading we mask out the values we need. So, we store `FILE_ATTRIBUTE_DIRECTORY` (or whatever else we have) when we create and we decide for ourselves whether it's a directory just like we do now.
I also notice that CreateFile() applies FILE_ATTRIBUTE_ARCHIVE to all files regardless of whether it was requested. Should we mask that out as well? Then again, I don't know if there's any real (space) cost to setting that on all Wine files, and maybe we should do it for correctness anyway.
I don't know why `CreateFile` does this, but if that's correct behavior then I would say we should store it.