Index: LVM2.2.02.58/daemons/cmirrord/cluster.h =================================================================== --- LVM2.2.02.58.orig/daemons/cmirrord/cluster.h +++ LVM2.2.02.58/daemons/cmirrord/cluster.h @@ -14,6 +14,7 @@ #include "dm-log-userspace.h" #include "libdevmapper.h" +#include "cmirrord-list.h" #define DM_ULOG_RESPONSE 0x1000U /* in last byte of 32-bit value */ #define DM_ULOG_CHECKPOINT_READY 21 Index: LVM2.2.02.58/Makefile.in =================================================================== --- LVM2.2.02.58.orig/Makefile.in +++ LVM2.2.02.58/Makefile.in @@ -27,7 +27,7 @@ ifeq ("@INTL@", "yes") SUBDIRS += po endif -SUBDIRS += lib tools daemons libdm +SUBDIRS += lib daemons ifeq ("@APPLIB@", "yes") SUBDIRS += liblvm Index: LVM2.2.02.58/lib/datastruct/lvm-types.h =================================================================== --- LVM2.2.02.58.orig/lib/datastruct/lvm-types.h +++ LVM2.2.02.58/lib/datastruct/lvm-types.h @@ -18,6 +18,7 @@ #include #include +#include "cmirrord-list.h" /* Define some portable printing types */ #define PRIsize_t "zu" Index: LVM2.2.02.58/libdm/libdevmapper.h =================================================================== --- LVM2.2.02.58.orig/libdm/libdevmapper.h +++ LVM2.2.02.58/libdm/libdevmapper.h @@ -674,6 +674,15 @@ struct dm_hash_node *dm_hash_get_next(st ****************/ /* + * Use static inline version of list helpers. + * Avoid depending on libdevmapper.so where the older versions had these + * functions with different name. list_* instead of dm_list_* + */ +#include "cmirrord-list.h" + +#if 0 + +/* * A list consists of a list head plus elements. * Each element has 'next' and 'previous' pointers. * The list head's pointers point to the first and the last element. @@ -860,6 +869,8 @@ struct dm_list *dm_list_next(const struc */ unsigned int dm_list_size(const struct dm_list *head); +#endif + /********* * selinux *********/ Index: LVM2.2.02.58/include/cmirrord-list.h =================================================================== --- /dev/null +++ LVM2.2.02.58/include/cmirrord-list.h @@ -0,0 +1,281 @@ +/* + * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. + * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _CMIRRORD_LIST_H +#define _CMIRRORD_LIST_H + +/* + * List implemetation copied and made "static inline" to allow linking to + * older versions of libdevmapper.so that do not provide dm_list_* + * functions, but only list_* functions. The list_* functions were renamed + * as dm_list_* only in later versions. + */ + +#include + +/* + * A list consists of a list head plus elements. + * Each element has 'next' and 'previous' pointers. + * The list head's pointers point to the first and the last element. + */ + +struct dm_list { + struct dm_list *n, *p; +}; + +/* + * Initialise a list before use. + * The list head's next and previous pointers point back to itself. + */ +#define DM_LIST_INIT(name) struct dm_list name = { &(name), &(name) } + + +/* + * Initialise a list before use. + * The list head's next and previous pointers point back to itself. + */ +static inline void dm_list_init(struct dm_list *head) +{ + head->n = head->p = head; +} + +/* + * Insert an element before 'head'. + * If 'head' is the list head, this adds an element to the end of the list. + */ +static inline void dm_list_add(struct dm_list *head, struct dm_list *elem) +{ + assert(head->n); + + elem->n = head; + elem->p = head->p; + + head->p->n = elem; + head->p = elem; +} + +/* + * Insert an element after 'head'. + * If 'head' is the list head, this adds an element to the front of the list. + */ +static inline void dm_list_add_h(struct dm_list *head, struct dm_list *elem) +{ + assert(head->n); + + elem->n = head->n; + elem->p = head; + + head->n->p = elem; + head->n = elem; +} + +/* + * Delete an element from its list. + * Note that this doesn't change the element itself - it may still be safe + * to follow its pointers. + */ +static inline void dm_list_del(struct dm_list *elem) +{ + elem->n->p = elem->p; + elem->p->n = elem->n; +} + +/* + * Remove an element from existing list and insert before 'head'. + */ +static inline void dm_list_move(struct dm_list *head, struct dm_list *elem) +{ + dm_list_del(elem); + dm_list_add(head, elem); +} + +/* + * Is the list empty? + */ +static inline int dm_list_empty(const struct dm_list *head) +{ + return head->n == head; +} + +/* + * Is this the first element of the list? + */ +static inline int dm_list_start(const struct dm_list *head, const struct dm_list *elem) +{ + return elem->p == head; +} + +/* + * Is this the last element of the list? + */ +static inline int dm_list_end(const struct dm_list *head, const struct dm_list *elem) +{ + return elem->n == head; +} + +/* + * Return first element of the list or NULL if empty + */ +static inline struct dm_list *dm_list_first(const struct dm_list *head) +{ + return (dm_list_empty(head) ? NULL : head->n); +} + +/* + * Return last element of the list or NULL if empty + */ +static inline struct dm_list *dm_list_last(const struct dm_list *head) +{ + return (dm_list_empty(head) ? NULL : head->p); +} + +/* + * Return the previous element of the list, or NULL if we've reached the start. + */ +static inline struct dm_list *dm_list_prev(const struct dm_list *head, const struct dm_list *elem) +{ + return (dm_list_start(head, elem) ? NULL : elem->p); +} + +/* + * Return the next element of the list, or NULL if we've reached the end. + */ +static inline struct dm_list *dm_list_next(const struct dm_list *head, const struct dm_list *elem) +{ + return (dm_list_end(head, elem) ? NULL : elem->n); +} + +/* + * Given the address v of an instance of 'struct dm_list' called 'head' + * contained in a structure of type t, return the containing structure. + */ +#define dm_list_struct_base(v, t, head) \ + ((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->head)) + +/* + * Given the address v of an instance of 'struct dm_list list' contained in + * a structure of type t, return the containing structure. + */ +#define dm_list_item(v, t) dm_list_struct_base((v), t, list) + +/* + * Given the address v of one known element e in a known structure of type t, + * return another element f. + */ +#define dm_struct_field(v, t, e, f) \ + (((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->e))->f) + +/* + * Given the address v of a known element e in a known structure of type t, + * return the list head 'list' + */ +#define dm_list_head(v, t, e) dm_struct_field(v, t, e, list) + +/* + * Set v to each element of a list in turn. + */ +#define dm_list_iterate(v, head) \ + for (v = (head)->n; v != head; v = v->n) + +/* + * Set v to each element in a list in turn, starting from the element + * in front of 'start'. + * You can use this to 'unwind' a list_iterate and back out actions on + * already-processed elements. + * If 'start' is 'head' it walks the list backwards. + */ +#define dm_list_uniterate(v, head, start) \ + for (v = (start)->p; v != head; v = v->p) + +/* + * A safe way to walk a list and delete and free some elements along + * the way. + * t must be defined as a temporary variable of the same type as v. + */ +#define dm_list_iterate_safe(v, t, head) \ + for (v = (head)->n, t = v->n; v != head; v = t, t = v->n) + +/* + * Walk a list, setting 'v' in turn to the containing structure of each item. + * The containing structure should be the same type as 'v'. + * The 'struct dm_list' variable within the containing structure is 'field'. + */ +#define dm_list_iterate_items_gen(v, head, field) \ + for (v = dm_list_struct_base((head)->n, typeof(*v), field); \ + &v->field != (head); \ + v = dm_list_struct_base(v->field.n, typeof(*v), field)) + +/* + * Walk a list, setting 'v' in turn to the containing structure of each item. + * The containing structure should be the same type as 'v'. + * The list should be 'struct dm_list list' within the containing structure. + */ +#define dm_list_iterate_items(v, head) dm_list_iterate_items_gen(v, (head), list) + +/* + * Walk a list, setting 'v' in turn to the containing structure of each item. + * The containing structure should be the same type as 'v'. + * The 'struct dm_list' variable within the containing structure is 'field'. + * t must be defined as a temporary variable of the same type as v. + */ +#define dm_list_iterate_items_gen_safe(v, t, head, field) \ + for (v = dm_list_struct_base((head)->n, typeof(*v), field), \ + t = dm_list_struct_base(v->field.n, typeof(*v), field); \ + &v->field != (head); \ + v = t, t = dm_list_struct_base(v->field.n, typeof(*v), field)) +/* + * Walk a list, setting 'v' in turn to the containing structure of each item. + * The containing structure should be the same type as 'v'. + * The list should be 'struct dm_list list' within the containing structure. + * t must be defined as a temporary variable of the same type as v. + */ +#define dm_list_iterate_items_safe(v, t, head) \ + dm_list_iterate_items_gen_safe(v, t, (head), list) + +/* + * Walk a list backwards, setting 'v' in turn to the containing structure + * of each item. + * The containing structure should be the same type as 'v'. + * The 'struct dm_list' variable within the containing structure is 'field'. + */ +#define dm_list_iterate_back_items_gen(v, head, field) \ + for (v = dm_list_struct_base((head)->p, typeof(*v), field); \ + &v->field != (head); \ + v = dm_list_struct_base(v->field.p, typeof(*v), field)) + +/* + * Walk a list backwards, setting 'v' in turn to the containing structure + * of each item. + * The containing structure should be the same type as 'v'. + * The list should be 'struct dm_list list' within the containing structure. + */ +#define dm_list_iterate_back_items(v, head) dm_list_iterate_back_items_gen(v, (head), list) + +/* + * Return the number of elements in a list by walking it. + */ +static inline unsigned int dm_list_size(const struct dm_list *head) +{ + unsigned int s = 0; + const struct dm_list *v; + + dm_list_iterate(v, head) + s++; + + return s; +} + + +#endif