[ntdll, cmd] Implement file attributes with xattr on mac and linux (fixes bug 15679)

Dan Kegel dank at kegel.com
Tue Sep 8 09:11:06 CDT 2009


Fixes http://bugs.winehq.org/show_bug.cgi?id=15679
In particular, cygwin's /bin/vi (which is a cygwin symlink
to vim.exe) now works in wine.

This patch uses filesystem extended attributes in
a way compatible with Samba 3 to store the win32 attribute bits.
It builds and runs on mac and linux, passes tests on linux and vista,
and should be easy-ish to port to solaris (though who knows
what xattr solaris' native cifs server uses, hopefully it's the
same as what samba 3 does).

Samba 3 and this patch store win32 file attributes
are stored as 0x followed by a one or two digit hex number in the
extended attribute named user.DOSATTRIB.

For backwards compatibility, if a file lacks native extended
attributes, wine synthesizes the ARCHIVE win32 attribute.
Likewise, if a file just has the ARCHIVE win32 attribute set,
wine does not set a native extended attribute.

Here's an example:
  touch foo.dat
  wine cmd /c attrib -a foo.dat
  xattr -l foo.dat
This outputs
  user.DOSATTRIB: 0x0

i.e. because the file has anything but the default attribute, we store
the entire win32 attribute bitmask in the extended attribute.

Another example:
  touch bar.dat
  wine cmd /c attrib +s bar.dat
  xattr -l bar.dat
This outputs
  user.DOSATTRIB: 0x24
or ARCHIVE | SYSTEM.

Note: the implementation of attrib in cmd is lame -- it only handles
two arguments.  It's enough for the moment, but the real attrib
can handle multiple attribute flags, and we should support that sometime.
Maybe the thing to do is merge EA Durbin's standalone attrib.exe patch, see
http://bugs.winehq.org/show_bug.cgi?id=18059
http://www.winehq.org/pipermail/wine-patches/2009-August/077184.html

Also note: we don't do the right thing on fat32 or ntfs yet, this
is just for emulating the dos attributes on native unix filesystems.

Finally, this patch adds a few tests, some of which are skipped
because our size for FILE_ALL_INFORMATION is too small,
causing Vista's NtQueryInformationFile to report buffer overflow.

(Why are we 4-5 years behind Samba on this?  Well,
it's only recently that desktop linux began shipping with
xattr support turned on by default, and only recently did
cygwin start working well enough on wine for this to
matter.  I'm not sure I've run into any other apps that
really need this, other than perhaps bug 9158.)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: attrib-6.patch
Type: text/x-patch
Size: 38373 bytes
Desc: not available
URL: <http://www.winehq.org/pipermail/wine-patches/attachments/20090908/db865417/attachment-0001.bin>


More information about the wine-patches mailing list