diff options
| author | Rajesh Amaravathi <rajesh@redhat.com> | 2011-12-07 20:51:03 +0530 | 
|---|---|---|
| committer | Vijay Bellur <vijay@gluster.com> | 2012-01-12 01:58:26 -0800 | 
| commit | 169c73f28dae61236de54889edcaa8236d91da59 (patch) | |
| tree | a4d74fc14c9198cbc78633a844480ab6c4ffdda3 /libglusterfs | |
| parent | 4e40a7e48757feedc959c7982acf05c73f739a15 (diff) | |
cli: volume status enhancement
    * Support "gluster volume status (all)" option to display all
      volumes' status.
    * On option "detail" appended to "gluster volume status *",
      amount of storage free, total storage, and backend filesystem
      details like inode size, inode count, free inodes, fs type,
      device name of each brick is displayed.
    * One can also obtain [detailed]status of only one brick.
    * Format of the enhanced volume status command is:
      "gluster volume status [all|<vol>] [<brick>] [detail]"
    * Some generic functions have been added to common-utils:
           skipword
           get_nth_word
      These functions enable parsing and fetching
      of words in a sentence.
           glusterd_get_brick_root    (in glusterd)
      These are self explanatory.
Change-Id: I6f40c1e19810f8504cd3b1786207364053d82e28
BUG: 765464
Signed-off-by: Rajesh Amaravathi <rajesh@redhat.com>
Reviewed-on: http://review.gluster.com/777
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Amar Tumballi <amar@gluster.com>
Diffstat (limited to 'libglusterfs')
| -rw-r--r-- | libglusterfs/src/common-utils.c | 49 | ||||
| -rw-r--r-- | libglusterfs/src/common-utils.h | 8 | 
2 files changed, 57 insertions, 0 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 1d0fb822f..d22ebd2ef 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -1607,6 +1607,55 @@ nwstrtail (char *str, char *pattern)          return *pattern ? NULL : str;  } +void +skipword (char **s) +{ +        if (!*s) +                return; + +        skipwhite (s); + +        while (!isspace(**s)) +                (*s)++; +} + +char * +get_nth_word (const char *str, int n) +{ +        char           buf[4096] = {0}; +        char          *start     = NULL; +        char          *word      = NULL; +        int            i         = 0; +        int            word_len  = 0; +        const char    *end       = NULL; + +        if (!str) +                goto out; + +        snprintf (buf, sizeof (buf), "%s", str); +        start = buf; + +        for (i = 0; i < n-1; i++) +                skipword (&start); + +        skipwhite (&start); +        end = strpbrk ((const char *)start, " \t\n\0"); + +        if (!end) +                goto out; + +        word_len = abs (end - start); + +        word = GF_CALLOC (1, word_len + 1, gf_common_mt_strdup); +        if (!word) +                goto out; + +        strncpy (word, start, word_len); +        *(word + word_len) = '\0'; + out: +        return word; +} +  /* RFC 1123 & 952 */  char  valid_host_name (char *address, int length) diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index 4cb3843d9..6045cd3ef 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -74,6 +74,11 @@ void trap (void);  #define WIPE(statp) do { typeof(*statp) z = {0,}; if (statp) *statp = z; } while (0) +#define IS_EXT_FS(fs_name)          \ +        (!strcmp (fs_name, "ext2") || \ +         !strcmp (fs_name, "ext3") || \ +         !strcmp (fs_name, "ext4")) +  enum _gf_boolean  {  	_gf_false = 0, @@ -409,6 +414,9 @@ int get_checksum_for_path (char *path, uint32_t *checksum);  char *strtail (char *str, const char *pattern);  void skipwhite (char **s);  char *nwstrtail (char *str, char *pattern); +void skip_word (char **str); +/* returns a new string with nth word of given string. n>=1 */ +char *get_nth_word (const char *str, int n);  char valid_host_name (char *address, int length);  char valid_ipv4_address (char *address, int length);  | 
