2003-01-30 00:26:44 +00: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 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-01-30 00:26:44 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __WINE_SERVER_FILE_H
|
|
|
|
#define __WINE_SERVER_FILE_H
|
|
|
|
|
|
|
|
#include "object.h"
|
|
|
|
|
|
|
|
struct fd;
|
2011-04-18 12:14:40 +00:00
|
|
|
struct mapping;
|
2007-04-02 18:09:29 +00:00
|
|
|
struct async_queue;
|
2007-09-27 20:03:39 +00:00
|
|
|
struct completion;
|
2003-01-30 00:26:44 +00:00
|
|
|
|
|
|
|
/* operations valid on file descriptor objects */
|
|
|
|
struct fd_ops
|
|
|
|
{
|
|
|
|
/* get the events we want to poll() for on this object */
|
2003-02-14 20:27:09 +00:00
|
|
|
int (*get_poll_events)(struct fd *);
|
2003-07-15 20:53:39 +00:00
|
|
|
/* a poll() event occurred */
|
2003-02-14 20:27:09 +00:00
|
|
|
void (*poll_event)(struct fd *,int event);
|
2003-01-30 00:26:44 +00:00
|
|
|
/* flush the object buffers */
|
2007-03-27 14:51:44 +00:00
|
|
|
void (*flush)(struct fd *, struct event **);
|
2003-01-30 00:26:44 +00:00
|
|
|
/* get file information */
|
2007-04-10 20:26:23 +00:00
|
|
|
enum server_fd_type (*get_fd_type)(struct fd *fd);
|
2007-04-16 12:45:03 +00:00
|
|
|
/* perform an ioctl on the file */
|
2008-12-30 19:37:20 +00:00
|
|
|
obj_handle_t (*ioctl)(struct fd *fd, ioctl_code_t code, const async_data_t *async, int blocking,
|
2007-05-03 15:43:18 +00:00
|
|
|
const void *data, data_size_t size);
|
2005-01-14 19:54:38 +00:00
|
|
|
/* queue an async operation */
|
2007-03-20 19:21:12 +00:00
|
|
|
void (*queue_async)(struct fd *, const async_data_t *data, int type, int count);
|
2007-04-10 15:07:27 +00:00
|
|
|
/* selected events for async i/o need an update */
|
|
|
|
void (*reselect_async)( struct fd *, struct async_queue *queue );
|
2005-01-14 19:54:38 +00:00
|
|
|
/* cancel an async operation */
|
2009-08-09 04:08:27 +00:00
|
|
|
void (*cancel_async)(struct fd *, struct process *process, struct thread *thread, client_ptr_t iosb);
|
2003-01-30 00:26:44 +00:00
|
|
|
};
|
|
|
|
|
2003-02-14 20:27:09 +00:00
|
|
|
/* file descriptor functions */
|
|
|
|
|
2007-05-03 14:07:30 +00:00
|
|
|
extern struct fd *alloc_pseudo_fd( const struct fd_ops *fd_user_ops, struct object *user,
|
|
|
|
unsigned int options );
|
2007-04-18 14:05:59 +00:00
|
|
|
extern void set_no_fd_status( struct fd *fd, unsigned int status );
|
2009-12-01 16:38:24 +00: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 22:38:14 +00:00
|
|
|
extern struct fd *create_anonymous_fd( const struct fd_ops *fd_user_ops,
|
2007-04-10 20:25:07 +00:00
|
|
|
int unix_fd, struct object *user, unsigned int options );
|
2009-11-23 16:09:08 +00:00
|
|
|
extern struct fd *dup_fd_object( struct fd *orig, unsigned int access, unsigned int sharing,
|
|
|
|
unsigned int options );
|
2011-04-19 15:19:31 +00:00
|
|
|
extern struct fd *get_fd_object_for_mapping( struct fd *fd, unsigned int access, unsigned int sharing );
|
2003-02-14 20:27:09 +00:00
|
|
|
extern void *get_fd_user( struct fd *fd );
|
2006-01-24 12:30:55 +00:00
|
|
|
extern void set_fd_user( struct fd *fd, const struct fd_ops *ops, struct object *user );
|
2007-04-10 20:25:07 +00:00
|
|
|
extern unsigned int get_fd_options( struct fd *fd );
|
2003-02-14 20:27:09 +00:00
|
|
|
extern int get_unix_fd( struct fd *fd );
|
2004-03-27 20:48:42 +00:00
|
|
|
extern int is_same_file_fd( struct fd *fd1, struct fd *fd2 );
|
2007-01-12 13:42:43 +00:00
|
|
|
extern int is_fd_removable( struct fd *fd );
|
2006-11-02 19:52:22 +00:00
|
|
|
extern int fd_close_handle( struct object *obj, struct process *process, obj_handle_t handle );
|
2003-02-14 20:27:09 +00:00
|
|
|
extern int check_fd_events( struct fd *fd, int events );
|
2003-02-19 00:33:32 +00:00
|
|
|
extern void set_fd_events( struct fd *fd, int events );
|
2003-03-18 05:04:33 +00: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 15:09:45 +00:00
|
|
|
extern void allow_fd_caching( struct fd *fd );
|
2007-04-04 17:39:29 +00:00
|
|
|
extern void set_fd_signaled( struct fd *fd, int signaled );
|
2009-06-09 10:11:05 +00:00
|
|
|
extern int is_fd_signaled( struct fd *fd );
|
2003-01-30 00:26:44 +00:00
|
|
|
|
|
|
|
extern int default_fd_signaled( struct object *obj, struct thread *thread );
|
2007-10-02 12:20:15 +00:00
|
|
|
extern unsigned int default_fd_map_access( struct object *obj, unsigned int access );
|
2005-06-07 20:09:01 +00:00
|
|
|
extern int default_fd_get_poll_events( struct fd *fd );
|
2003-02-14 20:27:09 +00:00
|
|
|
extern void default_poll_event( struct fd *fd, int event );
|
2008-12-26 11:27:48 +00:00
|
|
|
extern struct async *fd_queue_async( struct fd *fd, const async_data_t *data, int type );
|
2007-04-02 18:09:29 +00:00
|
|
|
extern void fd_async_wake_up( struct fd *fd, int type, unsigned int status );
|
2007-04-10 15:07:27 +00:00
|
|
|
extern void fd_reselect_async( struct fd *fd, struct async_queue *queue );
|
2009-11-23 15:16:46 +00:00
|
|
|
extern obj_handle_t no_fd_ioctl( struct fd *fd, ioctl_code_t code, const async_data_t *async,
|
|
|
|
int blocking, const void *data, data_size_t size );
|
2007-05-03 15:43:18 +00:00
|
|
|
extern obj_handle_t default_fd_ioctl( struct fd *fd, ioctl_code_t code, const async_data_t *async,
|
2008-12-30 19:37:20 +00:00
|
|
|
int blocking, const void *data, data_size_t size );
|
2009-11-23 15:16:46 +00:00
|
|
|
extern void no_fd_queue_async( struct fd *fd, const async_data_t *data, int type, int count );
|
2007-03-20 19:21:12 +00:00
|
|
|
extern void default_fd_queue_async( struct fd *fd, const async_data_t *data, int type, int count );
|
2007-04-10 15:07:27 +00:00
|
|
|
extern void default_fd_reselect_async( struct fd *fd, struct async_queue *queue );
|
2009-08-09 04:08:27 +00:00
|
|
|
extern void default_fd_cancel_async( struct fd *fd, struct process *process, struct thread *thread, client_ptr_t iosb );
|
2007-03-27 14:51:44 +00:00
|
|
|
extern void no_flush( struct fd *fd, struct event **event );
|
2003-02-19 00:33:32 +00:00
|
|
|
extern void main_loop(void);
|
2005-06-14 11:40:40 +00:00
|
|
|
extern void remove_process_locks( struct process *process );
|
2003-02-14 20:27:09 +00:00
|
|
|
|
2007-03-17 10:52:14 +00:00
|
|
|
static inline struct fd *get_obj_fd( struct object *obj ) { return obj->ops->get_fd( obj ); }
|
2003-02-14 20:27:09 +00:00
|
|
|
|
2003-02-19 00:33:32 +00:00
|
|
|
/* timeout functions */
|
|
|
|
|
|
|
|
struct timeout_user;
|
2007-04-17 18:08:59 +00:00
|
|
|
extern timeout_t current_time;
|
|
|
|
|
|
|
|
#define TICKS_PER_SEC 10000000
|
2003-02-19 00:33:32 +00:00
|
|
|
|
|
|
|
typedef void (*timeout_callback)( void *private );
|
|
|
|
|
2007-04-17 18:08:59 +00:00
|
|
|
extern struct timeout_user *add_timeout_user( timeout_t when, timeout_callback func, void *private );
|
2003-02-19 00:33:32 +00:00
|
|
|
extern void remove_timeout_user( struct timeout_user *user );
|
2007-04-17 18:08:59 +00:00
|
|
|
extern const char *get_timeout_str( timeout_t timeout );
|
2003-02-19 00:33:32 +00:00
|
|
|
|
2003-02-14 20:27:09 +00: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 15:20:15 +00:00
|
|
|
extern struct file *create_file_for_fd( int fd, unsigned int access, unsigned int sharing );
|
2011-04-18 11:41:54 +00:00
|
|
|
extern struct file *create_file_for_fd_obj( struct fd *fd, unsigned int access, unsigned int sharing );
|
2003-02-14 20:27:09 +00:00
|
|
|
extern void file_set_error(void);
|
2008-11-03 22:25:37 +00: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 00:26:44 +00:00
|
|
|
|
2011-04-18 11:41:54 +00: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 12:14:40 +00:00
|
|
|
extern struct mapping *grab_mapping_unless_removable( struct mapping *mapping );
|
2011-04-18 11:41:54 +00:00
|
|
|
extern int get_page_size(void);
|
|
|
|
|
2003-03-26 23:41:43 +00:00
|
|
|
/* change notification functions */
|
|
|
|
|
|
|
|
extern void do_change_notify( int unix_fd );
|
|
|
|
extern void sigio_callback(void);
|
2009-08-17 15:18:54 +00:00
|
|
|
extern struct object *create_dir_obj( struct fd *fd, unsigned int access, mode_t mode );
|
2009-12-01 16:38:24 +00:00
|
|
|
extern struct dir *get_dir_obj( struct process *process, obj_handle_t handle, unsigned int access );
|
2003-03-26 23:41:43 +00:00
|
|
|
|
2007-09-27 20:03:39 +00:00
|
|
|
/* completion */
|
|
|
|
|
2007-11-09 22:11:48 +00:00
|
|
|
extern struct completion *get_completion_obj( struct process *process, obj_handle_t handle, unsigned int access );
|
2008-12-15 12:29:38 +00:00
|
|
|
extern void add_completion( struct completion *completion, apc_param_t ckey, apc_param_t cvalue,
|
2008-12-15 12:30:25 +00:00
|
|
|
unsigned int status, unsigned int information );
|
2007-09-27 20:03:39 +00:00
|
|
|
|
2004-03-18 04:08:48 +00:00
|
|
|
/* serial port functions */
|
|
|
|
|
|
|
|
extern int is_serial_fd( struct fd *fd );
|
2007-04-10 20:25:07 +00:00
|
|
|
extern struct object *create_serial( struct fd *fd );
|
2004-03-18 04:08:48 +00:00
|
|
|
|
2005-01-14 19:54:38 +00:00
|
|
|
/* async I/O functions */
|
2007-04-02 18:09:29 +00:00
|
|
|
extern struct async_queue *create_async_queue( struct fd *fd );
|
2007-04-03 17:36:07 +00:00
|
|
|
extern void free_async_queue( struct async_queue *queue );
|
2007-04-02 18:41:59 +00:00
|
|
|
extern struct async *create_async( struct thread *thread, struct async_queue *queue,
|
|
|
|
const async_data_t *data );
|
2007-04-17 18:08:59 +00:00
|
|
|
extern void async_set_timeout( struct async *async, timeout_t timeout, unsigned int status );
|
2008-12-30 20:09:41 +00:00
|
|
|
extern void async_set_result( struct object *obj, unsigned int status,
|
|
|
|
unsigned int total, client_ptr_t apc );
|
2010-05-15 05:18:20 +00:00
|
|
|
extern int async_queued( struct async_queue *queue );
|
2007-04-02 18:09:29 +00:00
|
|
|
extern int async_waiting( struct async_queue *queue );
|
2007-05-08 18:37:21 +00:00
|
|
|
extern void async_terminate( struct async *async, unsigned int status );
|
2009-08-09 04:08:27 +00:00
|
|
|
extern int async_wake_up_by( struct async_queue *queue, struct process *process,
|
|
|
|
struct thread *thread, client_ptr_t iosb, unsigned int status );
|
2007-04-02 18:09:29 +00:00
|
|
|
extern void async_wake_up( struct async_queue *queue, unsigned int status );
|
2009-03-02 19:34:39 +00: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 );
|
2005-01-14 19:54:38 +00:00
|
|
|
|
2005-12-12 15:46:17 +00: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 */
|
|
|
|
#define FILE_UNIX_WRITE_ACCESS (FILE_WRITE_DATA|FILE_WRITE_ATTRIBUTES|FILE_WRITE_EA)
|
|
|
|
|
2009-11-23 16:09:08 +00:00
|
|
|
/* magic file access rights for mappings */
|
2009-11-23 16:24:09 +00: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 16:09:08 +00:00
|
|
|
|
2003-01-30 00:26:44 +00:00
|
|
|
#endif /* __WINE_SERVER_FILE_H */
|