2 * Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
6 * Distributed under the terms of the NewOS License.
12 #include "fssh_fs_interface.h"
13 #include "fssh_lock.h"
20 /* R5 figures, but we don't use a table for monitors anyway */
21 #define DEFAULT_FD_TABLE_SIZE 128
22 #define MAX_FD_TABLE_SIZE 8192
23 #define DEFAULT_NODE_MONITORS 4096
24 #define MAX_NODE_MONITORS 65536
28 struct file_descriptor
;
31 /** The I/O context of a process/team, holds the fd array among others */
32 typedef struct io_context
{
36 uint32_t num_used_fds
;
37 struct file_descriptor
**fds
;
38 uint8_t *fds_close_on_exec
;
50 /* macro to allocate a iovec array on the stack */
51 #define IOVECS(name, size) \
52 uint8_t _##name[sizeof(fssh_iovecs) + (size)*sizeof(fssh_iovec)]; \
53 fssh_iovecs *name = (fssh_iovecs *)_##name
56 fssh_status_t
vfs_init(struct kernel_args
*args
);
57 fssh_status_t
vfs_bootstrap_file_systems(void);
58 void vfs_mount_boot_file_system(struct kernel_args
*args
);
59 void vfs_exec_io_context(void *context
);
60 void* vfs_new_io_context(void *parentContext
);
61 fssh_status_t
vfs_free_io_context(void *context
);
63 /* calls needed by the VM for paging and by the file cache */
64 int vfs_get_vnode_from_fd(int fd
, bool kernel
, void **vnode
);
65 fssh_status_t
vfs_get_vnode_from_path(const char *path
, bool kernel
, void **vnode
);
66 fssh_status_t
vfs_get_vnode(fssh_mount_id mountID
, fssh_vnode_id vnodeID
,
68 fssh_status_t
vfs_entry_ref_to_vnode(fssh_mount_id mountID
,
69 fssh_vnode_id directoryID
, const char *name
, void **_vnode
);
70 void vfs_vnode_to_node_ref(void *_vnode
, fssh_mount_id
*_mountID
,
71 fssh_vnode_id
*_vnodeID
);
73 fssh_status_t
vfs_lookup_vnode(fssh_mount_id mountID
, fssh_vnode_id vnodeID
,
74 struct vnode
**_vnode
);
75 void vfs_put_vnode(void *vnode
);
76 void vfs_acquire_vnode(void *vnode
);
77 fssh_status_t
vfs_get_cookie_from_fd(int fd
, void **_cookie
);
78 fssh_status_t
vfs_read_pages(void *vnode
, void *cookie
, fssh_off_t pos
,
79 const fssh_iovec
*vecs
, fssh_size_t count
,
80 fssh_size_t
*_numBytes
);
81 fssh_status_t
vfs_write_pages(void *vnode
, void *cookie
,
82 fssh_off_t pos
, const fssh_iovec
*vecs
, fssh_size_t count
,
83 fssh_size_t
*_numBytes
);
84 fssh_status_t
vfs_get_file_map(void *_vnode
, fssh_off_t offset
,
85 fssh_size_t size
, fssh_file_io_vec
*vecs
,
87 fssh_status_t
vfs_get_fs_node_from_path(fssh_mount_id mountID
,
88 const char *path
, bool kernel
, void **_node
);
89 fssh_status_t
vfs_stat_vnode(void *_vnode
, struct fssh_stat
*stat
);
90 fssh_status_t
vfs_get_vnode_name(void *vnode
, char *name
,
91 fssh_size_t nameSize
);
92 fssh_status_t
vfs_get_cwd(fssh_mount_id
*_mountID
, fssh_vnode_id
*_vnodeID
);
93 void vfs_unlock_vnode_if_locked(struct file_descriptor
*descriptor
);
94 fssh_status_t
vfs_disconnect_vnode(fssh_mount_id mountID
,
95 fssh_vnode_id vnodeID
);
96 void vfs_free_unused_vnodes(int32_t level
);
98 /* special module convenience call */
99 fssh_status_t
vfs_get_module_path(const char *basePath
,
100 const char *moduleName
, char *pathBuffer
,
101 fssh_size_t bufferSize
);
103 /* service call for whoever needs a normalized path */
104 fssh_status_t
vfs_normalize_path(const char *path
, char *buffer
,
105 fssh_size_t bufferSize
, bool kernel
);
107 /* service call for the node monitor */
108 fssh_status_t
resolve_mount_point_to_volume_root(fssh_mount_id mountID
,
109 fssh_vnode_id nodeID
, fssh_mount_id
*resolvedMountID
,
110 fssh_vnode_id
*resolvedNodeID
);
112 // cache initialization functions defined in the respective cache implementation
113 extern fssh_status_t
block_cache_init();
114 extern fssh_status_t
file_cache_init();
116 } // namespace FSShell
119 #endif /* _FSSH_VFS_H */