struct proc { struct proc * p_next; /* active chain link next */ struct proc * p_prev; /* active chain link prev */ struct pid * p_pidp; /* process ID info */ struct vnode * p_trace; /* pointer to primary /proc vnode */ struct vnode * p_plist; /* list of /proc vnodes for process */ }
/* process ID info */ struct pid { unsigned int pid_prslot :24; pid_t pid_id; };
typedef struct prnode { vnode_t * pr_next; /* list of all vnodes for process */ prcommon_t * pr_common; /* common data structure */ prcommon_t * pr_pcommon; /* * process common data structure * 和上面那个成员什么区别 */ vnode_t ** pr_files; /* contained files array (directory) */ vnode_t pr_vnode; /* embedded vnode 这里不是指针 */ } prnode_t;
/* * 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; /* process slot number */ } prcommon_t;
/usr/include/sys/vnode.h
/* * All of the fields in the vnode are read-only once they are initialized * (created) except for: * v_flag: protected by v_lock * v_count: protected by v_lock * v_pages: file system must keep page list in sync with file size * v_filocks: protected by flock_lock in flock.c * v_shrlocks: protected by v_lock */ typedef struct vnode { caddr_t v_data; /* private data for fs */ } vnode_t;
Solaris 7 的procfs实现是基于64-bit内核的,但是同时支持32-bit和64-bit应 用,在/proc层次结构上提供了32-bit版本的可用数据文件。在64-bit Solaris 7内核中,描述每个/proc文件对象内容的数据结构同时拥有32-bit版本和64-bit版本,比如lwpstatus和lwpstatus32、psinfo和psinfo32等等。针对每个32-bit版本的结构定义,相应pr_read_xxx()函数做了支持32-bit数据模式的编码。