diff options
author | vmallika <vmallika@redhat.com> | 2016-04-14 17:51:19 +0530 |
---|---|---|
committer | Kaushal M <kaushal@redhat.com> | 2016-04-25 02:32:58 -0700 |
commit | 760dfb6e8aebc44b419e8943e4e3895591097b8b (patch) | |
tree | 25d15ed56dc389e2321c98af975845cc8f4aeaa2 /libglusterfs/src/common-utils.c | |
parent | fe6c4efcc66bca84aaceb352de38f0b58b70b780 (diff) |
cli/quota: Sort the list output alphabetically by path
Change-Id: I0b124e119d167817be2ae3eb52ac6c80fc7db5d1
BUG: 1320716
Signed-off-by: vmallika <vmallika@redhat.com>
Reviewed-on: http://review.gluster.org/14000
Smoke: Gluster Build System <jenkins@build.gluster.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaushal M <kaushal@redhat.com>
Diffstat (limited to 'libglusterfs/src/common-utils.c')
-rw-r--r-- | libglusterfs/src/common-utils.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index ef48aca056b..21fe3841be9 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -4214,6 +4214,54 @@ _unmask_cancellation (void) (void) pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL); } +/* This is a wrapper function to add a pointer to a list, + * which doesn't contain list member + */ +struct list_node* +_list_node_add (void *ptr, struct list_head *list, + int (*compare)(struct list_head *, struct list_head *)) +{ + struct list_node *node = NULL; + + if (ptr == NULL || list == NULL) + goto out; + + node = GF_CALLOC (1, sizeof (struct list_node), gf_common_list_node); + + if (node == NULL) + goto out; + + node->ptr = ptr; + if (compare) + list_add_order (&node->list, list, compare); + else + list_add_tail (&node->list, list); +out: + return node; +} + +struct list_node* +list_node_add (void *ptr, struct list_head *list) +{ + return _list_node_add (ptr, list, NULL); +} + +struct list_node* +list_node_add_order (void *ptr, struct list_head *list, + int (*compare)(struct list_head *, struct list_head *)) +{ + return _list_node_add (ptr, list, compare); +} + +void +list_node_del (struct list_node *node) +{ + if (node == NULL) + return; + + list_del_init (&node->list); + GF_FREE (node); +} const char * fop_enum_to_pri_string (glusterfs_fop_t fop) |