Sync with cat.c from netbsd-8
[minix3.git] / minix / servers / vfs / fproc.h
blob9ba946aea8f9ddcfbc5178d8fa7faff5770c1a78
1 #ifndef __VFS_FPROC_H__
2 #define __VFS_FPROC_H__
4 #include "threads.h"
6 #include <sys/select.h>
7 #include <minix/safecopies.h>
8 #include <minix/sef.h>
10 /* This is the per-process information. A slot is reserved for each potential
11 * process. Thus NR_PROCS must be the same as in the kernel. It is not
12 * possible or even necessary to tell when a slot is free here.
14 #define LOCK_DEBUG 0
15 EXTERN struct fproc {
16 unsigned fp_flags;
18 pid_t fp_pid; /* process id */
19 endpoint_t fp_endpoint; /* kernel endpoint number of this process */
21 struct vnode *fp_wd; /* working directory; NULL during reboot */
22 struct vnode *fp_rd; /* root directory; NULL during reboot */
24 struct filp *fp_filp[OPEN_MAX];/* the file descriptor table (free if NULL) */
25 fd_set fp_cloexec_set; /* bit map for POSIX Table 6-2 FD_CLOEXEC */
27 dev_t fp_tty; /* major/minor of controlling tty */
29 int fp_blocked_on; /* what is it blocked on */
30 union ixfer_fp_u { /* state per blocking type */
31 struct { /* FP_BLOCKED_ON_PIPE */
32 int callnr; /* user call: VFS_READ or VFS_WRITE */
33 int fd; /* file descriptor for blocking call */
34 vir_bytes buf; /* user buffer address */
35 size_t nbytes; /* number of bytes left */
36 size_t cum_io; /* partial (write) result byte count */
37 } u_pipe;
38 struct { /* FP_BLOCKED_ON_POPEN */
39 int fd; /* file descriptor for blocking call */
40 } u_popen;
41 struct { /* FP_BLOCKED_ON_FLOCK */
42 int fd; /* file descriptor for blocking call */
43 int cmd; /* fcntl command, always F_SETLKW */
44 vir_bytes arg; /* user address of flock structure */
45 } u_flock;
46 /* nothing for FP_BLOCKED_ON_SELECT for now */
47 struct { /* FP_BLOCKED_ON_CDEV */
48 dev_t dev; /* device number for blocking call */
49 endpoint_t endpt; /* driver endpoint */
50 cp_grant_id_t grant; /* data grant */
51 } u_cdev;
52 struct { /* FP_BLOCKED_ON_SDEV */
53 dev_t dev; /* socket number for blocking call */
54 int callnr; /* user call: a VFS_ socket call */
55 cp_grant_id_t grant[3]; /* data grant(s) */
56 union ixfer_u_aux {
57 int fd; /* listener file descr. (VFS_ACCEPT) */
58 vir_bytes buf; /* user buffer address (VFS_RECVMSG) */
59 } aux; /* call-specific auxiliary data */
60 } u_sdev;
61 } fp_u;
63 uid_t fp_realuid; /* real user id */
64 uid_t fp_effuid; /* effective user id */
65 gid_t fp_realgid; /* real group id */
66 gid_t fp_effgid; /* effective group id */
67 int fp_ngroups; /* number of supplemental groups */
68 gid_t fp_sgroups[NGROUPS_MAX];/* supplemental groups */
69 mode_t fp_umask; /* mask set by umask system call */
71 mutex_t fp_lock; /* mutex to lock fproc object */
72 struct worker_thread *fp_worker;/* active worker thread, or NULL */
73 void (*fp_func)(void); /* handler function for pending work */
74 message fp_msg; /* pending or active message from process */
75 message fp_pm_msg; /* pending/active postponed PM request */
77 char fp_name[PROC_NAME_LEN]; /* Last exec() */
78 #if LOCK_DEBUG
79 int fp_vp_rdlocks; /* number of read-only locks on vnodes */
80 int fp_vmnt_rdlocks; /* number of read-only locks on vmnts */
81 #endif
82 } fproc[NR_PROCS];
84 /* Shortcuts for block state union substructures. */
85 #define fp_pipe fp_u.u_pipe
86 #define fp_popen fp_u.u_popen
87 #define fp_flock fp_u.u_flock
88 #define fp_cdev fp_u.u_cdev
89 #define fp_sdev fp_u.u_sdev
91 /* fp_flags */
92 #define FP_NOFLAGS 0000
93 #define FP_SRV_PROC 0001 /* Set if process is a service */
94 #define FP_REVIVED 0002 /* Indicates process is being revived */
95 #define FP_SESLDR 0004 /* Set if process is session leader */
96 #define FP_PENDING 0010 /* Set if process has pending work */
97 #define FP_EXITING 0020 /* Set if process is exiting */
98 #define FP_PM_WORK 0040 /* Set if process has a postponed PM request */
100 /* Field values. */
101 #define NOT_REVIVING 0xC0FFEEE /* process is not being revived */
102 #define REVIVING 0xDEEAD /* process is being revived from suspension */
103 #define PID_FREE 0 /* process slot free */
106 * Upon request from the MIB service, this table is filled with a relatively
107 * small subset of per-process fields, so that the MIB service can avoid
108 * pulling in the entire fproc table. Other fields may be added to this
109 * structure as required by the MIB service.
111 EXTERN struct fproc_light {
112 dev_t fpl_tty; /* copy of fproc.fp_tty */
113 int fpl_blocked_on; /* copy of fproc.fp_blocked_on */
114 endpoint_t fpl_task; /* copy of fproc.fp_task */
115 } fproc_light[NR_PROCS];
117 #endif /* __VFS_FPROC_H__ */