|
|
72abff |
From 446f287e43f87b090c65bb17e397bd5e73101e34 Mon Sep 17 00:00:00 2001
|
|
|
72abff |
From: Sebastien GODARD <sysstat@orange.fr.fake>
|
|
|
72abff |
Date: Thu, 30 May 2013 22:26:18 +0200
|
|
|
72abff |
Subject: [PATCH] Handle octal codes in filesystems mount point names
|
|
|
72abff |
|
|
|
72abff |
sar -F was unable to get statistics about filesystems whose mount points
|
|
|
72abff |
(as given by /etc/mtab file) had octal codes in their names.
|
|
|
72abff |
So now sar replaces those octal codes with their corresponding
|
|
|
72abff |
characters before trying to collect stats about them.
|
|
|
72abff |
|
|
|
72abff |
(cherry picked from commit 919f10827b763d13427672515f18aa27c93c01bf)
|
|
|
72abff |
---
|
|
|
72abff |
rd_stats.c | 42 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
72abff |
rd_stats.h | 2 ++
|
|
|
72abff |
2 files changed, 44 insertions(+)
|
|
|
72abff |
|
|
|
72abff |
diff --git a/rd_stats.c b/rd_stats.c
|
|
|
72abff |
index 829dae5..c3ef70f 100644
|
|
|
72abff |
--- a/rd_stats.c
|
|
|
72abff |
+++ b/rd_stats.c
|
|
|
72abff |
@@ -42,6 +42,42 @@
|
|
|
72abff |
#define _(string) (string)
|
|
|
72abff |
#endif
|
|
|
72abff |
|
|
|
72abff |
+/*
|
|
|
72abff |
+ ***************************************************************************
|
|
|
72abff |
+ * Replace octal codes in string with their corresponding characters.
|
|
|
72abff |
+ *
|
|
|
72abff |
+ * IN:
|
|
|
72abff |
+ * str String to parse.
|
|
|
72abff |
+ *
|
|
|
72abff |
+ * OUT:
|
|
|
72abff |
+ * @str String with octal codes replaced with characters.
|
|
|
72abff |
+ ***************************************************************************
|
|
|
72abff |
+ */
|
|
|
72abff |
+void oct2chr(char *str)
|
|
|
72abff |
+{
|
|
|
72abff |
+ int i = 0;
|
|
|
72abff |
+ int j, len;
|
|
|
72abff |
+
|
|
|
72abff |
+ len = strlen(str);
|
|
|
72abff |
+
|
|
|
72abff |
+ while (i < len - 3) {
|
|
|
72abff |
+ if ((str[i] == '\\') &&
|
|
|
72abff |
+ (str[i + 1] >= '0') && (str[i + 1] <= '3') &&
|
|
|
72abff |
+ (str[i + 2] >= '0') && (str[i + 2] <= '7') &&
|
|
|
72abff |
+ (str[i + 3] >= '0') && (str[i + 3] <= '7')) {
|
|
|
72abff |
+ /* Octal code found */
|
|
|
72abff |
+ str[i] = (str[i + 1] - 48) * 64 +
|
|
|
72abff |
+ (str[i + 2] - 48) * 8 +
|
|
|
72abff |
+ (str[i + 3] - 48);
|
|
|
72abff |
+ for (j = i + 4; j <= len; j++) {
|
|
|
72abff |
+ str[j - 3] = str[j];
|
|
|
72abff |
+ }
|
|
|
72abff |
+ len -= 3;
|
|
|
72abff |
+ }
|
|
|
72abff |
+ i++;
|
|
|
72abff |
+ }
|
|
|
72abff |
+}
|
|
|
72abff |
+
|
|
|
72abff |
/*
|
|
|
72abff |
***************************************************************************
|
|
|
72abff |
* Read CPU statistics and machine uptime.
|
|
|
72abff |
@@ -1893,6 +1929,9 @@ void read_filesystem(struct stats_filesystem *st_filesystem, int nbr)
|
|
|
72abff |
/* Read current filesystem name and mount point */
|
|
|
72abff |
sscanf(line, "%71s %127s", fs_name, mountp);
|
|
|
72abff |
|
|
|
72abff |
+ /* Replace octal codes */
|
|
|
72abff |
+ oct2chr(mountp);
|
|
|
72abff |
+
|
|
|
72abff |
if ((statfs(mountp, &buf) < 0) || (!buf.f_blocks))
|
|
|
72abff |
continue;
|
|
|
72abff |
|
|
|
72abff |
@@ -2354,6 +2393,9 @@ int get_filesystem_nr(void)
|
|
|
72abff |
|
|
|
72abff |
/* Read filesystem name and mount point */
|
|
|
72abff |
sscanf(line, "%71s %127s", fs_name, mountp);
|
|
|
72abff |
+
|
|
|
72abff |
+ /* Replace octal codes */
|
|
|
72abff |
+ oct2chr(mountp);
|
|
|
72abff |
|
|
|
72abff |
/* Check that total size is not null */
|
|
|
72abff |
if (statfs(mountp, &buf) < 0)
|
|
|
72abff |
diff --git a/rd_stats.h b/rd_stats.h
|
|
|
72abff |
index 3f1edde..279178f 100644
|
|
|
72abff |
--- a/rd_stats.h
|
|
|
72abff |
+++ b/rd_stats.h
|
|
|
72abff |
@@ -541,6 +541,8 @@ struct stats_filesystem {
|
|
|
72abff |
***************************************************************************
|
|
|
72abff |
*/
|
|
|
72abff |
|
|
|
72abff |
+extern void
|
|
|
72abff |
+ oct2chr(char *);
|
|
|
72abff |
extern void
|
|
|
72abff |
read_stat_cpu(struct stats_cpu *, int,
|
|
|
72abff |
unsigned long long *, unsigned long long *);
|
|
|
72abff |
--
|
|
|
72abff |
2.14.3
|
|
|
72abff |
|