From 3283f817eb205b7a014bb171785b6ccde04d33bc Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 6 May 2010 10:10:15 +0000 Subject: [PATCH] Add dm_list_splice() to join two lists. --- WHATS_NEW | 2 ++ libdm/.exported_symbols | 1 + libdm/datastruct/list.c | 24 +++++++++++++++++++++++- libdm/libdevmapper.h | 5 +++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/WHATS_NEW b/WHATS_NEW index d905f239b..5009ee3bb 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,6 +1,8 @@ Version 2.02.65 - ================================= Suppress duplicate error messages about read failures and missing devices. + Install plugins to $(libdir)/device-mapper and $(libdir)/lvm2. + Add dm_list_splice() function to join two lists together. Version 2.02.64 - 30th April 2010 ================================= diff --git a/libdm/.exported_symbols b/libdm/.exported_symbols index 73ee5bd7d..32f664d91 100644 --- a/libdm/.exported_symbols +++ b/libdm/.exported_symbols @@ -155,6 +155,7 @@ dm_list_add dm_list_add_h dm_list_del dm_list_move +dm_list_splice dm_list_empty dm_list_start dm_list_end diff --git a/libdm/datastruct/list.c b/libdm/datastruct/list.c index 3d9ca8b38..c7a052fee 100644 --- a/libdm/datastruct/list.c +++ b/libdm/datastruct/list.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -144,3 +144,25 @@ unsigned int dm_list_size(const struct dm_list *head) return s; } + +/* + * Join two lists together. + * This moves all the elements of the list 'head1' to the end of the list + * 'head', leaving 'head1' empty. + */ +void dm_list_splice(struct dm_list *head, struct dm_list *head1) +{ + assert(head->n); + assert(head1->n); + + if (dm_list_empty(head1)) + return; + + head1->p->n = head; + head1->n->p = head->p; + + head->p->n = head1->n; + head->p = head1->p; + + dm_list_init(head1); +} diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h index 0900a3beb..26c15ba79 100644 --- a/libdm/libdevmapper.h +++ b/libdm/libdevmapper.h @@ -717,6 +717,11 @@ void dm_list_del(struct dm_list *elem); */ void dm_list_move(struct dm_list *head, struct dm_list *elem); +/* + * Join 'head1' to the of 'head'. + */ +void dm_list_splice(struct dm_list *head, struct dm_list *head1); + /* * Is the list empty? */ -- 2.43.5