procfs.h revision d2a70789f056fc6c9ce3ab047b52126d80b0e3da
/*
* 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 2012 DEY Storage Systems, Inc. All rights reserved.
*/
#ifndef _SYS_PROCFS_H
#define _SYS_PROCFS_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* This definition is temporary. Structured proc is the preferred API,
* and the older ioctl-based interface will be removed in a future version
* provide the older ioctl-based /proc definitions. To get the structured
* /proc definitions, either include <procfs.h> or define _STRUCTURED_PROC
*/
#ifndef _STRUCTURED_PROC
#define _STRUCTURED_PROC 0
#endif
#if !defined(_KERNEL) && _STRUCTURED_PROC == 0
#include <sys/old_procfs.h>
#else /* !defined(_KERNEL) && _STRUCTURED_PROC == 0 */
#include <sys/feature_tests.h>
#include <sys/time_impl.h>
#include <sys/procfs_isa.h>
#include <sys/secflags.h>
/*
* System call interfaces for /proc.
*/
/*
* Control codes (long values) for messages written to ctl and lwpctl files.
*/
#define PCNULL 0L /* null request, advance to next message */
/*
* PCRUN long operand flags.
*/
/*
* lwp status file. /proc/<pid>/lwp/<lwpid>/lwpstatus
*/
typedef struct lwpstatus {
int pr_flags; /* flags (see below) */
short pr_why; /* reason for lwp stop, if stopped */
short pr_what; /* more detailed reason */
short pr_cursig; /* current signal, if any */
short pr_pad1;
short pr_syscall; /* system call number (if in syscall) */
short pr_nsysarg; /* number of arguments to this syscall */
int pr_errno; /* errno for failed syscall, 0 if successful */
long pr_rval1; /* primary syscall return value */
long pr_rval2; /* second syscall return value, if any */
int pr_errpriv; /* missing privilege */
} lwpstatus_t;
/*
* process status file. /proc/<pid>/status
*/
typedef struct pstatus {
int pr_flags; /* flags (see below) */
int pr_nlwp; /* number of active lwps in the process */
char pr_dmodel; /* data model of the process (see below) */
char pr_pad[3];
int pr_nzomb; /* number of zombie lwps in the process */
} pstatus_t;
/*
* pr_flags (same values appear in both pstatus_t and lwpstatus_t pr_flags).
*
* These flags do *not* apply to psinfo_t.pr_flag or lwpsinfo_t.pr_flag
* (which are both deprecated).
*/
/* The following flags apply to the specific or representative lwp */
/* The following flags apply to the process, not to an individual lwp */
/*
* See <sys/procfs_isa.h> for possible values of pr_dmodel.
*/
/*
* Reasons for stopping (pr_why).
*/
#define PR_REQUESTED 1
#define PR_SIGNALLED 2
#define PR_SYSENTRY 3
#define PR_SYSEXIT 4
#define PR_JOBCONTROL 5
#define PR_FAULTED 6
#define PR_SUSPENDED 7
#define PR_CHECKPOINT 8
/*
* lwp ps(1) information file. /proc/<pid>/lwp/<lwpid>/lwpsinfo
*/
typedef struct lwpsinfo {
int pr_flag; /* lwp flags (DEPRECATED; do not use) */
char pr_stype; /* synchronization event type */
char pr_state; /* numeric lwp state */
char pr_sname; /* printable character for pr_state */
char pr_nice; /* nice for cpu usage */
short pr_syscall; /* system call number (if in syscall) */
char pr_oldpri; /* pre-SVR4, low value is high priority */
char pr_cpu; /* pre-SVR4, cpu usage for scheduling */
int pr_pri; /* priority, high value is high priority */
/* The following percent number is a 16-bit binary */
/* fraction [0 .. 1] with the binary point to the */
/* right of the high-order bit (1.0 == 0x8000) */
int pr_lgrp; /* lwp home lgroup */
} lwpsinfo_t;
/*
* process ps(1) information file. /proc/<pid>/psinfo
*/
typedef struct psinfo {
int pr_flag; /* process flags (DEPRECATED; do not use) */
int pr_nlwp; /* number of active lwps in the process */
/* The following percent numbers are 16-bit binary */
/* fractions [0 .. 1] with the binary point to the */
/* right of the high-order bit (1.0 == 0x8000) */
int pr_wstat; /* if zombie, the wait() status */
int pr_argc; /* initial argument count */
char pr_dmodel; /* data model of the process */
char pr_pad2[3];
int pr_nzomb; /* number of zombie lwps in the process */
} psinfo_t;
/*
* Memory-map interface. /proc/<pid>/map /proc/<pid>/rmap
*/
#define PRMAPSZ 64
typedef struct prmap {
int pr_mflags; /* protection and attribute flags (see below) */
int pr_pagesize; /* pagesize (bytes) for this mapping */
int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */
} prmap_t;
/*
* HAT memory-map interface. /proc/<pid>/xmap
*/
typedef struct prxmap {
int pr_mflags; /* protection and attribute flags (see below) */
int pr_pagesize; /* pagesize (bytes) for this mapping */
int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */
#ifdef _ILP32
#else
#endif
} prxmap_t;
/* Protection and attribute flags */
/*
* These are obsolete and unreliable.
* They are included here only for historical compatibility.
*/
/*
* Process credentials. PCSCRED and /proc/<pid>/cred
*/
typedef struct prcred {
int pr_ngroups; /* number of supplementary groups */
} prcred_t;
/*
* Process privileges. PCSPRIV and /proc/<pid>/priv
*/
typedef struct prpriv {
} prpriv_t;
#define PRSECFLAGS_VERSION_1 1
typedef struct prsecflags {
char pr_pad[4];
} prsecflags_t;
/*
* Watchpoint interface. PCWATCH and /proc/<pid>/watch
*/
typedef struct prwatch {
int pr_wflags; /* watch type flags */
int pr_pad;
} prwatch_t;
/* pr_wflags */
/*
*/
typedef struct priovec {
void *pio_base; /* buffer in controlling process */
} priovec_t;
/*
* Resource usage. /proc/<pid>/usage /proc/<pid>/lwp/<lwpid>/lwpusage
*/
typedef struct prusage {
int pr_count; /* number of contributing lwps */
} prusage_t;
/*
* Page data file. /proc/<pid>/pagedata
*/
/* page data file header */
typedef struct prpageheader {
long pr_nmap; /* number of address space mappings */
long pr_npage; /* total number of pages */
/* page data mapping header */
typedef struct prasmap {
int pr_mflags; /* protection and attribute flags */
int pr_pagesize; /* pagesize (bytes) for this mapping */
int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */
} prasmap_t;
/*
* pr_npage bytes (plus 0-7 null bytes to round up to an 8-byte boundary)
* follow each mapping header, each containing zero or more of these flags.
*/
/*
* Open files. Only in core files (for now). Note that we'd like to use
* the stat or stat64 structure, but both of these structures are unfortunately
* not consistent between 32 and 64 bit modes. To keep our lives simpler, we
* just define our own structure with types that are not sensitive to this
* difference. Also, it turns out that pfiles omits a lot of info from the
* struct stat (e.g. times, device sizes, etc.) so we don't bother adding those
* here.
*/
typedef struct prfdinfo {
int pr_fd;
int pr_fileflags; /* fcntl(F_GETXFL), etc */
int pr_fdflags; /* fcntl(F_GETFD), etc. */
char pr_path[MAXPATHLEN];
} prfdinfo_t;
/*
* Header for /proc/<pid>/lstatus /proc/<pid>/lpsinfo /proc/<pid>/lusage
*/
typedef struct prheader {
long pr_nent; /* number of entries */
long pr_entsize; /* size of each entry, in bytes */
} prheader_t;
/*
* Macros for manipulating sets of flags.
* sp must be a pointer to one of sigset_t, fltset_t, or sysset_t.
* flag must be a member of the enumeration corresponding to *sp.
*/
/* turn on all flags in set */
/* turn off all flags in set */
#define premptyset(sp) \
/* turn on specified flag in set */
/* turn off specified flag in set */
/* query: != 0 iff flag is turned on in set */
#if defined(_SYSCALL32)
/*
* dev32_t version of PRNODEV
*/
/*
* Kernel view of /proc structures for _ILP32 programs.
*/
/*
* _ILP32 lwp status file. /proc/<pid>/lwp/<lwpid>/lwpstatus
*/
typedef struct lwpstatus32 {
int pr_flags; /* flags */
short pr_why; /* reason for lwp stop, if stopped */
short pr_what; /* more detailed reason */
short pr_cursig; /* current signal, if any */
short pr_pad1;
short pr_syscall; /* system call number (if in syscall) */
short pr_nsysarg; /* number of arguments to this syscall */
int pr_errno; /* errno for failed syscall, 0 if successful */
int pr_errpriv; /* missing privilege */
/*
* _ILP32 process status file. /proc/<pid>/status
*/
typedef struct pstatus32 {
int pr_flags; /* flags */
int pr_nlwp; /* number of active lwps in the process */
char pr_dmodel; /* data model of the process */
char pr_pad[3];
int pr_nzomb; /* number of zombie lwps in the process */
} pstatus32_t;
/*
* _ILP32 lwp ps(1) information file. /proc/<pid>/lwp/<lwpid>/lwpsinfo
*/
typedef struct lwpsinfo32 {
int pr_flag; /* lwp flags */
char pr_stype; /* synchronization event type */
char pr_state; /* numeric lwp state */
char pr_sname; /* printable character for pr_state */
char pr_nice; /* nice for cpu usage */
short pr_syscall; /* system call number (if in syscall) */
char pr_oldpri; /* pre-SVR4, low value is high priority */
char pr_cpu; /* pre-SVR4, cpu usage for scheduling */
int pr_pri; /* priority, high value is high priority */
/* The following percent number is a 16-bit binary */
/* fraction [0 .. 1] with the binary point to the */
/* right of the high-order bit (1.0 == 0x8000) */
int pr_lgrp; /* lwp home lgroup */
} lwpsinfo32_t;
/*
* _ILP32 process ps(1) information file. /proc/<pid>/psinfo
*/
typedef struct psinfo32 {
int pr_flag; /* process flags */
int pr_nlwp; /* number of active lwps in the process */
int pr_wstat; /* if zombie, the wait() status */
int pr_argc; /* initial argument count */
char pr_dmodel; /* data model of the process */
char pr_pad2[3];
int pr_nzomb; /* number of zombie lwps in the process */
} psinfo32_t;
/*
* _ILP32 Memory-management interface. /proc/<pid>/map /proc/<pid>/rmap
*/
typedef struct prmap32 {
int pr_mflags; /* protection and attribute flags */
int pr_pagesize; /* pagesize (bytes) for this mapping */
int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */
} prmap32_t;
/*
* _ILP32 HAT memory-map interface. /proc/<pid>/xmap
*/
typedef struct prxmap32 {
int pr_mflags; /* protection and attribute flags (see below) */
int pr_pagesize; /* pagesize (bytes) for this mapping */
int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */
} prxmap32_t;
/*
* _ILP32 Process credentials. PCSCRED and /proc/<pid>/cred
*/
typedef struct prcred32 {
int pr_ngroups; /* number of supplementary groups */
} prcred32_t;
/*
* _ILP32 Watchpoint interface. PCWATCH and /proc/<pid>/watch
*/
typedef struct prwatch32 {
int pr_wflags; /* watch type flags */
int pr_pad;
} prwatch32_t;
/*
*/
typedef struct priovec32 {
} priovec32_t;
/*
* _ILP32 Resource usage. /proc/<pid>/usage /proc/<pid>/lwp/<lwpid>/lwpusage
*/
typedef struct prusage32 {
} prusage32_t;
/*
* _ILP32 Page data file. /proc/<pid>/pagedata
*/
/* _ILP32 page data file header */
typedef struct prpageheader32 {
/* _ILP32 page data mapping header */
typedef struct prasmap32 {
int pr_mflags; /* protection and attribute flags */
int pr_pagesize; /* pagesize (bytes) for this mapping */
int pr_shmid; /* SysV shmid, -1 if not SysV shared memory */
} prasmap32_t;
/*
* _ILP32 Header for /proc/<pid>/lstatus /proc/<pid>/lpsinfo /proc/<pid>/lusage
*/
typedef struct prheader32 {
} prheader32_t;
#endif /* _SYSCALL32 */
#endif /* !_KERNEL && _STRUCTURED_PROC == 0 */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_PROCFS_H */