Revise the DOS attributes patch to simplify the addition of extended attributes.

This commit is contained in:
Erich E. Hoover
2014-08-20 22:29:46 -06:00
parent 6fa663e823
commit d447778cfb
17 changed files with 468 additions and 489 deletions

View File

@ -1,4 +1,4 @@
From 3ef7e99e837ddc153bc3f608c9e33b4ec4f47d5b Mon Sep 17 00:00:00 2001
From 17d91743f19deb08a6fa0f36212cd8799c6c7270 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: ntdll: Add support for junction point creation.
@ -11,7 +11,7 @@ Subject: ntdll: Add support for junction point creation.
create mode 100644 include/ntifs.h
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 91f96ee..f56facd 100644
index 7b72876..14288b5 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -89,12 +89,14 @@
@ -29,7 +29,7 @@ index 91f96ee..f56facd 100644
#define SECSPERDAY 86400
#define SECS_1601_TO_1970 ((369 * 365 + 89) * (ULONGLONG)SECSPERDAY)
@@ -1576,6 +1578,76 @@ NTSTATUS WINAPI NtDeviceIoControlFile(HANDLE handle, HANDLE event,
@@ -1607,6 +1609,76 @@ NTSTATUS WINAPI NtDeviceIoControlFile(HANDLE handle, HANDLE event,
}
@ -106,7 +106,7 @@ index 91f96ee..f56facd 100644
/**************************************************************************
* NtFsControlFile [NTDLL.@]
* ZwFsControlFile [NTDLL.@]
@@ -1723,6 +1795,23 @@ NTSTATUS WINAPI NtFsControlFile(HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc
@@ -1754,6 +1826,23 @@ NTSTATUS WINAPI NtFsControlFile(HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc
}
break;
}

View File

@ -1,4 +1,4 @@
From 3870b0d2c6309e4aa93922d8af21ae32ddcf5652 Mon Sep 17 00:00:00 2001
From cb47f74a659bd5447ecbf65591962af6a753dda9 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 16 Jan 2014 20:57:57 -0700
Subject: ntdll: Add support for reading junction points.
@ -9,10 +9,10 @@ Subject: ntdll: Add support for reading junction points.
2 files changed, 76 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index f56facd..b02fe76 100644
index 14288b5..b1b8f51 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -1648,6 +1648,60 @@ cleanup:
@@ -1679,6 +1679,60 @@ cleanup:
}
@ -73,7 +73,7 @@ index f56facd..b02fe76 100644
/**************************************************************************
* NtFsControlFile [NTDLL.@]
* ZwFsControlFile [NTDLL.@]
@@ -1796,6 +1850,15 @@ NTSTATUS WINAPI NtFsControlFile(HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc
@@ -1827,6 +1881,15 @@ NTSTATUS WINAPI NtFsControlFile(HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc
break;
}

View File

@ -1,4 +1,4 @@
From 87bd79756bb80f37751ea79a449e70bad0a08465 Mon Sep 17 00:00:00 2001
From c0100e76f61a689e86c660a056ab30f19749a7b1 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 16 Jan 2014 21:00:21 -0700
Subject: ntdll: Add support for deleting junction points.
@ -10,10 +10,10 @@ Subject: ntdll: Add support for deleting junction points.
3 files changed, 85 insertions(+)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index b02fe76..682e2e8 100644
index b1b8f51..4b76d04 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -1702,6 +1702,41 @@ cleanup:
@@ -1733,6 +1733,41 @@ cleanup:
}
@ -55,7 +55,7 @@ index b02fe76..682e2e8 100644
/**************************************************************************
* NtFsControlFile [NTDLL.@]
* ZwFsControlFile [NTDLL.@]
@@ -1850,6 +1885,22 @@ NTSTATUS WINAPI NtFsControlFile(HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc
@@ -1881,6 +1916,22 @@ NTSTATUS WINAPI NtFsControlFile(HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc
break;
}

View File

@ -0,0 +1,28 @@
From 302be7aee826e9876d79be36a596692bac5331d1 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 16 Jan 2014 21:01:25 -0700
Subject: ntdll: Add a test for junction point advertisement.
---
dlls/ntdll/tests/file.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index cc241c8..3f1973c 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -2770,6 +2770,11 @@ static void test_junction_points(void)
bret = DeviceIoControl(hJunction, FSCTL_SET_REPARSE_POINT, (LPVOID)buffer, buffer_len, NULL, 0, &dwret, 0);
ok(bret, "Failed to create junction point! (0x%x)\n", GetLastError());
+ /* Check the file attributes of the junction point */
+ dwret = GetFileAttributesW(junction_path);
+ ok(dwret != (DWORD)~0, "Junction point doesn't exist (attributes: 0x%x)!\n", dwret);
+ ok(dwret & FILE_ATTRIBUTE_REPARSE_POINT, "File is not a junction point! (attributes: %d)\n", dwret);
+
/* Read back the junction point */
HeapFree(GetProcessHeap(), 0, buffer);
buffer_len = sizeof(*buffer) + MAX_PATH*sizeof(WCHAR);
--
1.7.9.5

View File

@ -1,62 +0,0 @@
From 624df21e36009121bf5d7ecab86fb0ace8ca15d7 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 16 Jan 2014 21:01:25 -0700
Subject: ntdll: Advertise that a file is a junction point.
---
dlls/ntdll/file.c | 7 +++++--
dlls/ntdll/tests/file.c | 5 +++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 682e2e8..3230d95 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -182,8 +182,8 @@ int get_file_info( const char *path, struct stat *st, ULONG *xattr )
if (S_ISLNK( st->st_mode ))
{
ret = stat( path, st );
+ st->st_mode |= S_IFLNK;
if (ret == -1) return ret;
- if (S_ISDIR( st->st_mode )) *xattr |= FILE_ATTRIBUTE_REPARSE_POINT;
}
len = xattr_get( path, SAMBA_XATTR_DOS_ATTRIB, hexattr, sizeof(hexattr)-1 );
if (len == -1) return ret;
@@ -2088,7 +2088,7 @@ static inline ULONG get_file_attributes( const ULONG xattr, const struct stat *s
{
ULONG attr;
- if (S_ISDIR(st->st_mode))
+ if (st->st_mode & S_IFDIR)
attr = FILE_ATTRIBUTE_DIRECTORY;
else
attr = FILE_ATTRIBUTE_ARCHIVE;
@@ -2098,6 +2098,9 @@ static inline ULONG get_file_attributes( const ULONG xattr, const struct stat *s
if (!(st->st_mode & (S_IWUSR | S_IWGRP | S_IWOTH)))
attr |= FILE_ATTRIBUTE_READONLY;
+
+ if (st->st_mode & S_IFLNK)
+ attr |= FILE_ATTRIBUTE_REPARSE_POINT;
return attr;
}
diff --git a/dlls/ntdll/tests/file.c b/dlls/ntdll/tests/file.c
index cc241c8..3f1973c 100644
--- a/dlls/ntdll/tests/file.c
+++ b/dlls/ntdll/tests/file.c
@@ -2770,6 +2770,11 @@ static void test_junction_points(void)
bret = DeviceIoControl(hJunction, FSCTL_SET_REPARSE_POINT, (LPVOID)buffer, buffer_len, NULL, 0, &dwret, 0);
ok(bret, "Failed to create junction point! (0x%x)\n", GetLastError());
+ /* Check the file attributes of the junction point */
+ dwret = GetFileAttributesW(junction_path);
+ ok(dwret != (DWORD)~0, "Junction point doesn't exist (attributes: 0x%x)!\n", dwret);
+ ok(dwret & FILE_ATTRIBUTE_REPARSE_POINT, "File is not a junction point! (attributes: %d)\n", dwret);
+
/* Read back the junction point */
HeapFree(GetProcessHeap(), 0, buffer);
buffer_len = sizeof(*buffer) + MAX_PATH*sizeof(WCHAR);
--
1.7.9.5

View File

@ -1,4 +1,4 @@
From e5c5d522bdf363ef1b07e7d18e73ddc2f7ff9305 Mon Sep 17 00:00:00 2001
From 0d309d17751b6bf821b449ba890b5c3465c495a8 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 16 Jan 2014 21:02:11 -0700
Subject: kernel32,ntdll: Add support for deleting junction points with

View File

@ -1,4 +1,4 @@
From 38d297f6be2c232433e9093ecbfcc45b2de715d2 Mon Sep 17 00:00:00 2001
From a7ca946b7bf408aeb905cb2f5dda782634566d83 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 16 Jan 2014 21:03:47 -0700
Subject: kernel32: Advertise junction point support.

View File

@ -1,4 +1,4 @@
From 1a343f1a7d57ed717c07026091bca8efe47a8fd6 Mon Sep 17 00:00:00 2001
From 07e1f990c05bc2b82d2c579ce6a57ee2e24852b5 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 16 Jan 2014 21:06:24 -0700
Subject: ntdll/tests: Add test for deleting junction point target.

View File

@ -0,0 +1,69 @@
From dc4f6f3e4ad3cd249872a297baca22370cc3267d Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Thu, 16 Jan 2014 21:07:43 -0700
Subject: ntdll: Use relative paths for creating links.
---
dlls/ntdll/file.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index 4b76d04..b42b4ef 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -1624,6 +1624,7 @@ NTSTATUS FILE_CreateSymlink(HANDLE handle, REPARSE_DATA_BUFFER *buffer)
int dest_fd, needs_close;
UNICODE_STRING nt_dest;
NTSTATUS status;
+ char *p;
if ((status = server_get_unix_fd( handle, FILE_SPECIAL_ACCESS, &dest_fd, &needs_close, NULL, NULL )))
return status;
@@ -1637,6 +1638,44 @@ NTSTATUS FILE_CreateSymlink(HANDLE handle, REPARSE_DATA_BUFFER *buffer)
goto cleanup;
dest_allocated = TRUE;
+ p = strstr(unix_src.Buffer, "/dosdevices/");
+ if (p)
+ {
+ int count = -1; /* do not count the slash at the end of dosdevices or the last directory */
+
+ p += 11; /* strlen("/dosdevices") */
+ do
+ {
+ p++; /* skip the slash */
+ count++;
+ p = strchr(p, '/');
+ } while(p);
+ FIXME("found %d directories up.\n", count);
+ p = strstr(unix_dest.Buffer, "/dosdevices/");
+ if (p)
+ {
+ ANSI_STRING tmp;
+ int dest_len;
+ char *d;
+
+ p += 12; /* strlen("/dosdevices/") */
+ dest_len = unix_dest.Length - (p-unix_dest.Buffer) + 1;
+ tmp.Length = dest_len + 3*count; /* strlen("../") = 3 */
+ tmp.Buffer = RtlAllocateHeap(GetProcessHeap(), 0, tmp.Length);
+ d = tmp.Buffer;
+ for(; count > 0; count--)
+ {
+ (d++)[0] = '.';
+ (d++)[0] = '.';
+ (d++)[0] = '/';
+ }
+ memcpy(d, p, dest_len);
+ RtlFreeAnsiString( &unix_dest );
+ unix_dest.Length = tmp.Length;
+ unix_dest.Buffer = tmp.Buffer;
+ }
+ }
+
TRACE("Linking %s to %s\n", unix_src.Buffer, unix_dest.Buffer);
/* Produce the link in a temporary location */
--
1.7.9.5