summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
8bccc43)
Share some of the existing statistics-gathering code by folding it
into a function, get_stats().
Signed-off-by: David M. Richter <richterd@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
static int mounts(const char *);
static int mounts(const char *);
+static void get_stats(const char *, statinfo *, int *, int, const char *);
static int has_stats(const unsigned int *);
#define PRNT_CALLS 0x0001
static int has_stats(const unsigned int *);
#define PRNT_CALLS 0x0001
int opt_all = 0,
opt_srv = 0,
opt_clt = 0,
int opt_all = 0,
opt_srv = 0,
opt_clt = 0,
- srv_info = 0,
- clt_info = 0,
opt_prt = 0;
int c;
char *progname;
opt_prt = 0;
int c;
char *progname;
- 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)
+ get_stats(NFSSVCSTAT, svcinfo, &opt_srv, opt_clt, "Server");
+ if (opt_clt)
+ get_stats(NFSCLTSTAT, cltinfo, &opt_clt, opt_srv, "Client");
if (opt_srv) {
if (opt_prt & PRNT_NET) {
if (opt_srv) {
if (opt_prt & PRNT_NET) {
+static void
+get_stats(const char *file, statinfo *info, int *opt, int other_opt, const char *label)
+{
+ if (!parse_statfile(file, info)) {
+ if (!other_opt) {
+ fprintf(stderr, "Warning: No %s Stats (%s: %m). \n", label, file);
+ exit(2);
+ }
+ *opt = 0;
+ }
+}
+
static int
has_stats(const unsigned int *info)
{
static int
has_stats(const unsigned int *info)
{