Commit 08351071 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

server: Fix the file notification interface to use directory handles.

parent 6d85f3bf
......@@ -65,7 +65,7 @@ HANDLE WINAPI FindFirstChangeNotificationW( LPCWSTR lpPathName, BOOL bWatchSubtr
if (!RtlDosPathNameToNtPathName_U( lpPathName, &nt_name, NULL, NULL ))
{
SetLastError( ERROR_PATH_NOT_FOUND );
return INVALID_HANDLE_VALUE;
return ret;
}
attr.Length = sizeof(attr);
......@@ -75,27 +75,28 @@ HANDLE WINAPI FindFirstChangeNotificationW( LPCWSTR lpPathName, BOOL bWatchSubtr
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
status = NtOpenFile( &file, 0, &attr, &io, 0,
status = NtOpenFile( &file, SYNCHRONIZE, &attr, &io,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
FILE_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT );
RtlFreeUnicodeString( &nt_name );
if (status != STATUS_SUCCESS)
{
SetLastError( RtlNtStatusToDosError(status) );
return INVALID_HANDLE_VALUE;
return ret;
}
SERVER_START_REQ( create_change_notification )
SERVER_START_REQ( read_directory_changes )
{
req->access = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE;
req->attributes = 0;
req->handle = file;
req->subtree = bWatchSubtree;
req->event = NULL;
req->filter = dwNotifyFilter;
if (!wine_server_call_err( req )) ret = reply->handle;
status = wine_server_call( req );
if (status == STATUS_PENDING)
ret = file;
}
SERVER_END_REQ;
CloseHandle( file );
return ret;
}
......@@ -104,16 +105,28 @@ HANDLE WINAPI FindFirstChangeNotificationW( LPCWSTR lpPathName, BOOL bWatchSubtr
*/
BOOL WINAPI FindNextChangeNotification( HANDLE handle )
{
BOOL ret;
BOOL ret = FALSE;
NTSTATUS status;
TRACE("%p\n",handle);
SERVER_START_REQ( next_change_notification )
if (!handle)
{
SetLastError( ERROR_INVALID_HANDLE );
return ret;
}
SERVER_START_REQ( read_directory_changes )
{
req->handle = handle;
ret = !wine_server_call_err( req );
req->handle = handle;
req->event = NULL;
req->filter = FILE_NOTIFY_CHANGE_SIZE; /* valid but ignored */
status = wine_server_call( req );
if (status == STATUS_PENDING)
ret = TRUE;
}
SERVER_END_REQ;
return ret;
}
......
......@@ -1778,6 +1778,16 @@ done:
return status;
}
#define FILE_NOTIFY_ALL ( \
FILE_NOTIFY_CHANGE_FILE_NAME | \
FILE_NOTIFY_CHANGE_DIR_NAME | \
FILE_NOTIFY_CHANGE_ATTRIBUTES | \
FILE_NOTIFY_CHANGE_SIZE | \
FILE_NOTIFY_CHANGE_LAST_WRITE | \
FILE_NOTIFY_CHANGE_LAST_ACCESS | \
FILE_NOTIFY_CHANGE_CREATION | \
FILE_NOTIFY_CHANGE_SECURITY )
/******************************************************************************
* NtNotifyChangeDirectoryFile [NTDLL.@]
*/
......@@ -1787,8 +1797,30 @@ NtNotifyChangeDirectoryFile( HANDLE FileHandle, HANDLE Event,
PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer,
ULONG BufferSize, ULONG CompletionFilter, BOOLEAN WatchTree )
{
FIXME("%p %p %p %p %p %p %lu %lu %d\n",
NTSTATUS status;
TRACE("%p %p %p %p %p %p %lu %lu %d\n",
FileHandle, Event, ApcRoutine, ApcContext, IoStatusBlock,
Buffer, BufferSize, CompletionFilter, WatchTree );
return STATUS_NOT_IMPLEMENTED;
if (!IoStatusBlock)
return STATUS_ACCESS_VIOLATION;
if (CompletionFilter == 0 || (CompletionFilter & ~FILE_NOTIFY_ALL))
return STATUS_INVALID_PARAMETER;
if (ApcRoutine || ApcContext || Buffer || BufferSize || WatchTree)
FIXME("parameters ignored %p %p %p %lu %d\n",
ApcRoutine, ApcContext, Buffer, BufferSize, WatchTree );
SERVER_START_REQ( read_directory_changes )
{
req->handle = FileHandle;
req->event = Event;
req->filter = CompletionFilter;
status = wine_server_call( req );
}
SERVER_END_REQ;
return status;
}
......@@ -64,10 +64,8 @@ static void test_ntncdf(void)
r = CreateDirectoryW(path, NULL);
ok( r == TRUE, "failed to create directory\n");
todo_wine {
r = pNtNotifyChangeDirectoryFile(NULL,NULL,NULL,NULL,NULL,NULL,0,0,0);
ok(r==STATUS_ACCESS_VIOLATION, "should return access violation\n");
}
fflags = FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED;
hdir = CreateFileW(path, GENERIC_READ|SYNCHRONIZE, FILE_SHARE_READ, NULL,
......@@ -76,7 +74,6 @@ static void test_ntncdf(void)
hEvent = CreateEvent( NULL, 0, 0, NULL );
todo_wine {
r = pNtNotifyChangeDirectoryFile(hdir,NULL,NULL,NULL,&iosb,NULL,0,0,0);
ok(r==STATUS_INVALID_PARAMETER, "should return invalid parameter\n");
......@@ -93,31 +90,28 @@ static void test_ntncdf(void)
filter |= FILE_NOTIFY_CHANGE_SECURITY;
r = pNtNotifyChangeDirectoryFile(hdir,hEvent,NULL,NULL,&iosb,buffer,sizeof buffer,filter,0);
ok(r==STATUS_PENDING, "should return invalid parameter\n");
}
ok(r==STATUS_PENDING, "should return status pending\n");
r = WaitForSingleObject( hEvent, 0 );
ok( r == STATUS_TIMEOUT, "event ready\n" );
ok( r == STATUS_TIMEOUT, "event shouldn't be ready\n" );
r = CreateDirectoryW( subdir, NULL );
ok( r == TRUE, "failed to create directory\n");
todo_wine {
r = WaitForSingleObject( hEvent, 0 );
ok( r == WAIT_OBJECT_0, "event ready\n" );
ok( r == WAIT_OBJECT_0, "event wasn't ready\n" );
r = pNtNotifyChangeDirectoryFile(hdir,0,NULL,NULL,&iosb,NULL,0,filter,0);
ok(r==STATUS_PENDING, "should return invalid parameter\n");
ok(r==STATUS_PENDING, "should return status pending\n");
r = WaitForSingleObject( hdir, 0 );
ok( r == STATUS_TIMEOUT, "event ready\n" );
}
ok( r == STATUS_TIMEOUT, "event shouldn't be ready\n" );
r = RemoveDirectoryW( subdir );
ok( r == TRUE, "failed to remove directory\n");
r = WaitForSingleObject( hdir, 0 );
ok( r == WAIT_OBJECT_0, "event ready\n" );
ok( r == WAIT_OBJECT_0, "event wasn't ready\n" );
todo_wine {
r = RemoveDirectoryW( path );
......
......@@ -1396,34 +1396,20 @@ struct send_console_signal_reply
struct create_change_notification_request
struct read_directory_changes_request
{
struct request_header __header;
unsigned int access;
unsigned int attributes;
obj_handle_t handle;
int subtree;
obj_handle_t event;
unsigned int filter;
};
struct create_change_notification_reply
struct read_directory_changes_reply
{
struct reply_header __header;
obj_handle_t handle;
};
struct next_change_notification_request
{
struct request_header __header;
obj_handle_t handle;
};
struct next_change_notification_reply
{
struct reply_header __header;
};
struct create_mapping_request
{
struct request_header __header;
......@@ -3782,8 +3768,7 @@ enum request
REQ_read_console_output,
REQ_move_console_output,
REQ_send_console_signal,
REQ_create_change_notification,
REQ_next_change_notification,
REQ_read_directory_changes,
REQ_create_mapping,
REQ_open_mapping,
REQ_get_mapping_info,
......@@ -4001,8 +3986,7 @@ union generic_request
struct read_console_output_request read_console_output_request;
struct move_console_output_request move_console_output_request;
struct send_console_signal_request send_console_signal_request;
struct create_change_notification_request create_change_notification_request;
struct next_change_notification_request next_change_notification_request;
struct read_directory_changes_request read_directory_changes_request;
struct create_mapping_request create_mapping_request;
struct open_mapping_request open_mapping_request;
struct get_mapping_info_request get_mapping_info_request;
......@@ -4218,8 +4202,7 @@ union generic_reply
struct read_console_output_reply read_console_output_reply;
struct move_console_output_reply move_console_output_reply;
struct send_console_signal_reply send_console_signal_reply;
struct create_change_notification_reply create_change_notification_reply;
struct next_change_notification_reply next_change_notification_reply;
struct read_directory_changes_reply read_directory_changes_reply;
struct create_mapping_reply create_mapping_reply;
struct open_mapping_reply open_mapping_reply;
struct get_mapping_info_reply get_mapping_info_reply;
......@@ -4362,6 +4345,6 @@ union generic_reply
struct query_symlink_reply query_symlink_reply;
};
#define SERVER_PROTOCOL_VERSION 221
#define SERVER_PROTOCOL_VERSION 222
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
......@@ -172,7 +172,9 @@ static struct object *create_file( const char *nameptr, size_t len, unsigned int
fd = open_fd( name, flags | O_NONBLOCK | O_LARGEFILE, &mode, access, sharing, options );
if (!fd) goto done;
if (S_ISCHR(mode) && is_serial_fd( fd ))
if (S_ISDIR(mode))
obj = create_dir_obj( fd );
else if (S_ISCHR(mode) && is_serial_fd( fd ))
obj = create_serial( fd, options );
else
obj = create_file_obj( fd, access, options );
......
......@@ -109,6 +109,7 @@ extern void file_set_error(void);
extern void do_change_notify( int unix_fd );
extern void sigio_callback(void);
extern struct object *create_dir_obj( struct fd *fd );
/* serial port functions */
......
......@@ -1041,23 +1041,14 @@ enum char_info_mode
@END
/* Create a change notification */
@REQ(create_change_notification)
unsigned int access; /* wanted access rights */
unsigned int attributes; /* object attributes */
/* enable directory change notifications */
@REQ(read_directory_changes)
obj_handle_t handle; /* handle to the directory */
int subtree; /* watch all the subtree */
obj_handle_t event; /* handle to the event */
unsigned int filter; /* notification filter */
@REPLY
obj_handle_t handle; /* handle to the change notification */
@END
/* Move to the next change notification */
@REQ(next_change_notification)
obj_handle_t handle; /* handle to the change notification */
@END
/* Create a file mapping */
@REQ(create_mapping)
unsigned int access; /* wanted access rights */
......
......@@ -180,8 +180,7 @@ DECL_HANDLER(fill_console_output);
DECL_HANDLER(read_console_output);
DECL_HANDLER(move_console_output);
DECL_HANDLER(send_console_signal);
DECL_HANDLER(create_change_notification);
DECL_HANDLER(next_change_notification);
DECL_HANDLER(read_directory_changes);
DECL_HANDLER(create_mapping);
DECL_HANDLER(open_mapping);
DECL_HANDLER(get_mapping_info);
......@@ -398,8 +397,7 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] =
(req_handler)req_read_console_output,
(req_handler)req_move_console_output,
(req_handler)req_send_console_signal,
(req_handler)req_create_change_notification,
(req_handler)req_next_change_notification,
(req_handler)req_read_directory_changes,
(req_handler)req_create_mapping,
(req_handler)req_open_mapping,
(req_handler)req_get_mapping_info,
......
......@@ -1445,25 +1445,13 @@ static void dump_send_console_signal_request( const struct send_console_signal_r
fprintf( stderr, " group_id=%04x", req->group_id );
}
static void dump_create_change_notification_request( const struct create_change_notification_request *req )
static void dump_read_directory_changes_request( const struct read_directory_changes_request *req )
{
fprintf( stderr, " access=%08x,", req->access );
fprintf( stderr, " attributes=%08x,", req->attributes );
fprintf( stderr, " handle=%p,", req->handle );
fprintf( stderr, " subtree=%d,", req->subtree );
fprintf( stderr, " event=%p,", req->event );
fprintf( stderr, " filter=%08x", req->filter );
}
static void dump_create_change_notification_reply( const struct create_change_notification_reply *req )
{
fprintf( stderr, " handle=%p", req->handle );
}
static void dump_next_change_notification_request( const struct next_change_notification_request *req )
{
fprintf( stderr, " handle=%p", req->handle );
}
static void dump_create_mapping_request( const struct create_mapping_request *req )
{
fprintf( stderr, " access=%08x,", req->access );
......@@ -3286,8 +3274,7 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_read_console_output_request,
(dump_func)dump_move_console_output_request,
(dump_func)dump_send_console_signal_request,
(dump_func)dump_create_change_notification_request,
(dump_func)dump_next_change_notification_request,
(dump_func)dump_read_directory_changes_request,
(dump_func)dump_create_mapping_request,
(dump_func)dump_open_mapping_request,
(dump_func)dump_get_mapping_info_request,
......@@ -3501,7 +3488,6 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_read_console_output_reply,
(dump_func)0,
(dump_func)0,
(dump_func)dump_create_change_notification_reply,
(dump_func)0,
(dump_func)dump_create_mapping_reply,
(dump_func)dump_open_mapping_reply,
......@@ -3716,8 +3702,7 @@ static const char * const req_names[REQ_NB_REQUESTS] = {
"read_console_output",
"move_console_output",
"send_console_signal",
"create_change_notification",
"next_change_notification",
"read_directory_changes",
"create_mapping",
"open_mapping",
"get_mapping_info",
......
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