1 #ifndef __VFS_PROTO_H__
2 #define __VFS_PROTO_H__
4 /* Function prototypes. */
7 #include <minix/timers.h>
14 /* Structs used in prototypes must be declared as such first. */
25 int bdev_open(dev_t dev
, int access
);
26 int bdev_close(dev_t dev
);
27 int bdev_ioctl(dev_t dev
, endpoint_t proc_e
, unsigned long req
, vir_bytes buf
);
28 void bdev_reply(void);
29 void bdev_up(devmajor_t major
);
32 dev_t
cdev_map(dev_t dev
, struct fproc
*rfp
);
33 int cdev_open(int fd
, dev_t dev
, int flags
);
34 int cdev_close(dev_t dev
);
35 int cdev_io(int op
, dev_t dev
, endpoint_t proc_e
, vir_bytes buf
, off_t pos
,
36 unsigned long bytes
, int flags
);
37 int cdev_select(dev_t dev
, int ops
);
38 int cdev_cancel(dev_t dev
, endpoint_t endpt
, cp_grant_id_t grant
);
39 void cdev_reply(void);
42 int drv_sendrec(endpoint_t drv_e
, message
*reqm
);
43 void fs_cancel(struct vmnt
*vmp
);
44 int fs_sendrec(endpoint_t fs_e
, message
*reqm
);
45 int vm_sendrec(message
*reqm
);
46 void fs_sendmore(struct vmnt
*vmp
);
48 int vm_vfs_procctl_handlemem(endpoint_t ep
, vir_bytes mem
, vir_bytes len
, int flags
);
52 cp_grant_id_t
make_ioctl_grant(endpoint_t driver_e
, endpoint_t user_e
,
53 vir_bytes buf
, unsigned long request
);
56 void lock_dmap(struct dmap
*dp
);
57 void unlock_dmap(struct dmap
*dp
);
58 int do_mapdriver(void);
60 int dmap_driver_match(endpoint_t proc
, devmajor_t major
);
61 void dmap_endpt_up(endpoint_t proc_nr
, int is_blk
);
62 struct dmap
*get_dmap_by_endpt(endpoint_t proc_e
);
63 struct dmap
*get_dmap_by_major(devmajor_t major
);
64 void dmap_unmap_by_endpt(endpoint_t proc_nr
);
65 int map_service(struct rprocpub
*rpub
);
68 void write_elf_core_file(struct filp
*f
, int csig
, char *exe_name
);
71 int pm_exec(vir_bytes path
, size_t path_len
, vir_bytes frame
, size_t frame_len
,
72 vir_bytes
*pc
, vir_bytes
*newsp
, vir_bytes
*ps_str
);
75 void check_filp_locks(void);
76 void check_filp_locks_by_me(void);
77 void init_filps(void);
78 struct filp
*find_filp(struct vnode
*vp
, mode_t bits
);
79 struct filp
*find_filp_by_sock_dev(dev_t dev
);
80 int check_fds(struct fproc
*rfp
, int nfds
);
81 int get_fd(struct fproc
*rfp
, int start
, mode_t bits
, int *k
,
83 struct filp
*get_filp(int fild
, tll_access_t locktype
);
84 struct filp
*get_filp2(struct fproc
*rfp
, int fild
, tll_access_t locktype
);
85 void lock_filp(struct filp
*filp
, tll_access_t locktype
);
86 void unlock_filp(struct filp
*filp
);
87 void unlock_filps(struct filp
*filp1
, struct filp
*filp2
);
88 void invalidate_filp(struct filp
*);
89 void invalidate_filp_by_endpt(endpoint_t proc_e
);
90 void invalidate_filp_by_char_major(devmajor_t major
);
91 void invalidate_filp_by_sock_drv(unsigned int num
);
92 int close_filp(struct filp
*fp
, int may_suspend
);
96 void nested_fs_call(message
*m
);
102 int do_truncate(void);
103 int do_ftruncate(void);
104 int truncate_vnode(struct vnode
*vp
, off_t newsize
);
105 int rdlink_direct(char *orig_path
, char *link_path
, struct fproc
*rfp
);
108 int lock_op(int fd
, int req
, vir_bytes arg
);
109 void lock_revive(void);
113 void lock_proc(struct fproc
*rfp
);
114 void unlock_proc(struct fproc
*rfp
);
115 void reply(message
*m_out
, endpoint_t whom
, int result
);
116 void replycode(endpoint_t whom
, int result
);
117 void service_pm_postponed(void);
118 void thread_cleanup(void);
123 void pm_fork(endpoint_t pproc
, endpoint_t cproc
, pid_t cpid
);
124 void pm_setgid(endpoint_t proc_e
, int egid
, int rgid
);
125 void pm_setuid(endpoint_t proc_e
, int euid
, int ruid
);
126 void pm_setgroups(endpoint_t proc_e
, int ngroups
, gid_t
*addr
);
127 void pm_setsid(endpoint_t proc_e
);
130 void pm_reboot(void);
132 int do_getsysinfo(void);
133 int do_vm_call(void);
134 int pm_dumpcore(int sig
, vir_bytes exe_name
);
136 int dupvm(struct fproc
*fp
, int pfd
, int *vmfd
, struct filp
**f
);
137 int do_getrusage(void);
142 int is_nonedev(dev_t dev
);
143 void mount_pfs(void);
144 int mount_fs(dev_t dev
, char mount_dev
[PATH_MAX
], char mount_path
[PATH_MAX
],
145 endpoint_t fs_e
, int rdonly
, char mount_type
[FSTYPE_MAX
],
146 char mount_label
[LABEL_MAX
]);
147 int unmount(dev_t dev
, char label
[LABEL_MAX
]);
148 void unmount_all(int force
);
152 int close_fd(struct fproc
*rfp
, int fd_nr
, int may_suspend
);
153 int common_open(char path
[PATH_MAX
], int oflags
, mode_t omode
, int for_exec
);
161 int actual_lseek(struct fproc
*rfp
, int seekfd
, int seekwhence
, off_t offset
,
165 struct vnode
*advance(struct vnode
*dirp
, struct lookup
*resolve
, struct
167 struct vnode
*eat_path(struct lookup
*resolve
, struct fproc
*rfp
);
168 struct vnode
*last_dir(struct lookup
*resolve
, struct fproc
*rfp
);
169 void lookup_init(struct lookup
*resolve
, char *path
, int flags
, struct
170 vmnt
**vmp
, struct vnode
**vp
);
171 int get_name(struct vnode
*dirp
, struct vnode
*entry
, char *_name
);
172 int canonical_path(char *orig_path
, struct fproc
*rfp
);
173 int do_socketpath(void);
177 int map_vnode(struct vnode
*vp
, endpoint_t fs_e
);
179 int pipe_check(struct filp
*filp
, int rw_flag
, int oflags
, int bytes
,
181 void release(struct vnode
*vp
, int op
, int count
);
182 void revive(endpoint_t proc_e
, int returned
);
183 void suspend(int why
);
184 void pipe_suspend(int callnr
, int fd
, vir_bytes buf
, size_t size
,
186 void unsuspend_by_endpt(endpoint_t proc_e
);
193 int forbidden(struct fproc
*rfp
, struct vnode
*vp
, mode_t
195 int read_only(struct vnode
*vp
);
199 int do_getdents(void);
201 void unlock_bsf(void);
202 void check_bsf_lock(void);
203 int do_read_write_peek(int rw_flag
, int fd
, vir_bytes buf
, size_t bytes
);
204 int actual_read_write_peek(struct fproc
*rfp
, int rw_flag
, int fd
,
205 vir_bytes buf
, size_t bytes
);
206 int read_write(struct fproc
*rfp
, int rw_flag
, int fd
, struct filp
*f
,
207 vir_bytes buffer
, size_t nbytes
, endpoint_t for_e
);
208 int rw_pipe(int rw_flag
, endpoint_t usr
, struct filp
*f
, int callnr
, int fd
,
209 vir_bytes buf
, size_t nbytes
, size_t cum_io
);
212 int req_breadwrite(endpoint_t fs_e
, endpoint_t user_e
, dev_t dev
, off_t pos
,
213 unsigned int num_of_bytes
, vir_bytes user_addr
, int rw_flag
,
214 off_t
*new_posp
, size_t *cum_iop
);
215 int req_chmod(endpoint_t fs_e
, ino_t inode_nr
, mode_t rmode
,
217 int req_chown(endpoint_t fs_e
, ino_t inode_nr
, uid_t newuid
, gid_t newgid
,
219 int req_create(endpoint_t fs_e
, ino_t inode_nr
, int omode
, uid_t uid
,
220 gid_t gid
, char *path
, node_details_t
*res
);
221 int req_flush(endpoint_t fs_e
, dev_t dev
);
222 int req_statvfs(endpoint_t fs_e
, struct statvfs
*buf
);
223 int req_ftrunc(endpoint_t fs_e
, ino_t inode_nr
, off_t start
, off_t end
);
224 int req_getdents(endpoint_t fs_e
, ino_t inode_nr
, off_t pos
, vir_bytes buf
,
225 size_t size
, off_t
*new_pos
, int direct
);
226 int req_inhibread(endpoint_t fs_e
, ino_t inode_nr
);
227 int req_link(endpoint_t fs_e
, ino_t link_parent
, char *lastc
,
229 int req_lookup(endpoint_t fs_e
, ino_t dir_ino
, ino_t root_ino
, uid_t uid
,
230 gid_t gid
, struct lookup
*resolve
, lookup_res_t
*res
,
232 int req_mkdir(endpoint_t fs_e
, ino_t inode_nr
, char *lastc
, uid_t uid
,
233 gid_t gid
, mode_t dmode
);
234 int req_mknod(endpoint_t fs_e
, ino_t inode_nr
, char *lastc
, uid_t uid
,
235 gid_t gid
, mode_t dmode
, dev_t dev
);
236 int req_mountpoint(endpoint_t fs_e
, ino_t inode_nr
);
237 int req_newnode(endpoint_t fs_e
, uid_t uid
, gid_t gid
, mode_t dmode
,
238 dev_t dev
, struct node_details
*res
);
239 int req_putnode(int fs_e
, ino_t inode_nr
, int count
);
240 int req_rdlink(endpoint_t fs_e
, ino_t inode_nr
, endpoint_t proc_e
,
241 vir_bytes buf
, size_t len
, int direct
);
242 int req_readsuper(struct vmnt
*vmp
, char *driver_name
, dev_t dev
, int readonly
,
243 int isroot
, struct node_details
*res_nodep
, unsigned int *fs_flags
);
244 int req_readwrite(endpoint_t fs_e
, ino_t inode_nr
, off_t pos
, int rw_flag
,
245 endpoint_t user_e
, vir_bytes user_addr
, unsigned int num_of_bytes
,
246 off_t
*new_posp
, size_t *cum_iop
);
247 int req_bpeek(endpoint_t fs_e
, dev_t dev
, off_t pos
, unsigned int num_of_bytes
);
248 int req_peek(endpoint_t fs_e
, ino_t inode_nr
, off_t pos
, unsigned int bytes
);
249 int req_rename(endpoint_t fs_e
, ino_t old_dir
, char *old_name
, ino_t new_dir
,
251 int req_rmdir(endpoint_t fs_e
, ino_t inode_nr
, char *lastc
);
252 int req_slink(endpoint_t fs_e
, ino_t inode_nr
, char *lastc
, endpoint_t proc_e
,
253 vir_bytes path_addr
, size_t path_length
, uid_t uid
, gid_t gid
);
254 int req_stat(endpoint_t fs_e
, ino_t inode_nr
, endpoint_t proc_e
, vir_bytes buf
);
255 int req_sync(endpoint_t fs_e
);
256 int req_unlink(endpoint_t fs_e
, ino_t inode_nr
, char *lastc
);
257 int req_unmount(endpoint_t fs_e
);
258 int req_utime(endpoint_t fs_e
, ino_t inode_nr
, struct timespec
* actv
,
259 struct timespec
* modtv
);
260 int req_newdriver(endpoint_t fs_e
, dev_t dev
, char *label
);
263 int sdev_socket(int domain
, int type
, int protocol
, dev_t
*dev
, int pair
);
264 int sdev_bind(dev_t dev
, vir_bytes addr
, unsigned int addr_len
,
266 int sdev_connect(dev_t dev
, vir_bytes addr
, unsigned int addr_len
,
268 int sdev_listen(dev_t dev
, int backlog
);
269 int sdev_accept(dev_t dev
, vir_bytes addr
, unsigned int addr_len
,
270 int filp_flags
, int fd
);
271 int sdev_readwrite(dev_t dev
, vir_bytes data_buf
, size_t data_len
,
272 vir_bytes ctl_buf
, unsigned int ctl_len
, vir_bytes addr_buf
,
273 unsigned int addr_len
, int flags
, int rw_flag
, int filp_flags
,
275 int sdev_ioctl(dev_t dev
, unsigned long request
, vir_bytes buf
,
277 int sdev_setsockopt(dev_t dev
, int level
, int name
, vir_bytes addr
,
279 int sdev_getsockopt(dev_t dev
, int level
, int name
, vir_bytes addr
,
281 int sdev_getsockname(dev_t dev
, vir_bytes addr
, unsigned int *addr_len
);
282 int sdev_getpeername(dev_t dev
, vir_bytes addr
, unsigned int *addr_len
);
283 int sdev_shutdown(dev_t dev
, int how
);
284 int sdev_close(dev_t dev
, int may_suspend
);
285 int sdev_select(dev_t dev
, int ops
);
286 void sdev_stop(struct fproc
*rfp
);
287 void sdev_cancel(void);
288 void sdev_reply(void);
291 void init_smap(void);
292 int smap_map(const char *label
, endpoint_t endpt
, const int *domains
,
293 unsigned int ndomains
);
294 void smap_unmap_by_endpt(endpoint_t endpt
);
295 void smap_endpt_up(endpoint_t endpt
);
296 dev_t
make_smap_dev(struct smap
*sp
, sockid_t sockid
);
297 struct smap
*get_smap_by_endpt(endpoint_t endpt
);
298 struct smap
*get_smap_by_domain(int domain
);
299 struct smap
*get_smap_by_dev(dev_t dev
, sockid_t
* sockidp
);
303 int do_socketpair(void);
305 int do_connect(void);
308 void resume_accept(struct fproc
*rfp
, int status
, dev_t dev
,
309 unsigned int addr_len
, int listen_fd
);
311 int do_recvfrom(void);
312 void resume_recvfrom(struct fproc
*rfp
, int status
, unsigned int addr_len
);
313 int do_sockmsg(void);
314 void resume_recvmsg(struct fproc
*rfp
, int status
, unsigned int ctl_len
,
315 unsigned int addr_len
, int flags
, vir_bytes msg_buf
);
316 int do_setsockopt(void);
317 int do_getsockopt(void);
318 int do_getsockname(void);
319 int do_getpeername(void);
320 int do_shutdown(void);
328 int do_statvfs(void);
329 int do_fstatvfs(void);
330 int do_getvfsstat(void);
333 int update_statvfs(struct vmnt
*vmp
, struct statvfs
*buf
);
336 int do_utimens(void);
339 void tll_downgrade(tll_t
*tllp
);
340 int tll_haspendinglock(tll_t
*tllp
);
341 void tll_init(tll_t
*tllp
);
342 int tll_islocked(tll_t
*tllp
);
343 int tll_lock(tll_t
*tllp
, tll_access_t locktype
);
344 int tll_locked_by_me(tll_t
*tllp
);
345 void tll_lockstat(tll_t
*tllp
);
346 int tll_unlock(tll_t
*tllp
);
347 void tll_upgrade(tll_t
*tllp
);
350 int copy_path(char *dest
, size_t size
);
351 int fetch_name(vir_bytes path
, size_t len
, char *dest
);
352 int isokendpt_f(const char *f
, int l
, endpoint_t e
, int *p
, int ft
);
353 int in_group(struct fproc
*rfp
, gid_t grp
);
354 int sys_datacopy_wrapper(endpoint_t src
, vir_bytes srcv
, endpoint_t dst
,
355 vir_bytes dstv
, size_t len
);
357 #define okendpt(e, p) isokendpt_f(__FILE__, __LINE__, (e), (p), 1)
358 #define isokendpt(e, p) isokendpt_f(__FILE__, __LINE__, (e), (p), 0)
361 void check_vmnt_locks(void);
362 void check_vmnt_locks_by_me(struct fproc
*rfp
);
363 void mark_vmnt_free(struct vmnt
*vmp
);
364 struct vmnt
*get_free_vmnt(void);
365 struct vmnt
*find_vmnt(endpoint_t fs_e
);
366 struct vmnt
*get_locked_vmnt(struct fproc
*rfp
);
367 void init_vmnts(void);
368 int lock_vmnt(struct vmnt
*vp
, tll_access_t locktype
);
369 void unlock_vmnt(struct vmnt
*vp
);
370 void vmnt_unmap_by_endpt(endpoint_t proc_e
);
371 void fetch_vmnt_paths(void);
372 void upgrade_vmnt_lock(struct vmnt
*vmp
);
373 void downgrade_vmnt_lock(struct vmnt
*vmp
);
376 void check_vnode_locks(void);
377 void check_vnode_locks_by_me(struct fproc
*rfp
);
378 struct vnode
*get_free_vnode(void);
379 struct vnode
*find_vnode(int fs_e
, ino_t inode
);
380 void init_vnodes(void);
381 int is_vnode_locked(struct vnode
*vp
);
382 int lock_vnode(struct vnode
*vp
, tll_access_t locktype
);
383 void unlock_vnode(struct vnode
*vp
);
384 void dup_vnode(struct vnode
*vp
);
385 void put_vnode(struct vnode
*vp
);
386 void vnode_clean_refs(struct vnode
*vp
);
387 void upgrade_vnode_lock(struct vnode
*vp
);
393 int do_gcov_flush(void);
395 #define do_gcov_flush NULL
400 void init_select(void);
401 void select_callback(struct filp
*, int ops
);
402 void select_forget(void);
403 void select_cdev_reply1(endpoint_t driver_e
, devminor_t minor
, int status
);
404 void select_cdev_reply2(endpoint_t driver_e
, devminor_t minor
, int status
);
405 void select_sdev_reply1(dev_t dev
, int status
);
406 void select_sdev_reply2(dev_t dev
, int status
);
407 void select_unsuspend_by_endpt(endpoint_t proc
);
408 void select_dump(void);
411 void worker_init(void);
412 void worker_cleanup(void);
413 int worker_idle(void);
414 int worker_available(void);
415 void worker_allow(int allow
);
416 struct worker_thread
*worker_get(thread_t worker_tid
);
417 void worker_signal(struct worker_thread
*worker
);
418 int worker_can_start(struct fproc
*rfp
);
419 void worker_start(struct fproc
*rfp
, void (*func
)(void), message
*m_ptr
,
421 void worker_stop(struct worker_thread
*worker
);
422 void worker_stop_by_endpt(endpoint_t proc_e
);
423 void worker_yield(void);
424 void worker_wait(void);
425 struct worker_thread
*worker_suspend(void);
426 void worker_resume(struct worker_thread
*org_self
);
427 void worker_set_proc(struct fproc
*rfp
);