Rebase against 98b73b5c32fa82218081f0e7668f9836ffe1b55d.

This commit is contained in:
Alistair Leslie-Hughes
2023-06-28 08:27:58 +10:00
parent d94c192f10
commit ef85449de2
4 changed files with 44 additions and 94 deletions

View File

@@ -1,4 +1,4 @@
From 1656f670f68ce218458fc26dc8688c78d99091cb Mon Sep 17 00:00:00 2001
From c58ac24e08827a2b5aac12f365197d1c5174db3a 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: [PATCH] server: Implement FILE_OPEN_REPARSE_POINT option.
@@ -6,14 +6,14 @@ Subject: [PATCH] server: Implement FILE_OPEN_REPARSE_POINT option.
Signed-off-by: Erich E. Hoover <erich.e.hoover@gmail.com>
---
dlls/kernelbase/file.c | 2 +
server/fd.c | 144 +++++++++++++++++++++++++++++++++++++++--
2 files changed, 139 insertions(+), 7 deletions(-)
server/fd.c | 152 +++++++++++++++++++++++++++++++++++++++--
2 files changed, 147 insertions(+), 7 deletions(-)
diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c
index ac04388acde..d0da370ae88 100644
index 7c2e132bdcb..2a8dc8df875 100644
--- a/dlls/kernelbase/file.c
+++ b/dlls/kernelbase/file.c
@@ -735,6 +735,8 @@ static UINT get_nt_file_options( DWORD attributes )
@@ -732,6 +732,8 @@ static UINT get_nt_file_options( DWORD attributes )
options |= FILE_SEQUENTIAL_ONLY;
if (attributes & FILE_FLAG_WRITE_THROUGH)
options |= FILE_WRITE_THROUGH;
@@ -23,7 +23,7 @@ index ac04388acde..d0da370ae88 100644
}
diff --git a/server/fd.c b/server/fd.c
index eaebe044f37..db645779dc6 100644
index 0b0e91ebfbb..233c9eb94ef 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -31,6 +31,7 @@
@@ -45,7 +45,7 @@ index eaebe044f37..db645779dc6 100644
#if defined(HAVE_SYS_EPOLL_H) && defined(HAVE_EPOLL_CREATE)
# include <sys/epoll.h>
# define USE_EPOLL
@@ -1140,6 +1145,59 @@ static void inode_dump( struct object *obj, int verbose )
@@ -1152,6 +1157,59 @@ static void inode_dump( struct object *obj, int verbose )
fprintf( stderr, "\n" );
}
@@ -105,16 +105,19 @@ index eaebe044f37..db645779dc6 100644
static void inode_destroy( struct object *obj )
{
struct inode *inode = (struct inode *)obj;
@@ -1159,10 +1217,29 @@ static void inode_destroy( struct object *obj )
{
/* make sure it is still the same file */
struct stat st;
- if (!stat( fd->unix_name, &st ) && st.st_dev == inode->device->dev && st.st_ino == inode->ino)
@@ -1168,7 +1226,34 @@ static void inode_destroy( struct object *obj )
list_remove( ptr );
if (fd->unix_fd != -1) close( fd->unix_fd );
if (fd->disp_flags & FILE_DISPOSITION_DELETE)
- unlink_closed_fd( inode, fd );
+ {
+ /* make sure it is still the same file */
+ struct stat st;
+ if (!lstat( fd->unix_name, &st ) && st.st_dev == inode->device->dev && st.st_ino == inode->ino)
{
+ {
+ int is_reparse_point = (is_reparse_dir( fd->unix_name, NULL ) == 0);
if (S_ISDIR(st.st_mode)) rmdir( fd->unix_name );
else unlink( fd->unix_name );
+ if (S_ISDIR(st.st_mode)) rmdir( fd->unix_name );
+ else unlink_closed_fd( inode, fd );
+ /* remove reparse point metadata (if applicable) */
+ if (is_reparse_point)
+ {
@@ -133,10 +136,12 @@ index eaebe044f37..db645779dc6 100644
+ rmdir_recursive( AT_FDCWD, metadata_path );
+ rmdir( dirname( metadata_path ) );
+ }
}
}
+ }
+ }
free( fd->unix_name );
@@ -1888,6 +1965,38 @@ void get_nt_name( struct fd *fd, struct unicode_str *name )
free( fd );
}
@@ -1902,6 +1987,38 @@ void get_nt_name( struct fd *fd, struct unicode_str *name )
name->len = fd->nt_namelen;
}
@@ -175,7 +180,7 @@ index eaebe044f37..db645779dc6 100644
/* open() wrapper that returns a struct fd with no fd user set */
struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_name,
int flags, mode_t *mode, unsigned int access,
@@ -1948,6 +2057,15 @@ struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_nam
@@ -1962,6 +2079,15 @@ struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_nam
}
else rw_mode = O_RDONLY;
@@ -191,7 +196,7 @@ index eaebe044f37..db645779dc6 100644
if ((fd->unix_fd = open( name, rw_mode | (flags & ~O_TRUNC), *mode )) == -1)
{
/* if we tried to open a directory for write access, retry read-only */
@@ -1972,7 +2090,7 @@ struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_nam
@@ -1986,7 +2112,7 @@ struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_nam
fd->unix_name = NULL;
if ((path = dup_fd_name( root, name )))
{
@@ -200,7 +205,7 @@ index eaebe044f37..db645779dc6 100644
free( path );
}
@@ -1983,10 +2101,11 @@ struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_nam
@@ -1997,10 +2123,11 @@ struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_nam
*mode = st.st_mode;
/* only bother with an inode for normal files and directories */
@@ -213,7 +218,7 @@ index eaebe044f37..db645779dc6 100644
if (!inode)
{
@@ -2001,13 +2120,17 @@ struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_nam
@@ -2015,13 +2142,17 @@ struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_nam
list_add_head( &inode->open, &fd->inode_entry );
closed_fd = NULL;
@@ -233,7 +238,7 @@ index eaebe044f37..db645779dc6 100644
{
set_error( STATUS_FILE_IS_A_DIRECTORY );
goto error;
@@ -2439,6 +2562,7 @@ static struct fd *get_handle_fd_obj( struct process *process, obj_handle_t handl
@@ -2454,6 +2585,7 @@ static struct fd *get_handle_fd_obj( struct process *process, obj_handle_t handl
static int is_dir_empty( int fd )
{
@@ -241,7 +246,7 @@ index eaebe044f37..db645779dc6 100644
DIR *dir;
int empty;
struct dirent *de;
@@ -2446,8 +2570,13 @@ static int is_dir_empty( int fd )
@@ -2461,8 +2593,13 @@ static int is_dir_empty( int fd )
if ((fd = dup( fd )) == -1)
return -1;
@@ -256,7 +261,7 @@ index eaebe044f37..db645779dc6 100644
close( fd );
return -1;
}
@@ -2459,6 +2588,7 @@ static int is_dir_empty( int fd )
@@ -2474,6 +2611,7 @@ static int is_dir_empty( int fd )
empty = 0;
}
closedir( dir );
@@ -264,15 +269,15 @@ index eaebe044f37..db645779dc6 100644
return empty;
}
@@ -2497,7 +2627,7 @@ static void set_fd_disposition( struct fd *fd, int unlink )
@@ -2512,7 +2650,7 @@ static void set_fd_disposition( struct fd *fd, unsigned int flags )
file_set_error();
return;
}
- if (S_ISREG( st.st_mode )) /* can't unlink files we don't have permission to write */
+ if (S_ISREG( st.st_mode ) || S_ISLNK( st.st_mode )) /* can't unlink files we don't have permission to write */
{
if (!(st.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH)))
{
if (!(flags & FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE) &&
!(st.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH)))
--
2.39.1
2.40.1