This patch set is based upon [patches from Wine Staging](https://github.com/wine-staging/wine-staging/tree/master/patches/n…, and implements support for the `SYSTEM`, `HIDDEN` and `READONLY` DOS file attributes. These have been implemented in various ways depending upon the capabilities of the operating system and the file system.
# Storage Methods
## FAT MSDOS file attributes
* Linux: [`ioctl_fat(2)`](https://www.man7.org/linux/man-pages/man2/ioctl_fat.2.html)
On Linux, the FAT filesystem implementation allows DOS file attributes to be applied to files and
queried through a family of ioctls. Note that these ioctls are not yet supported by the NTFS or CIFS
drivers.
## Extended File Attributes
* Linux: [`xattr(7)`](https://www.man7.org/linux/man-pages/man7/xattr.7.html)
* MacOS: [`getxattr(2)`](https://www.unix.com/man-page/osx/2/getxattr/), [`setxattr(2)`](https://www.unix.com/man-page/osx/2/setxattr/), [`removexattr(2)`](https://www.unix.com/man-page/osx/2/removexattr/)
* FreeBSD, NetBSD: [`extattr(2)`](https://nixdoc.net/man-pages/FreeBSD/man2/extattr.2.html)
Modern filesystems generally support Extended File Attributes - auxiliary blobs of binary data that can be attached to a file. Samba uses the `user.DOSATTRIB` attribute to store DOS attribute information in the form of a hexadecimal value.
Note that although FreeBSD and NetBSD support the extended attribute system calls, these are not currently implemented in the operating system, or supported in any of their filesystem drivers.
## BSD File Flags
* MacOS: [`fchflags(2)`](https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/fchflags.2.html)
* FreeBSD, NetBSD: [`fchflags(2)`](https://nixdoc.net/man-pages/FreeBSD/man2/fchflags.2.html)
On some BSD-like operating systems including MacOS, FreeBSD and NetBSD, the `struct stat` structure contains the `st_flags` member can carry flags of which the following can be used to represent DOS attributes:
* `UF_IMMUTABLE` can represent `FILE_ATTRIBUTE_READONLY`
* `UF_HIDDEN` can reprent `FILE_ATTRIBUTE_HIDDEN` (not available on NetBSD)
# Design
The implementation is takes an opportunistic approach. It will attempt to store flags by any of the above mentioned methods, and will retrieve flags using any available method and will combine flags from multiple sources together.
# See Also
* https://bugs.winehq.org/show_bug.cgi?id=9158
* https://bugs.winehq.org/show_bug.cgi?id=15679
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/924