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 */
|
|
|
|
};
|
|
|
|
|
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-02-15 22:12:37 +01:00
|
|
|
obj_handle_t (*read)(struct fd *, struct async *, int, file_pos_t );
|
2015-05-05 05:17:45 +02:00
|
|
|
/* perform a write on the file */
|
2017-02-15 22:12:37 +01:00
|
|
|
obj_handle_t (*write)(struct fd *, struct async *, int, file_pos_t );
|
2015-05-05 05:17:45 +02:00
|
|
|
/* flush the object buffers */
|
2017-02-15 22:13:17 +01:00
|
|
|
obj_handle_t (*flush)(struct fd *, struct async *, int);
|
2007-04-16 14:45:03 +02:00
|
|
|
/* perform an ioctl on the file */
|
2017-02-15 22:12:59 +01:00
|
|
|
obj_handle_t (*ioctl)(struct fd *fd, ioctl_code_t code, struct async *async, int blocking );
|
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 );
|
2007-04-18 16:05:59 +02:00
|
|
|
extern void set_no_fd_status( struct fd *fd, unsigned int status );
|
2009-12-01 17:38:24 +01:00
|
|
|
extern struct fd *open_fd( struct fd *root, const char *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 );
|
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 );
|
2006-11-02 20:52:22 +01:00
|
|
|
extern int fd_close_handle( struct object *obj, struct process *process, obj_handle_t handle );
|
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 );
|
2009-06-09 12:11:05 +02:00
|
|
|
extern int is_fd_signaled( struct fd *fd );
|
2015-08-21 07:26:44 +02:00
|
|
|
extern char *dup_fd_name( struct fd *root, const char *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 );
|
2007-10-02 14:20:15 +02:00
|
|
|
extern unsigned int default_fd_map_access( struct object *obj, unsigned int access );
|
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-02-22 14:50:49 +01:00
|
|
|
extern int 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-02-15 22:12:37 +01:00
|
|
|
extern obj_handle_t no_fd_read( struct fd *fd, struct async *async, int blocking, file_pos_t pos );
|
|
|
|
extern obj_handle_t no_fd_write( struct fd *fd, struct async *async, int blocking, file_pos_t pos );
|
2017-02-15 22:13:17 +01:00
|
|
|
extern obj_handle_t no_fd_flush( struct fd *fd, struct async *async, int blocking );
|
2017-02-15 22:12:59 +01:00
|
|
|
extern obj_handle_t no_fd_ioctl( struct fd *fd, ioctl_code_t code, struct async *async, int blocking );
|
|
|
|
extern obj_handle_t default_fd_ioctl( struct fd *fd, ioctl_code_t code, struct async *async, int blocking );
|
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;
|
|
|
|
|
|
|
|
#define TICKS_PER_SEC 10000000
|
2003-02-19 01:33:32 +01:00
|
|
|
|
|
|
|
typedef void (*timeout_callback)( void *private );
|
|
|
|
|
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 );
|
|
|
|
extern int is_same_file( struct file *file1, struct file *file2 );
|
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 );
|
2003-01-30 01:26:44 +01:00
|
|
|
|
2011-04-18 13:41:54 +02:00
|
|
|
/* file mapping functions */
|
|
|
|
|
|
|
|
extern struct mapping *get_mapping_obj( struct process *process, obj_handle_t handle,
|
|
|
|
unsigned int access );
|
|
|
|
extern obj_handle_t open_mapping_file( struct process *process, struct mapping *mapping,
|
|
|
|
unsigned int access, unsigned int sharing );
|
2011-04-18 14:14:40 +02:00
|
|
|
extern struct mapping *grab_mapping_unless_removable( struct mapping *mapping );
|
2011-04-18 13:41:54 +02:00
|
|
|
extern int get_page_size(void);
|
|
|
|
|
2015-05-21 10:19:51 +02:00
|
|
|
/* device functions */
|
|
|
|
|
2016-07-18 08:34:08 +02:00
|
|
|
extern struct object *create_named_pipe_device( struct object *root, const struct unicode_str *name );
|
|
|
|
extern struct object *create_mailslot_device( struct object *root, const struct unicode_str *name );
|
|
|
|
extern struct object *create_unix_device( struct object *root, const struct unicode_str *name,
|
2015-05-21 10:19:51 +02:00
|
|
|
const char *unix_path );
|
|
|
|
|
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 */
|
2007-04-02 20:09:29 +02:00
|
|
|
extern struct async_queue *create_async_queue( struct fd *fd );
|
2007-04-03 19:36:07 +02:00
|
|
|
extern void free_async_queue( struct async_queue *queue );
|
2017-02-15 22:12:28 +01:00
|
|
|
extern struct async *create_async( struct thread *thread, const async_data_t *data, struct iosb *iosb );
|
|
|
|
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 );
|
2008-12-30 21:09:41 +01:00
|
|
|
extern void async_set_result( struct object *obj, unsigned int status,
|
2015-03-03 07:52:23 +01:00
|
|
|
apc_param_t total, client_ptr_t apc, client_ptr_t apc_arg );
|
2010-05-15 07:18:20 +02:00
|
|
|
extern int async_queued( struct async_queue *queue );
|
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 );
|
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
|
|
|
|
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 */
|