Print this page
12046 Provide /proc/<PID>/fdinfo/


  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 2018 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.


 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_LWPNAME,             /* /proc/<pid>/lwp/<lwpid>/lwpname  */
 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        */
 147 #if defined(__sparc)
 148         PR_GWINDOWS,            /* /proc/<pid>/lwp/<lwpid>/gwindows */
 149         PR_ASRS,                /* /proc/<pid>/lwp/<lwpid>/asrs             */
 150 #endif
 151         PR_PRIV,                /* /proc/<pid>/priv                       */
 152         PR_PATHDIR,             /* /proc/<pid>/path                       */
 153         PR_PATH,                /* /proc/<pid>/path/xxx                   */


 271 extern  int     prnwatch;       /* number of supported watchpoints */
 272 extern  int     nproc_highbit;  /* highbit(v.v_nproc) */
 273 
 274 extern  struct vnodeops *prvnodeops;
 275 
 276 /*
 277  * Generic chained copyout buffers for procfs use.
 278  * In order to prevent procfs from making huge oversize kmem_alloc calls,
 279  * a list of smaller buffers can be concatenated and copied to userspace in
 280  * sequence.
 281  *
 282  * The implementation is opaque.
 283  *
 284  * A user of this will perform the following steps:
 285  *
 286  *      list_t  listhead;
 287  *      struct my *mp;
 288  *
 289  *      pr_iol_initlist(&listhead, sizeof (*mp), n);
 290  *      while (whatever) {
 291  *              mp = pr_iol_newbuf(&listhead, sizeof (*mp);
 292  *              ...
 293  *              error = ...
 294  *      }
 295  *
 296  * When done, depending on whether copyout() or uiomove() is supposed to
 297  * be used for transferring the buffered data to userspace, call either:
 298  *
 299  *      error = pr_iol_copyout_and_free(&listhead, &cmaddr, error);
 300  *
 301  * or else:
 302  *
 303  *      error = pr_iol_uiomove_and_free(&listhead, uiop, error);
 304  *
 305  * These two functions will in any case kmem_free() all list items, but
 306  * if an error occurred before they will not perform the copyout/uiomove.
 307  * If copyout/uiomove are done, the passed target address / uio_t
 308  * are updated. The error returned will either be the one passed in, or
 309  * the error that occurred during copyout/uiomove.
 310  */
 311 
 312 extern  void    pr_iol_initlist(list_t *head, size_t itemsize, int nitems);
 313 extern  void *  pr_iol_newbuf(list_t *head, size_t itemsize);
 314 extern  int     pr_iol_copyout_and_free(list_t *head, caddr_t *tgt, int errin);
 315 extern  int     pr_iol_uiomove_and_free(list_t *head, uio_t *uiop, int errin);

 316 
 317 #if defined(_SYSCALL32_IMPL)
 318 
 319 extern  int     prwritectl32(vnode_t *, struct uio *, cred_t *);
 320 extern  void    prgetaction32(proc_t *, user_t *, uint_t, struct sigaction32 *);
 321 extern  void    prcvtusage32(struct prhusage *, prusage32_t *);
 322 
 323 #endif  /* _SYSCALL32_IMPL */
 324 
 325 /* kludge to support old /proc interface */
 326 #if !defined(_SYS_OLD_PROCFS_H)
 327 extern  int     prgetmap(proc_t *, int, list_t *);
 328 extern  int     prgetxmap(proc_t *, list_t *);
 329 #if defined(_SYSCALL32_IMPL)
 330 extern  int     prgetmap32(proc_t *, int, list_t *);
 331 extern  int     prgetxmap32(proc_t *, list_t *);
 332 #endif  /* _SYSCALL32_IMPL */
 333 #endif /* !_SYS_OLD_PROCFS_H */
 334 
 335 extern  proc_t  *pr_p_lock(prnode_t *);
 336 extern  kthread_t *pr_thread(prnode_t *);
 337 extern  void    pr_stop(prnode_t *);
 338 extern  int     pr_wait_stop(prnode_t *, time_t);
 339 extern  int     pr_setrun(prnode_t *, ulong_t);
 340 extern  int     pr_wait(prcommon_t *, timestruc_t *, int);
 341 extern  void    pr_wait_die(prnode_t *);
 342 extern  int     pr_setsig(prnode_t *, siginfo_t *);
 343 extern  int     pr_kill(prnode_t *, int, cred_t *);
 344 extern  int     pr_unkill(prnode_t *, int);
 345 extern  int     pr_nice(proc_t *, int, cred_t *);
 346 extern  void    pr_setentryexit(proc_t *, sysset_t *, int);
 347 extern  int     pr_set(proc_t *, long);
 348 extern  int     pr_unset(proc_t *, long);
 349 extern  void    pr_sethold(prnode_t *, sigset_t *);


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




  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 2018 Joyent, Inc.
  31  * Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
  32  */
  33 
  34 #ifndef _SYS_PROC_PRDATA_H
  35 #define _SYS_PROC_PRDATA_H
  36 
  37 #include <sys/isa_defs.h>
  38 #include <sys/proc.h>
  39 #include <sys/vnode.h>
  40 #include <sys/prsystm.h>
  41 #include <sys/model.h>
  42 #include <sys/poll.h>
  43 #include <sys/list.h>
  44 
  45 #ifdef  __cplusplus
  46 extern "C" {
  47 #endif
  48 
  49 /*
  50  * Test for thread being stopped, not on an event of interest,
  51  * but with a directed stop in effect.


 115         PR_LSTATUS,             /* /proc/<pid>/lstatus                    */
 116         PR_PSINFO,              /* /proc/<pid>/psinfo                     */
 117         PR_LPSINFO,             /* /proc/<pid>/lpsinfo                    */
 118         PR_MAP,                 /* /proc/<pid>/map                        */
 119         PR_RMAP,                /* /proc/<pid>/rmap                       */
 120         PR_XMAP,                /* /proc/<pid>/xmap                       */
 121         PR_CRED,                /* /proc/<pid>/cred                       */
 122         PR_SIGACT,              /* /proc/<pid>/sigact                     */
 123         PR_AUXV,                /* /proc/<pid>/auxv                       */
 124 #if defined(__i386) || defined(__amd64)
 125         PR_LDT,                 /* /proc/<pid>/ldt                        */
 126 #endif
 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_FDINFODIR,           /* /proc/<pid>/fdinfo                     */
 136         PR_FDINFO,              /* /proc/<pid>/fdinfo/nn          */
 137         PR_OBJECTDIR,           /* /proc/<pid>/object                     */
 138         PR_OBJECT,              /* /proc/<pid>/object/xxx         */
 139         PR_LWPDIR,              /* /proc/<pid>/lwp                        */
 140         PR_LWPIDDIR,            /* /proc/<pid>/lwp/<lwpid>          */
 141         PR_LWPCTL,              /* /proc/<pid>/lwp/<lwpid>/lwpctl   */
 142         PR_LWPNAME,             /* /proc/<pid>/lwp/<lwpid>/lwpname  */
 143         PR_LWPSTATUS,           /* /proc/<pid>/lwp/<lwpid>/lwpstatus        */
 144         PR_LWPSINFO,            /* /proc/<pid>/lwp/<lwpid>/lwpsinfo */
 145         PR_LWPUSAGE,            /* /proc/<pid>/lwp/<lwpid>/lwpusage */
 146         PR_XREGS,               /* /proc/<pid>/lwp/<lwpid>/xregs    */
 147         PR_TMPLDIR,             /* /proc/<pid>/lwp/<lwpid>/templates        */
 148         PR_TMPL,                /* /proc/<pid>/lwp/<lwpid>/templates/<id> */
 149         PR_SPYMASTER,           /* /proc/<pid>/lwp/<lwpid>/spymaster        */
 150 #if defined(__sparc)
 151         PR_GWINDOWS,            /* /proc/<pid>/lwp/<lwpid>/gwindows */
 152         PR_ASRS,                /* /proc/<pid>/lwp/<lwpid>/asrs             */
 153 #endif
 154         PR_PRIV,                /* /proc/<pid>/priv                       */
 155         PR_PATHDIR,             /* /proc/<pid>/path                       */
 156         PR_PATH,                /* /proc/<pid>/path/xxx                   */


 274 extern  int     prnwatch;       /* number of supported watchpoints */
 275 extern  int     nproc_highbit;  /* highbit(v.v_nproc) */
 276 
 277 extern  struct vnodeops *prvnodeops;
 278 
 279 /*
 280  * Generic chained copyout buffers for procfs use.
 281  * In order to prevent procfs from making huge oversize kmem_alloc calls,
 282  * a list of smaller buffers can be concatenated and copied to userspace in
 283  * sequence.
 284  *
 285  * The implementation is opaque.
 286  *
 287  * A user of this will perform the following steps:
 288  *
 289  *      list_t  listhead;
 290  *      struct my *mp;
 291  *
 292  *      pr_iol_initlist(&listhead, sizeof (*mp), n);
 293  *      while (whatever) {
 294  *              mp = pr_iol_newbuf(&listhead, sizeof (*mp));
 295  *              ...
 296  *              error = ...
 297  *      }
 298  *
 299  * When done, depending on whether copyout() or uiomove() is supposed to
 300  * be used for transferring the buffered data to userspace, call either:
 301  *
 302  *      error = pr_iol_copyout_and_free(&listhead, &cmaddr, error);
 303  *
 304  * or else:
 305  *
 306  *      error = pr_iol_uiomove_and_free(&listhead, uiop, error);
 307  *
 308  * These two functions will in any case kmem_free() all list items, but
 309  * if an error occurred before they will not perform the copyout/uiomove.
 310  * If copyout/uiomove are done, the passed target address / uio_t
 311  * are updated. The error returned will either be the one passed in, or
 312  * the error that occurred during copyout/uiomove.
 313  */
 314 
 315 extern  void    pr_iol_initlist(list_t *head, size_t itemsize, int nitems);
 316 extern  void *  pr_iol_newbuf(list_t *head, size_t itemsize);
 317 extern  int     pr_iol_copyout_and_free(list_t *head, caddr_t *tgt, int errin);
 318 extern  int     pr_iol_uiomove_and_free(list_t *head, uio_t *uiop, int errin);
 319 extern  void    pr_iol_freelist(list_t *);
 320 
 321 #if defined(_SYSCALL32_IMPL)
 322 
 323 extern  int     prwritectl32(vnode_t *, struct uio *, cred_t *);
 324 extern  void    prgetaction32(proc_t *, user_t *, uint_t, struct sigaction32 *);
 325 extern  void    prcvtusage32(struct prhusage *, prusage32_t *);
 326 
 327 #endif  /* _SYSCALL32_IMPL */
 328 
 329 /* kludge to support old /proc interface */
 330 #if !defined(_SYS_OLD_PROCFS_H)
 331 extern  int     prgetmap(proc_t *, int, list_t *);
 332 extern  int     prgetxmap(proc_t *, list_t *);
 333 #if defined(_SYSCALL32_IMPL)
 334 extern  int     prgetmap32(proc_t *, int, list_t *);
 335 extern  int     prgetxmap32(proc_t *, list_t *);
 336 #endif  /* _SYSCALL32_IMPL */
 337 #endif /* !_SYS_OLD_PROCFS_H */
 338 
 339 extern  proc_t  *pr_p_lock(prnode_t *);
 340 extern  kthread_t *pr_thread(prnode_t *);
 341 extern  void    pr_stop(prnode_t *);
 342 extern  int     pr_wait_stop(prnode_t *, time_t);
 343 extern  int     pr_setrun(prnode_t *, ulong_t);
 344 extern  int     pr_wait(prcommon_t *, timestruc_t *, int);
 345 extern  void    pr_wait_die(prnode_t *);
 346 extern  int     pr_setsig(prnode_t *, siginfo_t *);
 347 extern  int     pr_kill(prnode_t *, int, cred_t *);
 348 extern  int     pr_unkill(prnode_t *, int);
 349 extern  int     pr_nice(proc_t *, int, cred_t *);
 350 extern  void    pr_setentryexit(proc_t *, sysset_t *, int);
 351 extern  int     pr_set(proc_t *, long);
 352 extern  int     pr_unset(proc_t *, long);
 353 extern  void    pr_sethold(prnode_t *, sigset_t *);
 354 extern  file_t  *pr_getf(proc_t *, uint_t, short *);
 355 extern  void    pr_releasef(proc_t *, uint_t);
 356 extern  void    pr_setfault(proc_t *, fltset_t *);
 357 extern  int     prusrio(proc_t *, enum uio_rw, struct uio *, int);
 358 extern  int     prwritectl(vnode_t *, struct uio *, cred_t *);
 359 extern  int     prlock(prnode_t *, int);
 360 extern  void    prunmark(proc_t *);
 361 extern  void    prunlock(prnode_t *);
 362 extern  size_t  prpdsize(struct as *);
 363 extern  int     prpdread(proc_t *, uint_t, struct uio *);
 364 extern  size_t  oprpdsize(struct as *);
 365 extern  int     oprpdread(struct as *, uint_t, struct uio *);
 366 extern  void    prgetaction(proc_t *, user_t *, uint_t, struct sigaction *);
 367 extern  void    prgetusage(kthread_t *, struct prhusage *);
 368 extern  void    praddusage(kthread_t *, struct prhusage *);
 369 extern  void    prcvtusage(struct prhusage *, prusage_t *);
 370 extern  void    prscaleusage(prhusage_t *);
 371 extern  kthread_t *prchoose(proc_t *);
 372 extern  void    allsetrun(proc_t *);
 373 extern  int     setisempty(uint32_t *, uint_t);
 374 extern  int     pr_u32tos(uint32_t, char *, int);
 375 extern  vnode_t *prlwpnode(prnode_t *, uint_t);