summaryrefslogtreecommitdiff
path: root/src/pmdas/linux/sysfs_kernel.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pmdas/linux/sysfs_kernel.c')
-rw-r--r--src/pmdas/linux/sysfs_kernel.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/pmdas/linux/sysfs_kernel.c b/src/pmdas/linux/sysfs_kernel.c
new file mode 100644
index 0000000..8880634
--- /dev/null
+++ b/src/pmdas/linux/sysfs_kernel.c
@@ -0,0 +1,41 @@
+/*
+ * Linux sysfs_kernel cluster
+ *
+ * Copyright (c) 2009,2014 Red Hat.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include "sysfs_kernel.h"
+#include "indom.h"
+
+int
+refresh_sysfs_kernel(sysfs_kernel_t *sk)
+{
+ char buf[MAXPATHLEN];
+ int fd, n;
+
+ snprintf(buf, sizeof(buf), "%s/sys/kernel/uevent_seqnum", linux_statspath);
+ if ((fd = open(buf, O_RDONLY)) < 0) {
+ sk->valid_uevent_seqnum = 0;
+ return -oserror();
+ }
+
+ if ((n = read(fd, buf, sizeof(buf))) <= 0)
+ sk->valid_uevent_seqnum = 0;
+ else {
+ buf[n-1] = '\0';
+ sscanf(buf, "%llu", (long long unsigned int *)&sk->uevent_seqnum);
+ sk->valid_uevent_seqnum = 1;
+ }
+ close(fd);
+ return 0;
+}