|
|
9a8d55 |
From f18b5d452e11bad46473d019e41fb7e43a5708ca Mon Sep 17 00:00:00 2001
|
|
|
9a8d55 |
From: Ondrej Dubaj <odubaj@redhat.com>
|
|
|
9a8d55 |
Date: Thu, 28 Feb 2019 15:29:08 +0100
|
|
|
9a8d55 |
Subject: [PATCH] ignoring autofs as real filesystem by counting number of
|
|
|
9a8d55 |
valid filesystems and getting all valid filesystems
|
|
|
9a8d55 |
|
|
|
9a8d55 |
(cherry-picked from commit 5b5339d06c4f50730e5cc679e0854ce716f39117)
|
|
|
9a8d55 |
---
|
|
|
9a8d55 |
rd_stats.c | 35 +++++++++++++++++++++++++++++++----
|
|
|
9a8d55 |
1 file changed, 31 insertions(+), 4 deletions(-)
|
|
|
9a8d55 |
|
|
|
9a8d55 |
diff --git a/rd_stats.c b/rd_stats.c
|
|
|
9a8d55 |
index c054b58..8114428 100644
|
|
|
9a8d55 |
--- a/rd_stats.c
|
|
|
9a8d55 |
+++ b/rd_stats.c
|
|
|
9a8d55 |
@@ -1915,9 +1915,9 @@ void read_bus_usb_dev(struct stats_pwr_usb *st_pwr_usb, int nbr)
|
|
|
9a8d55 |
void read_filesystem(struct stats_filesystem *st_filesystem, int nbr)
|
|
|
9a8d55 |
{
|
|
|
9a8d55 |
FILE *fp;
|
|
|
9a8d55 |
- char line[512], fs_name[128], mountp[256];
|
|
|
9a8d55 |
+ char line[512], fs_name[128], mountp[256], type[128];
|
|
|
9a8d55 |
int fs = 0, skip = 0, skip_next = 0;
|
|
|
9a8d55 |
- char *pos = 0;
|
|
|
9a8d55 |
+ char *pos = 0, *pos2 = NULL;
|
|
|
9a8d55 |
struct stats_filesystem *st_filesystem_i;
|
|
|
9a8d55 |
struct statvfs buf;
|
|
|
9a8d55 |
|
|
|
9a8d55 |
@@ -1941,6 +1941,20 @@ void read_filesystem(struct stats_filesystem *st_filesystem, int nbr)
|
|
|
9a8d55 |
if (pos == NULL)
|
|
|
9a8d55 |
continue;
|
|
|
9a8d55 |
|
|
|
9a8d55 |
+ /*
|
|
|
9a8d55 |
+ * Find second field separator position,
|
|
|
9a8d55 |
+ * read filesystem type,
|
|
|
9a8d55 |
+ * if filesystem type is autofs, skip it
|
|
|
9a8d55 |
+ */
|
|
|
9a8d55 |
+ memset(type, 0, sizeof(type));
|
|
|
9a8d55 |
+ pos2 = strchr(pos + 1, ' ');
|
|
|
9a8d55 |
+ if (pos2 == NULL)
|
|
|
9a8d55 |
+ continue;
|
|
|
9a8d55 |
+
|
|
|
9a8d55 |
+ sscanf(pos2 + 1, "%127s", type);
|
|
|
9a8d55 |
+ if(strcmp(type, "autofs") == 0)
|
|
|
9a8d55 |
+ continue;
|
|
|
9a8d55 |
+
|
|
|
9a8d55 |
/* Read current filesystem name */
|
|
|
9a8d55 |
sscanf(line, "%127s", fs_name);
|
|
|
9a8d55 |
/*
|
|
|
9a8d55 |
@@ -2411,9 +2425,9 @@ int get_usb_nr(void)
|
|
|
9a8d55 |
int get_filesystem_nr(void)
|
|
|
9a8d55 |
{
|
|
|
9a8d55 |
FILE *fp;
|
|
|
9a8d55 |
- char line[512], fs_name[MAX_FS_LEN], mountp[256];
|
|
|
9a8d55 |
+ char line[512], fs_name[MAX_FS_LEN], mountp[256], type[128];
|
|
|
9a8d55 |
int fs = 0, skip = 0, skip_next = 0;
|
|
|
9a8d55 |
- char *pos = 0;
|
|
|
9a8d55 |
+ char *pos = 0, *pos2 = NULL;
|
|
|
9a8d55 |
|
|
|
9a8d55 |
struct statvfs buf;
|
|
|
9a8d55 |
|
|
|
9a8d55 |
@@ -2438,6 +2452,19 @@ int get_filesystem_nr(void)
|
|
|
9a8d55 |
pos = strchr(line, ' ');
|
|
|
9a8d55 |
if (pos == NULL)
|
|
|
9a8d55 |
continue;
|
|
|
9a8d55 |
+ /*
|
|
|
9a8d55 |
+ * Find second field separator position,
|
|
|
9a8d55 |
+ * read filesystem type,
|
|
|
9a8d55 |
+ * if filesystem type is autofs, skip it
|
|
|
9a8d55 |
+ */
|
|
|
9a8d55 |
+ memset(type, 0, sizeof(type));
|
|
|
9a8d55 |
+ pos2 = strchr(pos + 1, ' ');
|
|
|
9a8d55 |
+ if (pos2 == NULL)
|
|
|
9a8d55 |
+ continue;
|
|
|
9a8d55 |
+
|
|
|
9a8d55 |
+ sscanf(pos2 + 1, "%127s", type);
|
|
|
9a8d55 |
+ if(strcmp(type, "autofs") == 0)
|
|
|
9a8d55 |
+ continue;
|
|
|
9a8d55 |
|
|
|
9a8d55 |
/* Read filesystem name and mount point */
|
|
|
9a8d55 |
sscanf(line, "%127s", fs_name);
|
|
|
9a8d55 |
--
|
|
|
9a8d55 |
2.17.2
|
|
|
9a8d55 |
|