Commit ee136f98 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ntdll: Check for an existing file on the server side.

parent 5b75d943
......@@ -2778,18 +2778,12 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
if (io->u.Status != STATUS_SUCCESS && io->u.Status != STATUS_NO_SUCH_FILE)
break;
if (!info->ReplaceIfExists && io->u.Status == STATUS_SUCCESS)
{
RtlFreeAnsiString( &unix_name );
io->u.Status = STATUS_OBJECT_NAME_COLLISION;
break;
}
SERVER_START_REQ( set_fd_name_info )
{
req->handle = wine_server_obj_handle( handle );
req->rootdir = wine_server_obj_handle( attr.RootDirectory );
req->link = FALSE;
req->replace = info->ReplaceIfExists;
wine_server_add_data( req, unix_name.Buffer, unix_name.Length );
io->u.Status = wine_server_call( req );
}
......@@ -2821,18 +2815,12 @@ NTSTATUS WINAPI NtSetInformationFile(HANDLE handle, PIO_STATUS_BLOCK io,
if (io->u.Status != STATUS_SUCCESS && io->u.Status != STATUS_NO_SUCH_FILE)
break;
if (!info->ReplaceIfExists && io->u.Status == STATUS_SUCCESS)
{
RtlFreeAnsiString( &unix_name );
io->u.Status = STATUS_OBJECT_NAME_COLLISION;
break;
}
SERVER_START_REQ( set_fd_name_info )
{
req->handle = wine_server_obj_handle( handle );
req->rootdir = wine_server_obj_handle( attr.RootDirectory );
req->link = TRUE;
req->replace = info->ReplaceIfExists;
wine_server_add_data( req, unix_name.Buffer, unix_name.Length );
io->u.Status = wine_server_call( req );
}
......
......@@ -5532,7 +5532,9 @@ struct set_fd_name_info_request
obj_handle_t handle;
obj_handle_t rootdir;
int link;
int replace;
/* VARARG(filename,string); */
char __pad_28[4];
};
struct set_fd_name_info_reply
{
......@@ -6704,6 +6706,6 @@ union generic_reply
struct resume_process_reply resume_process_reply;
};
#define SERVER_PROTOCOL_VERSION 595
#define SERVER_PROTOCOL_VERSION 596
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
......@@ -2325,7 +2325,7 @@ static void set_fd_disposition( struct fd *fd, int unlink )
/* set new name for the fd */
static void set_fd_name( struct fd *fd, struct fd *root, const char *nameptr,
data_size_t len, int create_link )
data_size_t len, int create_link, int replace )
{
struct inode *inode;
struct stat st;
......@@ -2367,6 +2367,12 @@ static void set_fd_name( struct fd *fd, struct fd *root, const char *nameptr,
if (!stat( name, &st ))
{
if (!replace)
{
set_error( STATUS_OBJECT_NAME_COLLISION );
goto failed;
}
/* can't replace directories or special files */
if (!S_ISREG( st.st_mode ))
{
......@@ -2695,7 +2701,7 @@ DECL_HANDLER(set_fd_name_info)
if ((fd = get_handle_fd_obj( current->process, req->handle, 0 )))
{
set_fd_name( fd, root_fd, get_req_data(), get_req_data_size(), req->link );
set_fd_name( fd, root_fd, get_req_data(), get_req_data_size(), req->link, req->replace );
release_object( fd );
}
if (root_fd) release_object( root_fd );
......
......@@ -3809,6 +3809,7 @@ struct handle_info
obj_handle_t handle; /* handle to a file or directory */
obj_handle_t rootdir; /* root directory */
int link; /* link instead of renaming */
int replace; /* replace an existing file? */
VARARG(filename,string); /* new file name */
@END
......
......@@ -2377,7 +2377,8 @@ C_ASSERT( sizeof(struct set_fd_disp_info_request) == 24 );
C_ASSERT( FIELD_OFFSET(struct set_fd_name_info_request, handle) == 12 );
C_ASSERT( FIELD_OFFSET(struct set_fd_name_info_request, rootdir) == 16 );
C_ASSERT( FIELD_OFFSET(struct set_fd_name_info_request, link) == 20 );
C_ASSERT( sizeof(struct set_fd_name_info_request) == 24 );
C_ASSERT( FIELD_OFFSET(struct set_fd_name_info_request, replace) == 24 );
C_ASSERT( sizeof(struct set_fd_name_info_request) == 32 );
C_ASSERT( FIELD_OFFSET(struct get_window_layered_info_request, handle) == 12 );
C_ASSERT( sizeof(struct get_window_layered_info_request) == 16 );
C_ASSERT( FIELD_OFFSET(struct get_window_layered_info_reply, color_key) == 8 );
......
......@@ -4464,6 +4464,7 @@ static void dump_set_fd_name_info_request( const struct set_fd_name_info_request
fprintf( stderr, " handle=%04x", req->handle );
fprintf( stderr, ", rootdir=%04x", req->rootdir );
fprintf( stderr, ", link=%d", req->link );
fprintf( stderr, ", replace=%d", req->replace );
dump_varargs_string( ", filename=", cur_size );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment