[PATCH v3 2/2] ntdll/server: Mark drive_c as case-insensitive when created

Gabriel Ivăncescu gabrielopcode at gmail.com
Fri May 24 07:09:35 CDT 2019


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47099
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---

This marks the 'drive_c' directory as case-insensitive for filesystems
that support it, when it is created on new prefixes (because it has to be
empty anyway).

The macro constant definitions were made similar in style to those in
ntdll/directory.

 dlls/ntdll/server.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c
index 094b530..ae12105 100644
--- a/dlls/ntdll/server.c
+++ b/dlls/ntdll/server.c
@@ -51,6 +51,12 @@
 #ifdef HAVE_SYS_MMAN_H
 #include <sys/mman.h>
 #endif
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+#ifdef HAVE_LINUX_IOCTL_H
+#include <linux/ioctl.h>
+#endif
 #ifdef HAVE_SYS_PRCTL_H
 # include <sys/prctl.h>
 #endif
@@ -84,6 +90,22 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(server);
 
+/* just in case... */
+#undef EXT2_IOC_GETFLAGS
+#undef EXT2_IOC_SETFLAGS
+#undef EXT4_CASEFOLD_FL
+
+#ifdef __linux__
+
+/* Define the ext2 ioctls for handling extra attributes */
+#define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
+#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
+
+/* Case-insensitivity attribute */
+#define EXT4_CASEFOLD_FL 0x40000000
+
+#endif
+
 /* Some versions of glibc don't define this */
 #ifndef SCM_RIGHTS
 #define SCM_RIGHTS 1
@@ -1119,6 +1141,28 @@ static void start_server(void)
 }
 
 
+/***********************************************************************
+ *           set_case_insensitive
+ *
+ * Make the supplied directory case insensitive, if available.
+ */
+static void set_case_insensitive(const char *dir)
+{
+#if defined(EXT2_IOC_GETFLAGS) && defined(EXT2_IOC_SETFLAGS) && defined(EXT4_CASEFOLD_FL)
+    int flags, fd;
+
+    if ((fd = open(dir, O_RDONLY | O_NONBLOCK | O_LARGEFILE)) == -1)
+        return;
+    if (ioctl(fd, EXT2_IOC_GETFLAGS, &flags) != -1 && !(flags & EXT4_CASEFOLD_FL))
+    {
+        flags |= EXT4_CASEFOLD_FL;
+        ioctl(fd, EXT2_IOC_SETFLAGS, &flags);
+    }
+    close(fd);
+#endif
+}
+
+
 /***********************************************************************
  *           setup_config_dir
  *
@@ -1162,6 +1206,7 @@ static int setup_config_dir(void)
     /* create the drive symlinks */
 
     mkdir( "drive_c", 0777 );
+    set_case_insensitive( "drive_c" );
     symlink( "../drive_c", "dosdevices/c:" );
     symlink( "/", "dosdevices/z:" );
 
-- 
2.21.0




More information about the wine-devel mailing list