Rebase against 634cb775c27b61ad6ce1fbe3e9972b0edfa31dcb.

This commit is contained in:
Zebediah Figura
2020-06-15 17:43:18 -05:00
parent b6595d9e28
commit 32fcc0d75b
19 changed files with 182 additions and 461 deletions

View File

@@ -1,31 +1,71 @@
From 9f17f2e4f9842549820691f34f7d2da5719ead0a Mon Sep 17 00:00:00 2001
From b099458217b2855bd8615b8c97bcc2462eb74b25 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Wed, 20 Aug 2014 00:08:52 -0600
Subject: [PATCH] ntdll: Implement storing DOS attributes in
NtSetInformationFile.
---
dlls/ntdll/file.c | 54 ++++++++++++++++++++++++++---------------
dlls/ntdll/tests/file.c | 8 +++---
dlls/ntdll/unix/file.c | 54 ++++++++++++++++++++++++++---------------
include/wine/port.h | 2 ++
libs/port/xattr.c | 20 +++++++++++++++
4 files changed, 60 insertions(+), 24 deletions(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index bd6e3cbcf88..c1f9808e497 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -177,6 +177,39 @@ int fd_get_file_info( int fd, unsigned int options, struct stat *st, ULONG *attr
return ret;
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index 184b7cdad59..37e5ac5d8a5 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -1364,7 +1364,7 @@ static void test_file_basic_information(void)
memset(&fbi, 0, sizeof(fbi));
res = pNtQueryInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation);
ok ( res == STATUS_SUCCESS, "can't get attributes\n");
- todo_wine ok ( (fbi.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_SYSTEM, "attribute %x not FILE_ATTRIBUTE_SYSTEM\n", fbi.FileAttributes );
+ ok ( (fbi.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_SYSTEM, "attribute %x not FILE_ATTRIBUTE_SYSTEM (ok in old linux without xattr)\n", fbi.FileAttributes );
/* Then HIDDEN */
memset(&fbi, 0, sizeof(fbi));
@@ -1377,7 +1377,7 @@ static void test_file_basic_information(void)
memset(&fbi, 0, sizeof(fbi));
res = pNtQueryInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation);
ok ( res == STATUS_SUCCESS, "can't get attributes\n");
- todo_wine ok ( (fbi.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_HIDDEN, "attribute %x not FILE_ATTRIBUTE_HIDDEN\n", fbi.FileAttributes );
+ ok ( (fbi.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_HIDDEN, "attribute %x not FILE_ATTRIBUTE_HIDDEN (ok in old linux without xattr)\n", fbi.FileAttributes );
/* Check NORMAL last of all (to make sure we can clear attributes) */
memset(&fbi, 0, sizeof(fbi));
@@ -1434,7 +1434,7 @@ static void test_file_all_information(void)
memset(&fai_buf.fai, 0, sizeof(fai_buf.fai));
res = pNtQueryInformationFile(h, &io, &fai_buf.fai, sizeof fai_buf, FileAllInformation);
ok ( res == STATUS_SUCCESS, "can't get attributes, res %x\n", res);
- todo_wine ok ( (fai_buf.fai.BasicInformation.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_SYSTEM, "attribute %x not FILE_ATTRIBUTE_SYSTEM\n", fai_buf.fai.BasicInformation.FileAttributes );
+ ok ( (fai_buf.fai.BasicInformation.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_SYSTEM, "attribute %x not FILE_ATTRIBUTE_SYSTEM (ok in old linux without xattr)\n", fai_buf.fai.BasicInformation.FileAttributes );
/* Then HIDDEN */
memset(&fai_buf.fai.BasicInformation, 0, sizeof(fai_buf.fai.BasicInformation));
@@ -1447,7 +1447,7 @@ static void test_file_all_information(void)
memset(&fai_buf.fai, 0, sizeof(fai_buf.fai));
res = pNtQueryInformationFile(h, &io, &fai_buf.fai, sizeof fai_buf, FileAllInformation);
ok ( res == STATUS_SUCCESS, "can't get attributes\n");
- todo_wine ok ( (fai_buf.fai.BasicInformation.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_HIDDEN, "attribute %x not FILE_ATTRIBUTE_HIDDEN\n", fai_buf.fai.BasicInformation.FileAttributes );
+ ok ( (fai_buf.fai.BasicInformation.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_HIDDEN, "attribute %x not FILE_ATTRIBUTE_HIDDEN (ok in old linux without xattr)\n", fai_buf.fai.BasicInformation.FileAttributes );
/* Check NORMAL last of all (to make sure we can clear attributes) */
memset(&fai_buf.fai.BasicInformation, 0, sizeof(fai_buf.fai.BasicInformation));
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index 70a76ca81ee..924d06b2caa 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -1497,6 +1497,39 @@ static int fd_get_file_info( int fd, unsigned int options, struct stat *st, ULON
}
+/* set the stat info and file attributes for a file (by file descriptor) */
+NTSTATUS fd_set_file_info( int fd, ULONG attr )
+{
+ char hexattr[11];
+ struct stat st;
+
+ if (fstat( fd, &st ) == -1) return FILE_GetNtStatus();
+ if (fstat( fd, &st ) == -1) return errno_to_status( errno );
+ if (attr & FILE_ATTRIBUTE_READONLY)
+ {
+ if (S_ISDIR( st.st_mode))
@@ -36,9 +76,9 @@ index bd6e3cbcf88..c1f9808e497 100644
+ else
+ {
+ /* add write permission only where we already have read permission */
+ st.st_mode |= (0600 | ((st.st_mode & 044) >> 1)) & (~FILE_umask);
+ st.st_mode |= (0600 | ((st.st_mode & 044) >> 1)) & (~start_umask);
+ }
+ if (fchmod( fd, st.st_mode ) == -1) return FILE_GetNtStatus();
+ if (fchmod( fd, st.st_mode ) == -1) return errno_to_status( errno );
+ attr &= ~FILE_ATTRIBUTE_NORMAL; /* do not store everything, but keep everything Samba can use */
+ if (attr != 0)
+ {
@@ -52,10 +92,10 @@ index bd6e3cbcf88..c1f9808e497 100644
+ return STATUS_SUCCESS;
+}
+
/* get the stat info and file attributes for a file (by name) */
static int get_file_info( const char *path, struct stat *st, ULONG *attr )
{
char *parent_path;
@@ -3113,7 +3146,6 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
@@ -4000,7 +4033,6 @@ NTSTATUS WINAPI NtSetInformationFile( HANDLE handle, IO_STATUS_BLOCK *io,
case FileBasicInformation:
if (len >= sizeof(FILE_BASIC_INFORMATION))
{
@@ -63,12 +103,12 @@ index bd6e3cbcf88..c1f9808e497 100644
const FILE_BASIC_INFORMATION *info = ptr;
LARGE_INTEGER mtime, atime;
@@ -3127,25 +3159,7 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
@@ -4014,25 +4046,7 @@ NTSTATUS WINAPI NtSetInformationFile( HANDLE handle, IO_STATUS_BLOCK *io,
io->u.Status = set_file_times( fd, &mtime, &atime );
if (io->u.Status == STATUS_SUCCESS && info->FileAttributes)
- {
- if (fstat( fd, &st ) == -1) io->u.Status = FILE_GetNtStatus();
- if (fstat( fd, &st ) == -1) io->u.Status = errno_to_status( errno );
- else
- {
- if (info->FileAttributes & FILE_ATTRIBUTE_READONLY)
@@ -81,60 +121,20 @@ index bd6e3cbcf88..c1f9808e497 100644
- else
- {
- /* add write permission only where we already have read permission */
- st.st_mode |= (0600 | ((st.st_mode & 044) >> 1)) & (~FILE_umask);
- st.st_mode |= (0600 | ((st.st_mode & 044) >> 1)) & (~start_umask);
- }
- if (fchmod( fd, st.st_mode ) == -1) io->u.Status = FILE_GetNtStatus();
- if (fchmod( fd, st.st_mode ) == -1) io->u.Status = errno_to_status( errno );
- }
- }
+ io->u.Status = fd_set_file_info( fd, info->FileAttributes );
if (needs_close) close( fd );
}
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index 67d54c81fb0..4c2e63d3679 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -1365,7 +1365,7 @@ static void test_file_basic_information(void)
memset(&fbi, 0, sizeof(fbi));
res = pNtQueryInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation);
ok ( res == STATUS_SUCCESS, "can't get attributes\n");
- todo_wine ok ( (fbi.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_SYSTEM, "attribute %x not FILE_ATTRIBUTE_SYSTEM\n", fbi.FileAttributes );
+ ok ( (fbi.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_SYSTEM, "attribute %x not FILE_ATTRIBUTE_SYSTEM (ok in old linux without xattr)\n", fbi.FileAttributes );
/* Then HIDDEN */
memset(&fbi, 0, sizeof(fbi));
@@ -1378,7 +1378,7 @@ static void test_file_basic_information(void)
memset(&fbi, 0, sizeof(fbi));
res = pNtQueryInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation);
ok ( res == STATUS_SUCCESS, "can't get attributes\n");
- todo_wine ok ( (fbi.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_HIDDEN, "attribute %x not FILE_ATTRIBUTE_HIDDEN\n", fbi.FileAttributes );
+ ok ( (fbi.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_HIDDEN, "attribute %x not FILE_ATTRIBUTE_HIDDEN (ok in old linux without xattr)\n", fbi.FileAttributes );
/* Check NORMAL last of all (to make sure we can clear attributes) */
memset(&fbi, 0, sizeof(fbi));
@@ -1435,7 +1435,7 @@ static void test_file_all_information(void)
memset(&fai_buf.fai, 0, sizeof(fai_buf.fai));
res = pNtQueryInformationFile(h, &io, &fai_buf.fai, sizeof fai_buf, FileAllInformation);
ok ( res == STATUS_SUCCESS, "can't get attributes, res %x\n", res);
- todo_wine ok ( (fai_buf.fai.BasicInformation.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_SYSTEM, "attribute %x not FILE_ATTRIBUTE_SYSTEM\n", fai_buf.fai.BasicInformation.FileAttributes );
+ ok ( (fai_buf.fai.BasicInformation.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_SYSTEM, "attribute %x not FILE_ATTRIBUTE_SYSTEM (ok in old linux without xattr)\n", fai_buf.fai.BasicInformation.FileAttributes );
/* Then HIDDEN */
memset(&fai_buf.fai.BasicInformation, 0, sizeof(fai_buf.fai.BasicInformation));
@@ -1448,7 +1448,7 @@ static void test_file_all_information(void)
memset(&fai_buf.fai, 0, sizeof(fai_buf.fai));
res = pNtQueryInformationFile(h, &io, &fai_buf.fai, sizeof fai_buf, FileAllInformation);
ok ( res == STATUS_SUCCESS, "can't get attributes\n");
- todo_wine ok ( (fai_buf.fai.BasicInformation.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_HIDDEN, "attribute %x not FILE_ATTRIBUTE_HIDDEN\n", fai_buf.fai.BasicInformation.FileAttributes );
+ ok ( (fai_buf.fai.BasicInformation.FileAttributes & attrib_mask) == FILE_ATTRIBUTE_HIDDEN, "attribute %x not FILE_ATTRIBUTE_HIDDEN (ok in old linux without xattr)\n", fai_buf.fai.BasicInformation.FileAttributes );
/* Check NORMAL last of all (to make sure we can clear attributes) */
memset(&fai_buf.fai.BasicInformation, 0, sizeof(fai_buf.fai.BasicInformation));
diff --git a/include/wine/port.h b/include/wine/port.h
index 6e81cb71a76..f90396727d6 100644
index 4670891ae77..e0249b4c59f 100644
--- a/include/wine/port.h
+++ b/include/wine/port.h
@@ -368,6 +368,8 @@ extern int mkstemps(char *template, int suffix_len);
@@ -359,6 +359,8 @@ extern int mkstemps(char *template, int suffix_len);
#endif
extern int xattr_fget( int filedes, const char *name, void *value, size_t size );

View File

@@ -1,23 +1,23 @@
From 08ece1e8da040d80c13348c2ffeb56052779dc53 Mon Sep 17 00:00:00 2001
From 29e0ef12afb2651e61492a8a9f021baca4c66519 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Thu, 14 Jan 2016 23:09:19 +0100
Subject: [PATCH] ntdll: Always store SAMBA_XATTR_DOS_ATTRIB when path could be
interpreted as hidden.
---
dlls/ntdll/file.c | 13 ++++++++-----
dlls/ntdll/unix/file.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index a0e54c27198..61b417ef678 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -250,12 +250,15 @@ int get_file_info( const char *path, struct stat *st, ULONG *attr )
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index 9636c0efe3e..444332e7baa 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -1561,12 +1561,15 @@ static int get_file_info( const char *path, struct stat *st, ULONG *attr )
RtlFreeHeap( GetProcessHeap(), 0, parent_path );
}
*attr |= get_file_attributes( st );
- /* convert Unix-style hidden files to a DOS hidden file attribute */
- if (DIR_is_hidden_file( path ))
- if (is_hidden_file( path ))
- *attr |= FILE_ATTRIBUTE_HIDDEN;
/* retrieve any stored DOS attributes */
len = xattr_get( path, SAMBA_XATTR_DOS_ATTRIB, hexattr, sizeof(hexattr)-1 );
@@ -25,22 +25,22 @@ index a0e54c27198..61b417ef678 100644
+ if (len == -1)
+ {
+ /* convert Unix-style hidden files to a DOS hidden file attribute */
+ if (DIR_is_hidden_file( path ))
+ if (is_hidden_file( path ))
+ *attr |= FILE_ATTRIBUTE_HIDDEN;
+ return ret;
+ }
*attr |= get_file_xattr( hexattr, len );
return ret;
}
@@ -268,7 +271,7 @@ NTSTATUS set_file_info( const char *path, ULONG attr )
@@ -3440,7 +3443,7 @@ NTSTATUS set_file_info( const char *path, ULONG attr )
/* Note: unix mode already set when called this way */
attr &= ~FILE_ATTRIBUTE_NORMAL; /* do not store everything, but keep everything Samba can use */
len = sprintf( hexattr, "0x%x", attr );
- if (attr != 0)
+ if (attr != 0 || DIR_is_hidden_file( path ))
+ if (attr != 0 || is_hidden_file( path ))
xattr_set( path, SAMBA_XATTR_DOS_ATTRIB, hexattr, len );
else
xattr_remove( path, SAMBA_XATTR_DOS_ATTRIB );
--
2.25.1
2.27.0

View File

@@ -1,7 +1,3 @@
Fixes: [9158] Support for DOS hidden/system file attributes
Fixes: [15679] cygwin symlinks not working in wine
# Depends: ntdll-Syscall_Wrappers
Depends: ntdll-Junction_Points
# Currently awkwardly split between ntdll.dll and ntdll.so; wait for the rest
# of the file functions to be moved to ntdll.so before finishing the rebase.
Disabled: true