summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--WHATS_NEW1
-rw-r--r--daemons/clvmd/lvm-functions.c2
-rw-r--r--daemons/clvmd/lvm-functions.h2
-rw-r--r--daemons/clvmd/refresh_clvmd.c2
-rw-r--r--lib/activate/activate.c4
-rw-r--r--lib/activate/activate.h2
-rw-r--r--lib/datastruct/btree.c13
-rw-r--r--lib/datastruct/btree.h10
-rw-r--r--lib/datastruct/list.c14
-rw-r--r--lib/datastruct/list.h14
-rw-r--r--lib/datastruct/str_list.c9
-rw-r--r--lib/datastruct/str_list.h9
-rw-r--r--lib/display/display.c49
-rw-r--r--lib/display/display.h36
-rw-r--r--lib/metadata/metadata-exported.h2
-rw-r--r--lib/metadata/metadata.c2
-rw-r--r--libdm/datastruct/list.c14
-rw-r--r--libdm/datastruct/list.h14
-rw-r--r--tools/toollib.c19
-rw-r--r--tools/toollib.h28
-rw-r--r--tools/tools.h2
-rw-r--r--tools/vgdisplay.c7
22 files changed, 134 insertions, 121 deletions
diff --git a/WHATS_NEW b/WHATS_NEW
index ffde82e6..0170b899 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.28 -
================================
+ Add const attributes where possible, first cut.
Add support for renaming mirrored LVs.
Factor out core of lvrename() to lv_rename lvm library function.
Add --log argument to specify log type for mirrors.
diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c
index 56219ac2..b8da034d 100644
--- a/daemons/clvmd/lvm-functions.c
+++ b/daemons/clvmd/lvm-functions.c
@@ -431,7 +431,7 @@ int post_lock_lv(unsigned char command, unsigned char lock_flags,
}
/* Check if a VG is un use by LVM1 so we don't stomp on it */
-int do_check_lvm1(char *vgname)
+int do_check_lvm1(const char *vgname)
{
int status;
diff --git a/daemons/clvmd/lvm-functions.h b/daemons/clvmd/lvm-functions.h
index d04964bf..b1e4da1b 100644
--- a/daemons/clvmd/lvm-functions.h
+++ b/daemons/clvmd/lvm-functions.h
@@ -24,7 +24,7 @@ extern int do_lock_lv(unsigned char lock_cmd, unsigned char lock_flags,
char *resource);
extern int post_lock_lv(unsigned char lock_cmd, unsigned char lock_flags,
char *resource);
-extern int do_check_lvm1(char *vgname);
+extern int do_check_lvm1(const char *vgname);
extern int do_refresh_cache(void);
extern int init_lvm(int using_gulm);
extern void init_lvhash(void);
diff --git a/daemons/clvmd/refresh_clvmd.c b/daemons/clvmd/refresh_clvmd.c
index 5103ec30..3a455b8f 100644
--- a/daemons/clvmd/refresh_clvmd.c
+++ b/daemons/clvmd/refresh_clvmd.c
@@ -79,7 +79,7 @@ static int _open_local_sock(void)
}
/* Send a request and return the status */
-static int _send_request(char *inbuf, int inlen, char **retbuf)
+static int _send_request(const char *inbuf, int inlen, char **retbuf)
{
char outbuf[PIPE_BUF];
struct clvm_header *outheader = (struct clvm_header *) outbuf;
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index c262ff39..51f393c4 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -642,9 +642,9 @@ int lvs_in_vg_activated(struct volume_group *vg)
return _lvs_in_vg_activated(vg, 0);
}
-int lvs_in_vg_opened(struct volume_group *vg)
+int lvs_in_vg_opened(const struct volume_group *vg)
{
- struct lv_list *lvl;
+ const struct lv_list *lvl;
int count = 0;
if (!activation())
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index c3e9700e..76d27e2e 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -84,7 +84,7 @@ int lv_mirror_percent(struct cmd_context *cmd, struct logical_volume *lv,
*/
int lvs_in_vg_activated(struct volume_group *vg);
int lvs_in_vg_activated_by_uuid_only(struct volume_group *vg);
-int lvs_in_vg_opened(struct volume_group *vg);
+int lvs_in_vg_opened(const struct volume_group *vg);
int monitor_dev_for_events(struct cmd_context *cmd,
diff --git a/lib/datastruct/btree.c b/lib/datastruct/btree.c
index 23b067be..b99f667d 100644
--- a/lib/datastruct/btree.c
+++ b/lib/datastruct/btree.c
@@ -55,7 +55,8 @@ static uint32_t _shuffle(uint32_t k)
#endif
}
-static struct node **_lookup(struct node **c, uint32_t key, struct node **p)
+static struct node **_lookup(struct node *const *c, uint32_t key,
+ struct node **p)
{
*p = NULL;
while (*c) {
@@ -70,10 +71,10 @@ static struct node **_lookup(struct node **c, uint32_t key, struct node **p)
c = &(*c)->r;
}
- return c;
+ return (struct node **)c;
}
-void *btree_lookup(struct btree *t, uint32_t k)
+void *btree_lookup(const struct btree *t, uint32_t k)
{
uint32_t key = _shuffle(k);
struct node *p, **c = _lookup(&t->root, key, &p);
@@ -102,7 +103,7 @@ int btree_insert(struct btree *t, uint32_t k, void *data)
return 1;
}
-void *btree_get_data(struct btree_iter *it)
+void *btree_get_data(const struct btree_iter *it)
{
return ((struct node *) it)->data;
}
@@ -114,7 +115,7 @@ static struct node *_left(struct node *n)
return n;
}
-struct btree_iter *btree_first(struct btree *t)
+struct btree_iter *btree_first(const struct btree *t)
{
if (!t->root)
return NULL;
@@ -122,7 +123,7 @@ struct btree_iter *btree_first(struct btree *t)
return (struct btree_iter *) _left(t->root);
}
-struct btree_iter *btree_next(struct btree_iter *it)
+struct btree_iter *btree_next(const struct btree_iter *it)
{
struct node *n = (struct node *) it;
uint32_t k = n->key;
diff --git a/lib/datastruct/btree.h b/lib/datastruct/btree.h
index 66dea80e..f91ced82 100644
--- a/lib/datastruct/btree.h
+++ b/lib/datastruct/btree.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
+ * Copyright (C) 2001-2004, 2007 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
@@ -20,13 +20,13 @@ struct btree;
struct btree *btree_create(struct dm_pool *mem);
-void *btree_lookup(struct btree *t, uint32_t k);
+void *btree_lookup(const struct btree *t, uint32_t k);
int btree_insert(struct btree *t, uint32_t k, void *data);
struct btree_iter;
-void *btree_get_data(struct btree_iter *it);
+void *btree_get_data(const struct btree_iter *it);
-struct btree_iter *btree_first(struct btree *t);
-struct btree_iter *btree_next(struct btree_iter *it);
+struct btree_iter *btree_first(const struct btree *t);
+struct btree_iter *btree_next(const struct btree_iter *it);
#endif
diff --git a/lib/datastruct/list.c b/lib/datastruct/list.c
index 17ee0e28..3918cf52 100644
--- a/lib/datastruct/list.c
+++ b/lib/datastruct/list.c
@@ -68,7 +68,7 @@ void list_del(struct list *elem)
/*
* Is the list empty?
*/
-int list_empty(struct list *head)
+int list_empty(const struct list *head)
{
return head->n == head;
}
@@ -76,7 +76,7 @@ int list_empty(struct list *head)
/*
* Is this the first element of the list?
*/
-int list_start(struct list *head, struct list *elem)
+int list_start(const struct list *head, const struct list *elem)
{
return elem->p == head;
}
@@ -84,7 +84,7 @@ int list_start(struct list *head, struct list *elem)
/*
* Is this the last element of the list?
*/
-int list_end(struct list *head, struct list *elem)
+int list_end(const struct list *head, const struct list *elem)
{
return elem->n == head;
}
@@ -92,7 +92,7 @@ int list_end(struct list *head, struct list *elem)
/*
* Return first element of the list or NULL if empty
*/
-struct list *list_first(struct list *head)
+struct list *list_first(const struct list *head)
{
return (list_empty(head) ? NULL : head->n);
}
@@ -100,7 +100,7 @@ struct list *list_first(struct list *head)
/*
* Return last element of the list or NULL if empty
*/
-struct list *list_last(struct list *head)
+struct list *list_last(const struct list *head)
{
return (list_empty(head) ? NULL : head->p);
}
@@ -108,7 +108,7 @@ struct list *list_last(struct list *head)
/*
* Return the previous element of the list, or NULL if we've reached the start.
*/
-struct list *list_prev(struct list *head, struct list *elem)
+struct list *list_prev(const struct list *head, const struct list *elem)
{
return (list_start(head, elem) ? NULL : elem->p);
}
@@ -116,7 +116,7 @@ struct list *list_prev(struct list *head, struct list *elem)
/*
* Return the next element of the list, or NULL if we've reached the end.
*/
-struct list *list_next(struct list *head, struct list *elem)
+struct list *list_next(const struct list *head, const struct list *elem)
{
return (list_end(head, elem) ? NULL : elem->n);
}
diff --git a/lib/datastruct/list.h b/lib/datastruct/list.h
index 316c537a..00d4d743 100644
--- a/lib/datastruct/list.h
+++ b/lib/datastruct/list.h
@@ -57,37 +57,37 @@ void list_del(struct list *elem);
/*
* Is the list empty?
*/
-int list_empty(struct list *head);
+int list_empty(const struct list *head);
/*
* Is this the first element of the list?
*/
-int list_start(struct list *head, struct list *elem);
+int list_start(const struct list *head, const struct list *elem);
/*
* Is this the last element of the list?
*/
-int list_end(struct list *head, struct list *elem);
+int list_end(const struct list *head, const struct list *elem);
/*
* Return first element of the list or NULL if empty
*/
-struct list *list_first(struct list *head);
+struct list *list_first(const struct list *head);
/*
* Return last element of the list or NULL if empty
*/
-struct list *list_last(struct list *head);
+struct list *list_last(const struct list *head);
/*
* Return the previous element of the list, or NULL if we've reached the start.
*/
-struct list *list_prev(struct list *head, struct list *elem);
+struct list *list_prev(const struct list *head, const struct list *elem);
/*
* Return the next element of the list, or NULL if we've reached the end.
*/
-struct list *list_next(struct list *head, struct list *elem);
+struct list *list_next(const struct list *head, const struct list *elem);
/*
* Given the address v of an instance of 'struct list' called 'head'
diff --git a/lib/datastruct/str_list.c b/lib/datastruct/str_list.c
index 94705dc4..68660d99 100644
--- a/lib/datastruct/str_list.c
+++ b/lib/datastruct/str_list.c
@@ -66,7 +66,8 @@ int str_list_del(struct list *sll, const char *str)
return 1;
}
-int str_list_dup(struct dm_pool *mem, struct list *sllnew, struct list *sllold)
+int str_list_dup(struct dm_pool *mem, struct list *sllnew,
+ const struct list *sllold)
{
struct str_list *sl;
@@ -85,7 +86,7 @@ int str_list_dup(struct dm_pool *mem, struct list *sllnew, struct list *sllold)
/*
* Is item on list?
*/
-int str_list_match_item(struct list *sll, const char *str)
+int str_list_match_item(const struct list *sll, const char *str)
{
struct str_list *sl;
@@ -99,7 +100,7 @@ int str_list_match_item(struct list *sll, const char *str)
/*
* Is at least one item on both lists?
*/
-int str_list_match_list(struct list *sll, struct list *sll2)
+int str_list_match_list(const struct list *sll, const struct list *sll2)
{
struct str_list *sl;
@@ -113,7 +114,7 @@ int str_list_match_list(struct list *sll, struct list *sll2)
/*
* Do both lists contain the same set of items?
*/
-int str_list_lists_equal(struct list *sll, struct list *sll2)
+int str_list_lists_equal(const struct list *sll, const struct list *sll2)
{
struct str_list *sl;
diff --git a/lib/datastruct/str_list.h b/lib/datastruct/str_list.h
index 329a1f65..46fb76d7 100644
--- a/lib/datastruct/str_list.h
+++ b/lib/datastruct/str_list.h
@@ -19,9 +19,10 @@
struct list *str_list_create(struct dm_pool *mem);
int str_list_add(struct dm_pool *mem, struct list *sll, const char *str);
int str_list_del(struct list *sll, const char *str);
-int str_list_match_item(struct list *sll, const char *str);
-int str_list_match_list(struct list *sll, struct list *sll2);
-int str_list_lists_equal(struct list *sll, struct list *sll2);
-int str_list_dup(struct dm_pool *mem, struct list *sllnew, struct list *sllold);
+int str_list_match_item(const struct list *sll, const char *str);
+int str_list_match_list(const struct list *sll, const struct list *sll2);
+int str_list_lists_equal(const struct list *sll, const struct list *sll2);
+int str_list_dup(struct dm_pool *mem, struct list *sllnew,
+ const struct list *sllold);
#endif
diff --git a/lib/display/display.c b/lib/display/display.c
index 4b2a0e46..c0f4e5b7 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -147,7 +147,8 @@ alloc_policy_t get_alloc_from_string(const char *str)
}
/* Size supplied in sectors */
-static const char *_display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl)
+static const char *_display_size(const struct cmd_context *cmd,
+ uint64_t size, size_len_t sl)
{
int s;
int suffix = 1, precision;
@@ -217,22 +218,22 @@ static const char *_display_size(struct cmd_context *cmd, uint64_t size, size_le
return size_buf;
}
-const char *display_size_long(struct cmd_context *cmd, uint64_t size)
+const char *display_size_long(const struct cmd_context *cmd, uint64_t size)
{
return _display_size(cmd, size, SIZE_LONG);
}
-const char *display_size_units(struct cmd_context *cmd, uint64_t size)
+const char *display_size_units(const struct cmd_context *cmd, uint64_t size)
{
return _display_size(cmd, size, SIZE_UNIT);
}
-const char *display_size(struct cmd_context *cmd, uint64_t size)
+const char *display_size(const struct cmd_context *cmd, uint64_t size)
{
return _display_size(cmd, size, SIZE_SHORT);
}
-void pvdisplay_colons(struct physical_volume *pv)
+void pvdisplay_colons(const struct physical_volume *pv)
{
char uuid[64] __attribute((aligned(8)));
@@ -258,9 +259,9 @@ void pvdisplay_colons(struct physical_volume *pv)
return;
}
-void pvdisplay_segments(struct physical_volume *pv)
+void pvdisplay_segments(const struct physical_volume *pv)
{
- struct pv_segment *pvseg;
+ const struct pv_segment *pvseg;
if (pv->pe_size)
log_print("--- Physical Segments ---");
@@ -286,7 +287,8 @@ void pvdisplay_segments(struct physical_volume *pv)
}
/* FIXME Include label fields */
-void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
+void pvdisplay_full(const struct cmd_context *cmd,
+ const struct physical_volume *pv,
void *handle __attribute((unused)))
{
char uuid[64] __attribute((aligned(8)));
@@ -346,9 +348,9 @@ void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
return;
}
-int pvdisplay_short(struct cmd_context *cmd __attribute((unused)),
- struct volume_group *vg __attribute((unused)),
- struct physical_volume *pv,
+int pvdisplay_short(const struct cmd_context *cmd __attribute((unused)),
+ const struct volume_group *vg __attribute((unused)),
+ const struct physical_volume *pv,
void *handle __attribute((unused)))
{
char uuid[64] __attribute((aligned(8)));
@@ -373,7 +375,7 @@ int pvdisplay_short(struct cmd_context *cmd __attribute((unused)),
return 0;
}
-void lvdisplay_colons(struct logical_volume *lv)
+void lvdisplay_colons(const struct logical_volume *lv)
{
int inkernel;
struct lvinfo info;
@@ -393,7 +395,8 @@ void lvdisplay_colons(struct logical_volume *lv)
return;
}
-int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
+int lvdisplay_full(struct cmd_context *cmd,
+ const struct logical_volume *lv,
void *handle __attribute((unused)))
{
struct lvinfo info;
@@ -535,9 +538,9 @@ void display_stripe(const struct lv_segment *seg, uint32_t s, const char *pre)
}
}
-int lvdisplay_segments(struct logical_volume *lv)
+int lvdisplay_segments(const struct logical_volume *lv)
{
- struct lv_segment *seg;
+ const struct lv_segment *seg;
log_print("--- Segments ---");
@@ -555,12 +558,12 @@ int lvdisplay_segments(struct logical_volume *lv)
return 1;
}
-void vgdisplay_extents(struct volume_group *vg __attribute((unused)))
+void vgdisplay_extents(const struct volume_group *vg __attribute((unused)))
{
return;
}
-void vgdisplay_full(struct volume_group *vg)
+void vgdisplay_full(const struct volume_group *vg)
{
uint32_t access;
uint32_t active_pvs;
@@ -639,7 +642,7 @@ void vgdisplay_full(struct volume_group *vg)
return;
}
-void vgdisplay_colons(struct volume_group *vg)
+void vgdisplay_colons(const struct volume_group *vg)
{
uint32_t active_pvs;
const char *access;
@@ -691,7 +694,7 @@ void vgdisplay_colons(struct volume_group *vg)
return;
}
-void vgdisplay_short(struct volume_group *vg)
+void vgdisplay_short(const struct volume_group *vg)
{
log_print("\"%s\" %-9s [%-9s used / %s free]", vg->name,
/********* FIXME if "open" print "/used" else print "/idle"??? ******/
@@ -705,18 +708,18 @@ void vgdisplay_short(struct volume_group *vg)
return;
}
-void display_formats(struct cmd_context *cmd)
+void display_formats(const struct cmd_context *cmd)
{
- struct format_type *fmt;
+ const struct format_type *fmt;
list_iterate_items(fmt, &cmd->formats) {
log_print("%s", fmt->name);
}
}
-void display_segtypes(struct cmd_context *cmd)
+void display_segtypes(const struct cmd_context *cmd)
{
- struct segment_type *segtype;
+ const struct segment_type *segtype;
list_iterate_items(segtype, &cmd->segtypes) {
log_print("%s", segtype->name);
diff --git a/lib/display/display.h b/lib/display/display.h
index 7605e15f..94f9c0eb 100644
--- a/lib/display/display.h
+++ b/lib/display/display.h
@@ -23,32 +23,34 @@
uint64_t units_to_bytes(const char *units, char *unit_type);
/* Specify size in KB */
-const char *display_size(struct cmd_context *cmd, uint64_t size);
-const char *display_size_long(struct cmd_context *cmd, uint64_t size);
-const char *display_size_units(struct cmd_context *cmd, uint64_t size);
+const char *display_size(const struct cmd_context *cmd, uint64_t size);
+const char *display_size_long(const struct cmd_context *cmd, uint64_t size);
+const char *display_size_units(const struct cmd_context *cmd, uint64_t size);
char *display_uuid(char *uuidstr);
void display_stripe(const struct lv_segment *seg, uint32_t s, const char *pre);
-void pvdisplay_colons(struct physical_volume *pv);
-void pvdisplay_segments(struct physical_volume *pv);
-void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
+void pvdisplay_colons(const struct physical_volume *pv);
+void pvdisplay_segments(const struct physical_volume *pv);
+void pvdisplay_full(const struct cmd_context *cmd,
+ const struct physical_volume *pv,
void *handle);
-int pvdisplay_short(struct cmd_context *cmd, struct volume_group *vg,
- struct physical_volume *pv, void *handle);
+int pvdisplay_short(const struct cmd_context *cmd,
+ const struct volume_group *vg,
+ const struct physical_volume *pv, void *handle);
-void lvdisplay_colons(struct logical_volume *lv);
-int lvdisplay_segments(struct logical_volume *lv);
-int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
+void lvdisplay_colons(const struct logical_volume *lv);
+int lvdisplay_segments(const struct logical_volume *lv);
+int lvdisplay_full(struct cmd_context *cmd, const struct logical_volume *lv,
void *handle);
-void vgdisplay_extents(struct volume_group *vg);
-void vgdisplay_full(struct volume_group *vg);
-void vgdisplay_colons(struct volume_group *vg);
-void vgdisplay_short(struct volume_group *vg);
+void vgdisplay_extents(const struct volume_group *vg);
+void vgdisplay_full(const struct volume_group *vg);
+void vgdisplay_colons(const struct volume_group *vg);
+void vgdisplay_short(const struct volume_group *vg);
-void display_formats(struct cmd_context *cmd);
-void display_segtypes(struct cmd_context *cmd);
+void display_formats(const struct cmd_context *cmd);
+void display_segtypes(const struct cmd_context *cmd);
/*
* Allocation policy display conversion routines.
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index afa4c6bf..4c88c316 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -397,7 +397,7 @@ int vg_add_snapshot(struct format_instance *fid, const char *name,
int vg_remove_snapshot(struct logical_volume *cow);
-int vg_check_status(struct volume_group *vg, uint32_t status);
+int vg_check_status(const struct volume_group *vg, uint32_t status);
/*
* Mirroring functions
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 3f5bdd0a..5397b52e 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -1763,7 +1763,7 @@ int pv_analyze(struct cmd_context *cmd, const char *pv_name,
* 0 - fail
* 1 - success
*/
-int vg_check_status(struct volume_group *vg, uint32_t status)
+int vg_check_status(const struct volume_group *vg, uint32_t status)
{
if ((status & CLUSTERED) &&
(vg->status & CLUSTERED) && !locking_is_clustered() &&
diff --git a/libdm/datastruct/list.c b/libdm/datastruct/list.c
index 17ee0e28..3918cf52 100644
--- a/libdm/datastruct/list.c
+++ b/libdm/datastruct/list.c
@@ -68,7 +68,7 @@ void list_del(struct list *elem)
/*
* Is the list empty?
*/
-int list_empty(struct list *head)
+int list_empty(const struct list *head)
{
return head->n == head;
}
@@ -76,7 +76,7 @@ int list_empty(struct list *head)
/*
* Is this the first element of the list?
*/
-int list_start(struct list *head, struct list *elem)
+int list_start(const struct list *head, const struct list *elem)
{
return elem->p == head;
}
@@ -84,7 +84,7 @@ int list_start(struct list *head, struct list *elem)
/*
* Is this the last element of the list?
*/
-int list_end(struct list *head, struct list *elem)
+int list_end(const struct list *head, const struct list *elem)
{
return elem->n == head;
}
@@ -92,7 +92,7 @@ int list_end(struct list *head, struct list *elem)
/*
* Return first element of the list or NULL if empty
*/
-struct list *list_first(struct list *head)
+struct list *list_first(const struct list *head)
{
return (list_empty(head) ? NULL : head->n);
}
@@ -100,7 +100,7 @@ struct list *list_first(struct list *head)
/*
* Return last element of the list or NULL if empty
*/
-struct list *list_last(struct list *head)
+struct list *list_last(const struct list *head)
{
return (list_empty(head) ? NULL : head->p);
}
@@ -108,7 +108,7 @@ struct list *list_last(struct list *head)
/*
* Return the previous element of the list, or NULL if we've reached the start.
*/
-struct list *list_prev(struct list *head, struct list *elem)
+struct list *list_prev(const struct list *head, const struct list *elem)
{
return (list_start(head, elem) ? NULL : elem->p);
}
@@ -116,7 +116,7 @@ struct list *list_prev(struct list *head, struct list *elem)
/*
* Return the next element of the list, or NULL if we've reached the end.
*/
-struct list *list_next(struct list *head, struct list *elem)
+struct list *list_next(const struct list *head, const struct list *elem)
{
return (list_end(head, elem) ? NULL : elem->n);
}
diff --git a/libdm/datastruct/list.h b/libdm/datastruct/list.h
index 316c537a..00d4d743 100644
--- a/libdm/datastruct/list.h
+++ b/libdm/datastruct/list.h
@@ -57,37 +57,37 @@ void list_del(struct list *elem);
/*
* Is the list empty?
*/
-int list_empty(struct list *head);
+int list_empty(const struct list *head);
/*
* Is this the first element of the list?
*/
-int list_start(struct list *head, struct list *elem);
+int list_start(const struct list *head, const struct list *elem);
/*
* Is this the last element of the list?
*/
-int list_end(struct list *head, struct list *elem);
+int list_end(const struct list *head, const struct list *elem);
/*
* Return first element of the list or NULL if empty
*/
-struct list *list_first(struct list *head);
+struct list *list_first(const struct list *head);
/*
* Return last element of the list or NULL if empty
*/
-struct list *list_last(struct list *head);
+struct list *list_last(const struct list *head);
/*
* Return the previous element of the list, or NULL if we've reached the start.
*/
-struct list *list_prev(struct list *head, struct list *elem);
+struct list *list_prev(const struct list *head, const struct list *elem);
/*
* Return the next element of the list, or NULL if we've reached the end.
*/
-struct list *list_next(struct list *head, struct list *elem);
+struct list *list_next(const struct list *head, const struct list *elem);
/*
* Given the address v of an instance of 'struct list' called 'head'
diff --git a/tools/toollib.c b/tools/toollib.c
index 5510e8ee..5753aff6 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -25,7 +25,7 @@
#define MIRROR_DISK_VERSION 2
/* Command line args */
-unsigned arg_count(struct cmd_context *cmd, int a)
+unsigned arg_count(const struct cmd_context *cmd, int a)
{
return cmd->args[a].count;
}
@@ -142,12 +142,12 @@ char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
/*
* Metadata iteration functions
*/
-int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
- struct list *arg_lvnames, struct list *tags,
+int process_each_lv_in_vg(struct cmd_context *cmd,
+ const struct volume_group *vg,
+ const struct list *arg_lvnames,
+ const struct list *tags,
void *handle,
- int (*process_single) (struct cmd_context * cmd,
- struct logical_volume * lv,
- void *handle))
+ process_single_lv_fn_t process_single)
{
int ret_max = 0;
int ret = 0;
@@ -603,11 +603,8 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
}
int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
- struct list *tags, void *handle,
- int (*process_single) (struct cmd_context * cmd,
- struct volume_group * vg,
- struct physical_volume * pv,
- void *handle))
+ const struct list *tags, void *handle,
+ process_single_pv_fn_t process_single)
{
int ret_max = 0;
int ret = 0;
diff --git a/tools/toollib.h b/tools/toollib.h
index b67fc403..93ab5b33 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -60,19 +60,25 @@ int process_each_segment_in_lv(struct cmd_context *cmd,
struct lv_segment * seg,
void *handle));
+typedef int (*process_single_pv_fn_t) (struct cmd_context *cmd,
+ struct volume_group *vg,
+ struct physical_volume *pv,
+ void *handle);
+
int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
- struct list *tags, void *handle,
- int (*process_single) (struct cmd_context * cmd,
- struct volume_group * vg,
- struct physical_volume * pv,
- void *handle));
-
-int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
- struct list *arg_lvnames, struct list *tags,
+ const struct list *tags, void *handle,
+ process_single_pv_fn_t process_single);
+
+typedef int (*process_single_lv_fn_t) (struct cmd_context *cmd,
+ struct logical_volume *lv,
+ void *handle);
+
+int process_each_lv_in_vg(struct cmd_context *cmd,
+ const struct volume_group *vg,
+ const struct list *arg_lvnames,
+ const struct list *tags,
void *handle,
- int (*process_single) (struct cmd_context * cmd,
- struct logical_volume * lv,
- void *handle));
+ process_single_lv_fn_t process_single);
char *default_vgname(struct cmd_context *cmd);
const char *extract_vgname(struct cmd_context *cmd, const char *lv_name);
diff --git a/tools/tools.h b/tools/tools.h
index bba7e9e3..eac7c028 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -147,7 +147,7 @@ int alloc_arg(struct cmd_context *cmd, struct arg *a);
char yes_no_prompt(const char *prompt, ...);
/* we use the enums to access the switches */
-unsigned int arg_count(struct cmd_context *cmd, int a);
+unsigned int arg_count(const struct cmd_context *cmd, int a);
const char *arg_value(struct cmd_context *cmd, int a);
const char *arg_str_value(struct cmd_context *cmd, int a, const char *def);
int32_t arg_int_value(struct cmd_context *cmd, int a, const int32_t def);
diff --git a/tools/vgdisplay.c b/tools/vgdisplay.c
index aa02129f..0881906a 100644
--- a/tools/vgdisplay.c
+++ b/tools/vgdisplay.c
@@ -46,10 +46,11 @@ static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name,
vgdisplay_extents(vg);
process_each_lv_in_vg(cmd, vg, NULL, NULL, NULL,
- &lvdisplay_full);
+ (process_single_lv_fn_t)lvdisplay_full);
log_print("--- Physical volumes ---");
- process_each_pv_in_vg(cmd, vg, NULL, NULL, &pvdisplay_short);
+ process_each_pv_in_vg(cmd, vg, NULL, NULL,
+ (process_single_pv_fn_t)pvdisplay_short);
}
check_current_backup(vg);
@@ -98,7 +99,7 @@ int vgdisplay(struct cmd_context *cmd, int argc, char **argv)
**********/
process_each_vg(cmd, argc, argv, LCK_VG_READ, 0, NULL,
- &vgdisplay_single);
+ vgdisplay_single);
/******** FIXME Need to count number processed
Add this to process_each_vg if arg_count(cmd,activevolumegroups_ARG) ?