+ }
+ return(error);
+}
+
+SYSCTL_PROC(_kern, KERN_SECURELVL, securelevel,
+ CTLTYPE_INT | CTLFLAG_RW,
+ 0, 0, sysctl_securelvl, "I", "");
+
+
+static int
+sysctl_domainname
+(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
+{
+ int error, changed;
+ error = sysctl_io_string(req, domainname, sizeof(domainname), 0, &changed);
+ if (changed) {
+ domainnamelen = strlen(domainname);
+ }
+ return(error);
+}
+
+SYSCTL_PROC(_kern, KERN_DOMAINNAME, nisdomainname,
+ CTLTYPE_STRING | CTLFLAG_RW,
+ 0, 0, sysctl_domainname, "A", "");
+
+SYSCTL_COMPAT_INT(_kern, KERN_HOSTID, hostid,
+ CTLFLAG_RW | CTLFLAG_KERN,
+ &hostid, 0, "");
+
+static int
+sysctl_hostname
+(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
+{
+ int error, changed;
+ error = sysctl_io_string(req, hostname, sizeof(hostname), 1, &changed);
+ if (changed) {
+ hostnamelen = req->newlen;
+ }
+ return(error);
+}
+
+
+SYSCTL_PROC(_kern, KERN_HOSTNAME, hostname,
+ CTLTYPE_STRING | CTLFLAG_RW,
+ 0, 0, sysctl_hostname, "A", "");
+
+static int
+sysctl_procname
+(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
+{
+ /* Original code allowed writing, I'm copying this, although this all makes
+ no sense to me. Besides, this sysctl is never used. */
+ return sysctl_io_string(req, &req->p->p_name[0], (2*MAXCOMLEN+1), 1, NULL);
+}
+
+SYSCTL_PROC(_kern, KERN_PROCNAME, procname,
+ CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_ANYBODY,
+ 0, 0, sysctl_procname, "A", "");
+
+SYSCTL_INT(_kern, KERN_SPECULATIVE_READS, speculative_reads_disabled,
+ CTLFLAG_RW | CTLFLAG_KERN,
+ &speculative_reads_disabled, 0, "");
+
+SYSCTL_UINT(_kern, OID_AUTO, preheat_pages_max,
+ CTLFLAG_RW | CTLFLAG_KERN,
+ &preheat_pages_max, 0, "");
+
+SYSCTL_UINT(_kern, OID_AUTO, preheat_pages_min,
+ CTLFLAG_RW | CTLFLAG_KERN,
+ &preheat_pages_min, 0, "");
+
+SYSCTL_UINT(_kern, OID_AUTO, preheat_pages_mult,
+ CTLFLAG_RW | CTLFLAG_KERN,
+ &preheat_pages_mult, 0, "");
+
+static int
+sysctl_boottime
+(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
+{
+ time_t tv_sec = boottime_sec();
+ struct proc *p = req->p;
+
+ if (proc_is64bit(p)) {
+ struct user64_timeval t;
+ t.tv_sec = tv_sec;
+ t.tv_usec = 0;
+ return sysctl_io_opaque(req, &t, sizeof(t), NULL);
+ } else {
+ struct user32_timeval t;
+ t.tv_sec = tv_sec;
+ t.tv_usec = 0;
+ return sysctl_io_opaque(req, &t, sizeof(t), NULL);
+ }
+}
+
+SYSCTL_PROC(_kern, KERN_BOOTTIME, boottime,
+ CTLTYPE_STRUCT | CTLFLAG_RD,
+ 0, 0, sysctl_boottime, "S,timeval", "");
+
+static int
+sysctl_symfile
+(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
+{
+ char *str;
+ int error = get_kernel_symfile(req->p, &str);
+ if (error)
+ return (error);
+ return sysctl_io_string(req, str, 0, 0, NULL);
+}
+
+
+SYSCTL_PROC(_kern, KERN_SYMFILE, symfile,
+ CTLTYPE_STRING | CTLFLAG_RD,
+ 0, 0, sysctl_symfile, "A", "");
+
+#if NFSCLIENT
+static int
+sysctl_netboot
+(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
+{
+ return sysctl_io_number(req, netboot_root(), sizeof(int), NULL, NULL);
+}
+
+SYSCTL_PROC(_kern, KERN_NETBOOT, netboot,
+ CTLTYPE_INT | CTLFLAG_RD,
+ 0, 0, sysctl_netboot, "I", "");
+#endif
+
+#ifdef CONFIG_IMGSRC_ACCESS
+static int
+sysctl_imgsrcdev
+(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
+{
+ vfs_context_t ctx = vfs_context_current();
+ vnode_t devvp;
+ int result;
+
+ if (!vfs_context_issuser(ctx)) {
+ return EPERM;
+ }
+
+ if (imgsrc_rootvnode == NULL) {
+ return ENOENT;
+ }
+
+ result = vnode_getwithref(imgsrc_rootvnode);
+ if (result != 0) {
+ return result;
+ }
+
+ devvp = vnode_mount(imgsrc_rootvnode)->mnt_devvp;
+ result = vnode_getwithref(devvp);
+ if (result != 0) {
+ goto out;
+ }
+
+ result = sysctl_io_number(req, vnode_specrdev(devvp), sizeof(dev_t), NULL, NULL);
+
+ vnode_put(devvp);
+out:
+ vnode_put(imgsrc_rootvnode);
+ return result;
+}
+
+SYSCTL_PROC(_kern, OID_AUTO, imgsrcdev,
+ CTLTYPE_INT | CTLFLAG_RD,
+ 0, 0, sysctl_imgsrcdev, "I", "");
+#endif /* CONFIG_IMGSRC_ACCESS */
+
+static int
+sysctl_usrstack
+(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
+{
+ return sysctl_io_number(req, (int)req->p->user_stack, sizeof(int), NULL, NULL);
+}
+
+SYSCTL_PROC(_kern, KERN_USRSTACK32, usrstack,
+ CTLTYPE_INT | CTLFLAG_RD,
+ 0, 0, sysctl_usrstack, "I", "");
+
+static int
+sysctl_usrstack64
+(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
+{
+ return sysctl_io_number(req, req->p->user_stack, sizeof(req->p->user_stack), NULL, NULL);
+}
+
+SYSCTL_PROC(_kern, KERN_USRSTACK64, usrstack64,
+ CTLTYPE_QUAD | CTLFLAG_RD,
+ 0, 0, sysctl_usrstack64, "Q", "");
+
+SYSCTL_STRING(_kern, KERN_COREFILE, corefile,
+ CTLFLAG_RW | CTLFLAG_KERN,
+ corefilename, sizeof(corefilename), "");
+
+static int
+sysctl_coredump
+(__unused struct sysctl_oid *oidp, __unused void *arg1, __unused int arg2, struct sysctl_req *req)
+{
+#ifdef SECURE_KERNEL
+ return (ENOTSUP);
+#endif
+ int new_value, changed;
+ int error = sysctl_io_number(req, do_coredump, sizeof(int), &new_value, &changed);
+ if (changed) {
+ if ((new_value == 0) || (new_value == 1))
+ do_coredump = new_value;