/* * 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 * or http://www.opensolaris.org/os/licensing. * 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 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* * Copyright 2015 Joyent, Inc. */ #ifndef _LXPROC_H #define _LXPROC_H #ifdef _LXPROC_BRANDED_H #error Attempted to include native lxproc.h after branded lx_proc.h #endif #define _LXPROC_NATIVE_H #ifdef __cplusplus extern "C" { #endif /* * lxproc.h: declarations, data structures and macros for lxprocfs */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define LX_SIGHUP 1 #define LX_SIGINT 2 #define LX_SIGQUIT 3 #define LX_SIGILL 4 #define LX_SIGTRAP 5 #define LX_SIGABRT 6 #define LX_SIGIOT 6 #define LX_SIGBUS 7 #define LX_SIGFPE 8 #define LX_SIGKILL 9 #define LX_SIGUSR1 10 #define LX_SIGSEGV 11 #define LX_SIGUSR2 12 #define LX_SIGPIPE 13 #define LX_SIGALRM 14 #define LX_SIGTERM 15 #define LX_SIGSTKFLT 16 #define LX_SIGCHLD 17 #define LX_SIGCONT 18 #define LX_SIGSTOP 19 #define LX_SIGTSTP 20 #define LX_SIGTTIN 21 #define LX_SIGTTOU 22 #define LX_SIGURG 23 #define LX_SIGXCPU 24 #define LX_SIGXFSZ 25 #define LX_SIGVTALRM 26 #define LX_SIGPROF 27 #define LX_SIGWINCH 28 #define LX_SIGIO 29 #define LX_SIGPOLL LX_SIGIO #define LX_SIGPWR 30 #define LX_SIGSYS 31 #define LX_SIGUNUSED 31 #define LX_NSIG 64 /* Linux _NSIG */ #define LX_SIGRTMIN 32 #define LX_SIGRTMAX LX_NSIG /* * Convert a vnode into an lxpr_mnt_t */ #define VTOLXPM(vp) ((lxpr_mnt_t *)(vp)->v_vfsp->vfs_data) /* * convert a vnode into an lxpr_node */ #define VTOLXP(vp) ((lxpr_node_t *)(vp)->v_data) /* * convert a lxprnode into a vnode */ #define LXPTOV(lxpnp) ((lxpnp)->lxpr_vnode) /* * convert a lxpr_node into zone for fs */ #define LXPTOZ(lxpnp) \ (((lxpr_mnt_t *)(lxpnp)->lxpr_vnode->v_vfsp->vfs_data)->lxprm_zone) #define LXPNSIZ 256 /* max size of lx /proc file name entries */ /* * Pretend that a directory entry takes 16 bytes */ #define LXPR_SDSIZE 16 /* * Node/file types for lx /proc files * (directories and files contained therein). */ typedef enum lxpr_nodetype { LXPR_PROCDIR, /* /proc */ LXPR_PIDDIR, /* /proc/ */ LXPR_PID_CMDLINE, /* /proc//cmdline */ LXPR_PID_CPU, /* /proc//cpu */ LXPR_PID_CURDIR, /* /proc//cwd */ LXPR_PID_ENV, /* /proc//environ */ LXPR_PID_EXE, /* /proc//exe */ LXPR_PID_MAPS, /* /proc//maps */ LXPR_PID_MEM, /* /proc//mem */ LXPR_PID_ROOTDIR, /* /proc//root */ LXPR_PID_STAT, /* /proc//stat */ LXPR_PID_STATM, /* /proc//statm */ LXPR_PID_STATUS, /* /proc//status */ LXPR_PID_FDDIR, /* /proc//fd */ LXPR_PID_FD_FD, /* /proc//fd/nn */ LXPR_CMDLINE, /* /proc/cmdline */ LXPR_CPUINFO, /* /proc/cpuinfo */ LXPR_DEVICES, /* /proc/devices */ LXPR_DMA, /* /proc/dma */ LXPR_FILESYSTEMS, /* /proc/filesystems */ LXPR_INTERRUPTS, /* /proc/interrupts */ LXPR_IOPORTS, /* /proc/ioports */ LXPR_KCORE, /* /proc/kcore */ LXPR_KMSG, /* /proc/kmsg */ LXPR_LOADAVG, /* /proc/loadavg */ LXPR_MEMINFO, /* /proc/meminfo */ LXPR_MOUNTS, /* /proc/mounts */ LXPR_NETDIR, /* /proc/net */ LXPR_NET_ARP, /* /proc/net/arp */ LXPR_NET_DEV, /* /proc/net/dev */ LXPR_NET_DEV_MCAST, /* /proc/net/dev_mcast */ LXPR_NET_IGMP, /* /proc/net/igmp */ LXPR_NET_IP_MR_CACHE, /* /proc/net/ip_mr_cache */ LXPR_NET_IP_MR_VIF, /* /proc/net/ip_mr_vif */ LXPR_NET_MCFILTER, /* /proc/net/mcfilter */ LXPR_NET_NETSTAT, /* /proc/net/netstat */ LXPR_NET_RAW, /* /proc/net/raw */ LXPR_NET_ROUTE, /* /proc/net/route */ LXPR_NET_RPC, /* /proc/net/rpc */ LXPR_NET_RT_CACHE, /* /proc/net/rt_cache */ LXPR_NET_SOCKSTAT, /* /proc/net/sockstat */ LXPR_NET_SNMP, /* /proc/net/snmp */ LXPR_NET_STAT, /* /proc/net/stat */ LXPR_NET_TCP, /* /proc/net/tcp */ LXPR_NET_UDP, /* /proc/net/udp */ LXPR_NET_UNIX, /* /proc/net/unix */ LXPR_PARTITIONS, /* /proc/partitions */ LXPR_SELF, /* /proc/self */ LXPR_STAT, /* /proc/stat */ LXPR_UPTIME, /* /proc/uptime */ LXPR_VERSION, /* /proc/version */ LXPR_NFILES /* number of lx /proc file types */ } lxpr_nodetype_t; /* * Number of fds allowed for in the inode number calculation * per process (if a process has more fds then inode numbers * may be duplicated) */ #define LXPR_FD_PERPROC 2000 /* * external dirent characteristics */ #define LXPRMAXNAMELEN 14 typedef struct { lxpr_nodetype_t d_type; char d_name[LXPRMAXNAMELEN]; } lxpr_dirent_t; /* * This is the lxprocfs private data object * which is attached to v_data in the vnode structure */ typedef struct lxpr_node { lxpr_nodetype_t lxpr_type; /* type of this node */ vnode_t *lxpr_vnode; /* vnode for the node */ vnode_t *lxpr_parent; /* parent directory */ vnode_t *lxpr_realvp; /* real vnode, file in dirs */ timestruc_t lxpr_time; /* creation etc time for file */ mode_t lxpr_mode; /* file mode bits */ uid_t lxpr_uid; /* file owner */ gid_t lxpr_gid; /* file group owner */ pid_t lxpr_pid; /* pid of proc referred to */ ino_t lxpr_ino; /* node id */ } lxpr_node_t; struct zone; /* forward declaration */ /* * This is the lxprocfs private data object * which is attached to vfs_data in the vfs structure */ typedef struct lxpr_mnt { lxpr_node_t *lxprm_node; /* node at root of proc mount */ struct zone *lxprm_zone; /* zone for this mount */ ldi_ident_t lxprm_li; /* ident for ldi */ } lxpr_mnt_t; extern vnodeops_t *lxpr_vnodeops; extern int nproc_highbit; /* highbit(v.v_nproc) */ typedef struct mounta mounta_t; extern void lxpr_initnodecache(); extern void lxpr_fininodecache(); extern void lxpr_initrootnode(lxpr_node_t **, vfs_t *); extern ino_t lxpr_inode(lxpr_nodetype_t, pid_t, int); extern ino_t lxpr_parentinode(lxpr_node_t *); extern lxpr_node_t *lxpr_getnode(vnode_t *, lxpr_nodetype_t, proc_t *, int); extern void lxpr_freenode(lxpr_node_t *); typedef struct lxpr_uiobuf lxpr_uiobuf_t; extern lxpr_uiobuf_t *lxpr_uiobuf_new(uio_t *); extern void lxpr_uiobuf_free(lxpr_uiobuf_t *); extern int lxpr_uiobuf_flush(lxpr_uiobuf_t *); extern void lxpr_uiobuf_seek(lxpr_uiobuf_t *, offset_t); extern void lxpr_uiobuf_write(lxpr_uiobuf_t *, const char *, size_t); extern void lxpr_uiobuf_printf(lxpr_uiobuf_t *, const char *, ...); extern void lxpr_uiobuf_seterr(lxpr_uiobuf_t *, int); proc_t *lxpr_lock(pid_t); void lxpr_unlock(proc_t *); #ifdef __cplusplus } #endif #endif /* _LXPROC_H */