home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Headers / bsd / sys / user.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-27  |  13.0 KB  |  456 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1987 Carnegie-Mellon University
  4.  * All rights reserved.  The CMU software License Agreement specifies
  5.  * the terms and conditions for use and redistribution.
  6.  */
  7. /* 
  8.  * HISTORY
  9.  * 27-Sep-89  Morris Meyer (mmeyer) at NeXT
  10.  *    NFS 4.0 Changes: ucred definition moved to ucred.h.
  11.  *             Addition of u_auid.
  12.  *
  13.  * 28-Apr-88  David Golub (dbg) at Carnegie-Mellon University
  14.  *    Move u_rpause and u_rfs from thread to task U-area - they are
  15.  *    both global process state.
  16.  *
  17.  * 26-Feb-88  David Kirschen (kirschen) at Encore Computer Corporation
  18.  *      Add include of param.h for NGROUPS, etc.
  19.  *
  20.  * 19-Nov-87  Avadis Tevanian (avie) at Carnegie-Mellon University
  21.  *    Eliminated conditionals, purged history.
  22.  */
  23.  
  24. /*
  25.  * Copyright (c) 1982, 1986 Regents of the University of California.
  26.  * All rights reserved.  The Berkeley software License Agreement
  27.  * specifies the terms and conditions for redistribution.
  28.  *
  29.  *    @(#)user.h    7.1 (Berkeley) 6/4/86
  30.  */
  31.  
  32. /* @(#)user.h    1.8 87/08/24 3.2/4.3NFSSRC */
  33.  
  34. #ifndef    _SYS_USER_H_
  35. #define    _SYS_USER_H_
  36.  
  37. #import <sys/types.h>
  38.  
  39. #import <kernserv/lock.h>
  40. #import <sys/param.h>
  41. #if    NeXT
  42. #else    NeXT
  43. #import <machine/thread.h>
  44. #endif    NeXT
  45. #import <sys/time.h>
  46. #import <sys/resource.h>
  47. #import <sys/ucred.h>
  48. #if    NeXT && m68k
  49. #import <bsd/m68k/fptrace.h>
  50. #endif    NeXT && m68k
  51.  
  52. /*
  53.  * Per process structure containing data that
  54.  * isn't needed in core when the process is swapped out.
  55.  */
  56.  
  57. #define    MAXCOMLEN    16        /* <= MAXNAMLEN, >= sizeof(ac_comm) */
  58.  
  59. #if    (defined(KERNEL) || defined(SHOW_UTT))
  60. /*
  61.  *    Per-thread U area.
  62.  *
  63.  *    It is likely that this structure contains no fields that must be
  64.  *    saved between system calls.
  65.  */
  66. struct uthread {
  67.     int    *uu_ar0;        /* address of users saved R0 */
  68.  
  69. /* syscall parameters, results and catches */
  70.     int    uu_arg[8];        /* arguments to current system call */
  71.     int    *uu_ap;            /* pointer to arglist */
  72.     label_t    uu_qsave;        /* for non-local gotos on interrupts */
  73.     union {                /* syscall return values */
  74.         struct    {
  75.             int    R_val1;
  76.             int    R_val2;
  77.         } u_rv;
  78. #define    r_val1    u_rv.R_val1
  79. #define    r_val2    u_rv.R_val2
  80.         off_t    r_off;
  81.         time_t    r_time;
  82.     } uu_r;
  83.     char    uu_error;        /* return error code */
  84.     char    uu_eosys;        /* special action on end of syscall */
  85.  
  86. /* CS_RPAUSE */
  87.     struct fs *uu_rpsfs;        /* resource pause file system */
  88.     char    uu_rpswhich;        /* resource pause operation selection */
  89. /* CS_RPAUSE */
  90.  
  91. /* thread exception handling */
  92.     int    uu_code;            /* ``code'' to trap */
  93.     char uu_cursig;                /* p_cursig for exc. */
  94.     int  uu_sig;                /* p_sig for exc. */
  95.  
  96. /* support for syscalls which use continuations */
  97.     struct timeval uu_syst;            /* snapshot for profiling */
  98.     union {
  99.         struct _select {
  100.             fd_set    ibits[3], obits[3];
  101.             struct    timeval atv;
  102.             int    poll, error;
  103.         } ss_select;            /* saved state for select() */
  104.         struct _wait {
  105.             int    f;
  106.         } ss_wait;            /* saved state for wait?() */
  107.     } uu_state;
  108. };
  109.  
  110. /*
  111.  *    Per-task U area - global process state.
  112.  */
  113. struct utask {
  114. #ifdef    NeXT
  115. #else    NeXT
  116.     struct    pcb uu_pcb;
  117. #endif    NeXT
  118.     struct    proc *uu_procp;        /* pointer to proc structure */
  119.     int    *uu_ar0;        /* address of users saved R0 */
  120.     char    uu_comm[MAXCOMLEN + 1];
  121.  
  122. /* 1.1 - processes and protection */
  123. #if    ROMP_DUALCALL
  124.     char    uu_calltype;        /* 0 - old calling sequence */
  125. #endif    ROMP_DUALCALL
  126. /* SUN_VFS */
  127.     struct ucred *uu_cred;        /* user credentials (uid, gid, etc) */
  128. #define    uu_uid    uu_cred->cr_uid
  129. #define    uu_gid    uu_cred->cr_gid
  130. #define    uu_groups uu_cred->cr_groups
  131. #define    uu_ruid    uu_cred->cr_ruid
  132. #define    uu_rgid    uu_cred->cr_rgid
  133. /* SUN_VFS */
  134.  
  135.     lock_data_t    uu_cred_lock;    /* lock for credentials */
  136. #define u_cred_lock()        lock_write(&u.utask->uu_cred_lock)
  137. #define u_cred_unlock()        lock_write_done(&u.utask->uu_cred_lock)
  138. #define u_cred_lock_init(lock)    lock_init(lock, TRUE);
  139.  
  140. /* 1.2 - memory management */
  141.     time_t    uu_outime;        /* user time at last sample */
  142.  
  143. /* 1.3 - signal management */
  144.     void    (*uu_signal[NSIG+1])();    /* disposition of signals */
  145.     int    uu_sigmask[NSIG+1];    /* signals to be blocked */
  146. #ifdef    i386
  147.     int    (*uu_sigreturn)();
  148. #endif    i386
  149. #ifdef    multimax
  150.     int    (*uu_sigcatch)();    /* used as a way not to do tramp. */
  151. #endif    multimax
  152. #ifdef    balance
  153.     int    (*uu_sigtramp)();    /* signal trampoline code */
  154. #endif    balance
  155.     int    uu_sigonstack;        /* signals to take on sigstack */
  156.     int    uu_sigintr;        /* signals that interrupt syscalls */
  157.     int    uu_oldmask;        /* saved mask from before sigpause */
  158.     struct    sigstack uu_sigstack;    /* sp & on stack state variable */
  159. #define    uu_onstack    uu_sigstack.ss_onstack
  160. #define    uu_sigsp    uu_sigstack.ss_sp
  161.  
  162. /* 1.4 - descriptor management */
  163. #if    NeXT
  164.     struct    file **uu_ofile;    /* file structures for open files */
  165.     char    *uu_pofile;        /* per-process flags of open files */
  166.     int    uu_lastfile;        /* high-water mark of uu_ofile */
  167.     int    uu_ofile_cnt;        /* number of file structs allocated */
  168. #else    NeXT
  169.     struct    file *uu_ofile[NOFILE];    /* file structures for open files */
  170.     char    uu_pofile[NOFILE];    /* per-process flags of open files */
  171.     int    uu_lastfile;        /* high-water mark of uu_ofile */
  172. #endif    NeXT
  173. #define    UF_EXCLOSE     0x1        /* auto-close on exec */
  174. #define    UF_MAPPED     0x2        /* mapped from device */
  175. #define UF_FDLOCK    0x4        /* file desc locked (SysV style) */
  176.     struct    vnode *uu_cdir;        /* current directory */
  177.     struct    vnode *uu_rdir;        /* root directory of current process */
  178.     struct    tty *uu_ttyp;        /* controlling tty pointer */
  179.     dev_t    uu_ttyd;        /* controlling tty dev */
  180.     short    uu_cmask;        /* mask for file creation */
  181.  
  182. /* 1.5 - timing and statistics */
  183.     struct    rusage uu_ru;        /* stats for this proc */
  184.     struct    rusage uu_cru;        /* sum of stats for reaped children */
  185.     struct    itimerval uu_timer[3];
  186.     int    uu_XXX[3];
  187.     struct    timeval uu_start;
  188.     short    uu_acflag;
  189.  
  190.     struct uuprof {            /* profile arguments */
  191.         simple_lock_t pr_lock;    /* lock for thread updating */
  192. #if    NeXT
  193.         struct uuprof *pr_next;    /* multiple profiling buffers allowed */
  194. #endif    NeXT
  195.         short    *pr_base;    /* buffer base */
  196.         unsigned pr_size;    /* buffer size */
  197.         unsigned pr_off;    /* pc offset */
  198.         unsigned pr_scale;    /* pc scaling */
  199.     } uu_prof;
  200. /* CS_RPAUSE */
  201.     u_char    uu_rpause;        /* resource pause flags: */
  202. #define    URPS_AGAIN    01        /* - no child processes available */
  203. #define    URPS_NOMEM    02        /* - no memory available */
  204. #define    URPS_NFILE    04        /* - file table overflow */
  205. #define    URPS_NOSPC    010        /* - no space on device */
  206. /* CS_RPAUSE */
  207.  
  208. /* 1.6 - resource controls */
  209.     struct    rlimit uu_rlimit[RLIM_NLIMITS];
  210.  
  211.     int    uu_stack[1];
  212. #if    defined(NeXT) && defined(DEBUG) && defined(m68k)
  213.     struct fptrace_data uu_fptrace;    /* fpemul trace data */
  214. #endif    defined(NeXT) && defined(DEBUG) && defined(m68k)
  215. };
  216.  
  217. #endif    defined(KERNEL)
  218. struct    user {
  219. #if    NeXT
  220. #else    NeXT
  221.     struct    pcb u_pcb;
  222. #endif    NeXT
  223.     struct    proc *u_procp;        /* pointer to proc structure */
  224.     int    *u_ar0;            /* address of users saved R0 */
  225.     char    u_comm[MAXCOMLEN + 1];
  226.  
  227. /* syscall parameters, results and catches */
  228.     int    u_arg[8];        /* arguments to current system call */
  229.     int    *u_ap;            /* pointer to arglist */
  230.     label_t    u_qsave;        /* for non-local gotos on interrupts */
  231.     union {                /* syscall return values */
  232.         struct    {
  233.             int    R_val1;
  234.             int    R_val2;
  235.         } u_rv;
  236. #define    r_val1    u_rv.R_val1
  237. #define    r_val2    u_rv.R_val2
  238.         off_t    r_off;
  239.         time_t    r_time;
  240.     } u_r;
  241.     char    u_error;        /* return error code */
  242.     char    u_eosys;        /* special action on end of syscall */
  243.  
  244. /* 1.1 - processes and protection */
  245. #if    ROMP_DUALCALL
  246.     char    u_calltype;        /* 0 == old calling sequence */
  247. #endif    ROMP_DUALCALL
  248. /* SUN_VFS */
  249.     struct ucred *u_cred;        /* user credentials (uid, gid, etc) */
  250. #define    u_uid        u_cred->cr_uid
  251. #define    u_gid        u_cred->cr_gid
  252. #define    u_groups     u_cred->cr_groups
  253. #define    u_ruid        u_cred->cr_ruid
  254. #define    u_rgid        u_cred->cr_rgid
  255. #define    u_auid        u_cred->cr_auid
  256. /* SUN_VFS */
  257.  
  258. /* 1.2 - memory management */
  259.     size_t    u_tsize;        /* text size (clicks) */
  260.     size_t    u_dsize;        /* data size (clicks) */
  261.     size_t    u_ssize;        /* stack size (clicks) */
  262.     caddr_t    u_text_start;        /* text starting address */
  263.     caddr_t    u_data_start;        /* data starting address */
  264.     time_t    u_outime;        /* user time at last sample */
  265.  
  266. /* 1.3 - signal management */
  267.     void    (*u_signal[NSIG+1])();    /* disposition of signals */
  268.     int    u_sigmask[NSIG+1];    /* signals to be blocked */
  269. #ifdef    i386
  270.     int    (*uu_sigreturn)();
  271. #endif    i386
  272. #ifdef    multimax
  273.     int    (*u_sigcatch)();    /* used as a way not to do tramp. */
  274. #endif    multimax
  275. #ifdef    balance
  276.     int    (*u_sigtramp)();    /* signal trampoline code */
  277. #endif    balance
  278.     int    u_sigonstack;        /* signals to take on sigstack */
  279.     int    u_sigintr;        /* signals that interrupt syscalls */
  280.     int    u_oldmask;        /* saved mask from before sigpause */
  281.     int    u_code;            /* ``code'' to trap */
  282.     struct    sigstack u_sigstack;    /* sp & on stack state variable */
  283. #define    u_onstack    u_sigstack.ss_onstack
  284. #define    u_sigsp        u_sigstack.ss_sp
  285.  
  286. /* 1.4 - descriptor management */
  287.     struct    file *u_ofile[NOFILE];    /* file structures for open files */
  288.     char    u_pofile[NOFILE];    /* per-process flags of open files */
  289.     int    u_lastfile;        /* high-water mark of u_ofile */
  290. #define    UF_EXCLOSE     0x1        /* auto-close on exec */
  291. #define    UF_MAPPED     0x2        /* mapped from device */
  292. #define UF_FDLOCK    0x4        /* file desc locked (SysV style) */
  293.     struct    vnode *u_cdir;        /* current directory */
  294.     struct    vnode *u_rdir;        /* root directory of current process */
  295.     struct    tty *u_ttyp;        /* controlling tty pointer */
  296.     dev_t    u_ttyd;            /* controlling tty dev */
  297.     short    u_cmask;        /* mask for file creation */
  298.  
  299. /* 1.5 - timing and statistics */
  300.     struct    rusage u_ru;        /* stats for this proc */
  301.     struct    rusage u_cru;        /* sum of stats for reaped children */
  302.     struct    itimerval u_timer[3];
  303.     int    u_XXX[3];
  304.     struct    timeval u_start;
  305.     short    u_acflag;
  306.  
  307.     struct uprof {            /* profile arguments */
  308.         simple_lock_t pr_lock;    /* lock for thread updating */
  309.         short    *pr_base;    /* buffer base */
  310.         unsigned pr_size;    /* buffer size */
  311.         unsigned pr_off;    /* pc offset */
  312.         unsigned pr_scale;    /* pc scaling */
  313.     } u_prof;
  314. /* CS_RPAUSE */
  315.     struct fs *u_rpsfs;        /* resource pause file system */
  316.     char    u_rpswhich;        /* resource pause operation selection */
  317. #define URPW_FNOSPC    0x01        /* - low on fragments */
  318. #define URPW_INOSPC    0x02        /* - low on inodes */
  319. #define URPW_QNOSPC    0x04        /* - out of quota */
  320. #define URPW_POLL    0x40        /* - poll until available */
  321. #define URPW_NOTIFY    0x80        /* - pause in progress */
  322.     u_char    u_rpause;        /* resource pause flags: */
  323. #define    URPS_AGAIN    01        /* - no child processes available */
  324. #define    URPS_NOMEM    02        /* - no memory available */
  325. #define    URPS_NFILE    04        /* - file table overflow */
  326. #define    URPS_NOSPC    010        /* - no space on device */
  327. /* CS_RPAUSE */
  328.  
  329. /* 1.6 - resource controls */
  330.     struct    rlimit u_rlimit[RLIM_NLIMITS];
  331.  
  332.     int    u_stack[1];
  333. };
  334.  
  335. /* u_eosys values */
  336. #define    JUSTRETURN    1
  337. #define    RESTARTSYS    2
  338. #define NORMALRETURN    3
  339.  
  340. /* u_error codes */
  341. #import <sys/errno.h>
  342.  
  343. #ifdef KERNEL
  344.  
  345. #import <machine/cpu.h>
  346.  
  347. #import <machine/user.h>
  348.  
  349. #ifndef    u
  350. #define u    (active_u[cpu_number()])
  351. #endif    u
  352.  
  353. struct _u_address {
  354.     struct utask    *utask;
  355.     struct uthread    *uthread;
  356. };
  357.  
  358. extern struct _u_address    active_u[];
  359.  
  360. #if    NeXT
  361. #else    NeXT
  362. #define u_pcb        uthread->uu_pcb
  363. #endif    NeXT
  364. #define u_procp        utask->uu_procp
  365. #define u_ar0        uthread->uu_ar0
  366. #define u_comm        utask->uu_comm
  367.  
  368. #define u_arg        uthread->uu_arg
  369. #define u_ap        uthread->uu_ap
  370. #define u_qsave        uthread->uu_qsave
  371. #define u_r        uthread->uu_r
  372. #define u_error        uthread->uu_error
  373. #define u_eosys        uthread->uu_eosys
  374. #define u_syst        uthread->uu_syst
  375. #define u_select    uthread->uu_state.ss_select
  376. #define u_wait        uthread->uu_state.ss_wait
  377.  
  378. /* SUN_VFS */
  379. #undef    u_cred
  380. #undef    u_uid
  381. #undef    u_gid
  382. #undef    u_groups
  383. #undef    u_ruid
  384. #undef    u_rgid
  385. #define    u_cred        utask->uu_cred
  386. #define    u_uid        utask->uu_cred->cr_uid
  387. #define    u_gid        utask->uu_cred->cr_gid
  388. #define    u_groups     utask->uu_cred->cr_groups
  389. #define    u_ruid        utask->uu_cred->cr_ruid
  390. #define    u_rgid        utask->uu_cred->cr_rgid
  391. /* SUN_VFS */
  392.  
  393. #define u_tsize        utask->uu_tsize
  394. #define u_dsize        utask->uu_dsize
  395. #define u_ssize        utask->uu_ssize
  396. #define    u_text_start    utask->uu_text_start
  397. #define    u_data_start    utask->uu_data_start
  398. #define u_outime    utask->uu_outime
  399.  
  400. #define u_signal    utask->uu_signal
  401. #ifdef    i386
  402. #define u_sigreturn     utask->uu_sigreturn
  403. #endif    i386
  404. #ifdef    multimax
  405. #define    u_sigcatch    utask->uu_sigcatch
  406. #endif    multimax
  407. #ifdef    balance
  408. #define    u_sigtramp    utask->uu_sigtramp
  409. #endif    balance
  410. #define u_sigmask    utask->uu_sigmask
  411. #define u_sigonstack    utask->uu_sigonstack
  412. #define u_sigintr    utask->uu_sigintr
  413. #define u_oldmask    utask->uu_oldmask
  414. #define u_code        uthread->uu_code
  415. #define u_sigstack    utask->uu_sigstack
  416.  
  417. #define    u_onstack    u_sigstack.ss_onstack
  418. #define    u_sigsp        u_sigstack.ss_sp
  419.  
  420. #define u_ofile        utask->uu_ofile
  421. #define u_pofile    utask->uu_pofile
  422. #define u_lastfile    utask->uu_lastfile
  423. #if    NeXT
  424. #define u_ofile_cnt    utask->uu_ofile_cnt
  425. #define u_fptrace    utask->uu_fptrace
  426. #endif    NeXT
  427. #define u_cdir        utask->uu_cdir
  428. #define u_rdir        utask->uu_rdir
  429. #define u_ttyp        utask->uu_ttyp
  430. #define u_ttyd        utask->uu_ttyd
  431. #define u_cmask        utask->uu_cmask
  432.  
  433. #define u_ru        utask->uu_ru
  434. #define u_cru        utask->uu_cru
  435. #define u_timer        utask->uu_timer
  436. #define u_XXX        utask->uu_XXX
  437. #define u_start        utask->uu_start
  438. #define u_acflag    utask->uu_acflag
  439.  
  440. #define u_prof        utask->uu_prof
  441. /* CS_RPAUSE */
  442. #define u_rpsfs        uthread->uu_rpsfs
  443. #define u_rpswhich    uthread->uu_rpswhich
  444. #define u_rpause    utask->uu_rpause
  445. /* CS_RPAUSE */
  446.  
  447. #define u_rlimit    utask->uu_rlimit
  448.  
  449. #define u_sig        uthread->uu_sig
  450. #define u_cursig    uthread->uu_cursig
  451. #endif
  452. #endif    _SYS_USER_H_
  453.  
  454.  
  455.  
  456.