summaryrefslogtreecommitdiffstats
path: root/sys/sys/user.h
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2007-12-02 10:10:27 +0000
committerrwatson <rwatson@FreeBSD.org>2007-12-02 10:10:27 +0000
commitc25458da37ba171afe76f0f5e3ba48ce24ad7769 (patch)
treeedfa0be7c63bacc470c567b77ae4806509c9af71 /sys/sys/user.h
parent663523e681b2bf457e0fbb8f5e841a4e2ead3dfc (diff)
downloadFreeBSD-src-c25458da37ba171afe76f0f5e3ba48ce24ad7769.zip
FreeBSD-src-c25458da37ba171afe76f0f5e3ba48ce24ad7769.tar.gz
Add two new sysctls in support of the forthcoming procstat(1) to support
its -f and -v arguments: kern.proc.filedesc - dump file descriptor information for a process, if debugging is permitted, including socket addresses, open flags, file offsets, file paths, etc. kern.proc.vmmap - dump virtual memory mapping information for a process, if debugging is permitted, including layout and information on underlying objects, such as the type of object and path. These provide a superset of the information historically available through the now-deprecated procfs(4), and are intended to be exported in an ABI-robust form.
Diffstat (limited to 'sys/sys/user.h')
-rw-r--r--sys/sys/user.h93
1 files changed, 92 insertions, 1 deletions
diff --git a/sys/sys/user.h b/sys/sys/user.h
index 348b3e0..9e4f14f 100644
--- a/sys/sys/user.h
+++ b/sys/sys/user.h
@@ -1,6 +1,8 @@
/*-
* Copyright (c) 1982, 1986, 1989, 1991, 1993
- * The Regents of the University of California. All rights reserved.
+ * The Regents of the University of California.
+ * Copyright (c) 2007 Robert N. M. Watson
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -56,6 +58,9 @@
#ifndef _SYS_SIGNALVAR_H_
#include <sys/signalvar.h>
#endif
+#ifndef _SYS_SOCKET_VAR_H_
+#include <sys/socket.h>
+#endif
/*
* KERN_PROC subtype ops return arrays of selected proc structure entries:
@@ -228,4 +233,90 @@ struct user {
struct kinfo_proc u_kproc; /* eproc */
};
+/*
+ * The KERN_PROC_FILE sysctl allows a process to dumpt the file descriptor
+ * array of another process.
+ */
+#define KF_TYPE_NONE 0
+#define KF_TYPE_VNODE 1
+#define KF_TYPE_SOCKET 2
+#define KF_TYPE_PIPE 3
+#define KF_TYPE_FIFO 4
+#define KF_TYPE_KQUEUE 5
+#define KF_TYPE_CRYPTO 6
+#define KF_TYPE_MQUEUE 7
+#define KF_TYPE_UNKNOWN 255
+
+#define KF_VTYPE_VNON 0
+#define KF_VTYPE_VREG 1
+#define KF_VTYPE_VDIR 2
+#define KF_VTYPE_VBLK 3
+#define KF_VTYPE_VCHR 4
+#define KF_VTYPE_VLNK 5
+#define KF_VTYPE_VSOCK 6
+#define KF_VTYPE_VFIFO 7
+#define KF_VTYPE_VBAD 8
+#define KF_VTYPE_UNKNOWN 255
+
+#define KF_FLAG_READ 0x00000001
+#define KF_FLAG_WRITE 0x00000002
+#define KF_FLAG_APPEND 0x00000004
+#define KF_FLAG_ASYNC 0x00000008
+#define KF_FLAG_FSYNC 0x00000010
+#define KF_FLAG_NONBLOCK 0x00000020
+#define KF_FLAG_DIRECT 0x00000040
+#define KF_FLAG_HASLOCK 0x00000080
+
+struct kinfo_file {
+ int kf_structsize; /* Size of kinfo_file. */
+ int kf_type; /* Descriptor type. */
+ int kf_fd; /* Array index. */
+ int kf_ref_count; /* Reference count. */
+ int kf_flags; /* Flags. */
+ off_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. */
+ char kf_path[PATH_MAX]; /* Path to file, if any. */
+ struct sockaddr_storage kf_sa_local; /* Socket address. */
+ struct sockaddr_storage kf_sa_peer; /* Peer address. */
+};
+
+/*
+ * The KERN_PROC_VMMAP sysctl allows a process to dump the VM layout of
+ * another process as a series of entries.
+ */
+#define KVME_TYPE_NONE 0
+#define KVME_TYPE_DEFAULT 1
+#define KVME_TYPE_VNODE 2
+#define KVME_TYPE_SWAP 3
+#define KVME_TYPE_DEVICE 4
+#define KVME_TYPE_PHYS 5
+#define KVME_TYPE_DEAD 6
+#define KVME_TYPE_UNKNOWN 255
+
+#define KVME_PROT_READ 0x00000001
+#define KVME_PROT_WRITE 0x00000002
+#define KVME_PROT_EXEC 0x00000004
+
+#define KVME_FLAG_COW 0x00000001
+#define KVME_FLAG_NEEDS_COPY 0x00000002
+
+struct kinfo_vmentry {
+ int kve_structsize; /* Size of kinfo_vmmapentry. */
+ int kve_type; /* Type of map entry. */
+ void *kve_start; /* Starting pointer. */
+ void *kve_end; /* Finishing pointer. */
+ 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. */
+ char kve_path[PATH_MAX]; /* Path to VM obj, if any. */
+ void *_kve_pspare[8]; /* Space for more stuff. */
+ int _kve_ispare[8]; /* Space for more stuff. */
+};
+
#endif
OpenPOWER on IntegriCloud