Blame SOURCES/0012-Add-option-to-display-mountpoint-names-instead-of-fi.patch

9a8d55
From b8eaf0cce7cbed0eb56e9fc509961269d718d096 Mon Sep 17 00:00:00 2001
9a8d55
From: Steve Kay <stevekay@gmail.com>
9a8d55
Date: Fri, 13 Mar 2015 15:24:10 -0700
9a8d55
Subject: [PATCH] Add option to display mountpoint names instead of filesystem
9a8d55
 names.
9a8d55
9a8d55
(cherry picked from commit d91ecce584d7dedf194714a4d189ecfba6276f6c)
9a8d55
---
9a8d55
 man/sar.in  | 23 ++++++++++++++---------
9a8d55
 pr_stats.c  | 11 ++++++-----
9a8d55
 rd_stats.c  |  1 +
9a8d55
 rd_stats.h  |  1 +
9a8d55
 sa.h        |  5 +++++
9a8d55
 sa_common.c |  6 ++++++
9a8d55
 sar.c       |  5 +++--
9a8d55
 7 files changed, 36 insertions(+), 16 deletions(-)
9a8d55
9a8d55
diff --git a/man/sar.in b/man/sar.in
9a8d55
index 6d964b3..4ea6ca0 100644
9a8d55
--- a/man/sar.in
9a8d55
+++ b/man/sar.in
9a8d55
@@ -315,17 +315,22 @@ value is close to 100%.
9a8d55
 Set the ending time of the report. The default ending time is
9a8d55
 18:00:00. Hours must be given in 24-hour format.
9a8d55
 This option can be used when data are read from
9a8d55
-or written to a file (options
9a8d55
-.B -f
9a8d55
-or
9a8d55
-.B -o
9a8d55
-).
9a8d55
-.IP -F
9a8d55
+or written to a file (options -f or -o).
9a8d55
+.IP "-F [ MOUNT ]"
9a8d55
 Display statistics for currently mounted filesystems. Pseudo-filesystems are
9a8d55
-ignored. At the end of the report,
9a8d55
-.B sar
9a8d55
+ignored.  At the end of the report, 
9a8d55
+.B sar 
9a8d55
 will display a summary of all those filesystems.
9a8d55
-Note that filesystems statistics depend on sadc option "-S XDISK" to be collected.
9a8d55
+Note that filesystems statistics depend on
9a8d55
+.B sadc
9a8d55
+option
9a8d55
+.B "-S XDISK"
9a8d55
+to be collected.
9a8d55
+Use of the 
9a8d55
+.B MOUNT
9a8d55
+parameter keyword indicates that mountpoint will be reported instead of 
9a8d55
+filesystem device.
9a8d55
+
9a8d55
 The following values are displayed:
9a8d55
 
9a8d55
 .B MBfsfree
9a8d55
diff --git a/pr_stats.c b/pr_stats.c
9a8d55
index d1edb5b..5bee25f 100644
9a8d55
--- a/pr_stats.c
9a8d55
+++ b/pr_stats.c
9a8d55
@@ -2454,11 +2454,11 @@ __print_funct_t stub_print_filesystem_stats(struct activity *a, int curr, int di
9a8d55
 	int i, j;
9a8d55
 	struct stats_filesystem *sfc, *sfm;
9a8d55
 
9a8d55
-	
9a8d55
 	if (dis) {
9a8d55
 		printf("\n%-11s  MBfsfree  MBfsused   %%fsused  %%ufsused"
9a8d55
-		       "     Ifree     Iused    %%Iused FILESYSTEM\n",
9a8d55
-		       (dispavg ? _("Summary") : timestamp[!curr]));
9a8d55
+		       "     Ifree     Iused    %%Iused %s\n",
9a8d55
+		       (dispavg ? _("Summary:") : timestamp[!curr]),
9a8d55
+		       DISPLAY_MOUNT(a->opt_flags) ? _("MOUNTPOINT") : _("FILESYSTEM"));
9a8d55
 	}
9a8d55
 
9a8d55
 	for (i = 0; i < a->nr; i++) {
9a8d55
@@ -2482,8 +2482,9 @@ __print_funct_t stub_print_filesystem_stats(struct activity *a, int curr, int di
9a8d55
 		       sfc->f_files - sfc->f_ffree,
9a8d55
 		       sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
9a8d55
 				    : 0.0,
9a8d55
-		       sfc->fs_name);
9a8d55
-		
9a8d55
+
9a8d55
+		       DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name);
9a8d55
+
9a8d55
 		if (!dispavg) {
9a8d55
 			/* Save current filesystem in summary list */
9a8d55
 			for (j = 0; j < a->nr; j++) {
9a8d55
diff --git a/rd_stats.c b/rd_stats.c
9a8d55
index c3ef70f..24a98f7 100644
9a8d55
--- a/rd_stats.c
9a8d55
+++ b/rd_stats.c
9a8d55
@@ -1942,6 +1942,7 @@ void read_filesystem(struct stats_filesystem *st_filesystem, int nbr)
9a8d55
 			st_filesystem_i->f_files  = buf.f_files;
9a8d55
 			st_filesystem_i->f_ffree  = buf.f_ffree;
9a8d55
 			strcpy(st_filesystem_i->fs_name, fs_name);
9a8d55
+			strcpy(st_filesystem_i->mountp, mountp);
9a8d55
 		}
9a8d55
 	}
9a8d55
 
9a8d55
diff --git a/rd_stats.h b/rd_stats.h
9a8d55
index 279178f..d958104 100644
9a8d55
--- a/rd_stats.h
9a8d55
+++ b/rd_stats.h
9a8d55
@@ -531,6 +531,7 @@ struct stats_filesystem {
9a8d55
 	unsigned long long f_files		__attribute__ ((aligned (16)));
9a8d55
 	unsigned long long f_ffree		__attribute__ ((aligned (16)));
9a8d55
 	char 		   fs_name[MAX_FS_LEN]	__attribute__ ((aligned (16)));
9a8d55
+	char 		   mountp[MAX_FS_LEN]	__attribute__ ((aligned (16)));
9a8d55
 };
9a8d55
 
9a8d55
 #define STATS_FILESYSTEM_SIZE	(sizeof(struct stats_filesystem))
9a8d55
diff --git a/sa.h b/sa.h
9a8d55
index eb2a426..7d24f2d 100644
9a8d55
--- a/sa.h
9a8d55
+++ b/sa.h
9a8d55
@@ -129,6 +129,11 @@
9a8d55
 
9a8d55
 #define COLLECT_PARTITIONS(m)	(((m) & AO_F_DISK_PART)   == AO_F_DISK_PART)
9a8d55
 
9a8d55
+/* Output flags for option -F */
9a8d55
+#define AO_F_MOUNT		0x00000001
9a8d55
+
9a8d55
+#define DISPLAY_MOUNT(m)	(((m) & AO_F_MOUNT)       == AO_F_MOUNT)
9a8d55
+
9a8d55
 /*
9a8d55
  ***************************************************************************
9a8d55
  * Various keywords and constants.
9a8d55
diff --git a/sa_common.c b/sa_common.c
9a8d55
index 3ccf24b..2206e9f 100644
9a8d55
--- a/sa_common.c
9a8d55
+++ b/sa_common.c
9a8d55
@@ -1284,6 +1284,12 @@ int parse_sar_opt(char *argv[], int *opt, struct activity *act[],
9a8d55
 
9a8d55
 		case 'F':
9a8d55
 			SELECT_ACTIVITY(A_FILESYSTEM);
9a8d55
+			p = get_activity_position(act, A_FILESYSTEM);
9a8d55
+			if (!*(argv[*opt] + i + 1) && argv[*opt + 1] && !strcmp(argv[*opt + 1], "MOUNT")) {
9a8d55
+				(*opt)++;
9a8d55
+				act[p]->opt_flags |= AO_F_MOUNT;
9a8d55
+				return 0;
9a8d55
+			}
9a8d55
 			break;
9a8d55
 			
9a8d55
 		case 'H':
9a8d55
diff --git a/sar.c b/sar.c
9a8d55
index 2674810..5dfd915 100644
9a8d55
--- a/sar.c
9a8d55
+++ b/sar.c
9a8d55
@@ -107,7 +107,7 @@ void usage(char *progname)
9a8d55
 {
9a8d55
 	print_usage_title(stderr, progname);
9a8d55
 	fprintf(stderr, _("Options are:\n"
9a8d55
-			  "[ -A ] [ -B ] [ -b ] [ -C ] [ -d ] [ -F ] [ -H ] [ -h ] [ -p ] [ -q ] [ -R ]\n"
9a8d55
+			  "[ -A ] [ -B ] [ -b ] [ -C ] [ -d ] [ -F [ MOUNTS ] ] [ -H ] [ -h ] [ -p ] [ -q ] [ -R ]\n"
9a8d55
 			  "[ -r ] [ -S ] [ -t ] [ -u [ ALL ] ] [ -V ] [ -v ] [ -W ] [ -w ] [ -y ]\n"
9a8d55
 			  "[ -I { <int> [,...] | SUM | ALL | XALL } ] [ -P { <cpu> [,...] | ALL } ]\n"
9a8d55
 			  "[ -m { <keyword> [,...] | ALL } ] [ -n { <keyword> [,...] | ALL } ]\n"
9a8d55
@@ -132,7 +132,8 @@ void display_help(char *progname)
9a8d55
 	printf(_("\t-b\tI/O and transfer rate statistics\n"));
9a8d55
 	printf(_("\t-B\tPaging statistics\n"));
9a8d55
 	printf(_("\t-d\tBlock device statistics\n"));
9a8d55
-	printf(_("\t-F\tFilesystems statistics\n"));
9a8d55
+	printf(_("\t-F [ MOUNTS ]\n"));
9a8d55
+	printf(_("\t\tFilesystems statistics\n"));
9a8d55
 	printf(_("\t-H\tHugepages utilization statistics\n"));
9a8d55
 	printf(_("\t-I { <int> | SUM | ALL | XALL }\n"
9a8d55
 		 "\t\tInterrupts statistics\n"));
9a8d55
-- 
9a8d55
2.14.3
9a8d55