1 /* @(#)user.h 2.1 3/25/82 */ 2 3 /* user.h 4.12 82/04/19 */ 4 5 #ifdef KERNEL 6 #include "../h/pcb.h" 7 #include "../h/dmap.h" 8 #include "../h/vtimes.h" 9 #else 10 #include <sys/pcb.h> 11 #include <sys/dmap.h> 12 #include <sys/vtimes.h> 13 #endif 14 /* 15 * The user structure. 16 * One allocated per process. 17 * Contains all per process data 18 * that doesn't need to be referenced 19 * while the process is swapped. 20 * The user block is UPAGES*NBPG bytes 21 * long; resides at virtual user 22 * loc 0x80000000-UPAGES*NBPG; contains the system 23 * stack per user; is cross referenced 24 * with the proc structure for the 25 * same process. 26 */ 27 28 #define SHSIZE 32 29 30 struct user 31 { 32 struct pcb u_pcb; 33 int u_arg[5]; /* arguments to current system call */ 34 label_t u_qsav; /* for non-local gotos on interrupts */ 35 char u_segflg; /* 0:user D; 1:system; 2:user I */ 36 char u_error; /* return error code */ 37 short u_uid; /* effective user id */ 38 short u_gid; /* effective group id */ 39 int u_grps[NGRPS/(sizeof(int)*8)]; 40 /* group bit array */ 41 short u_ruid; /* real user id */ 42 short u_rgid; /* real group id */ 43 struct proc *u_procp; /* pointer to proc structure */ 44 int *u_ap; /* pointer to arglist */ 45 union { /* syscall return values */ 46 struct { 47 int R_val1; 48 int R_val2; 49 } u_rv; 50 #define r_val1 u_rv.R_val1 51 #define r_val2 u_rv.R_val2 52 off_t r_off; 53 time_t r_time; 54 } u_r; 55 caddr_t u_base; /* base address for IO */ 56 unsigned int u_count; /* bytes remaining for IO */ 57 off_t u_offset; /* offset in file for IO */ 58 struct inode *u_cdir; /* pointer to inode of current directory */ 59 struct inode *u_rdir; /* root directory of current process */ 60 caddr_t u_dirp; /* pathname pointer */ 61 struct direct u_dent; /* current directory entry */ 62 struct inode *u_pdir; /* inode of parent directory of dirp */ 63 struct file *u_ofile[NOFILE]; /* pointers to file structures of open files */ 64 char u_pofile[NOFILE]; /* per-process flags of open files */ 65 #define EXCLOSE 01 /* auto-close on exec */ 66 label_t u_ssav; /* label variable for swapping */ 67 int (*u_signal[NSIG])(); /* disposition of signals */ 68 int u_code; /* ``code'' to trap */ 69 /* on SIGILL code passes compatibility mode fault address */ 70 /* on SIGFPE code passes more specific kind of floating point fault */ 71 int *u_ar0; /* address of users saved R0 */ 72 struct uprof { /* profile arguments */ 73 short *pr_base; /* buffer base */ 74 unsigned pr_size; /* buffer size */ 75 unsigned pr_off; /* pc offset */ 76 unsigned pr_scale; /* pc scaling */ 77 } u_prof; 78 char u_eosys; /* special action on end of syscall */ 79 char u_sep; /* flag for I and D separation */ 80 struct tty *u_ttyp; /* controlling tty pointer */ 81 dev_t u_ttyd; /* controlling tty dev */ 82 union { 83 struct { /* header of executable file */ 84 int Ux_mag; /* magic number */ 85 unsigned Ux_tsize; /* text size */ 86 unsigned Ux_dsize; /* data size */ 87 unsigned Ux_bsize; /* bss size */ 88 unsigned Ux_ssize; /* symbol table size */ 89 unsigned Ux_entloc; /* entry location */ 90 unsigned Ux_unused; 91 unsigned Ux_relflg; 92 } Ux_A; 93 char ux_shell[SHSIZE]; /* #! and name of interpreter */ 94 } u_exdata; 95 #define ux_mag Ux_A.Ux_mag 96 #define ux_tsize Ux_A.Ux_tsize 97 #define ux_dsize Ux_A.Ux_dsize 98 #define ux_bsize Ux_A.Ux_bsize 99 #define ux_ssize Ux_A.Ux_ssize 100 #define ux_entloc Ux_A.Ux_entloc 101 #define ux_unused Ux_A.Ux_unused 102 #define ux_relflg Ux_A.Ux_relflg 103 104 char u_comm[MAXNAMLEN + 1]; 105 time_t u_start; 106 char u_acflag; 107 short u_fpflag; /* unused now, will be later */ 108 short u_cmask; /* mask for file creation */ 109 size_t u_tsize; /* text size (clicks) */ 110 size_t u_dsize; /* data size (clicks) */ 111 size_t u_ssize; /* stack size (clicks) */ 112 struct vtimes u_vm; /* stats for this proc */ 113 struct vtimes u_cvm; /* sum of stats for reaped children */ 114 struct dmap u_dmap; /* disk map for data segment */ 115 struct dmap u_smap; /* disk map for stack segment */ 116 struct dmap u_cdmap, u_csmap; /* shadows of u_dmap, u_smap, for 117 use of parent during fork */ 118 time_t u_outime; /* user time at last sample */ 119 size_t u_odsize, u_ossize; /* for (clumsy) expansion swaps */ 120 size_t u_vrpages[NOFILE]; /* number vread pages hanging on fd */ 121 int u_limit[8]; /* see <sys/limit.h> */ 122 #ifdef notdef 123 unsigned u_vsave; /* saved previous fault page number */ 124 #endif 125 int u_stack[1]; 126 127 /* 128 * kernel stack per user 129 * extends from u + UPAGES*512 130 * backward not to reach here 131 */ 132 /* SHOULD INSTEAD GROW STACK BACKWARDS ABOVE u. TOWARDS A VIRTUAL HOLE */ 133 }; 134 135 /* u_eosys values */ 136 #define JUSTRETURN 0 137 #define RESTARTSYS 1 138 #define SIMULATERTI 2 139 140 /* u_error codes */ 141 #ifdef KERNEL 142 #include "../errno.h" 143 #else 144 #include <errno.h> 145 #endif 146 147 #ifdef KERNEL 148 extern struct user u; 149 extern struct user swaputl; 150 extern struct user forkutl; 151 extern struct user xswaputl; 152 extern struct user xswap2utl; 153 extern struct user pushutl; 154 extern struct user vfutl; 155 #endif 156