Print this page
OS-4277 lx procfs /proc/{pid}/environ always empty
OS-3463 expose process argv through procfs
OS-3207 in lx zone, 'ps auxww' does not show full cmdline for processes
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>


  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  27 /*        All Rights Reserved   */
  28 
  29 /*
  30  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
  31  */
  32 
  33 #ifndef _SYS_PROC_PRDATA_H
  34 #define _SYS_PROC_PRDATA_H
  35 
  36 #include <sys/isa_defs.h>
  37 #include <sys/proc.h>
  38 #include <sys/vnode.h>
  39 #include <sys/prsystm.h>
  40 #include <sys/model.h>
  41 #include <sys/poll.h>
  42 #include <sys/list.h>
  43 
  44 #ifdef  __cplusplus
  45 extern "C" {
  46 #endif
  47 
  48 /*
  49  * Test for thread being stopped, not on an event of interest,
  50  * but with a directed stop in effect.


 106  */
 107 typedef enum prnodetype {
 108         PR_PROCDIR,             /* /proc                                */
 109         PR_SELF,                /* /proc/self                           */
 110         PR_PIDDIR,              /* /proc/<pid>                            */
 111         PR_AS,                  /* /proc/<pid>/as                 */
 112         PR_CTL,                 /* /proc/<pid>/ctl                        */
 113         PR_STATUS,              /* /proc/<pid>/status                     */
 114         PR_LSTATUS,             /* /proc/<pid>/lstatus                    */
 115         PR_PSINFO,              /* /proc/<pid>/psinfo                     */
 116         PR_LPSINFO,             /* /proc/<pid>/lpsinfo                    */
 117         PR_MAP,                 /* /proc/<pid>/map                        */
 118         PR_RMAP,                /* /proc/<pid>/rmap                       */
 119         PR_XMAP,                /* /proc/<pid>/xmap                       */
 120         PR_CRED,                /* /proc/<pid>/cred                       */
 121         PR_SIGACT,              /* /proc/<pid>/sigact                     */
 122         PR_AUXV,                /* /proc/<pid>/auxv                       */
 123 #if defined(__i386) || defined(__amd64)
 124         PR_LDT,                 /* /proc/<pid>/ldt                        */
 125 #endif

 126         PR_USAGE,               /* /proc/<pid>/usage                      */
 127         PR_LUSAGE,              /* /proc/<pid>/lusage                     */
 128         PR_PAGEDATA,            /* /proc/<pid>/pagedata                   */
 129         PR_WATCH,               /* /proc/<pid>/watch                      */
 130         PR_CURDIR,              /* /proc/<pid>/cwd                        */
 131         PR_ROOTDIR,             /* /proc/<pid>/root                       */
 132         PR_FDDIR,               /* /proc/<pid>/fd                 */
 133         PR_FD,                  /* /proc/<pid>/fd/nn                      */
 134         PR_OBJECTDIR,           /* /proc/<pid>/object                     */
 135         PR_OBJECT,              /* /proc/<pid>/object/xxx         */
 136         PR_LWPDIR,              /* /proc/<pid>/lwp                        */
 137         PR_LWPIDDIR,            /* /proc/<pid>/lwp/<lwpid>          */
 138         PR_LWPCTL,              /* /proc/<pid>/lwp/<lwpid>/lwpctl   */
 139         PR_LWPSTATUS,           /* /proc/<pid>/lwp/<lwpid>/lwpstatus        */
 140         PR_LWPSINFO,            /* /proc/<pid>/lwp/<lwpid>/lwpsinfo */
 141         PR_LWPUSAGE,            /* /proc/<pid>/lwp/<lwpid>/lwpusage */
 142         PR_XREGS,               /* /proc/<pid>/lwp/<lwpid>/xregs    */
 143         PR_TMPLDIR,             /* /proc/<pid>/lwp/<lwpid>/templates        */
 144         PR_TMPL,                /* /proc/<pid>/lwp/<lwpid>/templates/<id> */
 145         PR_SPYMASTER,           /* /proc/<pid>/lwp/<lwpid>/spymaster        */


 330 #endif  /* _SYSCALL32_IMPL */
 331 #endif /* !_SYS_OLD_PROCFS_H */
 332 
 333 extern  proc_t  *pr_p_lock(prnode_t *);
 334 extern  kthread_t *pr_thread(prnode_t *);
 335 extern  void    pr_stop(prnode_t *);
 336 extern  int     pr_wait_stop(prnode_t *, time_t);
 337 extern  int     pr_setrun(prnode_t *, ulong_t);
 338 extern  int     pr_wait(prcommon_t *, timestruc_t *, int);
 339 extern  void    pr_wait_die(prnode_t *);
 340 extern  int     pr_setsig(prnode_t *, siginfo_t *);
 341 extern  int     pr_kill(prnode_t *, int, cred_t *);
 342 extern  int     pr_unkill(prnode_t *, int);
 343 extern  int     pr_nice(proc_t *, int, cred_t *);
 344 extern  void    pr_setentryexit(proc_t *, sysset_t *, int);
 345 extern  int     pr_set(proc_t *, long);
 346 extern  int     pr_unset(proc_t *, long);
 347 extern  void    pr_sethold(prnode_t *, sigset_t *);
 348 extern  void    pr_setfault(proc_t *, fltset_t *);
 349 extern  int     prusrio(proc_t *, enum uio_rw, struct uio *, int);


 350 extern  int     prwritectl(vnode_t *, struct uio *, cred_t *);
 351 extern  int     prlock(prnode_t *, int);
 352 extern  void    prunmark(proc_t *);
 353 extern  void    prunlock(prnode_t *);
 354 extern  size_t  prpdsize(struct as *);
 355 extern  int     prpdread(proc_t *, uint_t, struct uio *);
 356 extern  size_t  oprpdsize(struct as *);
 357 extern  int     oprpdread(struct as *, uint_t, struct uio *);
 358 extern  void    prgetaction(proc_t *, user_t *, uint_t, struct sigaction *);
 359 extern  void    prgetusage(kthread_t *, struct prhusage *);
 360 extern  void    praddusage(kthread_t *, struct prhusage *);
 361 extern  void    prcvtusage(struct prhusage *, prusage_t *);
 362 extern  void    prscaleusage(prhusage_t *);
 363 extern  kthread_t *prchoose(proc_t *);
 364 extern  void    allsetrun(proc_t *);
 365 extern  int     setisempty(uint32_t *, uint_t);
 366 extern  int     pr_u32tos(uint32_t, char *, int);
 367 extern  vnode_t *prlwpnode(prnode_t *, uint_t);
 368 extern  prnode_t *prgetnode(vnode_t *, prnodetype_t);
 369 extern  void    prfreenode(prnode_t *);




  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  27 /*        All Rights Reserved   */
  28 
  29 /*
  30  * Copyright 2015, Joyent, Inc.
  31  */
  32 
  33 #ifndef _SYS_PROC_PRDATA_H
  34 #define _SYS_PROC_PRDATA_H
  35 
  36 #include <sys/isa_defs.h>
  37 #include <sys/proc.h>
  38 #include <sys/vnode.h>
  39 #include <sys/prsystm.h>
  40 #include <sys/model.h>
  41 #include <sys/poll.h>
  42 #include <sys/list.h>
  43 
  44 #ifdef  __cplusplus
  45 extern "C" {
  46 #endif
  47 
  48 /*
  49  * Test for thread being stopped, not on an event of interest,
  50  * but with a directed stop in effect.


 106  */
 107 typedef enum prnodetype {
 108         PR_PROCDIR,             /* /proc                                */
 109         PR_SELF,                /* /proc/self                           */
 110         PR_PIDDIR,              /* /proc/<pid>                            */
 111         PR_AS,                  /* /proc/<pid>/as                 */
 112         PR_CTL,                 /* /proc/<pid>/ctl                        */
 113         PR_STATUS,              /* /proc/<pid>/status                     */
 114         PR_LSTATUS,             /* /proc/<pid>/lstatus                    */
 115         PR_PSINFO,              /* /proc/<pid>/psinfo                     */
 116         PR_LPSINFO,             /* /proc/<pid>/lpsinfo                    */
 117         PR_MAP,                 /* /proc/<pid>/map                        */
 118         PR_RMAP,                /* /proc/<pid>/rmap                       */
 119         PR_XMAP,                /* /proc/<pid>/xmap                       */
 120         PR_CRED,                /* /proc/<pid>/cred                       */
 121         PR_SIGACT,              /* /proc/<pid>/sigact                     */
 122         PR_AUXV,                /* /proc/<pid>/auxv                       */
 123 #if defined(__i386) || defined(__amd64)
 124         PR_LDT,                 /* /proc/<pid>/ldt                        */
 125 #endif
 126         PR_ARGV,                /* /proc/<pid>/argv                       */
 127         PR_USAGE,               /* /proc/<pid>/usage                      */
 128         PR_LUSAGE,              /* /proc/<pid>/lusage                     */
 129         PR_PAGEDATA,            /* /proc/<pid>/pagedata                   */
 130         PR_WATCH,               /* /proc/<pid>/watch                      */
 131         PR_CURDIR,              /* /proc/<pid>/cwd                        */
 132         PR_ROOTDIR,             /* /proc/<pid>/root                       */
 133         PR_FDDIR,               /* /proc/<pid>/fd                 */
 134         PR_FD,                  /* /proc/<pid>/fd/nn                      */
 135         PR_OBJECTDIR,           /* /proc/<pid>/object                     */
 136         PR_OBJECT,              /* /proc/<pid>/object/xxx         */
 137         PR_LWPDIR,              /* /proc/<pid>/lwp                        */
 138         PR_LWPIDDIR,            /* /proc/<pid>/lwp/<lwpid>          */
 139         PR_LWPCTL,              /* /proc/<pid>/lwp/<lwpid>/lwpctl   */
 140         PR_LWPSTATUS,           /* /proc/<pid>/lwp/<lwpid>/lwpstatus        */
 141         PR_LWPSINFO,            /* /proc/<pid>/lwp/<lwpid>/lwpsinfo */
 142         PR_LWPUSAGE,            /* /proc/<pid>/lwp/<lwpid>/lwpusage */
 143         PR_XREGS,               /* /proc/<pid>/lwp/<lwpid>/xregs    */
 144         PR_TMPLDIR,             /* /proc/<pid>/lwp/<lwpid>/templates        */
 145         PR_TMPL,                /* /proc/<pid>/lwp/<lwpid>/templates/<id> */
 146         PR_SPYMASTER,           /* /proc/<pid>/lwp/<lwpid>/spymaster        */


 331 #endif  /* _SYSCALL32_IMPL */
 332 #endif /* !_SYS_OLD_PROCFS_H */
 333 
 334 extern  proc_t  *pr_p_lock(prnode_t *);
 335 extern  kthread_t *pr_thread(prnode_t *);
 336 extern  void    pr_stop(prnode_t *);
 337 extern  int     pr_wait_stop(prnode_t *, time_t);
 338 extern  int     pr_setrun(prnode_t *, ulong_t);
 339 extern  int     pr_wait(prcommon_t *, timestruc_t *, int);
 340 extern  void    pr_wait_die(prnode_t *);
 341 extern  int     pr_setsig(prnode_t *, siginfo_t *);
 342 extern  int     pr_kill(prnode_t *, int, cred_t *);
 343 extern  int     pr_unkill(prnode_t *, int);
 344 extern  int     pr_nice(proc_t *, int, cred_t *);
 345 extern  void    pr_setentryexit(proc_t *, sysset_t *, int);
 346 extern  int     pr_set(proc_t *, long);
 347 extern  int     pr_unset(proc_t *, long);
 348 extern  void    pr_sethold(prnode_t *, sigset_t *);
 349 extern  void    pr_setfault(proc_t *, fltset_t *);
 350 extern  int     prusrio(proc_t *, enum uio_rw, struct uio *, int);
 351 extern  int     prreadargv(proc_t *, char *, size_t, size_t *);
 352 extern  int     prreadenvv(proc_t *, char *, size_t, size_t *);
 353 extern  int     prwritectl(vnode_t *, struct uio *, cred_t *);
 354 extern  int     prlock(prnode_t *, int);
 355 extern  void    prunmark(proc_t *);
 356 extern  void    prunlock(prnode_t *);
 357 extern  size_t  prpdsize(struct as *);
 358 extern  int     prpdread(proc_t *, uint_t, struct uio *);
 359 extern  size_t  oprpdsize(struct as *);
 360 extern  int     oprpdread(struct as *, uint_t, struct uio *);
 361 extern  void    prgetaction(proc_t *, user_t *, uint_t, struct sigaction *);
 362 extern  void    prgetusage(kthread_t *, struct prhusage *);
 363 extern  void    praddusage(kthread_t *, struct prhusage *);
 364 extern  void    prcvtusage(struct prhusage *, prusage_t *);
 365 extern  void    prscaleusage(prhusage_t *);
 366 extern  kthread_t *prchoose(proc_t *);
 367 extern  void    allsetrun(proc_t *);
 368 extern  int     setisempty(uint32_t *, uint_t);
 369 extern  int     pr_u32tos(uint32_t, char *, int);
 370 extern  vnode_t *prlwpnode(prnode_t *, uint_t);
 371 extern  prnode_t *prgetnode(vnode_t *, prnodetype_t);
 372 extern  void    prfreenode(prnode_t *);