152a38012Sejakowatz/*
28bca37d6SAdrien Destugues * Copyright 2002-2018, Axel D��rfler, axeld@pinc-software.de.
3d12de920SAxel Dörfler * Distributed under the terms of the MIT License.
4d12de920SAxel Dörfler *
5d12de920SAxel Dörfler * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
6d12de920SAxel Dörfler * Distributed under the terms of the NewOS License.
7d12de920SAxel Dörfler */
852a38012Sejakowatz#ifndef _KERNEL_VFS_H
952a38012Sejakowatz#define _KERNEL_VFS_H
1052a38012Sejakowatz
11606e0d36SAxel Dörfler
1252a38012Sejakowatz#include <kernel.h>
13f9bdcca5SAxel Dörfler#include <lock.h>
14c7a03dadSAxel Dörfler#include <util/list.h>
1552a38012Sejakowatz
16606e0d36SAxel Dörfler#include <fs_interface.h>
17606e0d36SAxel Dörfler
18606e0d36SAxel Dörfler#include <dirent.h>
19606e0d36SAxel Dörfler#include <signal.h>
20df50f7a9SIngo Weinhold#include <sys/socket.h>
21606e0d36SAxel Dörfler#include <sys/stat.h>
22606e0d36SAxel Dörfler#include <sys/select.h>
23606e0d36SAxel Dörfler
246b202f4eSIngo Weinhold#include <vfs_defs.h>
256b202f4eSIngo Weinhold
26606e0d36SAxel Dörfler
27245aecdaSAxel Dörfler#define DEFAULT_FD_TABLE_SIZE	256
282dedc014SFrançois Revol#define MAX_FD_TABLE_SIZE		8192
29e6bd90c5SIngo Weinhold#define DEFAULT_NODE_MONITORS	4096
302dedc014SFrançois Revol#define MAX_NODE_MONITORS		65536
3152a38012Sejakowatz
326e122bd9SIngo Weinhold#define B_UNMOUNT_BUSY_PARTITION	0x80000000
336e122bd9SIngo Weinhold
348ae594ffSAxel Dörflerstruct attr_info;
35f9bdcca5SAxel Dörflerstruct file_descriptor;
36435c43f5SIngo Weinholdstruct generic_io_vec;
37df50f7a9SIngo Weinholdstruct kernel_args;
38df50f7a9SIngo Weinholdstruct net_stat;
39df50f7a9SIngo Weinholdstruct pollfd;
408ae594ffSAxel Dörflerstruct rlimit;
41f9bdcca5SAxel Dörflerstruct selectsync;
4266c03dc3SIngo Weinholdstruct select_info;
435c99d639SIngo Weinholdstruct VMCache;
446d4aea47SAxel Dörflerstruct vnode;
45f9bdcca5SAxel Dörfler
46f9bdcca5SAxel Dörfler
47f9bdcca5SAxel Dörfler/** The I/O context of a process/team, holds the fd array among others */
48f9bdcca5SAxel Dörflertypedef struct io_context {
49360be1fcSIngo Weinhold	struct vnode *root;
50f9bdcca5SAxel Dörfler	struct vnode *cwd;
51f9bdcca5SAxel Dörfler	mutex		io_mutex;
525ecc4b37SIngo Weinhold	int32		ref_count;
53f9bdcca5SAxel Dörfler	uint32		table_size;
54f9bdcca5SAxel Dörfler	uint32		num_used_fds;
55f9bdcca5SAxel Dörfler	struct file_descriptor **fds;
5666c03dc3SIngo Weinhold	struct select_info **select_infos;
57681779f1SAxel Dörfler	uint8		*fds_close_on_exec;
58f9bdcca5SAxel Dörfler	struct list node_monitors;
59f9bdcca5SAxel Dörfler	uint32		num_monitors;
60f9bdcca5SAxel Dörfler	uint32		max_monitors;
616adf7a0cSAxel Dörfler	bool		inherit_fds;
62f9bdcca5SAxel Dörfler} io_context;
63f9bdcca5SAxel Dörfler
643aaee8e5SAxel Dörfler
6552a38012Sejakowatz#ifdef __cplusplus
6652a38012Sejakowatzextern "C" {
67e6bd90c5SIngo Weinhold#endif
6852a38012Sejakowatz
698ae594ffSAxel Dörflerstatus_t	vfs_init(struct kernel_args *args);
708ae594ffSAxel Dörflerstatus_t	vfs_bootstrap_file_systems(void);
718ae594ffSAxel Dörflervoid		vfs_mount_boot_file_system(struct kernel_args *args);
728ae594ffSAxel Dörflervoid		vfs_exec_io_context(io_context *context);
731ba04177SAxel Dörflerio_context*	vfs_new_io_context(io_context* parentContext,
741ba04177SAxel Dörfler				bool purgeCloseOnExec);
758ae594ffSAxel Dörflervoid		vfs_get_io_context(io_context *context);
768ae594ffSAxel Dörflervoid		vfs_put_io_context(io_context *context);
776bbd25f0SIngo Weinholdstatus_t	vfs_resize_fd_table(struct io_context* context, uint32 newSize);
7852a38012Sejakowatz
798ae594ffSAxel Dörflerint			vfs_getrlimit(int resource, struct rlimit *rlp);
808ae594ffSAxel Dörflerint			vfs_setrlimit(int resource, const struct rlimit *rlp);
8152a38012Sejakowatz
82cfd8ea78SAxel Dörfler/* calls needed by the VM for paging and by the file cache */
83a9689e84SIngo Weinholdstatus_t	vfs_get_vnode_from_fd(int fd, bool kernel, struct vnode **_vnode);
848ae594ffSAxel Dörflerstatus_t	vfs_get_vnode_from_path(const char *path, bool kernel,
858ae594ffSAxel Dörfler				struct vnode **_vnode);
868ae594ffSAxel Dörflerstatus_t	vfs_get_vnode(dev_t mountID, ino_t vnodeID, bool canWait,
878ae594ffSAxel Dörfler				struct vnode **_vnode);
888ae594ffSAxel Dörflerstatus_t	vfs_entry_ref_to_vnode(dev_t mountID, ino_t directoryID,
898ae594ffSAxel Dörfler				const char *name, struct vnode **_vnode);
908ae594ffSAxel Dörflervoid		vfs_vnode_to_node_ref(struct vnode *vnode, dev_t *_mountID,
918ae594ffSAxel Dörfler				ino_t *_vnodeID);
92137c5fe2SOliver Tappestruct fs_vnode* vfs_fsnode_for_vnode(struct vnode* vnode);
938ae594ffSAxel Dörfler
94a9689e84SIngo Weinholdint			vfs_open_vnode(struct vnode* vnode, int openMode, bool kernel);
958ae594ffSAxel Dörflerstatus_t	vfs_lookup_vnode(dev_t mountID, ino_t vnodeID,
968ae594ffSAxel Dörfler				struct vnode **_vnode);
978ae594ffSAxel Dörflervoid		vfs_put_vnode(struct vnode *vnode);
988ae594ffSAxel Dörflervoid		vfs_acquire_vnode(struct vnode *vnode);
998ae594ffSAxel Dörflerstatus_t	vfs_get_cookie_from_fd(int fd, void **_cookie);
1008ae594ffSAxel Dörflerbool		vfs_can_page(struct vnode *vnode, void *cookie);
1018ae594ffSAxel Dörflerstatus_t	vfs_read_pages(struct vnode *vnode, void *cookie, off_t pos,
102435c43f5SIngo Weinhold				const struct generic_io_vec *vecs, size_t count, uint32 flags,
103435c43f5SIngo Weinhold				generic_size_t *_numBytes);
1048ae594ffSAxel Dörflerstatus_t	vfs_write_pages(struct vnode *vnode, void *cookie, off_t pos,
105435c43f5SIngo Weinhold				const struct generic_io_vec *vecs, size_t count, uint32 flags,
106435c43f5SIngo Weinhold				generic_size_t *_numBytes);
1078ae594ffSAxel Dörflerstatus_t	vfs_vnode_io(struct vnode* vnode, void* cookie,
1088ae594ffSAxel Dörfler				io_request* request);
1098ae594ffSAxel Dörflerstatus_t	vfs_synchronous_io(io_request* request,
1108ae594ffSAxel Dörfler				status_t (*doIO)(void* cookie, off_t offset, void* buffer,
111a9689e84SIngo Weinhold					size_t* length),
112a9689e84SIngo Weinhold				void* cookie);
1138ae594ffSAxel Dörflerstatus_t	vfs_get_vnode_cache(struct vnode *vnode, struct VMCache **_cache,
1148ae594ffSAxel Dörfler				bool allocate);
115a9be0efbSAugustin Cavalierstatus_t	vfs_set_vnode_cache(struct vnode *vnode, struct VMCache *_cache);
1168ae594ffSAxel Dörflerstatus_t	vfs_get_file_map(struct vnode *vnode, off_t offset, size_t size,
1178ae594ffSAxel Dörfler				struct file_io_vec *vecs, size_t *_count);
1188ae594ffSAxel Dörflerstatus_t	vfs_get_fs_node_from_path(fs_volume *volume, const char *path,
119a9689e84SIngo Weinhold				bool traverseLeafLink, bool kernel, void **_node);
1208ae594ffSAxel Dörflerstatus_t	vfs_stat_vnode(struct vnode *vnode, struct stat *stat);
1218ae594ffSAxel Dörflerstatus_t	vfs_stat_node_ref(dev_t device, ino_t inode, struct stat *stat);
1228ae594ffSAxel Dörflerstatus_t	vfs_get_vnode_name(struct vnode *vnode, char *name,
1238ae594ffSAxel Dörfler				size_t nameSize);
1248ae594ffSAxel Dörflerstatus_t	vfs_entry_ref_to_path(dev_t device, ino_t inode, const char *leaf,
125237127fbSIngo Weinhold				bool kernel, char *path, size_t pathLength);
1268ae594ffSAxel Dörflerstatus_t	vfs_get_cwd(dev_t *_mountID, ino_t *_vnodeID);
1278ae594ffSAxel Dörflervoid		vfs_unlock_vnode_if_locked(struct file_descriptor *descriptor);
1288bca37d6SAdrien Destuguesstatus_t	vfs_release_posix_lock(io_context* context,
1298bca37d6SAdrien Destugues				struct file_descriptor* descriptor);
1308ae594ffSAxel Dörflerstatus_t	vfs_unmount(dev_t mountID, uint32 flags);
1318ae594ffSAxel Dörflerstatus_t	vfs_disconnect_vnode(dev_t mountID, ino_t vnodeID);
13267988f50SAxel Dörflerstatus_t	vfs_resolve_parent(struct vnode* parent, dev_t* device,
13367988f50SAxel Dörfler				ino_t* node);
1348ae594ffSAxel Dörflervoid		vfs_free_unused_vnodes(int32 level);
1358ae594ffSAxel Dörfler
1368ae594ffSAxel Dörflerstatus_t	vfs_read_stat(int fd, const char *path, bool traverseLeafLink,
1378ae594ffSAxel Dörfler				struct stat *stat, bool kernel);
1388c117a6dSIngo Weinhold
1395306fba3SAxel Dörfler/* special module convenience call */
1408ae594ffSAxel Dörflerstatus_t	vfs_get_module_path(const char *basePath, const char *moduleName,
1418ae594ffSAxel Dörfler				char *pathBuffer, size_t bufferSize);
1425306fba3SAxel Dörfler
1437fb2963aSIngo Weinhold/* service call for whoever needs a normalized path */
1448ae594ffSAxel Dörflerstatus_t	vfs_normalize_path(const char *path, char *buffer,
1458ae594ffSAxel Dörfler				size_t bufferSize, bool traverseLink, bool kernel);
1467fb2963aSIngo Weinhold
147f8b4d83fSIngo Weinhold/* service call for whoever wants to create a special node */
1488ae594ffSAxel Dörflerstatus_t	vfs_create_special_node(const char *path, fs_vnode *subVnode,
1498ae594ffSAxel Dörfler				mode_t mode, uint32 flags, bool kernel, fs_vnode *_superVnode,
1508ae594ffSAxel Dörfler				struct vnode **_createdVnode);
151f8b4d83fSIngo Weinhold
152244f03dcSIngo Weinhold/* service call for the node monitor */
153313e1e37SIngo Weinholdstatus_t	vfs_resolve_vnode_to_covering_vnode(dev_t mountID, ino_t nodeID,
1548ae594ffSAxel Dörfler				dev_t *resolvedMountID, ino_t *resolvedNodeID);
155244f03dcSIngo Weinhold
156d61a8548SIngo Weinhold/* service calls for private file systems */
157d61a8548SIngo Weinholdstatus_t	vfs_get_mount_point(dev_t mountID, dev_t* _mountPointMountID,
158d61a8548SIngo Weinhold				ino_t* _mountPointNodeID);
159d61a8548SIngo Weinholdstatus_t	vfs_bind_mount_directory(dev_t mountID, ino_t nodeID,
160d61a8548SIngo Weinhold				dev_t coveredMountID, ino_t coveredNodeID);
161d61a8548SIngo Weinhold
16252a38012Sejakowatz/* calls the syscall dispatcher should use for user file I/O */
1638ae594ffSAxel Dörflerdev_t		_user_mount(const char *path, const char *device,
1648ae594ffSAxel Dörfler				const char *fs_name, uint32 flags, const char *args,
1658ae594ffSAxel Dörfler				size_t argsLength);
1668ae594ffSAxel Dörflerstatus_t	_user_unmount(const char *path, uint32 flags);
1678ae594ffSAxel Dörflerstatus_t	_user_read_fs_info(dev_t device, struct fs_info *info);
1688ae594ffSAxel Dörflerstatus_t	_user_write_fs_info(dev_t device, const struct fs_info *info,
1698ae594ffSAxel Dörfler				int mask);
1708ae594ffSAxel Dörflerdev_t		_user_next_device(int32 *_cookie);
1718ae594ffSAxel Dörflerstatus_t	_user_sync(void);
1728ae594ffSAxel Dörflerstatus_t	_user_get_next_fd_info(team_id team, uint32 *cookie,
1738ae594ffSAxel Dörfler				struct fd_info *info, size_t infoSize);
1748ae594ffSAxel Dörflerstatus_t	_user_entry_ref_to_path(dev_t device, ino_t inode, const char *leaf,
1758ae594ffSAxel Dörfler				char *userPath, size_t pathLength);
1768ae594ffSAxel Dörflerstatus_t	_user_normalize_path(const char* userPath, bool traverseLink,
1778ae594ffSAxel Dörfler				char* buffer);
1788ae594ffSAxel Dörflerint			_user_open_entry_ref(dev_t device, ino_t inode, const char *name,
1798ae594ffSAxel Dörfler				int openMode, int perms);
1808ae594ffSAxel Dörflerint			_user_open(int fd, const char *path, int openMode, int perms);
1818ae594ffSAxel Dörflerint			_user_open_dir_node_ref(dev_t device, ino_t inode);
1828ae594ffSAxel Dörflerint			_user_open_dir_entry_ref(dev_t device, ino_t inode,
1838ae594ffSAxel Dörfler				const char *name);
1848ae594ffSAxel Dörflerint			_user_open_dir(int fd, const char *path);
1858ae594ffSAxel Dörflerint			_user_open_parent_dir(int fd, char *name, size_t nameLength);
186195a0f35SAlex Smithstatus_t	_user_fcntl(int fd, int op, size_t argument);
1878ae594ffSAxel Dörflerstatus_t	_user_fsync(int fd);
1888ae594ffSAxel Dörflerstatus_t	_user_flock(int fd, int op);
1898ae594ffSAxel Dörflerstatus_t	_user_read_stat(int fd, const char *path, bool traverseLink,
1908ae594ffSAxel Dörfler				struct stat *stat, size_t statSize);
1918ae594ffSAxel Dörflerstatus_t	_user_write_stat(int fd, const char *path, bool traverseLink,
1928ae594ffSAxel Dörfler				const struct stat *stat, size_t statSize, int statMask);
1938ae594ffSAxel Dörfleroff_t		_user_seek(int fd, off_t pos, int seekType);
1948ae594ffSAxel Dörflerstatus_t	_user_create_dir_entry_ref(dev_t device, ino_t inode,
1958ae594ffSAxel Dörfler				const char *name, int perms);
1968ae594ffSAxel Dörflerstatus_t	_user_create_dir(int fd, const char *path, int perms);
1978ae594ffSAxel Dörflerstatus_t	_user_remove_dir(int fd, const char *path);
1988ae594ffSAxel Dörflerstatus_t	_user_read_link(int fd, const char *path, char *buffer,
1998ae594ffSAxel Dörfler				size_t *_bufferSize);
2008ae594ffSAxel Dörflerstatus_t	_user_write_link(const char *path, const char *toPath);
2018ae594ffSAxel Dörflerstatus_t	_user_create_symlink(int fd, const char *path, const char *toPath,
2028ae594ffSAxel Dörfler				int mode);
203486fffdaSAxel Dörflerstatus_t	_user_create_link(int pathFD, const char *path, int toFD,
204486fffdaSAxel Dörfler				const char *toPath, bool traverseLeafLink);
2058ae594ffSAxel Dörflerstatus_t	_user_unlink(int fd, const char *path);
2068ae594ffSAxel Dörflerstatus_t	_user_rename(int oldFD, const char *oldpath, int newFD,
2078ae594ffSAxel Dörfler				const char *newpath);
208fb2500daSAxel Dörflerstatus_t	_user_create_fifo(int fd, const char *path, mode_t perms);
2098ae594ffSAxel Dörflerstatus_t	_user_create_pipe(int *fds);
210fb2500daSAxel Dörflerstatus_t	_user_access(int fd, const char *path, int mode,
211fb2500daSAxel Dörfler				bool effectiveUserGroup);
2128ae594ffSAxel Dörflerssize_t		_user_select(int numfds, fd_set *readSet, fd_set *writeSet,
2138ae594ffSAxel Dörfler				fd_set *errorSet, bigtime_t timeout, const sigset_t *sigMask);
2148ae594ffSAxel Dörflerssize_t		_user_poll(struct pollfd *fds, int numfds, bigtime_t timeout);
215d5e36fb5SAxel Dörflerint			_user_open_attr_dir(int fd, const char *path,
216d5e36fb5SAxel Dörfler				bool traverseLeafLink);
2178ae594ffSAxel Dörflerssize_t		_user_read_attr(int fd, const char *attribute, off_t pos,
2188ae594ffSAxel Dörfler				void *buffer, size_t readBytes);
2198ae594ffSAxel Dörflerssize_t		_user_write_attr(int fd, const char *attribute, uint32 type,
2208ae594ffSAxel Dörfler				off_t pos, const void *buffer, size_t readBytes);
2218ae594ffSAxel Dörflerstatus_t	_user_stat_attr(int fd, const char *attribute,
2228ae594ffSAxel Dörfler				struct attr_info *attrInfo);
2238ae594ffSAxel Dörflerint			_user_open_attr(int fd, const char* path, const char *name,
2248ae594ffSAxel Dörfler				uint32 type, int openMode);
2258ae594ffSAxel Dörflerstatus_t	_user_remove_attr(int fd, const char *name);
2268ae594ffSAxel Dörflerstatus_t	_user_rename_attr(int fromFile, const char *fromName, int toFile,
2278ae594ffSAxel Dörfler				const char *toName);
2288ae594ffSAxel Dörflerint			_user_open_index_dir(dev_t device);
2298ae594ffSAxel Dörflerstatus_t	_user_create_index(dev_t device, const char *name, uint32 type,
2308ae594ffSAxel Dörfler				uint32 flags);
2318ae594ffSAxel Dörflerstatus_t	_user_read_index_stat(dev_t device, const char *name,
2328ae594ffSAxel Dörfler				struct stat *stat);
2338ae594ffSAxel Dörflerstatus_t	_user_remove_index(dev_t device, const char *name);
2348ae594ffSAxel Dörflerstatus_t	_user_getcwd(char *buffer, size_t size);
2358ae594ffSAxel Dörflerstatus_t	_user_setcwd(int fd, const char *path);
2368ae594ffSAxel Dörflerstatus_t	_user_change_root(const char *path);
2378ae594ffSAxel Dörflerint			_user_open_query(dev_t device, const char *query,
2388ae594ffSAxel Dörfler				size_t queryLength, uint32 flags, port_id port, int32 token);
23952a38012Sejakowatz
240df50f7a9SIngo Weinhold/* fd user prototypes (implementation located in fd.cpp)  */
2418ae594ffSAxel Dörflerssize_t		_user_read(int fd, off_t pos, void *buffer, size_t bufferSize);
2428ae594ffSAxel Dörflerssize_t		_user_readv(int fd, off_t pos, const iovec *vecs, size_t count);
2438ae594ffSAxel Dörflerssize_t		_user_write(int fd, off_t pos, const void *buffer,
2448ae594ffSAxel Dörfler				size_t bufferSize);
2458ae594ffSAxel Dörflerssize_t		_user_writev(int fd, off_t pos, const iovec *vecs, size_t count);
2469d570af7SIngo Weinholdstatus_t	_user_ioctl(int fd, uint32 cmd, void *data, size_t length);
2478ae594ffSAxel Dörflerssize_t		_user_read_dir(int fd, struct dirent *buffer, size_t bufferSize,
2488ae594ffSAxel Dörfler				uint32 maxCount);
2498ae594ffSAxel Dörflerstatus_t	_user_rewind_dir(int fd);
2508ae594ffSAxel Dörflerstatus_t	_user_close(int fd);
2518ae594ffSAxel Dörflerint			_user_dup(int fd);
2528ae594ffSAxel Dörflerint			_user_dup2(int ofd, int nfd);
2538ae594ffSAxel Dörflerstatus_t	_user_lock_node(int fd);
2548ae594ffSAxel Dörflerstatus_t	_user_unlock_node(int fd);
25552a38012Sejakowatz
256df50f7a9SIngo Weinhold/* socket user prototypes (implementation in socket.cpp) */
2578ae594ffSAxel Dörflerint			_user_socket(int family, int type, int protocol);
2588ae594ffSAxel Dörflerstatus_t	_user_bind(int socket, const struct sockaddr *address,
2598ae594ffSAxel Dörfler				socklen_t addressLength);
2608ae594ffSAxel Dörflerstatus_t	_user_shutdown_socket(int socket, int how);
2618ae594ffSAxel Dörflerstatus_t	_user_connect(int socket, const struct sockaddr *address,
2628ae594ffSAxel Dörfler				socklen_t addressLength);
2638ae594ffSAxel Dörflerstatus_t	_user_listen(int socket, int backlog);
2648ae594ffSAxel Dörflerint			_user_accept(int socket, struct sockaddr *address,
2658ae594ffSAxel Dörfler				socklen_t *_addressLength);
2668ae594ffSAxel Dörflerssize_t		_user_recv(int socket, void *data, size_t length, int flags);
2678ae594ffSAxel Dörflerssize_t		_user_recvfrom(int socket, void *data, size_t length, int flags,
2688ae594ffSAxel Dörfler				struct sockaddr *address, socklen_t *_addressLength);
2698ae594ffSAxel Dörflerssize_t		_user_recvmsg(int socket, struct msghdr *message, int flags);
2708ae594ffSAxel Dörflerssize_t		_user_send(int socket, const void *data, size_t length, int flags);
2718ae594ffSAxel Dörflerssize_t		_user_sendto(int socket, const void *data, size_t length, int flags,
2728ae594ffSAxel Dörfler				const struct sockaddr *address, socklen_t addressLength);
2738ae594ffSAxel Dörflerssize_t		_user_sendmsg(int socket, const struct msghdr *message, int flags);
2748ae594ffSAxel Dörflerstatus_t	_user_getsockopt(int socket, int level, int option, void *value,
2758ae594ffSAxel Dörfler				socklen_t *_length);
2768ae594ffSAxel Dörflerstatus_t	_user_setsockopt(int socket, int level, int option,
2778ae594ffSAxel Dörfler				const void *value, socklen_t length);
2788ae594ffSAxel Dörflerstatus_t	_user_getpeername(int socket, struct sockaddr *address,
2798ae594ffSAxel Dörfler				socklen_t *_addressLength);
2808ae594ffSAxel Dörflerstatus_t	_user_getsockname(int socket, struct sockaddr *address,
2818ae594ffSAxel Dörfler				socklen_t *_addressLength);
2828ae594ffSAxel Dörflerint			_user_sockatmark(int socket);
2838ae594ffSAxel Dörflerstatus_t	_user_socketpair(int family, int type, int protocol,
2848ae594ffSAxel Dörfler				int *socketVector);
2858ae594ffSAxel Dörflerstatus_t	_user_get_next_socket_stat(int family, uint32 *cookie,
2868ae594ffSAxel Dörfler				struct net_stat *stat);
287df50f7a9SIngo Weinhold
28852a38012Sejakowatz#ifdef __cplusplus
28952a38012Sejakowatz}
290e6bd90c5SIngo Weinhold#endif
29152a38012Sejakowatz
29266394896SIngo Weinhold
29366394896SIngo Weinhold#ifdef __cplusplus
29466394896SIngo Weinhold
29566394896SIngo Weinholdclass AsyncIOCallback {
29666394896SIngo Weinholdpublic:
29766394896SIngo Weinhold	virtual						~AsyncIOCallback();
29866394896SIngo Weinhold
29966394896SIngo Weinhold	virtual	void				IOFinished(status_t status,
30066394896SIngo Weinhold									bool partialTransfer,
301435c43f5SIngo Weinhold									generic_size_t bytesTransferred) = 0;
30266394896SIngo Weinhold
30366394896SIngo Weinhold	static	status_t 			IORequestCallback(void* data,
30466394896SIngo Weinhold									io_request* request, status_t status,
30566394896SIngo Weinhold									bool partialTransfer,
306435c43f5SIngo Weinhold									generic_size_t transferEndOffset);
30766394896SIngo Weinhold};
30866394896SIngo Weinhold
30966394896SIngo Weinhold
31066394896SIngo Weinholdclass StackableAsyncIOCallback : public AsyncIOCallback {
31166394896SIngo Weinholdpublic:
31266394896SIngo Weinhold								StackableAsyncIOCallback(AsyncIOCallback* next);
31366394896SIngo Weinhold
31466394896SIngo Weinholdprotected:
31566394896SIngo Weinhold			AsyncIOCallback*	fNextCallback;
31666394896SIngo Weinhold};
31766394896SIngo Weinhold
31866394896SIngo Weinhold
3198ae594ffSAxel Dörflerstatus_t	vfs_asynchronous_read_pages(struct vnode* vnode, void* cookie,
320435c43f5SIngo Weinhold				off_t pos, const struct generic_io_vec* vecs, size_t count,
321435c43f5SIngo Weinhold				generic_size_t numBytes, uint32 flags,
322435c43f5SIngo Weinhold				AsyncIOCallback* callback);
32366394896SIngo Weinhold
3248ae594ffSAxel Dörflerstatus_t	vfs_asynchronous_write_pages(struct vnode* vnode, void* cookie,
325435c43f5SIngo Weinhold				off_t pos, const struct generic_io_vec* vecs, size_t count,
326435c43f5SIngo Weinhold				generic_size_t numBytes, uint32 flags,
327435c43f5SIngo Weinhold				AsyncIOCallback* callback);
32866394896SIngo Weinhold
32966394896SIngo Weinhold#endif	// __cplusplus
33066394896SIngo Weinhold
331071f62bcSAxel Dörfler#endif	/* _KERNEL_VFS_H */
332