summaryrefslogtreecommitdiffstats
path: root/sys/sys/user.h
diff options
context:
space:
mode:
authorstas <stas@FreeBSD.org>2011-05-12 10:11:39 +0000
committerstas <stas@FreeBSD.org>2011-05-12 10:11:39 +0000
commit5f9f79547658271f3f469b6423a176831fef7683 (patch)
tree9f873599b157e2ba06c3088d82cad8a221b42d18 /sys/sys/user.h
parentf47d00001ad33e13ec3b6fc74732b959cd485dc7 (diff)
downloadFreeBSD-src-5f9f79547658271f3f469b6423a176831fef7683.zip
FreeBSD-src-5f9f79547658271f3f469b6423a176831fef7683.tar.gz
- Commit work from libprocstat project. These patches add support for runtime
file and processes information retrieval from the running kernel via sysctl in the form of new library, libprocstat. The library also supports KVM backend for analyzing memory crash dumps. Both procstat(1) and fstat(1) utilities have been modified to take advantage of the library (as the bonus point the fstat(1) utility no longer need superuser privileges to operate), and the procstat(1) utility is now able to display information from memory dumps as well. The newly introduced fuser(1) utility also uses this library and able to operate via sysctl and kvm backends. The library is by no means complete (e.g. KVM backend is missing vnode name resolution routines, and there're no manpages for the library itself) so I plan to improve it further. I'm commiting it so it will get wider exposure and review. We won't be able to MFC this work as it relies on changes in HEAD, which was introduced some time ago, that break kernel ABI. OTOH we may be able to merge the library with KVM backend if we really need it there. Discussed with: rwatson
Diffstat (limited to 'sys/sys/user.h')
-rw-r--r--sys/sys/user.h99
1 files changed, 82 insertions, 17 deletions
diff --git a/sys/sys/user.h b/sys/sys/user.h
index 5c5cbd4..644f911 100644
--- a/sys/sys/user.h
+++ b/sys/sys/user.h
@@ -233,6 +233,8 @@ struct user {
* The KERN_PROC_FILE sysctl allows a process to dump the file descriptor
* array of another process.
*/
+#define KF_ATTR_VALID 0x0001
+
#define KF_TYPE_NONE 0
#define KF_TYPE_VNODE 1
#define KF_TYPE_SOCKET 2
@@ -260,6 +262,9 @@ struct user {
#define KF_FD_TYPE_CWD -1 /* Current working directory */
#define KF_FD_TYPE_ROOT -2 /* Root directory */
#define KF_FD_TYPE_JAIL -3 /* Jail directory */
+#define KF_FD_TYPE_TRACE -4 /* ptrace vnode */
+#define KF_FD_TYPE_TEXT -5 /* Text vnode */
+#define KF_FD_TYPE_CTTY -6 /* Controlling terminal */
#define KF_FLAG_READ 0x00000001
#define KF_FLAG_WRITE 0x00000002
@@ -269,6 +274,13 @@ struct user {
#define KF_FLAG_NONBLOCK 0x00000020
#define KF_FLAG_DIRECT 0x00000040
#define KF_FLAG_HASLOCK 0x00000080
+#define KF_FLAG_SHLOCK 0x00000100
+#define KF_FLAG_EXLOCK 0x00000200
+#define KF_FLAG_NOFOLLOW 0x00000400
+#define KF_FLAG_CREAT 0x00000800
+#define KF_FLAG_TRUNC 0x00001000
+#define KF_FLAG_EXCL 0x00002000
+#define KF_FLAG_EXEC 0x00004000
/*
* Old format. Has variable hidden padding due to alignment.
@@ -303,22 +315,67 @@ struct kinfo_ofile {
#endif
struct kinfo_file {
- int kf_structsize; /* Variable size of record. */
- int kf_type; /* Descriptor type. */
- int kf_fd; /* Array index. */
- int kf_ref_count; /* Reference count. */
- int kf_flags; /* Flags. */
- int _kf_pad0; /* Round to 64 bit alignment */
- int64_t kf_offset; /* Seek location. */
- int kf_vnode_type; /* Vnode type. */
- int kf_sock_domain; /* Socket domain. */
- int kf_sock_type; /* Socket type. */
- int kf_sock_protocol; /* Socket protocol. */
+ int kf_structsize; /* Variable size of record. */
+ int kf_type; /* Descriptor type. */
+ int kf_fd; /* Array index. */
+ int kf_ref_count; /* Reference count. */
+ int kf_flags; /* Flags. */
+ int kf_pad0; /* Round to 64 bit alignment. */
+ int64_t kf_offset; /* Seek location. */
+ int kf_vnode_type; /* Vnode type. */
+ int kf_sock_domain; /* Socket domain. */
+ int kf_sock_type; /* Socket type. */
+ int kf_sock_protocol; /* Socket protocol. */
struct sockaddr_storage kf_sa_local; /* Socket address. */
struct sockaddr_storage kf_sa_peer; /* Peer address. */
- int _kf_ispare[16]; /* Space for more stuff. */
+ union {
+ struct {
+ /* Address of so_pcb. */
+ uint64_t kf_sock_pcb;
+ /* Address of inp_ppcb. */
+ uint64_t kf_sock_inpcb;
+ /* Address of unp_conn. */
+ uint64_t kf_sock_unpconn;
+ /* Send buffer state. */
+ uint16_t kf_sock_snd_sb_state;
+ /* Receive buffer state. */
+ uint16_t kf_sock_rcv_sb_state;
+ /* Round to 64 bit alignment. */
+ uint32_t kf_sock_pad0;
+ } kf_sock;
+ struct {
+ /* Global file id. */
+ uint64_t kf_file_fileid;
+ /* File size. */
+ uint64_t kf_file_size;
+ /* Vnode filesystem id. */
+ uint32_t kf_file_fsid;
+ /* File device. */
+ uint32_t kf_file_rdev;
+ /* File mode. */
+ uint16_t kf_file_mode;
+ /* Round to 64 bit alignment. */
+ uint16_t kf_file_pad0;
+ uint32_t kf_file_pad1;
+ } kf_file;
+ struct {
+ uint64_t kf_pipe_addr;
+ uint64_t kf_pipe_peer;
+ uint32_t kf_pipe_buffer_cnt;
+ /* Round to 64 bit alignment. */
+ uint32_t kf_pipe_pad0[3];
+ } kf_pipe;
+ struct {
+ uint32_t kf_pts_dev;
+ /* Round to 64 bit alignment. */
+ uint32_t kf_pts_pad0[7];
+ } kf_pts;
+ } kf_un;
+ uint16_t kf_status; /* Status flags. */
+ uint16_t kf_pad1; /* Round to 32 bit alignment. */
+ int _kf_ispare[7]; /* Space for more stuff. */
/* Truncated before copyout in sysctl */
- char kf_path[PATH_MAX]; /* Path to file, if any. */
+ char kf_path[PATH_MAX]; /* Path to file, if any. */
};
/*
@@ -379,16 +436,20 @@ struct kinfo_vmentry {
uint64_t kve_start; /* Starting address. */
uint64_t kve_end; /* Finishing address. */
uint64_t kve_offset; /* Mapping offset in object */
- uint64_t kve_fileid; /* inode number if vnode */
- uint32_t kve_fsid; /* dev_t of vnode location */
+ uint64_t kve_vn_fileid; /* inode number if vnode */
+ uint32_t kve_vn_fsid; /* dev_t of vnode location */
int kve_flags; /* Flags on map entry. */
int kve_resident; /* Number of resident pages. */
int kve_private_resident; /* Number of private pages. */
int kve_protection; /* Protection bitmask. */
int kve_ref_count; /* VM obj ref count. */
int kve_shadow_count; /* VM obj shadow count. */
- int _kve_pad0; /* 64bit align next field */
- int _kve_ispare[16]; /* Space for more stuff. */
+ int kve_vn_type; /* Vnode type. */
+ uint64_t kve_vn_size; /* File size. */
+ uint32_t kve_vn_rdev; /* Device id if device. */
+ uint16_t kve_vn_mode; /* File mode. */
+ uint16_t kve_status; /* Status flags. */
+ int _kve_ispare[12]; /* Space for more stuff. */
/* Truncated before copyout in sysctl */
char kve_path[PATH_MAX]; /* Path to VM obj, if any. */
};
@@ -415,4 +476,8 @@ struct kinfo_kstack {
int _kkst_ispare[16]; /* Space for more stuff. */
};
+#ifdef _KERNEL
+int vntype_to_kinfo(int vtype);
+#endif /* !_KERNEL */
+
#endif
OpenPOWER on IntegriCloud