From: Gabriel Ivăncescu Subject: [PATCH v4 2/2] ntdll/server: Mark drive_c as case-insensitive when created Message-Id: <23918289964c4dceb9f687d47eff10e938c2a0a8.1559916311.git.gabrielopcode@gmail.com> Date: Fri, 7 Jun 2019 17:12:15 +0300 In-Reply-To: References: Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47099 Signed-off-by: Gabriel Ivăncescu --- dlls/ntdll/server.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c index 094b530..7dff7c1 100644 --- a/dlls/ntdll/server.c +++ b/dlls/ntdll/server.c @@ -51,6 +51,12 @@ #ifdef HAVE_SYS_MMAN_H #include #endif +#ifdef HAVE_SYS_IOCTL_H +#include +#endif +#ifdef HAVE_LINUX_IOCTL_H +#include +#endif #ifdef HAVE_SYS_PRCTL_H # include #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 possible. + */ +static void set_case_insensitive(const char *dir) +{ +#ifdef 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