1 #ifndef __VFS_PROTO_H__
2 #define __VFS_PROTO_H__
4 /* Function prototypes. */
7 #include <minix/timers.h>
13 /* Structs used in prototypes must be declared as such first. */
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 int vm_sendrec(message
*reqm
);
28 void fs_sendmore(struct vmnt
*vmp
);
30 int vm_vfs_procctl_handlemem(endpoint_t ep
, vir_bytes mem
, vir_bytes len
, int flags
);
33 int cdev_open(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 dev_t
cdev_map(dev_t dev
, struct fproc
*rfp
);
38 int cdev_select(dev_t dev
, int ops
);
39 int cdev_cancel(dev_t dev
);
40 void cdev_reply(void);
41 int bdev_open(dev_t dev
, int access
);
42 int bdev_close(dev_t dev
);
43 void bdev_reply(void);
44 void bdev_up(devmajor_t major
);
48 void lock_dmap(struct dmap
*dp
);
49 void unlock_dmap(struct dmap
*dp
);
50 int do_mapdriver(void);
52 int dmap_driver_match(endpoint_t proc
, devmajor_t major
);
53 void dmap_endpt_up(endpoint_t proc_nr
, int is_blk
);
54 struct dmap
*get_dmap(endpoint_t proc_e
);
55 struct dmap
*get_dmap_by_major(devmajor_t major
);
56 void dmap_unmap_by_endpt(endpoint_t proc_nr
);
57 int map_service(struct rprocpub
*rpub
);
60 void write_elf_core_file(struct filp
*f
, int csig
, char *exe_name
);
63 int pm_exec(vir_bytes path
, size_t path_len
, vir_bytes frame
, size_t frame_len
,
64 vir_bytes
*pc
, vir_bytes
*newsp
, vir_bytes
*ps_str
);
67 void check_filp_locks(void);
68 void check_filp_locks_by_me(void);
69 void init_filps(void);
70 struct filp
*find_filp(struct vnode
*vp
, mode_t bits
);
71 int get_fd(struct fproc
*rfp
, int start
, mode_t bits
, int *k
,
73 struct filp
*get_filp(int fild
, tll_access_t locktype
);
74 struct filp
*get_filp2(struct fproc
*rfp
, int fild
, tll_access_t locktype
);
75 void lock_filp(struct filp
*filp
, tll_access_t locktype
);
76 void unlock_filp(struct filp
*filp
);
77 void unlock_filps(struct filp
*filp1
, struct filp
*filp2
);
78 void invalidate_filp(struct filp
*);
79 void invalidate_filp_by_endpt(endpoint_t proc_e
);
80 void invalidate_filp_by_char_major(devmajor_t major
);
81 void close_filp(struct filp
*fp
);
85 void nested_fs_call(message
*m
);
91 int do_truncate(void);
92 int do_ftruncate(void);
93 int truncate_vnode(struct vnode
*vp
, off_t newsize
);
94 int rdlink_direct(char *orig_path
, char *link_path
, struct fproc
*rfp
);
97 int lock_op(struct filp
*f
, int req
);
98 void lock_revive(void);
102 void lock_proc(struct fproc
*rfp
);
103 void unlock_proc(struct fproc
*rfp
);
104 void replycode(endpoint_t whom
, int result
);
105 void service_pm_postponed(void);
106 void thread_cleanup(void);
111 void pm_fork(endpoint_t pproc
, endpoint_t cproc
, pid_t cpid
);
112 void pm_setgid(endpoint_t proc_e
, int egid
, int rgid
);
113 void pm_setuid(endpoint_t proc_e
, int euid
, int ruid
);
114 void pm_setgroups(endpoint_t proc_e
, int ngroups
, gid_t
*addr
);
115 void pm_setsid(endpoint_t proc_e
);
118 void pm_reboot(void);
120 int do_getsysinfo(void);
121 int do_vm_call(void);
122 int pm_dumpcore(int sig
, vir_bytes exe_name
);
124 int dupvm(struct fproc
*fp
, int pfd
, int *vmfd
, struct filp
**f
);
125 int do_getrusage(void);
130 int is_nonedev(dev_t dev
);
131 void mount_pfs(void);
132 int mount_fs(dev_t dev
, char mount_dev
[PATH_MAX
], char mount_path
[PATH_MAX
],
133 endpoint_t fs_e
, int rdonly
, char mount_type
[FSTYPE_MAX
],
134 char mount_label
[LABEL_MAX
]);
135 int unmount(dev_t dev
, char label
[LABEL_MAX
]);
136 void unmount_all(int force
);
140 int close_fd(struct fproc
*rfp
, int fd_nr
);
141 int common_open(char path
[PATH_MAX
], int oflags
, mode_t omode
);
149 int actual_lseek(struct fproc
*rfp
, int seekfd
, int seekwhence
, off_t offset
,
153 struct vnode
*advance(struct vnode
*dirp
, struct lookup
*resolve
, struct
155 struct vnode
*eat_path(struct lookup
*resolve
, struct fproc
*rfp
);
156 struct vnode
*last_dir(struct lookup
*resolve
, struct fproc
*rfp
);
157 void lookup_init(struct lookup
*resolve
, char *path
, int flags
, struct
158 vmnt
**vmp
, struct vnode
**vp
);
159 int get_name(struct vnode
*dirp
, struct vnode
*entry
, char *_name
);
160 int canonical_path(char *orig_path
, struct fproc
*rfp
);
161 int do_checkperms(void);
165 int map_vnode(struct vnode
*vp
, endpoint_t fs_e
);
167 int pipe_check(struct filp
*filp
, int rw_flag
, int oflags
, int bytes
,
169 void release(struct vnode
*vp
, int op
, int count
);
170 void revive(endpoint_t proc_e
, int returned
);
171 void suspend(int why
);
172 void pipe_suspend(struct filp
*rfilp
, vir_bytes buf
, size_t size
);
173 void unsuspend_by_endpt(endpoint_t proc_e
);
174 void wait_for(endpoint_t proc_e
);
181 int forbidden(struct fproc
*rfp
, struct vnode
*vp
, mode_t
183 int read_only(struct vnode
*vp
);
187 int do_getdents(void);
189 void unlock_bsf(void);
190 void check_bsf_lock(void);
191 int do_read_write_peek(int rw_flag
, int fd
, vir_bytes buf
, size_t bytes
);
192 int actual_read_write_peek(struct fproc
*rfp
, int rw_flag
, int fd
, vir_bytes buf
,
194 int read_write(struct fproc
*rfp
, int rw_flag
, struct filp
*f
, vir_bytes buffer
,
195 size_t nbytes
, endpoint_t for_e
);
196 int rw_pipe(int rw_flag
, endpoint_t usr
, struct filp
*f
, vir_bytes buf
,
200 int req_breadwrite(endpoint_t fs_e
, endpoint_t user_e
, dev_t dev
, off_t pos
,
201 unsigned int num_of_bytes
, vir_bytes user_addr
, int rw_flag
,
202 off_t
*new_posp
, unsigned int *cum_iop
);
203 int req_chmod(endpoint_t fs_e
, ino_t inode_nr
, mode_t rmode
,
205 int req_chown(endpoint_t fs_e
, ino_t inode_nr
, uid_t newuid
, gid_t newgid
,
207 int req_create(endpoint_t fs_e
, ino_t inode_nr
, int omode
, uid_t uid
,
208 gid_t gid
, char *path
, node_details_t
*res
);
209 int req_flush(endpoint_t fs_e
, dev_t dev
);
210 int req_statvfs(endpoint_t fs_e
, struct statvfs
*buf
);
211 int req_ftrunc(endpoint_t fs_e
, ino_t inode_nr
, off_t start
, off_t end
);
212 int req_getdents(endpoint_t fs_e
, ino_t inode_nr
, off_t pos
, vir_bytes buf
,
213 size_t size
, off_t
*new_pos
, int direct
);
214 int req_inhibread(endpoint_t fs_e
, ino_t inode_nr
);
215 int req_link(endpoint_t fs_e
, ino_t link_parent
, char *lastc
,
217 int req_lookup(endpoint_t fs_e
, ino_t dir_ino
, ino_t root_ino
, uid_t uid
,
218 gid_t gid
, struct lookup
*resolve
, lookup_res_t
*res
,
220 int req_mkdir(endpoint_t fs_e
, ino_t inode_nr
, char *lastc
, uid_t uid
,
221 gid_t gid
, mode_t dmode
);
222 int req_mknod(endpoint_t fs_e
, ino_t inode_nr
, char *lastc
, uid_t uid
,
223 gid_t gid
, mode_t dmode
, dev_t dev
);
224 int req_mountpoint(endpoint_t fs_e
, ino_t inode_nr
);
225 int req_newnode(endpoint_t fs_e
, uid_t uid
, gid_t gid
, mode_t dmode
,
226 dev_t dev
, struct node_details
*res
);
227 int req_putnode(int fs_e
, ino_t inode_nr
, int count
);
228 int req_rdlink(endpoint_t fs_e
, ino_t inode_nr
, endpoint_t proc_e
,
229 vir_bytes buf
, size_t len
, int direct
);
230 int req_readsuper(struct vmnt
*vmp
, char *driver_name
, dev_t dev
, int readonly
,
231 int isroot
, struct node_details
*res_nodep
, unsigned int *fs_flags
);
232 int req_readwrite(endpoint_t fs_e
, ino_t inode_nr
, off_t pos
, int rw_flag
,
233 endpoint_t user_e
, vir_bytes user_addr
, unsigned int num_of_bytes
,
234 off_t
*new_posp
, unsigned int *cum_iop
);
235 int req_bpeek(endpoint_t fs_e
, dev_t dev
, off_t pos
, unsigned int num_of_bytes
);
236 int req_peek(endpoint_t fs_e
, ino_t inode_nr
, off_t pos
, unsigned int bytes
);
237 int req_rename(endpoint_t fs_e
, ino_t old_dir
, char *old_name
, ino_t new_dir
,
239 int req_rmdir(endpoint_t fs_e
, ino_t inode_nr
, char *lastc
);
240 int req_slink(endpoint_t fs_e
, ino_t inode_nr
, char *lastc
, endpoint_t proc_e
,
241 vir_bytes path_addr
, size_t path_length
, uid_t uid
, gid_t gid
);
242 int req_stat(endpoint_t fs_e
, ino_t inode_nr
, endpoint_t proc_e
, vir_bytes buf
);
243 int req_sync(endpoint_t fs_e
);
244 int req_unlink(endpoint_t fs_e
, ino_t inode_nr
, char *lastc
);
245 int req_unmount(endpoint_t fs_e
);
246 int req_utime(endpoint_t fs_e
, ino_t inode_nr
, struct timespec
* actv
,
247 struct timespec
* modtv
);
248 int req_newdriver(endpoint_t fs_e
, dev_t dev
, char *label
);
256 int do_statvfs(void);
257 int do_fstatvfs(void);
258 int do_getvfsstat(void);
261 int update_statvfs(struct vmnt
*vmp
, struct statvfs
*buf
);
264 int do_utimens(void);
267 void tll_downgrade(tll_t
*tllp
);
268 int tll_haspendinglock(tll_t
*tllp
);
269 void tll_init(tll_t
*tllp
);
270 int tll_islocked(tll_t
*tllp
);
271 int tll_lock(tll_t
*tllp
, tll_access_t locktype
);
272 int tll_locked_by_me(tll_t
*tllp
);
273 void tll_lockstat(tll_t
*tllp
);
274 int tll_unlock(tll_t
*tllp
);
275 void tll_upgrade(tll_t
*tllp
);
278 struct timespec
clock_timespec(void);
279 int copy_path(char *dest
, size_t size
);
280 int fetch_name(vir_bytes path
, size_t len
, char *dest
);
281 int isokendpt_f(const char *f
, int l
, endpoint_t e
, int *p
, int ft
);
282 int in_group(struct fproc
*rfp
, gid_t grp
);
283 int sys_datacopy_wrapper(endpoint_t src
, vir_bytes srcv
, endpoint_t dst
, vir_bytes dstv
,
286 #define okendpt(e, p) isokendpt_f(__FILE__, __LINE__, (e), (p), 1)
287 #define isokendpt(e, p) isokendpt_f(__FILE__, __LINE__, (e), (p), 0)
290 void check_vmnt_locks(void);
291 void check_vmnt_locks_by_me(struct fproc
*rfp
);
292 void mark_vmnt_free(struct vmnt
*vmp
);
293 struct vmnt
*get_free_vmnt(void);
294 struct vmnt
*find_vmnt(endpoint_t fs_e
);
295 struct vmnt
*get_locked_vmnt(struct fproc
*rfp
);
296 void init_vmnts(void);
297 int lock_vmnt(struct vmnt
*vp
, tll_access_t locktype
);
298 void unlock_vmnt(struct vmnt
*vp
);
299 void vmnt_unmap_by_endpt(endpoint_t proc_e
);
300 void fetch_vmnt_paths(void);
301 void upgrade_vmnt_lock(struct vmnt
*vmp
);
302 void downgrade_vmnt_lock(struct vmnt
*vmp
);
305 void check_vnode_locks(void);
306 void check_vnode_locks_by_me(struct fproc
*rfp
);
307 struct vnode
*get_free_vnode(void);
308 struct vnode
*find_vnode(int fs_e
, ino_t inode
);
309 void init_vnodes(void);
310 int is_vnode_locked(struct vnode
*vp
);
311 int lock_vnode(struct vnode
*vp
, tll_access_t locktype
);
312 void unlock_vnode(struct vnode
*vp
);
313 void dup_vnode(struct vnode
*vp
);
314 void put_vnode(struct vnode
*vp
);
315 void vnode_clean_refs(struct vnode
*vp
);
316 void upgrade_vnode_lock(struct vnode
*vp
);
322 int do_gcov_flush(void);
324 #define do_gcov_flush NULL
329 void init_select(void);
330 void select_callback(struct filp
*, int ops
);
331 void select_forget(void);
332 void select_reply1(endpoint_t driver_e
, devminor_t minor
, int status
);
333 void select_reply2(endpoint_t driver_e
, devminor_t minor
, int status
);
334 void select_timeout_check(minix_timer_t
*);
335 void select_unsuspend_by_endpt(endpoint_t proc
);
338 void worker_init(void);
339 int worker_available(void);
340 struct worker_thread
*worker_get(thread_t worker_tid
);
341 void worker_signal(struct worker_thread
*worker
);
342 int worker_can_start(struct fproc
*rfp
);
343 void worker_start(struct fproc
*rfp
, void (*func
)(void), message
*m_ptr
,
345 void worker_stop(struct worker_thread
*worker
);
346 void worker_stop_by_endpt(endpoint_t proc_e
);
347 void worker_wait(void);
348 struct worker_thread
*worker_suspend(void);
349 void worker_resume(struct worker_thread
*org_self
);
350 void worker_set_proc(struct fproc
*rfp
);