[v2 2/3] ntdll: Implement FileIdInformation class support in NtQueryInformationFile.

Jonathan Doron jond at wizery.com
Thu Jan 26 05:09:58 CST 2017


Signed-off-by: Jonathan Doron <jond at wizery.com>
---
 configure           | 24 ++++++++++++++++++++++++
 configure.ac        | 16 ++++++++++++++++
 dlls/ntdll/file.c   | 22 +++++++++++++++++++++-
 include/config.h.in |  3 +++
 include/winbase.h   |  9 +++++++++
 5 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 1a96117..a9d7878 100755
--- a/configure
+++ b/configure
@@ -16407,6 +16407,30 @@ _ACEOF
 fi
 
 
+ac_fn_c_check_member "$LINENO" "struct statfs" "f_fsid.__val" "ac_cv_member_struct_statfs_f_fsid___val" "#include <sys/types.h>
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+#ifdef HAVE_SYS_MOUNT_H
+# include <sys/mount.h>
+#endif
+#ifdef HAVE_SYS_VFS_H
+# include <sys/vfs.h>
+#endif
+#ifdef HAVE_SYS_STATFS_H
+# include <sys/statfs.h>
+#endif
+"
+if test "x$ac_cv_member_struct_statfs_f_fsid___val" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_STATFS_F_SID_VAL 1
+_ACEOF
+
+
+fi
+
+
 ac_fn_c_check_member "$LINENO" "struct statvfs" "f_blocks" "ac_cv_member_struct_statvfs_f_blocks" "#ifdef HAVE_SYS_STATVFS_H
 #include <sys/statvfs.h>
 #endif
diff --git a/configure.ac b/configure.ac
index 353f271..3790a39 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2277,6 +2277,22 @@ AC_CHECK_MEMBERS([struct statfs.f_bfree, struct statfs.f_bavail, struct statfs.f
 # include <sys/statfs.h>
 #endif])
 
+dnl Check for f_fsid.__val
+AC_CHECK_MEMBERS([struct f_fsid.f_fsid.__val],,,
+[#include <sys/types.h>
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+#ifdef HAVE_SYS_MOUNT_H
+# include <sys/mount.h>
+#endif
+#ifdef HAVE_SYS_VFS_H
+# include <sys/vfs.h>
+#endif
+#ifdef HAVE_SYS_STATFS_H
+# include <sys/statfs.h>
+#endif])
+
 AC_CHECK_MEMBERS([struct statvfs.f_blocks],,,
 [#ifdef HAVE_SYS_STATVFS_H
 #include <sys/statvfs.h>
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 6eddd19..38ca0c5 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -2379,7 +2379,7 @@ NTSTATUS WINAPI NtQueryInformationFile( HANDLE hFile, PIO_STATUS_BLOCK io,
         0,                                             /* FileRenameInformationBypassAccessCheck */
         0,                                             /* FileLinkInformationBypassAccessCheck */
         0,                                             /* FileVolumeNameInformation */
-        0,                                             /* FileIdInformation */
+        sizeof(FILE_ID_INFORMATION),                   /* FileIdInformation */
         0,                                             /* FileIdExtdDirectoryInformation */
         0,                                             /* FileReplaceCompletionInformation */
         0,                                             /* FileHardLinkFullIdInformation */
@@ -2621,6 +2621,26 @@ NTSTATUS WINAPI NtQueryInformationFile( HANDLE hFile, PIO_STATUS_BLOCK io,
             }
         }
         break;
+    case FileIdInformation:
+        {
+            struct statfs volstats;
+            FILE_ID_INFORMATION *info = ptr;
+            if ((fstat(fd, &st) == -1) || (fstatfs(fd, &volstats) == -1))
+            {
+                io->u.Status = FILE_GetNtStatus();
+            }
+            else
+            {
+                memset(info, 0, sizeof(*info));
+#ifdef HAVE_STRUCT_STATFS_F_SID_VAL
+                memcpy(&info->VolumeSerialNumber,
+                       &volstats.f_fsid.__val,
+                       min(sizeof(info->VolumeSerialNumber), sizeof(volstats.f_fsid.__val)));
+#endif
+                ((PLARGE_INTEGER)&info->FileId)->QuadPart = st.st_ino;
+            }
+        }
+        break;
     default:
         FIXME("Unsupported class (%d)\n", class);
         io->u.Status = STATUS_NOT_IMPLEMENTED;
diff --git a/include/config.h.in b/include/config.h.in
index 5dcd90b..6bba9df 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -963,6 +963,9 @@
 /* Define to 1 if `f_namelen' is a member of `struct statfs'. */
 #undef HAVE_STRUCT_STATFS_F_NAMELEN
 
+/* Define to 1 if `f_fsid.__val' is a member of `struct statfs'. */
+#undef HAVE_STRUCT_STATFS_F_SID_VAL
+
 /* Define to 1 if `f_blocks' is a member of `struct statvfs'. */
 #undef HAVE_STRUCT_STATVFS_F_BLOCKS
 
diff --git a/include/winbase.h b/include/winbase.h
index eff5972..83c27f8 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -905,6 +905,15 @@ typedef struct _FILE_REMOTE_PROTOCOL_INFO {
     } ProtocolSpecificReserved;
 } FILE_REMOTE_PROTOCOL_INFO, *PFILE_REMOTE_PROTOCOL_INFO;
 
+typedef struct _FILE_ID_128 {
+    BYTE Identifier[16];
+} FILE_ID_128, *PFILE_ID_128;
+
+typedef struct _FILE_ID_INFORMATION {
+    ULONGLONG VolumeSerialNumber;
+    FILE_ID_128 FileId;
+} FILE_ID_INFORMATION, *PFILE_ID_INFORMATION;
+
 #define PIPE_ACCESS_INBOUND  1
 #define PIPE_ACCESS_OUTBOUND 2
 #define PIPE_ACCESS_DUPLEX   3
-- 
2.9.3




More information about the wine-patches mailing list