]> git.saurik.com Git - apple/xnu.git/blobdiff - iokit/Kernel/IOStatistics.cpp
xnu-7195.101.1.tar.gz
[apple/xnu.git] / iokit / Kernel / IOStatistics.cpp
index 20d9cc3efc72b7ff6086c49e18c8f83db8bb3d57..d0e87bf2447a945d7011dc34b9d91caa2a0577f2 100644 (file)
@@ -151,6 +151,10 @@ oid_sysctl(__unused struct sysctl_oid *oidp, __unused void *arg1, int arg2, stru
        int error = EINVAL;
        uint32_t request = arg2;
 
+       if (!IOStatistics::isEnabled()) {
+               return ENOENT;
+       }
+
        switch (request) {
        case kIOStatisticsGeneral:
                error = IOStatistics::getStatistics(req);
@@ -171,17 +175,18 @@ oid_sysctl(__unused struct sysctl_oid *oidp, __unused void *arg1, int arg2, stru
 SYSCTL_NODE(_debug, OID_AUTO, iokit_statistics, CTLFLAG_RW | CTLFLAG_LOCKED, NULL, "IOStatistics");
 
 static SYSCTL_PROC(_debug_iokit_statistics, OID_AUTO, general,
-    CTLTYPE_STRUCT | CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN | CTLFLAG_LOCKED,
+    CTLTYPE_STRUCT | CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED,
     NULL, kIOStatisticsGeneral, oid_sysctl, "S", "");
 
 static SYSCTL_PROC(_debug_iokit_statistics, OID_AUTO, workloop,
-    CTLTYPE_STRUCT | CTLFLAG_RD | CTLFLAG_NOAUTO | CTLFLAG_KERN | CTLFLAG_LOCKED,
+    CTLTYPE_STRUCT | CTLFLAG_RD | CTLFLAG_KERN | CTLFLAG_LOCKED,
     NULL, kIOStatisticsWorkLoop, oid_sysctl, "S", "");
 
 static SYSCTL_PROC(_debug_iokit_statistics, OID_AUTO, userclient,
-    CTLTYPE_STRUCT | CTLFLAG_RW | CTLFLAG_NOAUTO | CTLFLAG_KERN | CTLFLAG_LOCKED,
+    CTLTYPE_STRUCT | CTLFLAG_RW | CTLFLAG_KERN | CTLFLAG_LOCKED,
     NULL, kIOStatisticsUserClient, oid_sysctl, "S", "");
 
+
 void
 IOStatistics::initialize()
 {
@@ -194,10 +199,6 @@ IOStatistics::initialize()
                return;
        }
 
-       sysctl_register_oid(&sysctl__debug_iokit_statistics_general);
-       sysctl_register_oid(&sysctl__debug_iokit_statistics_workloop);
-       sysctl_register_oid(&sysctl__debug_iokit_statistics_userclient);
-
        lock = IORWLockAlloc();
        if (!lock) {
                return;