2 * Copyright 2002-2006, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
15 struct file_descriptor
;
19 extern io_context
* gKernelIOContext
;
23 fssh_status_t (*fd_read
)(struct file_descriptor
*, fssh_off_t pos
,
24 void *buffer
, fssh_size_t
*length
);
25 fssh_status_t (*fd_write
)(struct file_descriptor
*, fssh_off_t pos
,
26 const void *buffer
, fssh_size_t
*length
);
27 fssh_off_t (*fd_seek
)(struct file_descriptor
*, fssh_off_t pos
,
29 fssh_status_t (*fd_ioctl
)(struct file_descriptor
*, uint32_t op
,
30 void *buffer
, fssh_size_t length
);
31 fssh_status_t (*fd_select
)(struct file_descriptor
*, uint8_t event
,
32 uint32_t ref
, struct select_sync
*sync
);
33 fssh_status_t (*fd_deselect
)(struct file_descriptor
*, uint8_t event
,
34 struct select_sync
*sync
);
35 fssh_status_t (*fd_read_dir
)(struct file_descriptor
*,
36 struct fssh_dirent
*buffer
, fssh_size_t bufferSize
,
38 fssh_status_t (*fd_rewind_dir
)(struct file_descriptor
*);
39 fssh_status_t (*fd_read_stat
)(struct file_descriptor
*,
41 fssh_status_t (*fd_write_stat
)(struct file_descriptor
*,
42 const struct fssh_stat
*, int statMask
);
43 fssh_status_t (*fd_close
)(struct file_descriptor
*);
44 void (*fd_free
)(struct file_descriptor
*);
47 struct file_descriptor
{
48 int32_t type
; /* descriptor type */
54 struct fs_mount
* mount
;
62 /* Types of file descriptors we can create */
75 // additional open mode - kernel special
76 #define FSSH_O_DISCONNECTED 0x80000000
80 extern file_descriptor
* alloc_fd(void);
81 extern int new_fd_etc(struct io_context
*,
82 struct file_descriptor
*, int firstIndex
);
83 extern int new_fd(struct io_context
*, struct file_descriptor
*);
84 extern file_descriptor
* get_fd(struct io_context
*, int);
85 extern void close_fd(struct file_descriptor
*descriptor
);
86 extern void put_fd(struct file_descriptor
*descriptor
);
87 extern void disconnect_fd(struct file_descriptor
*descriptor
);
88 extern void inc_fd_ref_count(struct file_descriptor
*descriptor
);
89 extern fssh_status_t
select_fd(int fd
, uint8_t event
, uint32_t ref
,
90 struct select_sync
*sync
, bool kernel
);
91 extern fssh_status_t
deselect_fd(int fd
, uint8_t event
,
92 struct select_sync
*sync
, bool kernel
);
93 extern bool fd_is_valid(int fd
, bool kernel
);
94 extern vnode
* fd_vnode(struct file_descriptor
*descriptor
);
96 extern bool fd_close_on_exec(struct io_context
*context
, int fd
);
97 extern void fd_set_close_on_exec(struct io_context
*context
, int fd
,
100 static io_context
* get_current_io_context(bool kernel
);
102 /* The prototypes of the (sys|user)_ functions are currently defined in vfs.h */
107 static inline struct io_context
*
108 get_current_io_context(bool /*kernel*/)
110 return gKernelIOContext
;
114 } // namespace FSShell
117 #endif /* _FSSH_FD_H */