From f6b156b5bccac55814eeee4fd10013ea3a76f384 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Wed, 20 Aug 2014 16:04:34 -0600
Subject: ntdll: Implement retrieving DOS attributes in
 NtQuery[Full]AttributesFile and NtQueryDirectoryFile.

---
 dlls/ntdll/file.c   |  6 +++++-
 include/wine/port.h |  1 +
 libs/port/xattr.c   | 10 ++++++++++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 83d07e2..b977e45 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -152,7 +152,8 @@ int fd_get_file_info( int fd, struct stat *st, ULONG *attr )
 /* get the stat info and file attributes for a file (by name) */
 int get_file_info( const char *path, struct stat *st, ULONG *attr )
 {
-    int ret;
+    char hexattr[11];
+    int len, ret;
 
     *attr = 0;
     ret = lstat( path, st );
@@ -165,6 +166,9 @@ int get_file_info( const char *path, struct stat *st, ULONG *attr )
         if (S_ISDIR( st->st_mode )) *attr |= FILE_ATTRIBUTE_REPARSE_POINT;
     }
     *attr |= get_file_attributes( st );
+    len = xattr_get( path, SAMBA_XATTR_DOS_ATTRIB, hexattr, sizeof(hexattr)-1 );
+    if (len == -1) return ret;
+    *attr |= get_file_xattr( hexattr, len );
     return ret;
 }
 
diff --git a/include/wine/port.h b/include/wine/port.h
index 521246b..7977eb9 100644
--- a/include/wine/port.h
+++ b/include/wine/port.h
@@ -370,6 +370,7 @@ extern int _spawnvp(int mode, const char *cmdname, const char * const argv[]);
 #endif
 
 extern int xattr_fget( int filedes, const char *name, void *value, size_t size );
+extern int xattr_get( const char *path, const char *name, void *value, size_t size );
 
 /* Interlocked functions */
 
diff --git a/libs/port/xattr.c b/libs/port/xattr.c
index 94b7713..88e900d 100644
--- a/libs/port/xattr.c
+++ b/libs/port/xattr.c
@@ -37,3 +37,13 @@ int xattr_fget( int filedes, const char *name, void *value, size_t size )
     return -1;
 #endif
 }
+
+int xattr_get( const char *path, const char *name, void *value, size_t size )
+{
+#if defined(HAVE_ATTR_XATTR_H)
+    return getxattr( path, name, value, size );
+#else
+    errno = ENOSYS;
+    return -1;
+#endif
+}
-- 
1.9.1

