summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorvmallika <vmallika@redhat.com>2016-04-25 16:23:29 +0530
committerVijaikumar Mallikarjuna <vmallika@redhat.com>2016-04-27 09:46:50 -0700
commit7433fcfdf7a663ab228de67099e8a53fed526fb0 (patch)
treee9f7b6eeb0d3731dc743e63cc2d9e3d8492ac943 /libglusterfs
parentfa78b755e9c58328c1df4ef1bfeb752d47534a4a (diff)
cli/quota: Sort the list output alphabetically by path
This is a backport of http://review.gluster.org/14000 > 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> Change-Id: I87e12d58c8e267b2af67e287998e7313efc70af4 BUG: 1330018 Signed-off-by: vmallika <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/14061 Smoke: Gluster Build System <jenkins@build.gluster.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/common-utils.c50
-rw-r--r--libglusterfs/src/common-utils.h10
-rw-r--r--libglusterfs/src/mem-types.h1
3 files changed, 61 insertions, 0 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 81e01bf..716f002 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -4016,3 +4016,53 @@ _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);
+}
+
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index e374285..53f220c 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -165,6 +165,16 @@ typedef struct dht_changelog_rename_info {
char buffer[1];
} dht_changelog_rename_info_t;
+struct list_node {
+ void *ptr;
+ struct list_head list;
+};
+
+struct list_node *list_node_add (void *ptr, struct list_head *list);
+struct list_node *list_node_add_order (void *ptr, struct list_head *list,
+ int (*compare)(struct list_head *,
+ struct list_head *));
+void list_node_del (struct list_node *node);
typedef int (*gf_cmp) (void *, void *);
diff --git a/libglusterfs/src/mem-types.h b/libglusterfs/src/mem-types.h
index dd96cc6..124e569 100644
--- a/libglusterfs/src/mem-types.h
+++ b/libglusterfs/src/mem-types.h
@@ -156,6 +156,7 @@ enum gf_common_mem_types_ {
gf_common_mt_syncstack,
gf_common_mt_syncenv,
gf_common_mt_scan_data,
+ gf_common_list_node,
gf_common_mt_end
};
#endif