prdata.h revision d1b18d1a1255ac607d5e072515d727cdfe52f878
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
*/
#ifndef _SYS_PROC_PRDATA_H
#define _SYS_PROC_PRDATA_H
#include <sys/isa_defs.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Test for thread being stopped, not on an event of interest,
* but with a directed stop in effect.
*/
#define DSTOPPED(t) \
((t)->t_state == TS_STOPPED && \
((t)->t_proc_flag & TP_PRSTOP))
/*
* Common file object to which all /proc vnodes for a specific process
* or lwp refer. One for the process, one for each lwp.
*/
typedef struct prcommon {
int prc_slot; /* procdir slot number */
int prc_tslot; /* lwpdir slot number, -1 if reaped */
int prc_refcnt; /* this structure's reference count */
} prcommon_t;
/* prc_flags */
/*
* Macros for mapping between i-numbers and pids.
*/
(nodetype) + 2)
/* for old /proc interface */
#define PRBIAS 64
/*
* Node types for /proc files (directories and files contained therein).
*/
typedef enum prnodetype {
PR_PROCDIR, /* /proc */
PR_PIDDIR, /* /proc/<pid> */
PR_AS, /* /proc/<pid>/as */
PR_CTL, /* /proc/<pid>/ctl */
PR_STATUS, /* /proc/<pid>/status */
PR_LSTATUS, /* /proc/<pid>/lstatus */
PR_PSINFO, /* /proc/<pid>/psinfo */
PR_LPSINFO, /* /proc/<pid>/lpsinfo */
PR_MAP, /* /proc/<pid>/map */
PR_RMAP, /* /proc/<pid>/rmap */
PR_XMAP, /* /proc/<pid>/xmap */
PR_CRED, /* /proc/<pid>/cred */
PR_SIGACT, /* /proc/<pid>/sigact */
PR_AUXV, /* /proc/<pid>/auxv */
PR_LDT, /* /proc/<pid>/ldt */
#endif
PR_USAGE, /* /proc/<pid>/usage */
PR_LUSAGE, /* /proc/<pid>/lusage */
PR_PAGEDATA, /* /proc/<pid>/pagedata */
PR_WATCH, /* /proc/<pid>/watch */
PR_CURDIR, /* /proc/<pid>/cwd */
PR_ROOTDIR, /* /proc/<pid>/root */
PR_FDDIR, /* /proc/<pid>/fd */
PR_OBJECTDIR, /* /proc/<pid>/object */
PR_LWPDIR, /* /proc/<pid>/lwp */
PR_LWPIDDIR, /* /proc/<pid>/lwp/<lwpid> */
PR_LWPCTL, /* /proc/<pid>/lwp/<lwpid>/lwpctl */
PR_LWPSTATUS, /* /proc/<pid>/lwp/<lwpid>/lwpstatus */
PR_LWPSINFO, /* /proc/<pid>/lwp/<lwpid>/lwpsinfo */
PR_LWPUSAGE, /* /proc/<pid>/lwp/<lwpid>/lwpusage */
PR_XREGS, /* /proc/<pid>/lwp/<lwpid>/xregs */
PR_TMPLDIR, /* /proc/<pid>/lwp/<lwpid>/templates */
PR_TMPL, /* /proc/<pid>/lwp/<lwpid>/templates/<id> */
PR_SPYMASTER, /* /proc/<pid>/lwp/<lwpid>/spymaster */
#if defined(__sparc)
PR_GWINDOWS, /* /proc/<pid>/lwp/<lwpid>/gwindows */
PR_ASRS, /* /proc/<pid>/lwp/<lwpid>/asrs */
#endif
PR_PRIV, /* /proc/<pid>/priv */
PR_PATHDIR, /* /proc/<pid>/path */
PR_CTDIR, /* /proc/<pid>/contracts */
PR_CT, /* /proc/<pid>/contracts/<ctid> */
PR_PIDFILE, /* old process file */
PR_LWPIDFILE, /* old lwp file */
PR_OPAGEDATA, /* old page data file */
PR_NFILES /* number of /proc node types */
} prnodetype_t;
typedef struct prnode {
int pr_cttype; /* active template type */
} prnode_t;
/*
* Values for pr_flags.
*/
/*
* Conversion macros.
*/
/*
* Flags to prlock().
*/
#define ZNO 0 /* Fail on encountering a zombie process. */
/*
* Assign one set to another (possible different sizes).
*
* Assigning to a smaller set causes members to be lost.
* Assigning to a larger set causes extra members to be cleared.
*/
{ \
while (--_i_ >= 0) \
}
/*
* Determine whether or not a set (of arbitrary size) is empty.
*/
/*
* Resource usage with times as hrtime_t rather than timestruc_t.
* Each member exactly matches the corresponding member in prusage_t.
* This is for convenience of internal computation.
*/
typedef struct prhusage {
int pr_count; /* number of contributing lwps */
} prhusage_t;
#if defined(_KERNEL)
/* Exclude system processes from this test */
#define PROCESS_NOT_32BIT(p) \
(p)->p_model != DATAMODEL_ILP32)
extern int prnwatch; /* number of supported watchpoints */
extern int nproc_highbit; /* highbit(v.v_nproc) */
extern struct vnodeops *prvnodeops;
/*
* Generic chained copyout buffers for procfs use.
* In order to prevent procfs from making huge oversize kmem_alloc calls,
* a list of smaller buffers can be concatenated and copied to userspace in
* sequence.
*
* The implementation is opaque.
*
* A user of this will perform the following steps:
*
* list_t listhead;
* struct my *mp;
*
* pr_iol_initlist(&listhead, sizeof (*mp), n);
* while (whatever) {
* mp = pr_iol_newbuf(&listhead, sizeof (*mp);
* ...
* error = ...
* }
*
* When done, depending on whether copyout() or uiomove() is supposed to
* be used for transferring the buffered data to userspace, call either:
*
* error = pr_iol_copyout_and_free(&listhead, &cmaddr, error);
*
* or else:
*
* error = pr_iol_uiomove_and_free(&listhead, uiop, error);
*
* These two functions will in any case kmem_free() all list items, but
* are updated. The error returned will either be the one passed in, or
*/
#if defined(_SYSCALL32_IMPL)
#endif /* _SYSCALL32_IMPL */
/* kludge to support old /proc interface */
#if !defined(_SYS_OLD_PROCFS_H)
#if defined(_SYSCALL32_IMPL)
#endif /* _SYSCALL32_IMPL */
#endif /* !_SYS_OLD_PROCFS_H */
extern void pr_wait_die(prnode_t *);
extern void prscaleusage(prhusage_t *);
extern void prfreenode(prnode_t *);
extern void pr_free_watchpoints(proc_t *);
/*
* Machine-dependent routines (defined in prmachdep.c).
*/
#if defined(_SYSCALL32_IMPL)
#endif /* _SYSCALL32_IMPL */
extern void prpokethread(kthread_t *t);
extern int prgetrvals(klwp_t *, long *, long *);
extern int prgetprxregsize(proc_t *);
extern int prhasfp(void);
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_PROC_PRDATA_H */