2003-01-30 01:26:44 +01:00
|
|
|
/*
|
|
|
|
* Server-side file definitions
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Alexandre Julliard
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-01-30 01:26:44 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __WINE_SERVER_FILE_H
|
|
|
|
#define __WINE_SERVER_FILE_H
|
|
|
|
|
2014-08-23 17:01:29 +02:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
2003-01-30 01:26:44 +01:00
|
|
|
#include "object.h"
|
|
|
|
|
|
|
|
struct fd;
|
2011-04-18 14:14:40 +02:00
|
|
|
struct mapping;
|
2007-04-02 20:09:29 +02:00
|
|
|
struct async_queue;
|
2007-09-27 22:03:39 +02:00
|
|
|
struct completion;
|
2003-01-30 01:26:44 +01:00
|
|
|
|
2017-01-26 00:51:49 +01:00
|
|
|
/* server-side representation of I/O status block */
|
|
|
|
struct iosb
|
|
|
|
{
|
|
|
|
struct object obj; /* object header */
|
|
|
|
unsigned int status; /* resulting status (or STATUS_PENDING) */
|
|
|
|
data_size_t result; /* size of result (input or output depending on the type) */
|
|
|
|
data_size_t in_size; /* size of input data */
|
|
|
|
void *in_data; /* input data */
|
|
|
|
data_size_t out_size; /* size of output data */
|
|
|
|
void *out_data; /* output data */
|
|
|
|
};
|
|
|
|
|
2017-07-04 15:26:19 +02:00
|
|
|
struct async_queue
|
|
|
|
{
|
|
|
|
struct list queue; /* queue of async objects */
|
|
|
|
};
|
|
|
|
|
2003-01-30 01:26:44 +01:00
|
|
|
/* operations valid on file descriptor objects */
|
|
|
|
struct fd_ops
|
|
|
|
{
|
|
|
|
/* get the events we want to poll() for on this object */
|
2003-02-14 21:27:09 +01:00
|
|
|
int (*get_poll_events)(struct fd *);
|
2003-07-15 22:53:39 +02:00
|
|
|
/* a poll() event occurred */
|
2003-02-14 21:27:09 +01:00
|
|
|
void (*poll_event)(struct fd *,int event);
|
2003-01-30 01:26:44 +01:00
|
|
|
/* get file information */
|
2007-04-10 22:26:23 +02:00
|
|
|
enum server_fd_type (*get_fd_type)(struct fd *fd);
|
2015-05-05 05:17:45 +02:00
|
|
|
/* perform a read on the file */
|
2017-06-26 12:17:36 +02:00
|
|
|
int (*read)(struct fd *, struct async *, file_pos_t );
|
2015-05-05 05:17:45 +02:00
|
|
|
/* perform a write on the file */
|
2017-06-26 12:18:23 +02:00
|
|
|
int (*write)(struct fd *, struct async *, file_pos_t );
|
2015-05-05 05:17:45 +02:00
|
|
|
/* flush the object buffers */
|
2017-06-26 12:20:20 +02:00
|
|
|
int (*flush)(struct fd *, struct async *);
|
2017-12-21 16:12:01 +01:00
|
|
|
/* query file info */
|
2018-10-15 13:40:36 +02:00
|
|
|
void (*get_file_info)( struct fd *, obj_handle_t, unsigned int );
|
2017-10-02 16:42:16 +02:00
|
|
|
/* query volume info */
|
2020-05-24 05:39:41 +02:00
|
|
|
int (*get_volume_info)( struct fd *, struct async *, unsigned int );
|
2007-04-16 14:45:03 +02:00
|
|
|
/* perform an ioctl on the file */
|
2017-06-26 12:20:10 +02:00
|
|
|
int (*ioctl)(struct fd *fd, ioctl_code_t code, struct async *async );
|
2005-01-14 20:54:38 +01:00
|
|
|
/* queue an async operation */
|
2017-02-15 22:12:45 +01:00
|
|
|
void (*queue_async)(struct fd *, struct async *async, int type, int count);
|
2007-04-10 17:07:27 +02:00
|
|
|
/* selected events for async i/o need an update */
|
|
|
|
void (*reselect_async)( struct fd *, struct async_queue *queue );
|
2003-01-30 01:26:44 +01:00
|
|
|
};
|
|
|
|
|
2003-02-14 21:27:09 +01:00
|
|
|
/* file descriptor functions */
|
|
|
|
|
2007-05-03 16:07:30 +02:00
|
|
|
extern struct fd *alloc_pseudo_fd( const struct fd_ops *fd_user_ops, struct object *user,
|
|
|
|
unsigned int options );
|
2021-02-09 14:11:07 +01:00
|
|
|
extern struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_name,
|
|
|
|
int flags, mode_t *mode, unsigned int access,
|
|
|
|
unsigned int sharing, unsigned int options );
|
2003-03-12 23:38:14 +01:00
|
|
|
extern struct fd *create_anonymous_fd( const struct fd_ops *fd_user_ops,
|
2007-04-10 22:25:07 +02:00
|
|
|
int unix_fd, struct object *user, unsigned int options );
|
2009-11-23 17:09:08 +01:00
|
|
|
extern struct fd *dup_fd_object( struct fd *orig, unsigned int access, unsigned int sharing,
|
|
|
|
unsigned int options );
|
2011-04-19 17:19:31 +02:00
|
|
|
extern struct fd *get_fd_object_for_mapping( struct fd *fd, unsigned int access, unsigned int sharing );
|
2003-02-14 21:27:09 +01:00
|
|
|
extern void *get_fd_user( struct fd *fd );
|
2006-01-24 13:30:55 +01:00
|
|
|
extern void set_fd_user( struct fd *fd, const struct fd_ops *ops, struct object *user );
|
2007-04-10 22:25:07 +02:00
|
|
|
extern unsigned int get_fd_options( struct fd *fd );
|
2018-10-31 16:44:56 +01:00
|
|
|
extern int is_fd_overlapped( struct fd *fd );
|
2003-02-14 21:27:09 +01:00
|
|
|
extern int get_unix_fd( struct fd *fd );
|
2004-03-27 21:48:42 +01:00
|
|
|
extern int is_same_file_fd( struct fd *fd1, struct fd *fd2 );
|
2007-01-12 14:42:43 +01:00
|
|
|
extern int is_fd_removable( struct fd *fd );
|
2003-02-14 21:27:09 +01:00
|
|
|
extern int check_fd_events( struct fd *fd, int events );
|
2003-02-19 01:33:32 +01:00
|
|
|
extern void set_fd_events( struct fd *fd, int events );
|
2003-03-18 06:04:33 +01:00
|
|
|
extern obj_handle_t lock_fd( struct fd *fd, file_pos_t offset, file_pos_t count, int shared, int wait );
|
|
|
|
extern void unlock_fd( struct fd *fd, file_pos_t offset, file_pos_t count );
|
2010-08-23 17:09:45 +02:00
|
|
|
extern void allow_fd_caching( struct fd *fd );
|
2007-04-04 19:39:29 +02:00
|
|
|
extern void set_fd_signaled( struct fd *fd, int signaled );
|
2015-08-21 07:26:44 +02:00
|
|
|
extern char *dup_fd_name( struct fd *root, const char *name );
|
2021-02-09 14:11:07 +01:00
|
|
|
extern void get_nt_name( struct fd *fd, struct unicode_str *name );
|
2003-01-30 01:26:44 +01:00
|
|
|
|
2013-08-26 11:55:04 +02:00
|
|
|
extern int default_fd_signaled( struct object *obj, struct wait_queue_entry *entry );
|
2005-06-07 22:09:01 +02:00
|
|
|
extern int default_fd_get_poll_events( struct fd *fd );
|
2003-02-14 21:27:09 +01:00
|
|
|
extern void default_poll_event( struct fd *fd, int event );
|
2017-07-04 15:26:35 +02:00
|
|
|
extern void fd_queue_async( struct fd *fd, struct async *async, int type );
|
2007-04-02 20:09:29 +02:00
|
|
|
extern void fd_async_wake_up( struct fd *fd, int type, unsigned int status );
|
2007-04-10 17:07:27 +02:00
|
|
|
extern void fd_reselect_async( struct fd *fd, struct async_queue *queue );
|
2017-06-26 12:17:36 +02:00
|
|
|
extern int no_fd_read( struct fd *fd, struct async *async, file_pos_t pos );
|
2017-06-26 12:18:23 +02:00
|
|
|
extern int no_fd_write( struct fd *fd, struct async *async, file_pos_t pos );
|
2017-06-26 12:20:20 +02:00
|
|
|
extern int no_fd_flush( struct fd *fd, struct async *async );
|
2018-10-15 13:40:36 +02:00
|
|
|
extern void no_fd_get_file_info( struct fd *fd, obj_handle_t handle, unsigned int info_class );
|
2018-10-23 17:45:06 +02:00
|
|
|
extern void default_fd_get_file_info( struct fd *fd, obj_handle_t handle, unsigned int info_class );
|
2020-05-24 05:39:41 +02:00
|
|
|
extern int no_fd_get_volume_info( struct fd *fd, struct async *async, unsigned int info_class );
|
2017-06-26 12:20:10 +02:00
|
|
|
extern int no_fd_ioctl( struct fd *fd, ioctl_code_t code, struct async *async );
|
|
|
|
extern int default_fd_ioctl( struct fd *fd, ioctl_code_t code, struct async *async );
|
2017-02-15 22:12:45 +01:00
|
|
|
extern void no_fd_queue_async( struct fd *fd, struct async *async, int type, int count );
|
|
|
|
extern void default_fd_queue_async( struct fd *fd, struct async *async, int type, int count );
|
2007-04-10 17:07:27 +02:00
|
|
|
extern void default_fd_reselect_async( struct fd *fd, struct async_queue *queue );
|
2003-02-19 01:33:32 +01:00
|
|
|
extern void main_loop(void);
|
2005-06-14 13:40:40 +02:00
|
|
|
extern void remove_process_locks( struct process *process );
|
2003-02-14 21:27:09 +01:00
|
|
|
|
2007-03-17 11:52:14 +01:00
|
|
|
static inline struct fd *get_obj_fd( struct object *obj ) { return obj->ops->get_fd( obj ); }
|
2003-02-14 21:27:09 +01:00
|
|
|
|
2003-02-19 01:33:32 +01:00
|
|
|
/* timeout functions */
|
|
|
|
|
|
|
|
struct timeout_user;
|
2007-04-17 20:08:59 +02:00
|
|
|
extern timeout_t current_time;
|
2020-04-06 17:21:03 +02:00
|
|
|
extern timeout_t monotonic_time;
|
2020-05-25 20:25:50 +02:00
|
|
|
extern struct _KUSER_SHARED_DATA *user_shared_data;
|
2007-04-17 20:08:59 +02:00
|
|
|
|
|
|
|
#define TICKS_PER_SEC 10000000
|
2003-02-19 01:33:32 +01:00
|
|
|
|
|
|
|
typedef void (*timeout_callback)( void *private );
|
|
|
|
|
2020-04-06 17:21:03 +02:00
|
|
|
static inline abstime_t timeout_to_abstime( timeout_t timeout )
|
|
|
|
{
|
|
|
|
return timeout > 0 ? timeout : timeout - monotonic_time;
|
|
|
|
}
|
|
|
|
|
2020-04-06 17:21:07 +02:00
|
|
|
static inline timeout_t abstime_to_timeout( abstime_t abstime )
|
|
|
|
{
|
|
|
|
if (abstime > 0) return abstime;
|
|
|
|
return -abstime < monotonic_time ? 0 : abstime + monotonic_time;
|
|
|
|
}
|
|
|
|
|
2020-04-06 17:20:58 +02:00
|
|
|
extern void set_current_time( void );
|
2007-04-17 20:08:59 +02:00
|
|
|
extern struct timeout_user *add_timeout_user( timeout_t when, timeout_callback func, void *private );
|
2003-02-19 01:33:32 +01:00
|
|
|
extern void remove_timeout_user( struct timeout_user *user );
|
2007-04-17 20:08:59 +02:00
|
|
|
extern const char *get_timeout_str( timeout_t timeout );
|
2003-02-19 01:33:32 +01:00
|
|
|
|
2003-02-14 21:27:09 +01:00
|
|
|
/* file functions */
|
|
|
|
|
|
|
|
extern struct file *get_file_obj( struct process *process, obj_handle_t handle,
|
|
|
|
unsigned int access );
|
|
|
|
extern int get_file_unix_fd( struct file *file );
|
2009-11-23 16:20:15 +01:00
|
|
|
extern struct file *create_file_for_fd( int fd, unsigned int access, unsigned int sharing );
|
2011-04-18 13:41:54 +02:00
|
|
|
extern struct file *create_file_for_fd_obj( struct fd *fd, unsigned int access, unsigned int sharing );
|
2003-02-14 21:27:09 +01:00
|
|
|
extern void file_set_error(void);
|
2008-11-03 23:25:37 +01:00
|
|
|
extern struct security_descriptor *mode_to_sd( mode_t mode, const SID *user, const SID *group );
|
|
|
|
extern mode_t sd_to_mode( const struct security_descriptor *sd, const SID *owner );
|
2020-03-11 04:38:25 +01:00
|
|
|
extern int is_file_executable( const char *name );
|
2003-01-30 01:26:44 +01:00
|
|
|
|
2011-04-18 13:41:54 +02:00
|
|
|
/* file mapping functions */
|
|
|
|
|
2021-02-02 10:12:56 +01:00
|
|
|
struct memory_view;
|
|
|
|
|
|
|
|
extern struct memory_view *find_mapped_view( struct process *process, client_ptr_t base );
|
|
|
|
extern struct memory_view *get_exe_view( struct process *process );
|
|
|
|
extern struct file *get_view_file( const struct memory_view *view, unsigned int access, unsigned int sharing );
|
|
|
|
extern const pe_image_info_t *get_view_image_info( const struct memory_view *view, client_ptr_t *base );
|
2021-02-09 16:14:27 +01:00
|
|
|
extern int get_view_nt_name( const struct memory_view *view, struct unicode_str *name );
|
2017-09-26 14:11:49 +02:00
|
|
|
extern void free_mapped_views( struct process *process );
|
2011-04-18 13:41:54 +02:00
|
|
|
extern int get_page_size(void);
|
2020-11-27 16:41:07 +01:00
|
|
|
extern struct mapping *create_fd_mapping( struct object *root, const struct unicode_str *name, struct fd *fd,
|
|
|
|
unsigned int attr, const struct security_descriptor *sd );
|
2020-05-29 12:26:57 +02:00
|
|
|
extern struct object *create_user_data_mapping( struct object *root, const struct unicode_str *name,
|
|
|
|
unsigned int attr, const struct security_descriptor *sd );
|
2020-05-11 13:12:48 +02:00
|
|
|
|
2015-05-21 10:19:51 +02:00
|
|
|
/* device functions */
|
|
|
|
|
2020-09-23 11:32:47 +02:00
|
|
|
extern struct object *create_named_pipe_device( struct object *root, const struct unicode_str *name,
|
|
|
|
unsigned int attr, const struct security_descriptor *sd );
|
|
|
|
extern struct object *create_mailslot_device( struct object *root, const struct unicode_str *name,
|
|
|
|
unsigned int attr, const struct security_descriptor *sd );
|
|
|
|
extern struct object *create_console_device( struct object *root, const struct unicode_str *name,
|
|
|
|
unsigned int attr, const struct security_descriptor *sd );
|
|
|
|
extern struct object *create_socket_device( struct object *root, const struct unicode_str *name,
|
|
|
|
unsigned int attr, const struct security_descriptor *sd );
|
2016-07-18 08:34:08 +02:00
|
|
|
extern struct object *create_unix_device( struct object *root, const struct unicode_str *name,
|
2020-09-23 11:32:47 +02:00
|
|
|
unsigned int attr, const struct security_descriptor *sd, const char *unix_path );
|
2015-05-21 10:19:51 +02:00
|
|
|
|
2003-03-27 00:41:43 +01:00
|
|
|
/* change notification functions */
|
|
|
|
|
|
|
|
extern void do_change_notify( int unix_fd );
|
|
|
|
extern void sigio_callback(void);
|
2009-08-17 17:18:54 +02:00
|
|
|
extern struct object *create_dir_obj( struct fd *fd, unsigned int access, mode_t mode );
|
2009-12-01 17:38:24 +01:00
|
|
|
extern struct dir *get_dir_obj( struct process *process, obj_handle_t handle, unsigned int access );
|
2003-03-27 00:41:43 +01:00
|
|
|
|
2007-09-27 22:03:39 +02:00
|
|
|
/* completion */
|
|
|
|
|
2007-11-09 23:11:48 +01:00
|
|
|
extern struct completion *get_completion_obj( struct process *process, obj_handle_t handle, unsigned int access );
|
2008-12-15 13:29:38 +01:00
|
|
|
extern void add_completion( struct completion *completion, apc_param_t ckey, apc_param_t cvalue,
|
2013-08-23 12:37:51 +02:00
|
|
|
unsigned int status, apc_param_t information );
|
2007-09-27 22:03:39 +02:00
|
|
|
|
2004-03-18 05:08:48 +01:00
|
|
|
/* serial port functions */
|
|
|
|
|
|
|
|
extern int is_serial_fd( struct fd *fd );
|
2007-04-10 22:25:07 +02:00
|
|
|
extern struct object *create_serial( struct fd *fd );
|
2004-03-18 05:08:48 +01:00
|
|
|
|
2005-01-14 20:54:38 +01:00
|
|
|
/* async I/O functions */
|
2021-02-09 00:40:42 +01:00
|
|
|
|
|
|
|
typedef void (*async_completion_callback)( void *private );
|
|
|
|
|
2007-04-03 19:36:07 +02:00
|
|
|
extern void free_async_queue( struct async_queue *queue );
|
2017-06-26 12:19:28 +02:00
|
|
|
extern struct async *create_async( struct fd *fd, struct thread *thread, const async_data_t *data, struct iosb *iosb );
|
2018-10-25 14:56:08 +02:00
|
|
|
extern struct async *create_request_async( struct fd *fd, unsigned int comp_flags, const async_data_t *data );
|
2018-10-31 16:45:04 +01:00
|
|
|
extern obj_handle_t async_handoff( struct async *async, int success, data_size_t *result, int force_blocking );
|
2017-02-15 22:12:28 +01:00
|
|
|
extern void queue_async( struct async_queue *queue, struct async *async );
|
2007-04-17 20:08:59 +02:00
|
|
|
extern void async_set_timeout( struct async *async, timeout_t timeout, unsigned int status );
|
2017-04-10 13:21:41 +02:00
|
|
|
extern void async_set_result( struct object *obj, unsigned int status, apc_param_t total );
|
2021-02-09 00:40:42 +01:00
|
|
|
extern void async_set_completion_callback( struct async *async, async_completion_callback func, void *private );
|
2019-05-23 19:36:27 +02:00
|
|
|
extern void set_async_pending( struct async *async, int signal );
|
2007-04-02 20:09:29 +02:00
|
|
|
extern int async_waiting( struct async_queue *queue );
|
2007-05-08 20:37:21 +02:00
|
|
|
extern void async_terminate( struct async *async, unsigned int status );
|
2007-04-02 20:09:29 +02:00
|
|
|
extern void async_wake_up( struct async_queue *queue, unsigned int status );
|
2009-03-02 20:34:39 +01:00
|
|
|
extern struct completion *fd_get_completion( struct fd *fd, apc_param_t *p_key );
|
|
|
|
extern void fd_copy_completion( struct fd *src, struct fd *dst );
|
2016-12-04 21:21:25 +01:00
|
|
|
extern struct iosb *create_iosb( const void *in_data, data_size_t in_size, data_size_t out_size );
|
2017-02-15 22:12:37 +01:00
|
|
|
extern struct iosb *async_get_iosb( struct async *async );
|
2020-10-19 18:21:19 +02:00
|
|
|
extern struct thread *async_get_thread( struct async *async );
|
2017-04-12 13:53:41 +02:00
|
|
|
extern int async_is_blocking( struct async *async );
|
2017-03-23 15:41:43 +01:00
|
|
|
extern struct async *find_pending_async( struct async_queue *queue );
|
2016-12-01 12:10:47 +01:00
|
|
|
extern void cancel_process_asyncs( struct process *process );
|
2005-01-14 20:54:38 +01:00
|
|
|
|
2017-07-04 15:26:19 +02:00
|
|
|
static inline void init_async_queue( struct async_queue *queue )
|
|
|
|
{
|
|
|
|
list_init( &queue->queue );
|
|
|
|
}
|
|
|
|
|
2017-07-04 15:26:26 +02:00
|
|
|
static inline int async_queued( struct async_queue *queue )
|
|
|
|
{
|
|
|
|
return !list_empty( &queue->queue );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-12 16:46:17 +01:00
|
|
|
/* access rights that require Unix read permission */
|
|
|
|
#define FILE_UNIX_READ_ACCESS (FILE_READ_DATA|FILE_READ_ATTRIBUTES|FILE_READ_EA)
|
|
|
|
|
|
|
|
/* access rights that require Unix write permission */
|
2013-10-02 07:01:28 +02:00
|
|
|
#define FILE_UNIX_WRITE_ACCESS (FILE_WRITE_DATA|FILE_APPEND_DATA|FILE_WRITE_ATTRIBUTES|FILE_WRITE_EA)
|
2005-12-12 16:46:17 +01:00
|
|
|
|
2009-11-23 17:09:08 +01:00
|
|
|
/* magic file access rights for mappings */
|
2009-11-23 17:24:09 +01:00
|
|
|
#define FILE_MAPPING_IMAGE 0x80000000 /* set for SEC_IMAGE mappings */
|
|
|
|
#define FILE_MAPPING_WRITE 0x40000000 /* set for writable shared mappings */
|
|
|
|
#define FILE_MAPPING_ACCESS 0x20000000 /* set for all mappings */
|
2009-11-23 17:09:08 +01:00
|
|
|
|
2003-01-30 01:26:44 +01:00
|
|
|
#endif /* __WINE_SERVER_FILE_H */
|