Skip to contentSkip to conversation

nfs-utils - 4 of 6 - nfsstat - removed needless warning

PATCH In review Steve Dickson 2 participants 2 messages Jun 18, 2003 – Jul 2, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfs-utils - 4 of 6 - nfsstat - removed needless warning

Reworked the diagnostics of nfsstat so warnings
are not displayed for statistics that are not
asked for and don't exist.

SteveD.

utils/nfsstat/nfsstat.c renamed from utils/nfsstat/nfsstat.c.org +23 -5
@@ -124,6 +124,8 @@
 	int		opt_all = 0,
 			opt_srv = 0,
 			opt_clt = 0,
+			srv_info = 0,
+			clt_info = 0,
 			opt_prt = 0;
 	int		c;
 
@@ -184,9 +186,25 @@
 			"server.\n");
 	}
 
-	if ((opt_srv && !parse_statfile(NFSSVCSTAT, svcinfo))
-	 || (opt_clt && !parse_statfile(NFSCLTSTAT, cltinfo)))
-		return 2;
+	if (opt_srv) {
+		srv_info = parse_statfile(NFSSVCSTAT, svcinfo);
+		if (srv_info == 0 && opt_clt == 0) {
+			fprintf(stderr, "Warning: No Server Stats (%s: %m).\n", NFSSVCSTAT);
+			return 2;
+		}
+		if (srv_info == 0)
+			opt_srv = 0;
+	}
+
+	if (opt_clt) {
+		clt_info = parse_statfile(NFSCLTSTAT, cltinfo);
+		if (opt_srv == 0 && clt_info == 0) {
+			fprintf(stderr, "Warning: No Client Stats (%s: %m).\n", NFSCLTSTAT);
+			return 2;
+		}
+		if (clt_info == 0)
+			opt_clt = 0;
+	}
 
 	if (opt_srv) {
 		if (opt_prt & PRNT_NET) {
@@ -338,8 +356,8 @@
 	 * be a fatal error -- it usually means the module isn't loaded.
 	 */
 	if ((fp = fopen(name, "r")) == NULL) {
-		fprintf(stderr, "Warning: %s: %m\n", name);
-		return 1;
+		// fprintf(stderr, "Warning: %s: %m\n", name);
+		return 0;
 	}
 
 	while (fgets(buffer, sizeof(buffer), fp) != NULL) {
#1 lore raw
Quoted 4 lines · On Wednesday June 18, [email protected] wrote:

Reworked the diagnostics of nfsstat so warnings
are not displayed for statistics that are not
asked for and don't exist.

I've committed this and the two mountd patches to CVS.

NeilBrown

-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs