Rebase against fb4d36c66131d1c45ebdcb5d56151e8f7782ebd1.

This commit is contained in:
Alistair Leslie-Hughes
2023-07-12 08:54:04 +10:00
parent e5cf862a14
commit a88d536fba
5 changed files with 97 additions and 97 deletions

View File

@@ -1,4 +1,4 @@
From 3c2f30734ab4ab7a602f1f66d415a245063ee6d8 Mon Sep 17 00:00:00 2001
From dbd70302047bc3c592882cb6d93f6251f49e27c7 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 16 Jan 2014 20:56:49 -0700
Subject: [PATCH] ntdll: Add support for creating reparse points.
@@ -13,10 +13,10 @@ Signed-off-by: Erich E. Hoover <erich.e.hoover@gmail.com>
5 files changed, 447 insertions(+), 19 deletions(-)
diff --git a/configure.ac b/configure.ac
index c4f34e9e851..ec76805b3e6 100644
index 0b57210400b..e2f8d2ddfe3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2025,6 +2025,8 @@ AC_CHECK_FUNCS(\
@@ -2044,6 +2044,8 @@ AC_CHECK_FUNCS(\
prctl \
proc_pidinfo \
sched_yield \
@@ -39,7 +39,7 @@ index 2e862c68b7e..f8ca3e689ec 100644
EXTRADLLFLAGS = -nodefaultlibs
i386_EXTRADLLFLAGS = -Wl,--image-base,0x7bc00000
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index 6186afdfb63..7f753caef47 100644
index d4d80efe13b..592d7815026 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -38,6 +38,7 @@
@@ -50,7 +50,7 @@ index 6186afdfb63..7f753caef47 100644
#ifndef IO_COMPLETION_ALL_ACCESS
#define IO_COMPLETION_ALL_ACCESS 0x001F0003
@@ -5406,32 +5407,154 @@ static void test_mailslot_name(void)
@@ -5574,32 +5575,154 @@ static void test_mailslot_name(void)
CloseHandle( device );
}
@@ -101,9 +101,7 @@ index 6186afdfb63..7f753caef47 100644
+ INT buffer_len;
+ HANDLE handle;
+ BOOL bret;
- pRtlInitUnicodeString( &nameW, L"\\??\\C:\\" );
- InitializeObjectAttributes( &attr, &nameW, 0, NULL, NULL );
+
+ /* Create a temporary folder for the junction point tests */
+ GetTempFileNameW(dotW, fooW, 0, path);
+ DeleteFileW(path);
@@ -112,9 +110,7 @@ index 6186afdfb63..7f753caef47 100644
+ win_skip("Unable to create a temporary junction point directory.\n");
+ return;
+ }
- status = pNtOpenFile( &handle, READ_CONTROL, &attr, &io, 0, 0 );
- ok( !status, "open %s failed %#lx\n", wine_dbgstr_w(nameW.Buffer), status );
+
+ /* Check that the volume this folder is located on supports junction points */
+ pRtlDosPathNameToNtPathName_U(path, &nameW, NULL, NULL);
+ volW[0] = nameW.Buffer[4];
@@ -131,17 +127,15 @@ index 6186afdfb63..7f753caef47 100644
+ RemoveDirectoryW(path);
+ return;
+ }
- status = pNtFsControlFile( handle, NULL, NULL, NULL, &io, FSCTL_GET_REPARSE_POINT, NULL, 0, NULL, 0 );
- ok( status == STATUS_INVALID_USER_BUFFER, "expected %#lx, got %#lx\n", STATUS_INVALID_USER_BUFFER, status );
+
+ /* Create the folder to be replaced by a junction point */
+ lstrcpyW(reparse_path, path);
+ lstrcatW(reparse_path, reparseW);
+ bret = CreateDirectoryW(reparse_path, NULL);
+ ok(bret, "Failed to create junction point directory.\n");
- status = pNtFsControlFile( handle, NULL, NULL, NULL, &io, FSCTL_GET_REPARSE_POINT, NULL, 0, reparse_data, 0 );
- ok( status == STATUS_INVALID_USER_BUFFER, "expected %#lx, got %#lx\n", STATUS_INVALID_USER_BUFFER, status );
- pRtlInitUnicodeString( &nameW, L"\\??\\C:\\" );
- InitializeObjectAttributes( &attr, &nameW, 0, NULL, NULL );
+ /* Create a destination folder for the junction point to target */
+ lstrcpyW(target_path, path);
+ for (int i=0; i<1; i++)
@@ -154,9 +148,8 @@ index 6186afdfb63..7f753caef47 100644
+ ok(bret, "Failed to create junction point target directory.\n");
+ pRtlDosPathNameToNtPathName_U(path, &nameW, NULL, NULL);
- /* a volume cannot be a reparse point by definition */
- status = pNtFsControlFile( handle, NULL, NULL, NULL, &io, FSCTL_GET_REPARSE_POINT, NULL, 0, reparse_data, 1 );
- ok( status == STATUS_NOT_A_REPARSE_POINT, "expected %#lx, got %#lx\n", STATUS_NOT_A_REPARSE_POINT, status );
- status = pNtOpenFile( &handle, READ_CONTROL, &attr, &io, 0, 0 );
- ok( !status, "open %s failed %#lx\n", wine_dbgstr_w(nameW.Buffer), status );
+ /* construct a too long pathname (resulting reparse buffer over 16 kiB limit) */
+ long_path = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 32767);
+ lstrcpyW(long_path, nameW.Buffer);
@@ -166,8 +159,7 @@ index 6186afdfb63..7f753caef47 100644
+ lstrcatW(long_path, path);
+ }
+ lstrcatW(long_path, targetW);
- CloseHandle( handle );
+
+ /* Create the junction point */
+ handle = CreateFileW(reparse_path, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, 0);
@@ -181,7 +173,9 @@ index 6186afdfb63..7f753caef47 100644
+ ok(!bret && GetLastError()==ERROR_INVALID_REPARSE_DATA, "Unexpected error (0x%lx)\n", GetLastError());
+ HeapFree(GetProcessHeap(), 0, buffer);
+ CloseHandle(handle);
+
- status = pNtFsControlFile( handle, NULL, NULL, NULL, &io, FSCTL_GET_REPARSE_POINT, NULL, 0, NULL, 0 );
- ok( status == STATUS_INVALID_USER_BUFFER, "expected %#lx, got %#lx\n", STATUS_INVALID_USER_BUFFER, status );
+ /* construct a long pathname to demonstrate correct behavior with very large reparse points */
+ pRtlDosPathNameToNtPathName_U(path, &nameW, NULL, NULL);
+ lstrcpyW(long_path, nameW.Buffer);
@@ -191,11 +185,16 @@ index 6186afdfb63..7f753caef47 100644
+ lstrcatW(long_path, path);
+ }
+ lstrcatW(long_path, targetW);
+
- status = pNtFsControlFile( handle, NULL, NULL, NULL, &io, FSCTL_GET_REPARSE_POINT, NULL, 0, reparse_data, 0 );
- ok( status == STATUS_INVALID_USER_BUFFER, "expected %#lx, got %#lx\n", STATUS_INVALID_USER_BUFFER, status );
+ /* use a sane (not obscenely long) target for the rest of testing */
+ pRtlFreeUnicodeString(&nameW);
+ pRtlDosPathNameToNtPathName_U(target_path, &nameW, NULL, NULL);
+
- /* a volume cannot be a reparse point by definition */
- status = pNtFsControlFile( handle, NULL, NULL, NULL, &io, FSCTL_GET_REPARSE_POINT, NULL, 0, reparse_data, 1 );
- ok( status == STATUS_NOT_A_REPARSE_POINT, "expected %#lx, got %#lx\n", STATUS_NOT_A_REPARSE_POINT, status );
+ /* Create the junction point */
+ handle = CreateFileW(reparse_path, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, 0);
@@ -208,7 +207,8 @@ index 6186afdfb63..7f753caef47 100644
+ bret = DeviceIoControl(handle, FSCTL_SET_REPARSE_POINT, (LPVOID)buffer, buffer_len, NULL, 0, &dwret, 0);
+ ok(bret, "Failed to create junction point! (0x%lx)\n", GetLastError());
+ CloseHandle(handle);
+
- CloseHandle( handle );
+cleanup:
+ /* Cleanup */
+ pRtlFreeUnicodeString(&nameW);
@@ -222,7 +222,7 @@ index 6186afdfb63..7f753caef47 100644
}
START_TEST(file)
@@ -5506,6 +5629,6 @@ START_TEST(file)
@@ -5675,6 +5798,6 @@ START_TEST(file)
test_ioctl();
test_query_ea();
test_flush_buffers_file();
@@ -231,7 +231,7 @@ index 6186afdfb63..7f753caef47 100644
+ test_mailslot_name();
}
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index eca75b2d4fb..0cef6438c7e 100644
index eef21e12ceb..fbb33442460 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -36,6 +36,8 @@
@@ -243,7 +243,7 @@ index eca75b2d4fb..0cef6438c7e 100644
#include <limits.h>
#include <unistd.h>
#ifdef HAVE_MNTENT_H
@@ -125,6 +127,7 @@
@@ -124,6 +126,7 @@
#include "wine/list.h"
#include "wine/debug.h"
#include "unix_private.h"
@@ -251,7 +251,7 @@ index eca75b2d4fb..0cef6438c7e 100644
WINE_DEFAULT_DEBUG_CHANNEL(file);
WINE_DECLARE_DEBUG_CHANNEL(winediag);
@@ -136,6 +139,12 @@ WINE_DECLARE_DEBUG_CHANNEL(winediag);
@@ -135,6 +138,12 @@ WINE_DECLARE_DEBUG_CHANNEL(winediag);
#undef EXT2_IOC_GETFLAGS
#undef EXT4_CASEFOLD_FL
@@ -264,7 +264,7 @@ index eca75b2d4fb..0cef6438c7e 100644
#ifdef linux
/* We want the real kernel dirent structure, not the libc one */
@@ -247,6 +256,95 @@ static const BOOL is_case_sensitive = FALSE;
@@ -246,6 +255,95 @@ static const BOOL is_case_sensitive = FALSE;
static pthread_mutex_t dir_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t mnt_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -360,7 +360,7 @@ index eca75b2d4fb..0cef6438c7e 100644
/* check if a given Unicode char is OK in a DOS short name */
static inline BOOL is_invalid_dos_char( WCHAR ch )
{
@@ -1562,6 +1660,28 @@ static int parse_samba_dos_attrib_data( char *data, int len )
@@ -1565,6 +1663,28 @@ static int parse_samba_dos_attrib_data( char *data, int len )
}
@@ -389,7 +389,7 @@ index eca75b2d4fb..0cef6438c7e 100644
static BOOL fd_is_mount_point( int fd, const struct stat *st )
{
struct stat parent;
@@ -3335,6 +3455,181 @@ done:
@@ -3339,6 +3459,181 @@ done:
}
@@ -571,7 +571,7 @@ index eca75b2d4fb..0cef6438c7e 100644
/******************************************************************************
* lookup_unix_name
*
@@ -6099,6 +6394,13 @@ NTSTATUS WINAPI NtFsControlFile( HANDLE handle, HANDLE event, PIO_APC_ROUTINE ap
@@ -6127,6 +6422,13 @@ NTSTATUS WINAPI NtFsControlFile( HANDLE handle, HANDLE event, PIO_APC_ROUTINE ap
break;
}
@@ -586,17 +586,17 @@ index eca75b2d4fb..0cef6438c7e 100644
TRACE("FSCTL_SET_SPARSE: Ignoring request\n");
io->Information = 0;
diff --git a/include/Makefile.in b/include/Makefile.in
index f52314e745d..2ec4d835743 100644
index 5fd20858aee..53561e66c3e 100644
--- a/include/Makefile.in
+++ b/include/Makefile.in
@@ -572,6 +572,7 @@ SOURCES = \
@@ -576,6 +576,7 @@ SOURCES = \
ntdef.h \
ntdsapi.h \
ntgdi.h \
+ ntifs.h \
ntioring_x.h \
ntlsa.h \
ntquery.h \
ntsecapi.h \
--
2.39.2
2.40.1

View File

@@ -1,8 +1,8 @@
From 009a7b9e0b6be6fc559078b9544d4ca7b505a186 Mon Sep 17 00:00:00 2001
From 14e979a3f3623a580b592ebaff952445307b87c5 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Wed, 13 Mar 2019 16:02:05 -0600
Subject: kernel32: Implement CreateSymbolicLink[A|W] with ntdll reparse
points.
Subject: [PATCH] kernel32: Implement CreateSymbolicLink[A|W] with ntdll
reparse points.
Signed-off-by: Erich E. Hoover <erich.e.hoover@gmail.com>
---
@@ -14,10 +14,10 @@ Signed-off-by: Erich E. Hoover <erich.e.hoover@gmail.com>
5 files changed, 266 insertions(+), 81 deletions(-)
diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
index 2dd3eac3c26..97428dd4d95 100644
index f4bdc08b87e..49c4c6437a8 100644
--- a/dlls/kernel32/path.c
+++ b/dlls/kernel32/path.c
@@ -352,8 +352,16 @@ WCHAR * CDECL wine_get_dos_file_name( LPCSTR str )
@@ -463,8 +463,16 @@ WCHAR * CDECL wine_get_dos_file_name( LPCSTR str )
*/
BOOLEAN WINAPI CreateSymbolicLinkA(LPCSTR link, LPCSTR target, DWORD flags)
{
@@ -37,7 +37,7 @@ index 2dd3eac3c26..97428dd4d95 100644
/*************************************************************************
diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c
index 3c57e81f4c6..fa143cb4e48 100644
index 7e122780602..2ce175e1749 100644
--- a/dlls/kernel32/tests/path.c
+++ b/dlls/kernel32/tests/path.c
@@ -83,6 +83,9 @@ static NTSTATUS (WINAPI *pLdrGetDllPath)(LPCWSTR,ULONG,LPWSTR*,LPWSTR*);
@@ -58,7 +58,7 @@ index 3c57e81f4c6..fa143cb4e48 100644
mod = GetModuleHandleA("ntdll.dll");
MAKEFUNC(LdrGetDllPath);
MAKEFUNC(RtlGetExePath);
@@ -2692,6 +2696,95 @@ static void test_LdrGetDllPath(void)
@@ -2691,6 +2695,95 @@ static void test_LdrGetDllPath(void)
SetEnvironmentVariableW( pathW, old_path );
}
@@ -154,25 +154,25 @@ index 3c57e81f4c6..fa143cb4e48 100644
START_TEST(path)
{
CHAR origdir[MAX_PATH],curdir[MAX_PATH], curDrive, otherDrive;
@@ -2721,4 +2814,5 @@ START_TEST(path)
@@ -2720,4 +2813,5 @@ START_TEST(path)
test_RtlGetSearchPath();
test_RtlGetExePath();
test_LdrGetDllPath();
+ test_CreateSymbolicLink();
}
diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c
index 53b9651a8fa..bf6e9e17c9e 100644
index 2c261e0f57d..562440f4f8b 100644
--- a/dlls/kernelbase/file.c
+++ b/dlls/kernelbase/file.c
@@ -38,6 +38,7 @@
#include "shlwapi.h"
@@ -37,6 +37,7 @@
#include "ddk/ntddk.h"
#include "ddk/ntddser.h"
#include "ioringapi.h"
+#include "ntifs.h"
#include "kernelbase.h"
#include "wine/exception.h"
@@ -948,8 +949,106 @@ done:
@@ -946,8 +947,106 @@ done:
*/
BOOLEAN WINAPI /* DECLSPEC_HOTPATCH */ CreateSymbolicLinkW( LPCWSTR link, LPCWSTR target, DWORD flags )
{
@@ -424,7 +424,7 @@ index 44c0a3f0fe0..e5561636584 100644
}
diff --git a/dlls/msvcp140/tests/msvcp140.c b/dlls/msvcp140/tests/msvcp140.c
index 640e44e5b7c..6e9727f5854 100644
index 6affa2f9c29..b830bab160e 100644
--- a/dlls/msvcp140/tests/msvcp140.c
+++ b/dlls/msvcp140/tests/msvcp140.c
@@ -857,16 +857,15 @@ static void test_Stat(void)
@@ -535,5 +535,5 @@ index 640e44e5b7c..6e9727f5854 100644
}
--
2.17.1
2.40.1