1 #ifndef __VFS_FPROC_H__ 2 #define __VFS_FPROC_H__ 3 4 #include "threads.h" 5 6 #include <sys/select.h> 7 #include <minix/safecopies.h> 8 #include <minix/sef.h> 9 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. 13 */ 14 #define LOCK_DEBUG 0 15 EXTERN struct fproc { 16 unsigned fp_flags; 17 18 pid_t fp_pid; /* process id */ 19 endpoint_t fp_endpoint; /* kernel endpoint number of this process */ 20 21 struct vnode *fp_wd; /* working directory; NULL during reboot */ 22 struct vnode *fp_rd; /* root directory; NULL during reboot */ 23 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 */ 26 27 dev_t fp_tty; /* major/minor of controlling tty */ 28 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 } fp_u; 53 54 uid_t fp_realuid; /* real user id */ 55 uid_t fp_effuid; /* effective user id */ 56 gid_t fp_realgid; /* real group id */ 57 gid_t fp_effgid; /* effective group id */ 58 int fp_ngroups; /* number of supplemental groups */ 59 gid_t fp_sgroups[NGROUPS_MAX];/* supplemental groups */ 60 mode_t fp_umask; /* mask set by umask system call */ 61 62 mutex_t fp_lock; /* mutex to lock fproc object */ 63 struct worker_thread *fp_worker;/* active worker thread, or NULL */ 64 void (*fp_func)(void); /* handler function for pending work */ 65 message fp_msg; /* pending or active message from process */ 66 message fp_pm_msg; /* pending/active postponed PM request */ 67 68 char fp_name[PROC_NAME_LEN]; /* Last exec() */ 69 #if LOCK_DEBUG 70 int fp_vp_rdlocks; /* number of read-only locks on vnodes */ 71 int fp_vmnt_rdlocks; /* number of read-only locks on vmnts */ 72 #endif 73 } fproc[NR_PROCS]; 74 75 /* Shortcuts for block state union substructures. */ 76 #define fp_pipe fp_u.u_pipe 77 #define fp_popen fp_u.u_popen 78 #define fp_flock fp_u.u_flock 79 #define fp_cdev fp_u.u_cdev 80 81 /* fp_flags */ 82 #define FP_NOFLAGS 0000 83 #define FP_SRV_PROC 0001 /* Set if process is a service */ 84 #define FP_REVIVED 0002 /* Indicates process is being revived */ 85 #define FP_SESLDR 0004 /* Set if process is session leader */ 86 #define FP_PENDING 0010 /* Set if process has pending work */ 87 #define FP_EXITING 0020 /* Set if process is exiting */ 88 #define FP_PM_WORK 0040 /* Set if process has a postponed PM request */ 89 90 /* Field values. */ 91 #define NOT_REVIVING 0xC0FFEEE /* process is not being revived */ 92 #define REVIVING 0xDEEAD /* process is being revived from suspension */ 93 #define PID_FREE 0 /* process slot free */ 94 95 /* 96 * Upon request from the MIB service, this table is filled with a relatively 97 * small subset of per-process fields, so that the MIB service can avoid 98 * pulling in the entire fproc table. Other fields may be added to this 99 * structure as required by the MIB service. 100 */ 101 EXTERN struct fproc_light { 102 dev_t fpl_tty; /* copy of fproc.fp_tty */ 103 int fpl_blocked_on; /* copy of fproc.fp_blocked_on */ 104 endpoint_t fpl_task; /* copy of fproc.fp_task */ 105 } fproc_light[NR_PROCS]; 106 107 #endif /* __VFS_FPROC_H__ */ 108