1 #ifndef __VFS_PROTO_H__
2 #define __VFS_PROTO_H__
4 /* Function prototypes. */
12 /* Structs used in prototypes must be declared as such first. */
21 typedef struct filp
* filp_id_t
;
24 int drv_sendrec(endpoint_t drv_e
, message
*reqm
);
25 void fs_cancel(struct vmnt
*vmp
);
26 int fs_sendrec(endpoint_t fs_e
, message
*reqm
);
27 void fs_sendmore(struct vmnt
*vmp
);
31 int dev_open(dev_t dev
, endpoint_t proc_e
, int flags
);
32 int dev_reopen(dev_t dev
, int filp_no
, int flags
);
33 void dev_reply(struct dmap
*dp
);
34 int dev_close(dev_t dev
, int filp_no
);
35 int bdev_open(dev_t dev
, int access
);
36 int bdev_close(dev_t dev
);
37 int dev_io(int op
, dev_t dev
, endpoint_t proc_e
, void *buf
, u64_t pos
,
38 size_t bytes
, int flags
, int suspend_reopen
);
39 int gen_opcl(int op
, dev_t dev
, endpoint_t task_nr
, int flags
);
40 int gen_io(endpoint_t driver_e
, message
*mess_ptr
);
41 int asyn_io(endpoint_t drv_e
, message
*mess_ptr
);
42 int no_dev(int op
, dev_t dev
, int proc
, int flags
);
43 int no_dev_io(int, message
*);
44 int tty_opcl(int op
, dev_t dev
, endpoint_t proc
, int flags
);
45 int ctty_opcl(int op
, dev_t dev
, endpoint_t proc
, int flags
);
46 int clone_opcl(int op
, dev_t dev
, int proc
, int flags
);
47 int ctty_io(int task_nr
, message
*mess_ptr
);
49 void pm_setsid(endpoint_t proc_e
);
50 void dev_status(endpoint_t drv_e
);
51 void bdev_up(int major
);
52 void cdev_up(int major
);
53 endpoint_t
find_suspended_ep(endpoint_t driver
, cp_grant_id_t g
);
54 void reopen_reply(void);
55 void open_reply(void);
58 void lock_dmap(struct dmap
*dp
);
59 void unlock_dmap(struct dmap
*dp
);
60 int do_mapdriver(void);
62 void init_dmap_locks(void);
63 int dmap_driver_match(endpoint_t proc
, int major
);
64 void dmap_endpt_up(int proc_nr
, int is_blk
);
65 void dmap_unmap_by_endpt(int proc_nr
);
66 struct dmap
*get_dmap(endpoint_t proc_e
);
67 struct dmap
*get_dmap_by_major(int major
);
68 int do_mapdriver(void);
69 int map_service(struct rprocpub
*rpub
);
70 void dmap_unmap_by_endpt(int proc_nr
);
71 int map_driver(const char *label
, int major
, endpoint_t proc_nr
, int
72 dev_style
, int flags
);
73 int map_service(struct rprocpub
*rpub
);
76 void write_elf_core_file(struct filp
*f
, int csig
, char *exe_name
);
79 int pm_exec(endpoint_t proc_e
, vir_bytes path
, size_t path_len
, vir_bytes frame
,
80 size_t frame_len
, vir_bytes
*pc
, vir_bytes
*newsp
, int flags
);
83 void *do_filp_gc(void *arg
);
84 void check_filp_locks(void);
85 void check_filp_locks_by_me(void);
86 void init_filps(void);
87 struct filp
*find_filp(struct vnode
*vp
, mode_t bits
);
88 int get_fd(int start
, mode_t bits
, int *k
, struct filp
**fpt
);
89 struct filp
*get_filp(int fild
, tll_access_t locktype
);
90 struct filp
*get_filp2(struct fproc
*rfp
, int fild
, tll_access_t
92 void lock_filp(struct filp
*filp
, tll_access_t locktype
);
93 void unlock_filp(struct filp
*filp
);
94 void unlock_filps(struct filp
*filp1
, struct filp
*filp2
);
95 int invalidate_filp(struct filp
*);
96 void invalidate_filp_by_endpt(endpoint_t proc_e
);
97 void invalidate_filp_by_char_major(int major
);
98 int do_verify_fd(void);
99 int set_filp(filp_id_t sfilp
);
100 int do_set_filp(void);
101 int copy_filp(endpoint_t to_ep
, filp_id_t cfilp
);
102 int do_copy_filp(void);
103 int put_filp(filp_id_t pfilp
);
104 int do_put_filp(void);
105 int cancel_fd(endpoint_t ep
, int fd
);
106 int do_cancel_fd(void);
107 void close_filp(struct filp
*fp
);
110 void nested_fs_call(message
*m
);
116 int do_truncate(void);
117 int do_ftruncate(void);
118 int truncate_vnode(struct vnode
*vp
, off_t newsize
);
119 int rdlink_direct(char *orig_path
, char *link_path
, struct fproc
*rfp
);
122 int lock_op(struct filp
*f
, int req
);
123 void lock_revive(void);
127 void lock_proc(struct fproc
*rfp
, int force_lock
);
128 void reply(endpoint_t whom
, int result
);
129 void thread_cleanup(struct fproc
*rfp
);
130 void unlock_proc(struct fproc
*rfp
);
134 void pm_exit(int proc
);
136 void pm_fork(int pproc
, int cproc
, int cpid
);
137 void pm_setgid(int proc_e
, int egid
, int rgid
);
138 void pm_setuid(int proc_e
, int euid
, int ruid
);
139 void pm_setgroups(int proc_e
, int ngroups
, gid_t
*addr
);
142 void pm_reboot(void);
144 int do_getsysinfo(void);
145 int pm_dumpcore(endpoint_t proc_e
, int sig
, vir_bytes exe_name
);
146 void * ds_event(void *arg
);
149 int do_fsready(void);
152 int is_nonedev(dev_t dev
);
153 void mount_pfs(void);
154 int mount_fs(dev_t dev
, char fullpath
[PATH_MAX
+1], endpoint_t fs_e
, int
155 rdonly
, char mount_label
[LABEL_MAX
]);
156 int unmount(dev_t dev
, char label
[LABEL_MAX
]);
157 void unmount_all(void);
161 int close_fd(struct fproc
*rfp
, int fd_nr
);
162 void close_reply(void);
163 int common_open(char path
[PATH_MAX
], int oflags
, mode_t omode
);
171 int do_vm_open(void);
172 int do_vm_close(void);
175 struct vnode
*advance(struct vnode
*dirp
, struct lookup
*resolve
, struct
177 struct vnode
*eat_path(struct lookup
*resolve
, struct fproc
*rfp
);
178 struct vnode
*last_dir(struct lookup
*resolve
, struct fproc
*rfp
);
179 void lookup_init(struct lookup
*resolve
, char *path
, int flags
, struct
180 vmnt
**vmp
, struct vnode
**vp
);
181 int get_name(struct vnode
*dirp
, struct vnode
*entry
, char *_name
);
182 int canonical_path(char *orig_path
, struct fproc
*rfp
);
183 int do_check_perms(void);
187 int map_vnode(struct vnode
*vp
, endpoint_t fs_e
);
188 void unpause(endpoint_t proc_e
);
189 int pipe_check(struct vnode
*vp
, int rw_flag
, int oflags
, int bytes
,
190 u64_t position
, int notouch
);
191 void release(struct vnode
*vp
, int op
, int count
);
192 void revive(endpoint_t proc_e
, int returned
);
193 void suspend(int why
);
194 void pipe_suspend(struct filp
*rfilp
, char *buf
, size_t size
);
195 void unsuspend_by_endpt(endpoint_t proc_e
);
196 void wait_for(endpoint_t proc_e
);
203 int forbidden(struct fproc
*rfp
, struct vnode
*vp
, mode_t
205 int read_only(struct vnode
*vp
);
209 int do_getdents(void);
211 void unlock_bsf(void);
212 void check_bsf_lock(void);
213 int do_read_write(int rw_flag
);
214 int read_write(int rw_flag
, struct filp
*f
, char *buffer
, size_t nbytes
,
216 int rw_pipe(int rw_flag
, endpoint_t usr
, struct filp
*f
, char *buf
,
220 int req_breadwrite(endpoint_t fs_e
, endpoint_t user_e
, dev_t dev
, u64_t pos
,
221 unsigned int num_of_bytes
, char *user_addr
, int rw_flag
,
222 u64_t
*new_posp
, unsigned int *cum_iop
);
223 int req_chmod(int fs_e
, ino_t inode_nr
, mode_t rmode
, mode_t
*new_modep
);
224 int req_chown(endpoint_t fs_e
, ino_t inode_nr
, uid_t newuid
, gid_t newgid
,
226 int req_create(int fs_e
, ino_t inode_nr
, int omode
, uid_t uid
, gid_t gid
,
227 char *path
, node_details_t
*res
);
228 int req_flush(endpoint_t fs_e
, dev_t dev
);
229 int req_fstatfs(endpoint_t fs_e
, endpoint_t proc_e
, vir_bytes buf
);
230 int req_statvfs(endpoint_t fs_e
, endpoint_t proc_e
, vir_bytes buf
);
231 int req_ftrunc(endpoint_t fs_e
, ino_t inode_nr
, off_t start
, off_t end
);
232 int req_getdents(endpoint_t fs_e
, ino_t inode_nr
, u64_t pos
, char *buf
,
233 size_t size
, u64_t
*new_pos
, int direct
);
234 int req_inhibread(endpoint_t fs_e
, ino_t inode_nr
);
235 int req_link(endpoint_t fs_e
, ino_t link_parent
, char *lastc
,
237 int req_lookup(endpoint_t fs_e
, ino_t dir_ino
, ino_t root_ino
, uid_t uid
,
238 gid_t gid
, struct lookup
*resolve
, lookup_res_t
*res
,
240 int req_mkdir(endpoint_t fs_e
, ino_t inode_nr
, char *lastc
, uid_t uid
,
241 gid_t gid
, mode_t dmode
);
242 int req_mknod(endpoint_t fs_e
, ino_t inode_nr
, char *lastc
, uid_t uid
,
243 gid_t gid
, mode_t dmode
, dev_t dev
);
244 int req_mountpoint(endpoint_t fs_e
, ino_t inode_nr
);
245 int req_newnode(endpoint_t fs_e
, uid_t uid
, gid_t gid
, mode_t dmode
, dev_t dev
,
246 struct node_details
*res
);
247 int req_putnode(int fs_e
, ino_t inode_nr
, int count
);
248 int req_rdlink(endpoint_t fs_e
, ino_t inode_nr
, endpoint_t proc_e
,
249 vir_bytes buf
, size_t len
, int direct
);
250 int req_readsuper(endpoint_t fs_e
, char *driver_name
, dev_t dev
, int readonly
,
251 int isroot
, struct node_details
*res_nodep
, int *con_reqs
);
252 int req_readwrite(endpoint_t fs_e
, ino_t inode_nr
, u64_t pos
, int rw_flag
,
253 endpoint_t user_e
, char *user_addr
, unsigned int num_of_bytes
,
254 u64_t
*new_posp
, unsigned int *cum_iop
);
255 int req_rename(endpoint_t fs_e
, ino_t old_dir
, char *old_name
, ino_t new_dir
,
257 int req_rmdir(endpoint_t fs_e
, ino_t inode_nr
, char *lastc
);
258 int req_slink(endpoint_t fs_e
, ino_t inode_nr
, char *lastc
, endpoint_t proc_e
,
259 vir_bytes path_addr
, size_t path_length
, uid_t uid
, gid_t gid
);
260 int req_stat(endpoint_t fs_e
, ino_t inode_nr
, endpoint_t proc_e
, vir_bytes buf
,
262 int req_sync(endpoint_t fs_e
);
263 int req_unlink(endpoint_t fs_e
, ino_t inode_nr
, char *lastc
);
264 int req_unmount(endpoint_t fs_e
);
265 int req_utime(endpoint_t fs_e
, ino_t inode_nr
, time_t actime
, time_t modtime
);
266 int req_newdriver(endpoint_t fs_e
, dev_t dev
, char *label
);
274 int do_fstatfs(void);
275 int do_statvfs(void);
276 int do_fstatvfs(void);
284 void tll_downgrade(tll_t
*tllp
);
285 int tll_haspendinglock(tll_t
*tllp
);
286 void tll_init(tll_t
*tllp
);
287 int tll_islocked(tll_t
*tllp
);
288 int tll_lock(tll_t
*tllp
, tll_access_t locktype
);
289 int tll_locked_by_me(tll_t
*tllp
);
290 void tll_lockstat(tll_t
*tllp
);
291 int tll_unlock(tll_t
*tllp
);
292 void tll_upgrade(tll_t
*tllp
);
295 time_t clock_time(void);
296 unsigned conv2(int norm
, int w
);
297 long conv4(int norm
, long x
);
298 int copy_name(size_t len
, char *dest
);
299 int fetch_name(vir_bytes path
, size_t len
, char *dest
);
301 int isokendpt_f(char *f
, int l
, endpoint_t e
, int *p
, int ft
);
302 int in_group(struct fproc
*rfp
, gid_t grp
);
304 #define okendpt(e, p) isokendpt_f(__FILE__, __LINE__, (e), (p), 1)
305 #define isokendpt(e, p) isokendpt_f(__FILE__, __LINE__, (e), (p), 0)
308 void check_vmnt_locks(void);
309 void check_vmnt_locks_by_me(struct fproc
*rfp
);
310 void mark_vmnt_free(struct vmnt
*vmp
);
311 struct vmnt
*get_free_vmnt(void);
312 struct vmnt
*find_vmnt(endpoint_t fs_e
);
313 struct vmnt
*get_locked_vmnt(struct fproc
*rfp
);
314 void init_vmnts(void);
315 int lock_vmnt(struct vmnt
*vp
, tll_access_t locktype
);
316 void unlock_vmnt(struct vmnt
*vp
);
317 void vmnt_unmap_by_endpt(endpoint_t proc_e
);
320 void check_vnode_locks(void);
321 void check_vnode_locks_by_me(struct fproc
*rfp
);
322 struct vnode
*get_free_vnode(void);
323 struct vnode
*find_vnode(int fs_e
, ino_t inode
);
324 void init_vnodes(void);
325 int is_vnode_locked(struct vnode
*vp
);
326 int lock_vnode(struct vnode
*vp
, tll_access_t locktype
);
327 void unlock_vnode(struct vnode
*vp
);
328 void dup_vnode(struct vnode
*vp
);
329 void put_vnode(struct vnode
*vp
);
330 void vnode_clean_refs(struct vnode
*vp
);
336 int do_gcov_flush(void);
338 #define do_gcov_flush no_sys
343 void init_select(void);
344 void select_callback(struct filp
*, int ops
);
345 void select_forget(endpoint_t proc_e
);
346 void select_reply1(endpoint_t driver_e
, int minor
, int status
);
347 void select_reply2(endpoint_t driver_e
, int minor
, int status
);
348 void select_timeout_check(timer_t
*);
349 void select_unsuspend_by_endpt(endpoint_t proc
);
352 int worker_available(void);
353 struct worker_thread
*worker_get(thread_t worker_tid
);
354 struct job
*worker_getjob(thread_t worker_tid
);
355 void worker_init(struct worker_thread
*worker
);
356 void worker_signal(struct worker_thread
*worker
);
357 void worker_start(void *(*func
)(void *arg
));
358 void worker_stop(struct worker_thread
*worker
);
359 void worker_stop_by_endpt(endpoint_t proc_e
);
360 void worker_wait(void);
361 void sys_worker_start(void *(*func
)(void *arg
));
362 void dl_worker_start(void *(*func
)(void *arg
));