Blame SOURCES/0001-ignoring-autofs-as-real-filesystem-by-counting-numbe.patch

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