]> granicus.if.org Git - sysstat/commitdiff
Fix a problem with long NFS and CIFS share names in cifsiostat and
authorSebastien Godard <sysstat@orange.fr>
Sun, 6 Feb 2011 09:09:17 +0000 (10:09 +0100)
committerSebastien Godard <sysstat@orange.fr>
Sun, 6 Feb 2011 09:09:17 +0000 (10:09 +0100)
nfsiostat.

Mail from Ivana Varekova (varekova@redhat.com) 02/02/2011
    Hello, I'm sending 6 patches - 3 for nfsiostat and 3 for cifsiostat
nfsiostat:
    nfsiostat3.patch - fix the problem with long nfs shares names
(...)

cifsiostat:
    cifsiostat3.patch - fix the problem with long cifs shares names
(...)

CHANGES
cifsiostat.c
nfsiostat.c

diff --git a/CHANGES b/CHANGES
index e5525c3beebeedbb8b718aeaa5e709bd38bde83c..64e09864eebda3ed9147edf9023cc1ce55aff34c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
 Changes:
 
 xxxx/xx/xx: Version 10.0.0 - Sebastien Godard (sysstat <at> orange.fr)
+       * [Ivana Varekova]: Fix a problem with long NFS and CIFS share
+         names in cifsiostat and nfsiostat.
        * [Ivana Varekova]: Check calloc() return value in cifsiostat
          and nfsiostat.
        * [Jan Kaluza]: Added --debuginfo option to cifsiostat and
index 5d9f127833a101ca1140c79c8df3317f689b2529..7e66f10877f688cfbf0248f3123ffa418ff6deac 100644 (file)
@@ -287,13 +287,13 @@ void read_cifs_stat(int curr)
        if ((fp = fopen(CIFSSTATS, "r")) == NULL)
                return;
 
-       sprintf(aux, "%%%ds %%10s %%10s",
-               MAX_NAME_LEN < 200 ? MAX_NAME_LEN : 200);
+       sprintf(aux, "%%*d) %%%ds",
+               MAX_NAME_LEN < 200 ? MAX_NAME_LEN - 1 : 200);
 
        while (fgets(line, 256, fp) != NULL) {
 
                /* Read CIFS directory name */
-               if (isdigit((unsigned char) line[0]) && sscanf(line, "%*d) %s", name_tmp) == 1) {
+               if (isdigit((unsigned char) line[0]) && sscanf(line, aux , name_tmp) == 1) {
                        if (start) {
                                save_stats(cifs_name, curr, &scifs);
                        }
index 4222bd358e4f097e89d0c085d9468628804ca02a..48d579b49415feb53d40efac418d3726ebcb98d0 100644 (file)
@@ -307,6 +307,7 @@ void read_nfs_stat(int curr)
        int sw = 0;
        char line[256];
        char *xprt_line;
+       char *mount_part;
        char nfs_name[MAX_NAME_LEN];
        char mount[10], on[10], prefix[10], aux[32];
        char operation[16];
@@ -319,7 +320,7 @@ void read_nfs_stat(int curr)
        if ((fp = fopen(NFSMOUNTSTATS, "r")) == NULL)
                return;
 
-       sprintf(aux, "%%%ds %%10s %%10s",
+       sprintf(aux, "%%%ds",
                MAX_NAME_LEN < 200 ? MAX_NAME_LEN : 200);
 
        while (fgets(line, 256, fp) != NULL) {
@@ -327,9 +328,13 @@ void read_nfs_stat(int curr)
                /* Read NFS directory name */
                if (!strncmp(line, "device", 6)) {
                        sw = 0;
-                       sscanf(line + 6, aux, nfs_name, mount, on);
-                       if ((!strncmp(mount, "mounted", 7)) && (!strncmp(on, "on", 2))) {
-                               sw = 1;
+                       sscanf(line + 6, aux, nfs_name);
+                       mount_part = strchr(line + 7, ' ');
+                       if (mount_part != NULL) {
+                               sscanf(mount_part, "%10s %10s", mount, on);
+                               if ((!strncmp(mount, "mounted", 7)) && (!strncmp(on, "on", 2))) {
+                                       sw = 1;
+                               }
                        }
                }