Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_sysctl.c
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | |||||
#define SYSCTL_ASSERT_LOCKED() rm_assert(&sysctllock, RA_LOCKED) | #define SYSCTL_ASSERT_LOCKED() rm_assert(&sysctllock, RA_LOCKED) | ||||
#define SYSCTL_ASSERT_WLOCKED() rm_assert(&sysctllock, RA_WLOCKED) | #define SYSCTL_ASSERT_WLOCKED() rm_assert(&sysctllock, RA_WLOCKED) | ||||
#define SYSCTL_ASSERT_RLOCKED() rm_assert(&sysctllock, RA_RLOCKED) | #define SYSCTL_ASSERT_RLOCKED() rm_assert(&sysctllock, RA_RLOCKED) | ||||
#define SYSCTL_INIT() rm_init_flags(&sysctllock, "sysctl lock", \ | #define SYSCTL_INIT() rm_init_flags(&sysctllock, "sysctl lock", \ | ||||
RM_SLEEPABLE) | RM_SLEEPABLE) | ||||
#define SYSCTL_SLEEP(ch, wmesg, timo) \ | #define SYSCTL_SLEEP(ch, wmesg, timo) \ | ||||
rm_sleep(ch, &sysctllock, 0, wmesg, timo) | rm_sleep(ch, &sysctllock, 0, wmesg, timo) | ||||
static void sysctl_fetch_fqname(struct sysctl_oid *, struct sbuf *); | |||||
static int sysctl_root(SYSCTL_HANDLER_ARGS); | static int sysctl_root(SYSCTL_HANDLER_ARGS); | ||||
/* Root list */ | /* Root list */ | ||||
struct sysctl_oid_list sysctl__children = SLIST_HEAD_INITIALIZER(&sysctl__children); | struct sysctl_oid_list sysctl__children = SLIST_HEAD_INITIALIZER(&sysctl__children); | ||||
static int sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, | static int sysctl_remove_oid_locked(struct sysctl_oid *oidp, int del, | ||||
int recurse); | int recurse); | ||||
static int sysctl_old_kernel(struct sysctl_req *, const void *, size_t); | static int sysctl_old_kernel(struct sysctl_req *, const void *, size_t); | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | sysctl_root_handler_locked(struct sysctl_oid *oid, void *arg1, intmax_t arg2, | ||||
if (oid->oid_kind & CTLFLAG_DYN) | if (oid->oid_kind & CTLFLAG_DYN) | ||||
atomic_add_int(&oid->oid_running, 1); | atomic_add_int(&oid->oid_running, 1); | ||||
if (tracker != NULL) | if (tracker != NULL) | ||||
SYSCTL_RUNLOCK(tracker); | SYSCTL_RUNLOCK(tracker); | ||||
else | else | ||||
SYSCTL_WUNLOCK(); | SYSCTL_WUNLOCK(); | ||||
if ((oid->oid_kind & CTLFLAG_DEPRECATED) != 0) { | |||||
struct sbuf *sb; | |||||
sb = sbuf_new_auto(); | |||||
sysctl_fetch_fqname(oid, sb); | |||||
sbuf_finish(sb); | |||||
printf("Deprecated sysctl (to be removed in a future version): %s\n", | |||||
sbuf_data(sb)); | |||||
sbuf_delete(sb); | |||||
} | |||||
if (!(oid->oid_kind & CTLFLAG_MPSAFE)) | if (!(oid->oid_kind & CTLFLAG_MPSAFE)) | ||||
mtx_lock(&Giant); | mtx_lock(&Giant); | ||||
error = oid->oid_handler(oid, arg1, arg2, req); | error = oid->oid_handler(oid, arg1, arg2, req); | ||||
if (!(oid->oid_kind & CTLFLAG_MPSAFE)) | if (!(oid->oid_kind & CTLFLAG_MPSAFE)) | ||||
mtx_unlock(&Giant); | mtx_unlock(&Giant); | ||||
KFAIL_POINT_ERROR(_debug_fail_point, sysctl_running, error); | KFAIL_POINT_ERROR(_debug_fail_point, sysctl_running, error); | ||||
▲ Show 20 Lines • Show All 179 Lines • ▼ Show 20 Lines | while (indx < CTL_MAXNAME && indx >= 0) { | ||||
} | } | ||||
if ((nodes[indx]->oid_kind & CTLTYPE) == CTLTYPE_NODE) { | if ((nodes[indx]->oid_kind & CTLTYPE) == CTLTYPE_NODE) { | ||||
indx++; | indx++; | ||||
continue; | continue; | ||||
} | } | ||||
} | } | ||||
return (-1); | return (-1); | ||||
} | |||||
static void | |||||
sysctl_fetch_fqname(struct sysctl_oid *oid, struct sbuf *sb) | |||||
{ | |||||
struct sysctl_oid *parent; | |||||
if ((parent = SYSCTL_PARENT(oid)) != NULL) { | |||||
sysctl_fetch_fqname(parent, sb); | |||||
sbuf_printf(sb, ".%s", oid->oid_name); | |||||
} else { | |||||
sbuf_printf(sb, "%s", oid->oid_name); | |||||
} | |||||
} | } | ||||
static void | static void | ||||
sysctl_warn_reuse(const char *func, struct sysctl_oid *leaf) | sysctl_warn_reuse(const char *func, struct sysctl_oid *leaf) | ||||
{ | { | ||||
struct sysctl_oid *nodes[CTL_MAXNAME]; | struct sysctl_oid *nodes[CTL_MAXNAME]; | ||||
char buf[128]; | char buf[128]; | ||||
struct sbuf sb; | struct sbuf sb; | ||||
▲ Show 20 Lines • Show All 2,464 Lines • Show Last 20 Lines |