aboutsummaryrefslogtreecommitdiff
path: root/daemon/KMod.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/KMod.cpp')
-rw-r--r--daemon/KMod.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/daemon/KMod.cpp b/daemon/KMod.cpp
index 559297f..9300002 100644
--- a/daemon/KMod.cpp
+++ b/daemon/KMod.cpp
@@ -1,5 +1,5 @@
/**
- * Copyright (C) ARM Limited 2013. All rights reserved.
+ * Copyright (C) ARM Limited 2013-2014. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -12,9 +12,9 @@
#include <dirent.h>
#include <unistd.h>
-#include "Collector.h"
#include "ConfigurationXML.h"
#include "Counter.h"
+#include "DriverSource.h"
#include "Logging.h"
// Claim all the counters in /dev/gator/events
@@ -38,9 +38,9 @@ void KMod::resetCounters() {
continue;
snprintf(base, sizeof(base), "/dev/gator/events/%s", ent->d_name);
snprintf(text, sizeof(text), "%s/enabled", base);
- Collector::writeDriver(text, 0);
+ DriverSource::writeDriver(text, 0);
snprintf(text, sizeof(text), "%s/count", base);
- Collector::writeDriver(text, 0);
+ DriverSource::writeDriver(text, 0);
}
closedir(dir);
}
@@ -53,22 +53,22 @@ void KMod::setupCounter(Counter &counter) {
snprintf(text, sizeof(text), "%s/enabled", base);
int enabled = true;
- if (Collector::writeReadDriver(text, &enabled) || !enabled) {
+ if (DriverSource::writeReadDriver(text, &enabled) || !enabled) {
counter.setEnabled(false);
return;
}
snprintf(text, sizeof(text), "%s/key", base);
int key = 0;
- Collector::readIntDriver(text, &key);
+ DriverSource::readIntDriver(text, &key);
counter.setKey(key);
snprintf(text, sizeof(text), "%s/event", base);
- Collector::writeDriver(text, counter.getEvent());
+ DriverSource::writeDriver(text, counter.getEvent());
snprintf(text, sizeof(text), "%s/count", base);
if (access(text, F_OK) == 0) {
int count = counter.getCount();
- if (Collector::writeReadDriver(text, &count) && counter.getCount() > 0) {
+ if (DriverSource::writeReadDriver(text, &count) && counter.getCount() > 0) {
logg->logError(__FILE__, __LINE__, "Cannot enable EBS for %s:%i with a count of %d\n", counter.getType(), counter.getEvent(), counter.getCount());
handleException();
}
@@ -80,23 +80,26 @@ void KMod::setupCounter(Counter &counter) {
}
}
-void KMod::writeCounters(mxml_node_t *root) const {
+int KMod::writeCounters(mxml_node_t *root) const {
struct dirent *ent;
mxml_node_t *counter;
// counters.xml is simply a file listing of /dev/gator/events
DIR* dir = opendir("/dev/gator/events");
if (dir == NULL) {
- logg->logError(__FILE__, __LINE__, "Cannot create counters.xml since unable to read /dev/gator/events");
- handleException();
+ return 0;
}
+ int count = 0;
while ((ent = readdir(dir)) != NULL) {
// skip hidden files, current dir, and parent dir
if (ent->d_name[0] == '.')
continue;
counter = mxmlNewElement(root, "counter");
mxmlElementSetAttr(counter, "name", ent->d_name);
+ ++count;
}
closedir(dir);
+
+ return count;
}