home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 8.ddi / usr / include / sys / procfs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  9.5 KB  |  248 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. #ifndef _SYS_PROCFS_H
  11. #define _SYS_PROCFS_H
  12.  
  13. #ident    "@(#)/usr/include/sys/procfs.h.sl 1.1 4.0 12/08/90 16312 AT&T-USL"
  14.  
  15. #include <sys/types.h>
  16. #include <sys/time.h>
  17. #include <sys/regset.h>
  18. #include <sys/tss.h>
  19. #include <sys/signal.h>
  20. #include <sys/siginfo.h>
  21. #include <sys/ucontext.h>
  22. #include <sys/fault.h>
  23. #include <sys/syscall.h>
  24.  
  25. /*
  26.  * ioctl codes and system call interfaces for /proc.
  27.  */
  28.  
  29. #define    PIOC        ('q'<<8)
  30. #define    PIOCSTATUS    (PIOC|1)    /* get process status */
  31. #define    PIOCSTOP    (PIOC|2)    /* post STOP request and... */
  32. #define    PIOCWSTOP    (PIOC|3)    /* wait for process to STOP */
  33. #define    PIOCRUN        (PIOC|4)    /* make process runnable */
  34. #define    PIOCGTRACE    (PIOC|5)    /* get traced signal set */
  35. #define    PIOCSTRACE    (PIOC|6)    /* set traced signal set */
  36. #define    PIOCSSIG    (PIOC|7)    /* set current signal */
  37. #define    PIOCKILL    (PIOC|8)    /* send signal */
  38. #define    PIOCUNKILL    (PIOC|9)    /* delete a signal */
  39. #define    PIOCGHOLD    (PIOC|10)    /* get held signal set */
  40. #define    PIOCSHOLD    (PIOC|11)    /* set held signal set */
  41. #define    PIOCMAXSIG    (PIOC|12)    /* get max signal number */
  42. #define    PIOCACTION    (PIOC|13)    /* get signal action structs */
  43. #define    PIOCGFAULT    (PIOC|14)    /* get traced fault set */
  44. #define    PIOCSFAULT    (PIOC|15)    /* set traced fault set */
  45. #define    PIOCCFAULT    (PIOC|16)    /* clear current fault */
  46. #define    PIOCGENTRY    (PIOC|17)    /* get syscall entry set */
  47. #define    PIOCSENTRY    (PIOC|18)    /* set syscall entry set */
  48. #define    PIOCGEXIT    (PIOC|19)    /* get syscall exit set */
  49. #define    PIOCSEXIT    (PIOC|20)    /* set syscall exit set */
  50. #define    PIOCSFORK    (PIOC|21)    /* set inherit-on-fork flag */
  51. #define    PIOCRFORK    (PIOC|22)    /* reset inherit-on-fork flag */
  52. #define    PIOCSRLC    (PIOC|23)    /* set run-on-last-close flag */
  53. #define    PIOCRRLC    (PIOC|24)    /* reset run-on-last-close flag */
  54. #define    PIOCGREG    (PIOC|25)    /* get general registers */
  55. #define    PIOCSREG    (PIOC|26)    /* set general registers */
  56. #define    PIOCGFPREG    (PIOC|27)    /* get floating-point registers */
  57. #define    PIOCSFPREG    (PIOC|28)    /* set floating-point registers */
  58. #define    PIOCNICE    (PIOC|29)    /* set nice priority */
  59. #define    PIOCPSINFO    (PIOC|30)    /* get ps(1) information */
  60. #define    PIOCNMAP    (PIOC|31)    /* get number of memory mappings */
  61. #define    PIOCMAP        (PIOC|32)    /* get memory map information */
  62. #define    PIOCOPENM    (PIOC|33)    /* open mapped object for reading */
  63. #define    PIOCCRED    (PIOC|34)    /* get process credentials */
  64. #define    PIOCGROUPS    (PIOC|35)    /* get supplementary groups */
  65. #define    PIOCGETPR    (PIOC|36)    /* read struct proc */
  66. #define    PIOCGETU    (PIOC|37)    /* read user area */
  67. #define    PIOCGDBREG    (PIOC|40)    /* get debug registers */
  68. #define    PIOCSDBREG    (PIOC|41)    /* set debug registers */
  69.  
  70. /* Holds one 3B2 instruction op code */
  71.  
  72. typedef    char    instr_t;
  73.  
  74. /* Process status structure */
  75.  
  76. typedef struct prstatus {
  77.     long    pr_flags;    /* Process flags */
  78.     short    pr_why;        /* Reason for process stop (if stopped) */
  79.     short    pr_what;    /* More detailed reason */
  80.     siginfo_t pr_info;    /* Info associated with signal or fault */
  81.     short    pr_cursig;    /* Current signal */
  82.     short    pr_pad;        /* pad to long boundary */
  83.     sigset_t pr_sigpend;    /* Set of other pending signals */
  84.     sigset_t pr_sighold;    /* Set of of held signals */
  85.     struct    sigaltstack pr_altstack; /* Alternate signal stack info */
  86.     struct    sigaction pr_action; /* Signal action for current signal */
  87.     pid_t    pr_pid;        /* Process id */
  88.     pid_t    pr_ppid;    /* Parent process id */
  89.     pid_t    pr_pgrp;    /* Process group id */
  90.     pid_t    pr_sid;        /* Session id */
  91.     timestruc_t pr_utime;    /* Process user cpu time */
  92.     timestruc_t pr_stime;    /* Process system cpu time */
  93.     timestruc_t pr_cutime;    /* Sum of children's user times */
  94.     timestruc_t pr_cstime;    /* Sum of children's system times */
  95.     char    pr_clname[8];    /* Scheduling class name */
  96.     long    pr_filler[20];    /* Filler area for future expansion */
  97.     long    pr_instr;    /* Current instruction */
  98.     gregset_t pr_reg;    /* General registers */
  99. } prstatus_t;
  100.  
  101. /* Process status flags */
  102.  
  103. #define    PR_STOPPED    0x0001    /* Process is stopped */
  104. #define    PR_ISTOP    0x0002    /* Process stopped on an event of interest */
  105. #define    PR_DSTOP    0x0004    /* A stop directive is in effect */
  106. #define    PR_ASLEEP    0x0008    /* Process is sleep()ing in a system call */
  107. #define    PR_FORK        0x0010    /* Inherit-on-fork is in effect */
  108. #define    PR_RLC        0x0020    /* Run-on-last-close is in effect */
  109. #define    PR_PTRACE    0x0040    /* Process is being controlled by ptrace(2) */
  110. #define    PR_PCINVAL    0x0080    /* %pc refers to an invalid virtual address */
  111. #define    PR_ISSYS    0x0100    /* System process */
  112.  
  113. /* Reasons for stopping */
  114.  
  115. #define    PR_REQUESTED    1
  116. #define    PR_SIGNALLED    2
  117. #define    PR_SYSENTRY    3
  118. #define    PR_SYSEXIT    4
  119. #define    PR_JOBCONTROL    5
  120. #define    PR_FAULTED    6
  121.  
  122. /* Information for the ps(1) command */
  123.  
  124. #define    PRARGSZ        80        /* Number of chars of arguments */
  125.  
  126. typedef struct prpsinfo {
  127.     char    pr_state;    /* numeric process state (see pr_sname) */
  128.     char    pr_sname;    /* printable character representing pr_state */
  129.     char    pr_zomb;    /* !=0: process terminated but not waited for */
  130.     char    pr_nice;    /* nice for cpu usage */
  131.     u_long    pr_flag;    /* process flags */
  132.     uid_t    pr_uid;        /* real user id */
  133.     gid_t    pr_gid;        /* real group id */
  134.     pid_t    pr_pid;        /* unique process id */
  135.     pid_t    pr_ppid;    /* process id of parent */
  136.     pid_t    pr_pgrp;    /* pid of process group leader */
  137.     pid_t    pr_sid;        /* session id */
  138.     caddr_t    pr_addr;    /* physical address of process */
  139.     long    pr_size;    /* size of process image in pages */
  140.     long    pr_rssize;    /* resident set size in pages */
  141.     caddr_t    pr_wchan;    /* wait addr for sleeping process */
  142.     timestruc_t pr_start;    /* process start time, sec+nsec since epoch */
  143.     timestruc_t pr_time;    /* usr+sys cpu time for this process */
  144.     long    pr_pri;        /* priority, high value is high priority */
  145.     char    pr_oldpri;    /* pre-SVR4, low value is high priority */
  146.     char    pr_cpu;        /* pre-SVR4, cpu usage for scheduling */
  147.     o_dev_t    pr_ottydev;    /* short tty device number */
  148.     dev_t    pr_lttydev;    /* controlling tty device (PRNODEV if none) */
  149.     char    pr_clname[8];    /* Scheduling class name */
  150.     char    pr_fname[16];    /* last component of exec()ed pathname */
  151.     char    pr_psargs[PRARGSZ];    /* initial characters of arg list */
  152.     long    pr_filler[20];    /* for future expansion */
  153. } prpsinfo_t;
  154.  
  155. #if !defined(_STYPES)
  156. #define    pr_ttydev    pr_lttydev
  157. #else
  158. #define    pr_ttydev    pr_ottydev
  159. #endif    
  160.  
  161. #define    PRNODEV    (dev_t)(-1)    /* non-existent device */
  162.  
  163. /* Optional actions to take when process continues */
  164.  
  165. typedef struct prrun {
  166.     long    pr_flags;    /* Flags */
  167.     sigset_t pr_trace;    /* Set of signals to be traced */
  168.     sigset_t pr_sighold;    /* Set of signals to be held */
  169.     fltset_t pr_fault;    /* Set of faults to be traced */
  170.     caddr_t    pr_vaddr;    /* Virtual address at which to resume */
  171.     long    pr_filler[8];    /* Filler area for future expansion */
  172. } prrun_t;
  173.  
  174. #define    PRCSIG        0x001    /* Clear current signal */
  175. #define    PRCFAULT    0x002    /* Clear current fault */
  176. #define    PRSTRACE    0x004    /* Use traced-signal set in pr_trace */
  177. #define    PRSHOLD        0x008    /* Use held-signal set in pr_sighold */
  178. #define    PRSFAULT    0x010    /* Use traced-fault set in pr_fault */
  179. #define    PRSVADDR    0x020    /* Resume at virtual address in pr_vaddr */
  180. #define    PRSTEP        0x040    /* Single-step the process */
  181. #define    PRSABORT    0x080    /* Abort syscall */
  182. #define    PRSTOP        0x100    /* Set directed stop request */
  183.  
  184. /* Memory-management interface */
  185.  
  186. typedef struct prmap {
  187.     caddr_t        pr_vaddr;    /* Virtual address base */
  188.     u_long        pr_size;    /* Size of mapping in bytes */
  189.     off_t        pr_off;        /* Offset into mapped object, if any */
  190.     long        pr_mflags;    /* Protection and attribute flags */
  191.     long        pr_filler[4];    /* Filler for future expansion */
  192. } prmap_t;
  193.  
  194. /* Protection and attribute flags */
  195.  
  196. #define    MA_READ        0x04    /* Readable by the traced process */
  197. #define    MA_WRITE    0x02    /* Writable by the traced process */
  198. #define    MA_EXEC        0x01    /* Executable by the traced process */
  199. #define    MA_SHARED    0x08    /* Changes are shared by mapped object */
  200. #define    MA_BREAK    0x10    /* Grown by brk(2) */
  201. #define    MA_STACK    0x20    /* Grown automatically on stack faults */
  202.  
  203. /* Process credentials */
  204.  
  205. typedef struct prcred {
  206.     uid_t    pr_euid;    /* Effective user id */
  207.     uid_t    pr_ruid;    /* Real user id */
  208.     uid_t    pr_suid;    /* Saved user id (from exec) */
  209.     gid_t    pr_egid;    /* Effective group id */
  210.     gid_t    pr_rgid;    /* Real group id */
  211.     gid_t    pr_sgid;    /* Saved group id (from exec) */
  212.     u_int    pr_ngroups;    /* Number of supplementary groups */
  213. } prcred_t;
  214.  
  215. /*
  216.  * Macros for manipulating sets of flags.
  217.  * sp must be a pointer to one of sigset_t, fltset_t, or sysset_t.
  218.  * flag must be a member of the enumeration corresponding to *sp.
  219.  */
  220.  
  221. /* turn on all flags in set */
  222. #define    prfillset(sp) \
  223.     { register int _i_ = sizeof(*(sp))/sizeof(u_long); \
  224.         while(_i_) ((u_long*)(sp))[--_i_] = 0xFFFFFFFF; }
  225.  
  226. /* turn off all flags in set */
  227. #define    premptyset(sp) \
  228.     { register int _i_ = sizeof(*(sp))/sizeof(u_long); \
  229.         while(_i_) ((u_long*)(sp))[--_i_] = 0L; }
  230.  
  231. /* turn on specified flag in set */
  232. #define    praddset(sp, flag) \
  233.     (((unsigned)((flag)-1) < 32*sizeof(*(sp))/sizeof(u_long)) ? \
  234.     (((u_long*)(sp))[((flag)-1)/32] |= (1L<<(((flag)-1)%32))) : 0)
  235.  
  236. /* turn off specified flag in set */
  237. #define    prdelset(sp, flag) \
  238.     (((unsigned)((flag)-1) < 32*sizeof(*(sp))/sizeof(u_long)) ? \
  239.     (((u_long*)(sp))[((flag)-1)/32] &= ~(1L<<(((flag)-1)%32))) : 0)
  240.  
  241. /* query: != 0 iff flag is turned on in set */
  242. #define    prismember(sp, flag) \
  243.     (((unsigned)((flag)-1) < 32*sizeof(*(sp))/sizeof(u_long)) \
  244.     && (((u_long*)(sp))[((flag)-1)/32] & (1L<<(((flag)-1)%32))))
  245.  
  246.  
  247. #endif    /* _SYS_PROCFS_H */
  248.