1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Check for libsepol.

Add some cflow & scope support.
Separate out DEFS from CFLAGS.
Remove inlines and use unique function names.
This commit is contained in:
Alasdair Kergon 2006-04-19 15:33:07 +00:00
parent d81e3d0bad
commit 8a2fc58645
48 changed files with 2316 additions and 1351 deletions

View File

@ -57,3 +57,13 @@ po.pofile: tools.pofile daemons.pofile dmeventd.pofile
pofile: po.pofile
endif
ifneq ("@CFLOW_CMD@", "")
tools.cflow: lib.cflow
cflow: tools.cflow
endif
ifneq ("@CSCOPE_CMD@", "")
cscope.out: tools
@CSCOPE_CMD@ -b -R
all: cscope.out
endif

View File

@ -1,5 +1,9 @@
Version 2.02.04 -
=================================
Check for libsepol.
Add some cflow & scope support.
Separate out DEFS from CFLAGS.
Remove inlines and use unique function names.
Version 2.02.03 - 14th April 2006
=================================

2650
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -65,6 +65,8 @@ AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PATH_PROG(CFLOW_CMD, cflow)
AC_PATH_PROG(CSCOPE_CMD, cscope)
################################################################################
dnl -- Checks for header files.
@ -150,7 +152,7 @@ AC_ARG_ENABLE(lvm1_fallback, [ --enable-lvm1_fallback Use this to fall back an
AC_MSG_RESULT($LVM1_FALLBACK)
if test x$LVM1_FALLBACK = xyes; then
CFLAGS="$CFLAGS -DLVM1_FALLBACK"
LVM_DEFS="$LVM_DEFS -DLVM1_FALLBACK"
fi
################################################################################
@ -170,7 +172,7 @@ if [[ "x$LVM1" != xnone -a "x$LVM1" != xinternal -a "x$LVM1" != xshared ]];
fi;
if test x$LVM1 = xinternal; then
CFLAGS="$CFLAGS -DLVM1_INTERNAL"
LVM_DEFS="$LVM_DEFS -DLVM1_INTERNAL"
fi
################################################################################
@ -190,7 +192,7 @@ if [[ "x$POOL" != xnone -a "x$POOL" != xinternal -a "x$POOL" != xshared ]];
fi;
if test x$POOL = xinternal; then
CFLAGS="$CFLAGS -DPOOL_INTERNAL"
LVM_DEFS="$LVM_DEFS -DPOOL_INTERNAL"
fi
################################################################################
@ -209,7 +211,7 @@ if [[ "x$CLUSTER" != xnone -a "x$CLUSTER" != xinternal -a "x$CLUSTER" != xshared
fi;
if test x$CLUSTER = xinternal; then
CFLAGS="$CFLAGS -DCLUSTER_LOCKING_INTERNAL"
LVM_DEFS="$LVM_DEFS -DCLUSTER_LOCKING_INTERNAL"
fi
################################################################################
@ -229,7 +231,7 @@ if [[ "x$SNAPSHOTS" != xnone -a "x$SNAPSHOTS" != xinternal -a "x$SNAPSHOTS" != x
fi;
if test x$SNAPSHOTS = xinternal; then
CFLAGS="$CFLAGS -DSNAPSHOT_INTERNAL"
LVM_DEFS="$LVM_DEFS -DSNAPSHOT_INTERNAL"
fi
################################################################################
@ -249,7 +251,7 @@ if [[ "x$MIRRORS" != xnone -a "x$MIRRORS" != xinternal -a "x$MIRRORS" != xshared
fi;
if test x$MIRRORS = xinternal; then
CFLAGS="$CFLAGS -DMIRRORED_INTERNAL"
LVM_DEFS="$LVM_DEFS -DMIRRORED_INTERNAL"
fi
################################################################################
@ -267,7 +269,7 @@ READLINE=$enableval, READLINE=no)
AC_MSG_RESULT($READLINE)
if test x$READLINE = xyes; then
CFLAGS="$CFLAGS -DREADLINE_SUPPORT"
LVM_DEFS="$LVM_DEFS -DREADLINE_SUPPORT"
fi
################################################################################
@ -305,6 +307,8 @@ AC_MSG_RESULT($DEBUG)
dnl -- Normally turn off optimisation for debug builds
if test x$DEBUG = xyes; then
COPTIMISE_FLAG=
else
CSCOPE_CMD=
fi
################################################################################
@ -323,7 +327,7 @@ DEVMAPPER=$enableval)
AC_MSG_RESULT($DEVMAPPER)
if test x$DEVMAPPER = xyes; then
CFLAGS="$CFLAGS -DDEVMAPPER_SUPPORT"
LVM_DEFS="$LVM_DEFS -DDEVMAPPER_SUPPORT"
fi
################################################################################
@ -334,7 +338,7 @@ ODIRECT=$enableval)
AC_MSG_RESULT($ODIRECT)
if test x$ODIRECT = xyes; then
CFLAGS="$CFLAGS -DO_DIRECT_SUPPORT"
LVM_DEFS="$LVM_DEFS -DO_DIRECT_SUPPORT"
fi
################################################################################
@ -345,7 +349,7 @@ CMDLIB=$enableval, CMDLIB=no)
AC_MSG_RESULT($CMDLIB)
if test x$CMDLIB = xyes; then
CFLAGS="$CFLAGS -DCMDLIB"
LVM_DEFS="$LVM_DEFS -DCMDLIB"
fi
################################################################################
@ -370,7 +374,7 @@ AC_MSG_ERROR(
fi
if test x$DMEVENTD = xyes; then
CFLAGS="$CFLAGS -DDMEVENTD"
LVM_DEFS="$LVM_DEFS -DDMEVENTD"
fi
################################################################################
dnl -- Mess with default exec_prefix
@ -407,7 +411,7 @@ dnl -- Check for dlopen
AC_CHECK_LIB(dl, dlopen, HAVE_LIBDL=yes, HAVE_LIBDL=no)
if [[ "x$HAVE_LIBDL" = xyes ]]; then
CFLAGS="$CFLAGS -DHAVE_LIBDL"
LVM_DEFS="$LVM_DEFS -DHAVE_LIBDL"
LIBS="-ldl $LIBS"
else
HAVE_LIBDL=no
@ -424,14 +428,22 @@ Features cannot be 'shared' when building statically
fi
################################################################################
dnl -- Check for is_selinux_enabled
dnl -- Check for selinux
if test x$SELINUX = xyes; then
AC_MSG_CHECKING(for sepol_check_context function)
AC_CHECK_LIB(sepol, sepol_check_context, HAVE_SEPOL=yes, HAVE_SEPOL=no)
AC_MSG_RESULT($HAVE_SEPOL)
if test x$HAVE_SEPOL = xyes; then
LIBS="-lsepol $LIBS"
fi
AC_MSG_CHECKING(for is_selinux_enabled function)
AC_CHECK_LIB(selinux, is_selinux_enabled, HAVE_SELINUX=yes, HAVE_SELINUX=no)
AC_MSG_RESULT($HAVE_SELINUX)
if test x$HAVE_SELINUX = xyes; then
CFLAGS="$CFLAGS -DHAVE_SELINUX"
LVM_DEFS="$LVM_DEFS -DHAVE_SELINUX"
LIBS="-lselinux $LIBS"
else
AC_MSG_WARN(Disabling selinux)
@ -440,7 +452,7 @@ fi
################################################################################
dnl -- Check for getopt
AC_CHECK_HEADERS(getopt.h, CFLAGS="$CFLAGS -DHAVE_GETOPTLONG")
AC_CHECK_HEADERS(getopt.h, LVM_DEFS="$LVM_DEFS -DHAVE_GETOPTLONG")
################################################################################
dnl -- Check for readline (Shamelessly copied from parted 1.4.17)
@ -455,7 +467,7 @@ Note: if you are using precompiled packages you will also need the development
package as well (which may be called readline-devel or something similar).
)
)
AC_CHECK_FUNC(rl_completion_matches, CFLAGS="$CFLAGS -DHAVE_RL_COMPLETION_MATCHES")
AC_CHECK_FUNC(rl_completion_matches, LVM_DEFS="$LVM_DEFS -DHAVE_RL_COMPLETION_MATCHES")
fi
@ -536,7 +548,7 @@ fi
AC_PATH_PROG(MODPROBE_CMD, modprobe)
if test x$MODPROBE_CMD != x; then
CFLAGS="$CFLAGS -DMODPROBE_CMD=\\\"$MODPROBE_CMD\\\""
LVM_DEFS="$LVM_DEFS -DMODPROBE_CMD=\\\"$MODPROBE_CMD\\\""
fi
################################################################################
@ -556,6 +568,7 @@ AC_SUBST(MIRRORS)
AC_SUBST(OWNER)
AC_SUBST(GROUP)
AC_SUBST(CFLAGS)
AC_SUBST(LVM_DEFS)
AC_SUBST(COPTIMISE_FLAG)
AC_SUBST(CLDFLAGS)
AC_SUBST(CLDWHOLEARCHIVE)
@ -581,6 +594,8 @@ AC_SUBST(CLVMD)
AC_SUBST(CLUSTER)
AC_SUBST(FSADM)
AC_SUBST(DMEVENTD)
AC_SUBST(CFLOW_CMD)
AC_SUBST(CSCOPE_CMD)
################################################################################
dnl -- First and last lines should not contain files to generate in order to

View File

@ -35,19 +35,19 @@ ifeq ("@CLVMD@", "all")
endif
ifeq ("@DEBUG@", "yes")
CFLAGS += -DDEBUG
DEFS += -DDEBUG
endif
ifeq ("$(GULM)", "yes")
SOURCES += clvmd-gulm.c tcp-comms.c
LMLIBS += -lccs -lgulm
CFLAGS += -DUSE_GULM
DEFS += -DUSE_GULM
endif
ifeq ("$(CMAN)", "yes")
SOURCES += clvmd-cman.c
LMLIBS += -ldlm -lcman
CFLAGS += -DUSE_CMAN
DEFS += -DUSE_CMAN
endif
TARGETS = \
@ -63,7 +63,8 @@ ifeq ("@DEVMAPPER@", "yes")
LVMLIBS += -ldevmapper
endif
CFLAGS += -D_REENTRANT -fno-strict-aliasing
DEFS += -D_REENTRANT
CFLAGS += -fno-strict-aliasing
include $(top_srcdir)/make.tmpl

View File

@ -41,3 +41,5 @@ install:
install_cluster:
cflow:

View File

@ -38,6 +38,7 @@ SOURCES =\
commands/toolcontext.c \
config/config.c \
datastruct/btree.c \
datastruct/list.c \
datastruct/str_list.c \
device/dev-cache.c \
device/dev-io.c \
@ -141,5 +142,14 @@ LIB_STATIC = liblvm.a
$(SUBDIRS): $(LIB_STATIC)
CLEAN_TARGETS += liblvm.cflow
include $(top_srcdir)/make.tmpl
liblvm.cflow: $(SOURCES)
set -e; (echo -n "SOURCES += "; \
echo $(SOURCES) | \
sed "s/^/ /;s/ / $(top_srcdir)\/lib\//g;s/$$//"; \
) > $@
cflow: liblvm.cflow

View File

@ -85,7 +85,7 @@ char *build_dlid(struct dev_manager *dm, const char *lvid, const char *layer)
return _build_dlid(dm->mem, lvid, layer);
}
static inline int _read_only_lv(struct logical_volume *lv)
static int _read_only_lv(struct logical_volume *lv)
{
return (!(lv->vg->status & LVM_WRITE) || !(lv->status & LVM_WRITE));
}

View File

@ -107,7 +107,7 @@ void *btree_get_data(struct btree_iter *it)
return ((struct node *) it)->data;
}
static inline struct node *_left(struct node *n)
static struct node *_left(struct node *n)
{
while (n->l)
n = n->l;

View File

@ -33,107 +33,61 @@ struct list {
* The list head's next and previous pointers point back to itself.
*/
#define LIST_INIT(name) struct list name = { &(name), &(name) }
static inline void list_init(struct list *head)
{
head->n = head->p = head;
}
void list_init(struct list *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 list_add(struct list *head, struct list *elem)
{
assert(head->n);
elem->n = head;
elem->p = head->p;
head->p->n = elem;
head->p = elem;
}
void list_add(struct list *head, struct list *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 list_add_h(struct list *head, struct list *elem)
{
assert(head->n);
elem->n = head->n;
elem->p = head;
head->n->p = elem;
head->n = elem;
}
void list_add_h(struct list *head, struct list *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 list_del(struct list *elem)
{
elem->n->p = elem->p;
elem->p->n = elem->n;
}
void list_del(struct list *elem);
/*
* Is the list empty?
*/
static inline int list_empty(struct list *head)
{
return head->n == head;
}
int list_empty(struct list *head);
/*
* Is this the first element of the list?
*/
static inline int list_start(struct list *head, struct list *elem)
{
return elem->p == head;
}
int list_start(struct list *head, struct list *elem);
/*
* Is this the last element of the list?
*/
static inline int list_end(struct list *head, struct list *elem)
{
return elem->n == head;
}
int list_end(struct list *head, struct list *elem);
/*
* Return first element of the list or NULL if empty
*/
static inline struct list *list_first(struct list *head)
{
return (list_empty(head) ? NULL : head->n);
}
struct list *list_first(struct list *head);
/*
* Return last element of the list or NULL if empty
*/
static inline struct list *list_last(struct list *head)
{
return (list_empty(head) ? NULL : head->p);
}
struct list *list_last(struct list *head);
/*
* Return the previous element of the list, or NULL if we've reached the start.
*/
static inline struct list *list_prev(struct list *head, struct list *elem)
{
return (list_start(head, elem) ? NULL : elem->p);
}
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.
*/
static inline struct list *list_next(struct list *head, struct list *elem)
{
return (list_end(head, elem) ? NULL : elem->n);
}
struct list *list_next(struct list *head, struct list *elem);
/*
* Given the address v of an instance of 'struct list' called 'head'
@ -244,15 +198,6 @@ static inline struct list *list_next(struct list *head, struct list *elem)
/*
* Return the number of elements in a list by walking it.
*/
static inline unsigned int list_size(const struct list *head)
{
unsigned int s = 0;
const struct list *v;
list_iterate(v, head)
s++;
return s;
}
unsigned int list_size(const struct list *head);
#endif

View File

@ -479,7 +479,7 @@ static void _check_closed(struct device *dev)
log_err("Device '%s' has been left open.", dev_name(dev));
}
static inline void _check_for_open_devices(void)
static void _check_for_open_devices(void)
{
dm_hash_iter(_cache.names, (dm_hash_iterate_fn) _check_closed);
}
@ -664,7 +664,7 @@ void dev_iter_destroy(struct dev_iter *iter)
dm_free(iter);
}
static inline struct device *_iter_next(struct dev_iter *iter)
static struct device *_iter_next(struct dev_iter *iter)
{
struct device *d = btree_get_data(iter->current);
iter->current = btree_next(iter->current);
@ -682,3 +682,14 @@ struct device *dev_iter_get(struct dev_iter *iter)
return NULL;
}
int dev_fd(struct device *dev)
{
return dev->fd;
}
const char *dev_name(const struct device *dev)
{
return (dev) ? list_item(dev->aliases.n, struct str_list)->str :
"unknown device";
}

View File

@ -74,10 +74,8 @@ int dev_close_immediate(struct device *dev);
void dev_close_all(void);
int dev_test_excl(struct device *dev);
static inline int dev_fd(struct device *dev)
{
return dev->fd;
}
int dev_fd(struct device *dev);
const char *dev_name(const struct device *dev);
int dev_read(struct device *dev, uint64_t offset, size_t len, void *buffer);
int dev_write(struct device *dev, uint64_t offset, size_t len, void *buffer);
@ -88,12 +86,6 @@ void dev_flush(struct device *dev);
struct device *dev_create_file(const char *filename, struct device *dev,
struct str_list *alias, int use_malloc);
static inline const char *dev_name(const struct device *dev)
{
return (dev) ? list_item(dev->aliases.n, struct str_list)->str :
"unknown device";
}
/* Return a valid device name from the alias list; NULL otherwise */
const char *dev_name_confirmed(struct device *dev, int quiet);

View File

@ -24,12 +24,12 @@
#include "lvm-string.h"
#include "activate.h"
static const char *_name(const struct lv_segment *seg)
static const char *_errseg_name(const struct lv_segment *seg)
{
return seg->segtype->name;
}
static int _merge_segments(struct lv_segment *seg1, struct lv_segment *seg2)
static int _errseg_merge_segments(struct lv_segment *seg1, struct lv_segment *seg2)
{
seg1->len += seg2->len;
seg1->area_len += seg2->area_len;
@ -38,7 +38,7 @@ static int _merge_segments(struct lv_segment *seg1, struct lv_segment *seg2)
}
#ifdef DEVMAPPER_SUPPORT
static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem,
static int _errseg_add_target_line(struct dev_manager *dm, struct dm_pool *mem,
struct config_tree *cft, void **target_state,
struct lv_segment *seg,
struct dm_tree_node *node, uint64_t len,
@ -47,34 +47,34 @@ static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem,
return dm_tree_node_add_error_target(node, len);
}
static int _target_present(void)
static int _errseg_target_present(void)
{
static int checked = 0;
static int present = 0;
static int _errseg_checked = 0;
static int _errseg_present = 0;
/* Reported truncated in older kernels */
if (!checked &&
if (!_errseg_checked &&
(target_present("error", 0) || target_present("erro", 0)))
present = 1;
_errseg_present = 1;
checked = 1;
return present;
_errseg_checked = 1;
return _errseg_present;
}
#endif
static void _destroy(const struct segment_type *segtype)
static void _errseg_destroy(const struct segment_type *segtype)
{
dm_free((void *) segtype);
}
static struct segtype_handler _error_ops = {
name:_name,
merge_segments:_merge_segments,
name:_errseg_name,
merge_segments:_errseg_merge_segments,
#ifdef DEVMAPPER_SUPPORT
add_target_line:_add_target_line,
target_present:_target_present,
add_target_line:_errseg_add_target_line,
target_present:_errseg_target_present,
#endif
destroy:_destroy,
destroy:_errseg_destroy,
};
struct segment_type *init_error_segtype(struct cmd_context *cmd)

View File

@ -33,7 +33,7 @@ static int _and_p(struct dev_filter *f, struct device *dev)
return 1;
}
static void _destroy(struct dev_filter *f)
static void _composite_destroy(struct dev_filter *f)
{
struct dev_filter **filters = (struct dev_filter **) f->private;
@ -70,7 +70,7 @@ struct dev_filter *composite_filter_create(int n, struct dev_filter **filters)
}
cft->passes_filter = _and_p;
cft->destroy = _destroy;
cft->destroy = _composite_destroy;
cft->private = filters_copy;
return cft;

View File

@ -217,7 +217,7 @@ static int _lookup_p(struct dev_filter *f, struct device *dev)
return (l == PF_BAD_DEVICE) ? 0 : 1;
}
static void _destroy(struct dev_filter *f)
static void _persistent_destroy(struct dev_filter *f)
{
struct pfilter *pf = (struct pfilter *) f->private;
@ -258,7 +258,7 @@ struct dev_filter *persistent_filter_create(struct dev_filter *real,
}
f->passes_filter = _lookup_p;
f->destroy = _destroy;
f->destroy = _persistent_destroy;
f->private = pf;
return f;

View File

@ -191,7 +191,7 @@ static int _accept_p(struct dev_filter *f, struct device *dev)
return !rejected;
}
static void _destroy(struct dev_filter *f)
static void _regex_destroy(struct dev_filter *f)
{
struct rfilter *rf = (struct rfilter *) f->private;
dm_pool_destroy(rf->mem);
@ -226,7 +226,7 @@ struct dev_filter *regex_filter_create(struct config_value *patterns)
}
f->passes_filter = _accept_p;
f->destroy = _destroy;
f->destroy = _regex_destroy;
f->private = rf;
return f;

View File

@ -88,7 +88,7 @@ static struct dev_set *_dev_set_create(struct dm_pool *mem, const char *sys_bloc
return ds;
}
static inline unsigned _hash_dev(dev_t dev)
static unsigned _hash_dev(dev_t dev)
{
return (major(dev) ^ minor(dev)) & (SET_BUCKETS - 1);
}

View File

@ -269,7 +269,7 @@ static int _read_uuids(struct disk_list *data)
return 1;
}
static inline int _check_lvd(struct lv_disk *lvd)
static int _check_lvd(struct lv_disk *lvd)
{
return !(lvd->lv_name[0] == '\0');
}

View File

@ -173,7 +173,7 @@ static struct volume_group *_build_vg(struct format_instance *fid,
return NULL;
}
static struct volume_group *_vg_read(struct format_instance *fid,
static struct volume_group *_format1_vg_read(struct format_instance *fid,
const char *vg_name,
struct metadata_area *mda)
{
@ -264,7 +264,7 @@ static int _flatten_vg(struct format_instance *fid, struct dm_pool *mem,
return 1;
}
static int _vg_write(struct format_instance *fid, struct volume_group *vg,
static int _format1_vg_write(struct format_instance *fid, struct volume_group *vg,
struct metadata_area *mda)
{
struct dm_pool *mem = dm_pool_create("lvm1 vg_write", 1024 * 10);
@ -287,7 +287,7 @@ static int _vg_write(struct format_instance *fid, struct volume_group *vg,
return r;
}
static int _pv_read(const struct format_type *fmt, const char *pv_name,
static int _format1_pv_read(const struct format_type *fmt, const char *pv_name,
struct physical_volume *pv, struct list *mdas)
{
struct dm_pool *mem = dm_pool_create("lvm1 pv_read", 1024);
@ -326,7 +326,7 @@ static int _pv_read(const struct format_type *fmt, const char *pv_name,
return r;
}
static int _pv_setup(const struct format_type *fmt,
static int _format1_pv_setup(const struct format_type *fmt,
uint64_t pe_start, uint32_t extent_count,
uint32_t extent_size,
int pvmetadatacopies,
@ -364,7 +364,7 @@ static int _pv_setup(const struct format_type *fmt,
return 1;
}
static int _lv_setup(struct format_instance *fid, struct logical_volume *lv)
static int _format1_lv_setup(struct format_instance *fid, struct logical_volume *lv)
{
uint64_t max_size = UINT_MAX;
@ -386,7 +386,7 @@ static int _lv_setup(struct format_instance *fid, struct logical_volume *lv)
return 1;
}
static int _pv_write(const struct format_type *fmt, struct physical_volume *pv,
static int _format1_pv_write(const struct format_type *fmt, struct physical_volume *pv,
struct list *mdas, int64_t sector)
{
struct dm_pool *mem;
@ -449,7 +449,7 @@ static int _pv_write(const struct format_type *fmt, struct physical_volume *pv,
return 0;
}
static int _vg_setup(struct format_instance *fid, struct volume_group *vg)
static int _format1_vg_setup(struct format_instance *fid, struct volume_group *vg)
{
/* just check max_pv and max_lv */
if (!vg->max_lv || vg->max_lv >= MAX_LV)
@ -484,7 +484,7 @@ static int _vg_setup(struct format_instance *fid, struct volume_group *vg)
return 1;
}
static int _segtype_supported (struct format_instance *fid,
static int _format1_segtype_supported(struct format_instance *fid,
struct segment_type *segtype)
{
if (!(segtype->flags & SEG_FORMAT1_SUPPORT)) {
@ -496,11 +496,11 @@ static int _segtype_supported (struct format_instance *fid,
}
static struct metadata_area_ops _metadata_format1_ops = {
vg_read:_vg_read,
vg_write:_vg_write,
vg_read:_format1_vg_read,
vg_write:_format1_vg_write,
};
static struct format_instance *_create_instance(const struct format_type *fmt,
static struct format_instance *_format1_create_instance(const struct format_type *fmt,
const char *vgname,
const char *vgid,
void *private)
@ -530,26 +530,26 @@ static struct format_instance *_create_instance(const struct format_type *fmt,
return fid;
}
static void _destroy_instance(struct format_instance *fid)
static void _format1_destroy_instance(struct format_instance *fid)
{
return;
}
static void _destroy(const struct format_type *fmt)
static void _format1_destroy(const struct format_type *fmt)
{
dm_free((void *) fmt);
}
static struct format_handler _format1_ops = {
pv_read:_pv_read,
pv_setup:_pv_setup,
pv_write:_pv_write,
lv_setup:_lv_setup,
vg_setup:_vg_setup,
segtype_supported:_segtype_supported,
create_instance:_create_instance,
destroy_instance:_destroy_instance,
destroy:_destroy,
pv_read:_format1_pv_read,
pv_setup:_format1_pv_setup,
pv_write:_format1_pv_write,
lv_setup:_format1_lv_setup,
vg_setup:_format1_vg_setup,
segtype_supported:_format1_segtype_supported,
create_instance:_format1_create_instance,
destroy_instance:_format1_destroy_instance,
destroy:_format1_destroy,
};
#ifdef LVM1_INTERNAL

View File

@ -19,16 +19,18 @@
/*
* Only works with powers of 2.
*/
static inline uint32_t _round_up(uint32_t n, uint32_t size)
static uint32_t _round_up(uint32_t n, uint32_t size)
{
size--;
return (n + size) & ~size;
}
static inline uint32_t _div_up(uint32_t n, uint32_t size)
/* Unused.
static uint32_t _div_up(uint32_t n, uint32_t size)
{
return _round_up(n, size) / size;
}
*/
/*
* Each chunk of metadata should be aligned to

View File

@ -30,7 +30,7 @@ static void _not_supported(const char *op)
op);
}
static int _can_handle(struct labeller *l, char *buf, uint64_t sector)
static int _lvm1_can_handle(struct labeller *l, char *buf, uint64_t sector)
{
struct pv_disk *pvd = (struct pv_disk *) buf;
uint32_t version;
@ -48,13 +48,13 @@ static int _can_handle(struct labeller *l, char *buf, uint64_t sector)
return 0;
}
static int _write(struct label *label, char *buf)
static int _lvm1_write(struct label *label, char *buf)
{
_not_supported("write");
return 0;
}
static int _read(struct labeller *l, struct device *dev, char *buf,
static int _lvm1_read(struct labeller *l, struct device *dev, char *buf,
struct label **label)
{
struct pv_disk *pvd = (struct pv_disk *) buf;
@ -85,31 +85,31 @@ static int _read(struct labeller *l, struct device *dev, char *buf,
return 1;
}
static int _initialise_label(struct labeller *l, struct label *label)
static int _lvm1_initialise_label(struct labeller *l, struct label *label)
{
strcpy(label->type, "LVM1");
return 1;
}
static void _destroy_label(struct labeller *l, struct label *label)
static void _lvm1_destroy_label(struct labeller *l, struct label *label)
{
return;
}
static void _destroy(struct labeller *l)
static void _lvm1_destroy(struct labeller *l)
{
dm_free(l);
}
struct label_ops _lvm1_ops = {
can_handle:_can_handle,
write:_write,
read:_read,
verify:_can_handle,
initialise_label:_initialise_label,
destroy_label:_destroy_label,
destroy:_destroy
can_handle:_lvm1_can_handle,
write:_lvm1_write,
read:_lvm1_read,
verify:_lvm1_can_handle,
initialise_label:_lvm1_initialise_label,
destroy_label:_lvm1_destroy_label,
destroy:_lvm1_destroy
};
struct labeller *lvm1_labeller_create(struct format_type *fmt)

View File

@ -169,7 +169,7 @@ static struct volume_group *_build_vg_from_pds(struct format_instance
return vg;
}
static struct volume_group *_vg_read(struct format_instance *fid,
static struct volume_group *_pool_vg_read(struct format_instance *fid,
const char *vg_name,
struct metadata_area *mda)
{
@ -206,7 +206,7 @@ static struct volume_group *_vg_read(struct format_instance *fid,
return vg;
}
static int _pv_setup(const struct format_type *fmt,
static int _pool_pv_setup(const struct format_type *fmt,
uint64_t pe_start, uint32_t extent_count,
uint32_t extent_size,
int pvmetadatacopies,
@ -216,7 +216,7 @@ static int _pv_setup(const struct format_type *fmt,
return 1;
}
static int _pv_read(const struct format_type *fmt, const char *pv_name,
static int _pool_pv_read(const struct format_type *fmt, const char *pv_name,
struct physical_volume *pv, struct list *mdas)
{
struct dm_pool *mem = dm_pool_create("pool pv_read", 1024);
@ -262,11 +262,11 @@ static int _pv_read(const struct format_type *fmt, const char *pv_name,
/* *INDENT-OFF* */
static struct metadata_area_ops _metadata_format_pool_ops = {
vg_read:_vg_read,
vg_read:_pool_vg_read,
};
/* *INDENT-ON* */
static struct format_instance *_create_instance(const struct format_type *fmt,
static struct format_instance *_pool_create_instance(const struct format_type *fmt,
const char *vgname,
const char *vgid,
void *private)
@ -298,23 +298,23 @@ static struct format_instance *_create_instance(const struct format_type *fmt,
return fid;
}
static void _destroy_instance(struct format_instance *fid)
static void _pool_destroy_instance(struct format_instance *fid)
{
return;
}
static void _destroy(const struct format_type *fmt)
static void _pool_destroy(const struct format_type *fmt)
{
dm_free((void *) fmt);
}
/* *INDENT-OFF* */
static struct format_handler _format_pool_ops = {
pv_read:_pv_read,
pv_setup:_pv_setup,
create_instance:_create_instance,
destroy_instance:_destroy_instance,
destroy:_destroy,
pv_read:_pool_pv_read,
pv_setup:_pool_pv_setup,
create_instance:_pool_create_instance,
destroy_instance:_pool_destroy_instance,
destroy:_pool_destroy,
};
/* *INDENT-ON */

View File

@ -23,13 +23,13 @@
#include <sys/stat.h>
#include <fcntl.h>
static void _not_supported(const char *op)
static void _pool_not_supported(const char *op)
{
log_error("The '%s' operation is not supported for the pool labeller.",
op);
}
static int _can_handle(struct labeller *l, char *buf, uint64_t sector)
static int _pool_can_handle(struct labeller *l, char *buf, uint64_t sector)
{
struct pool_disk pd;
@ -50,13 +50,13 @@ static int _can_handle(struct labeller *l, char *buf, uint64_t sector)
return 0;
}
static int _write(struct label *label, char *buf)
static int _pool_write(struct label *label, char *buf)
{
_not_supported("write");
_pool_not_supported("write");
return 0;
}
static int _read(struct labeller *l, struct device *dev, char *buf,
static int _pool_read(struct labeller *l, struct device *dev, char *buf,
struct label **label)
{
struct pool_list pl;
@ -64,31 +64,31 @@ static int _read(struct labeller *l, struct device *dev, char *buf,
return read_pool_label(&pl, l, dev, buf, label);
}
static int _initialise_label(struct labeller *l, struct label *label)
static int _pool_initialise_label(struct labeller *l, struct label *label)
{
strcpy(label->type, "POOL");
return 1;
}
static void _destroy_label(struct labeller *l, struct label *label)
static void _pool_destroy_label(struct labeller *l, struct label *label)
{
return;
}
static void _destroy(struct labeller *l)
static void _label_pool_destroy(struct labeller *l)
{
dm_free(l);
}
struct label_ops _pool_ops = {
can_handle:_can_handle,
write:_write,
read:_read,
verify:_can_handle,
initialise_label:_initialise_label,
destroy_label:_destroy_label,
destroy:_destroy
can_handle:_pool_can_handle,
write:_pool_write,
read:_pool_read,
verify:_pool_can_handle,
initialise_label:_pool_initialise_label,
destroy_label:_pool_destroy_label,
destroy:_label_pool_destroy
};
struct labeller *pool_labeller_create(struct format_type *fmt)

View File

@ -87,7 +87,7 @@ static int _split_vg(const char *filename, char *vgname, size_t vg_size,
return 1;
}
static void _insert_file(struct list *head, struct archive_file *b)
static void _insert_archive_file(struct list *head, struct archive_file *b)
{
struct archive_file *bf = NULL;
@ -107,7 +107,7 @@ static void _insert_file(struct list *head, struct archive_file *b)
list_add_h(&bf->list, &b->list);
}
static char *_join(struct dm_pool *mem, const char *dir, const char *name)
static char *_join_file_to_dir(struct dm_pool *mem, const char *dir, const char *name)
{
if (!dm_pool_begin_object(mem, 32) ||
!dm_pool_grow_object(mem, dir, strlen(dir)) ||
@ -161,7 +161,7 @@ static struct list *_scan_archive(struct dm_pool *mem,
if (strcmp(vgname, vgname_found))
continue;
if (!(path = _join(mem, dir, dirent[i]->d_name))) {
if (!(path = _join_file_to_dir(mem, dir, dirent[i]->d_name))) {
stack;
goto out;
}
@ -181,7 +181,7 @@ static struct list *_scan_archive(struct dm_pool *mem,
/*
* Insert it to the correct part of the list.
*/
_insert_file(results, af);
_insert_archive_file(results, af);
}
out:
@ -360,7 +360,7 @@ int backup_list(struct cmd_context *cmd, const char *dir, const char *vgname)
{
struct archive_file af;
if (!(af.path = _join(cmd->mem, dir, vgname))) {
if (!(af.path = _join_file_to_dir(cmd->mem, dir, vgname))) {
stack;
return 0;
}

View File

@ -354,8 +354,7 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
* Get the pv%d name from the formatters hash
* table.
*/
static inline const char *_get_pv_name(struct formatter *f,
struct physical_volume *pv)
static const char *_get_pv_name(struct formatter *f, struct physical_volume *pv)
{
return (pv) ? (const char *)
dm_hash_lookup(f->pv_names, dev_name(pv->dev)) : "Missing";

View File

@ -39,7 +39,7 @@
#define FMT_TEXT_NAME "lvm2"
#define FMT_TEXT_ALIAS "text"
static struct format_instance *_create_text_instance(const struct format_type
static struct format_instance *_text_create_text_instance(const struct format_type
*fmt, const char *vgname,
const char *vgid,
void *context);
@ -69,7 +69,7 @@ struct text_context {
* NOTE: Currently there can be only one vg per text file.
*/
static int _vg_setup(struct format_instance *fid, struct volume_group *vg)
static int _text_vg_setup(struct format_instance *fid, struct volume_group *vg)
{
if (vg->extent_size & (vg->extent_size - 1)) {
log_error("Extent size must be power of 2");
@ -79,7 +79,7 @@ static int _vg_setup(struct format_instance *fid, struct volume_group *vg)
return 1;
}
static int _lv_setup(struct format_instance *fid, struct logical_volume *lv)
static int _text_lv_setup(struct format_instance *fid, struct logical_volume *lv)
{
/******** FIXME Any LV size restriction?
uint64_t max_size = UINT_MAX;
@ -859,7 +859,7 @@ static int _scan_file(const struct format_type *fmt)
}
/* FIXME stat file to see if it's changed */
fid = _create_text_instance(fmt, NULL, NULL,
fid = _text_create_text_instance(fmt, NULL, NULL,
NULL);
if ((vg = _vg_read_file_name(fid, vgname,
path)))
@ -979,7 +979,7 @@ static int _scan_raw(const struct format_type *fmt)
return 1;
}
static int _scan(const struct format_type *fmt)
static int _text_scan(const struct format_type *fmt)
{
return (_scan_file(fmt) & _scan_raw(fmt));
}
@ -1125,7 +1125,7 @@ static int _mda_setup(const struct format_type *fmt,
/* Only for orphans */
/* Set label_sector to -1 if rewriting existing label into same sector */
static int _pv_write(const struct format_type *fmt, struct physical_volume *pv,
static int _text_pv_write(const struct format_type *fmt, struct physical_volume *pv,
struct list *mdas, int64_t label_sector)
{
struct label *label;
@ -1250,7 +1250,7 @@ static int _add_raw(struct list *raw_list, struct device_area *dev_area)
return 1;
}
static int _pv_read(const struct format_type *fmt, const char *pv_name,
static int _text_pv_read(const struct format_type *fmt, const char *pv_name,
struct physical_volume *pv, struct list *mdas)
{
struct label *label;
@ -1332,7 +1332,7 @@ static int _pv_read(const struct format_type *fmt, const char *pv_name,
return 1;
}
static void _destroy_instance(struct format_instance *fid)
static void _text_destroy_instance(struct format_instance *fid)
{
return;
}
@ -1357,7 +1357,7 @@ static void _free_raws(struct list *raw_list)
}
}
static void _destroy(const struct format_type *fmt)
static void _text_destroy(const struct format_type *fmt)
{
if (fmt->private) {
_free_dirs(&((struct mda_lists *) fmt->private)->dirs);
@ -1394,7 +1394,7 @@ static struct metadata_area_ops _metadata_text_raw_ops = {
};
/* pvmetadatasize in sectors */
static int _pv_setup(const struct format_type *fmt,
static int _text_pv_setup(const struct format_type *fmt,
uint64_t pe_start, uint32_t extent_count,
uint32_t extent_size,
int pvmetadatacopies,
@ -1411,7 +1411,7 @@ static int _pv_setup(const struct format_type *fmt,
/* FIXME if vg, adjust start/end of pe area to avoid mdas! */
/* FIXME Cope with pvchange */
/* FIXME Merge code with _create_text_instance */
/* FIXME Merge code with _text_create_text_instance */
/* If new vg, add any further mdas on this PV to the fid's mda list */
if (vg) {
@ -1479,7 +1479,7 @@ static int _pv_setup(const struct format_type *fmt,
}
/* NULL vgname means use only the supplied context e.g. an archive file */
static struct format_instance *_create_text_instance(const struct format_type
static struct format_instance *_text_create_text_instance(const struct format_type
*fmt, const char *vgname,
const char *vgid,
void *context)
@ -1649,15 +1649,15 @@ void *create_text_context(struct cmd_context *cmd, const char *path,
}
static struct format_handler _text_handler = {
scan:_scan,
pv_read:_pv_read,
pv_setup:_pv_setup,
pv_write:_pv_write,
vg_setup:_vg_setup,
lv_setup:_lv_setup,
create_instance:_create_text_instance,
destroy_instance:_destroy_instance,
destroy:_destroy
scan:_text_scan,
pv_read:_text_pv_read,
pv_setup:_text_pv_setup,
pv_write:_text_pv_write,
vg_setup:_text_vg_setup,
lv_setup:_text_lv_setup,
create_instance:_text_create_text_instance,
destroy_instance:_text_destroy_instance,
destroy:_text_destroy
};
static int _add_dir(const char *dir, struct list *dir_list)

View File

@ -35,12 +35,12 @@ const char *text_vgname_import(const struct format_type *fmt,
struct text_vg_version_ops **vsn;
const char *vgname;
static int _initialised = 0;
static int _text_import_initialised = 0;
if (!_initialised) {
if (!_text_import_initialised) {
_text_vsn_list[0] = text_vg_vsn1_init();
_text_vsn_list[1] = NULL;
_initialised = 1;
_text_import_initialised = 1;
}
if (!(cft = create_config_tree(NULL)))
@ -83,12 +83,12 @@ struct volume_group *text_vg_import_fd(struct format_instance *fid,
struct config_tree *cft;
struct text_vg_version_ops **vsn;
static int _initialised = 0;
static int _text_vg_import_initialised = 0;
if (!_initialised) {
if (!_text_vg_import_initialised) {
_text_vsn_list[0] = text_vg_vsn1_init();
_text_vsn_list[1] = NULL;
_initialised = 1;
_text_vg_import_initialised = 1;
}
*desc = NULL;

View File

@ -23,7 +23,7 @@
#include <sys/stat.h>
#include <fcntl.h>
static int _can_handle(struct labeller *l, char *buf, uint64_t sector)
static int _text_can_handle(struct labeller *l, char *buf, uint64_t sector)
{
struct label_header *lh = (struct label_header *) buf;
@ -33,7 +33,7 @@ static int _can_handle(struct labeller *l, char *buf, uint64_t sector)
return 0;
}
static int _write(struct label *label, char *buf)
static int _text_write(struct label *label, char *buf)
{
struct label_header *lh = (struct label_header *) buf;
struct pv_header *pvhdr;
@ -179,14 +179,14 @@ void del_mdas(struct list *mdas)
}
}
static int _initialise_label(struct labeller *l, struct label *label)
static int _text_initialise_label(struct labeller *l, struct label *label)
{
strncpy(label->type, LVM2_LABEL, sizeof(label->type));
return 1;
}
static int _read(struct labeller *l, struct device *dev, char *buf,
static int _text_read(struct labeller *l, struct device *dev, char *buf,
struct label **label)
{
struct label_header *lh = (struct label_header *) buf;
@ -248,7 +248,7 @@ static int _read(struct labeller *l, struct device *dev, char *buf,
return 1;
}
static void _destroy_label(struct labeller *l, struct label *label)
static void _text_destroy_label(struct labeller *l, struct label *label)
{
struct lvmcache_info *info = (struct lvmcache_info *) label->info;
@ -258,19 +258,19 @@ static void _destroy_label(struct labeller *l, struct label *label)
del_das(&info->das);
}
static void _destroy(struct labeller *l)
static void _fmt_text_destroy(struct labeller *l)
{
dm_free(l);
}
struct label_ops _text_ops = {
can_handle:_can_handle,
write:_write,
read:_read,
verify:_can_handle,
initialise_label:_initialise_label,
destroy_label:_destroy_label,
destroy:_destroy
can_handle:_text_can_handle,
write:_text_write,
read:_text_read,
verify:_text_can_handle,
initialise_label:_text_initialise_label,
destroy_label:_text_destroy_label,
destroy:_fmt_text_destroy
};
struct labeller *text_labeller_create(const struct format_type *fmt)

View File

@ -102,7 +102,7 @@ void reset_locking(void)
_unblock_signals();
}
static inline void _update_vg_lock_count(int flags)
static void _update_vg_lock_count(int flags)
{
if ((flags & LCK_SCOPE_MASK) != LCK_VG)
return;

View File

@ -23,9 +23,9 @@
#include "ctype.h"
#include "dev-cache.h"
#include "lvm-string.h"
#include "uuid.h"
#define NAME_LEN 128
#define MAX_STRIPES 128
#define SECTOR_SHIFT 9L
#define SECTOR_SIZE ( 1L << SECTOR_SHIFT )
@ -609,29 +609,4 @@ uint32_t find_free_lvnum(struct logical_volume *lv);
char *generate_lv_name(struct volume_group *vg, const char *format,
char *buffer, size_t len);
static inline int validate_name(const char *n)
{
register char c;
register int len = 0;
if (!n || !*n)
return 0;
/* Hyphen used as VG-LV separator - ambiguity if LV starts with it */
if (*n == '-')
return 0;
if (!strcmp(n, ".") || !strcmp(n, ".."))
return 0;
while ((len++, c = *n++))
if (!isalnum(c) && c != '.' && c != '_' && c != '-' && c != '+')
return 0;
if (len > NAME_LEN)
return 0;
return 1;
}
#endif

View File

@ -43,12 +43,12 @@ struct mirror_state {
uint32_t default_region_size;
};
static const char *_name(const struct lv_segment *seg)
static const char *_mirrored_name(const struct lv_segment *seg)
{
return seg->segtype->name;
}
static void _display(const struct lv_segment *seg)
static void _mirrored_display(const struct lv_segment *seg)
{
const char *size;
uint32_t s;
@ -73,7 +73,7 @@ static void _display(const struct lv_segment *seg)
log_print(" ");
}
static int _text_import_area_count(struct config_node *sn, uint32_t *area_count)
static int _mirrored_text_import_area_count(struct config_node *sn, uint32_t *area_count)
{
if (!get_config_uint32(sn, "mirror_count", area_count)) {
log_error("Couldn't read 'mirror_count' for "
@ -84,7 +84,7 @@ static int _text_import_area_count(struct config_node *sn, uint32_t *area_count)
return 1;
}
static int _text_import(struct lv_segment *seg, const struct config_node *sn,
static int _mirrored_text_import(struct lv_segment *seg, const struct config_node *sn,
struct dm_hash_table *pv_hash)
{
const struct config_node *cn;
@ -139,7 +139,7 @@ static int _text_import(struct lv_segment *seg, const struct config_node *sn,
return text_import_areas(seg, sn, cn, pv_hash, MIRROR_IMAGE);
}
static int _text_export(const struct lv_segment *seg, struct formatter *f)
static int _mirrored_text_export(const struct lv_segment *seg, struct formatter *f)
{
outf(f, "mirror_count = %u", seg->area_count);
if (seg->status & PVMOVE)
@ -154,7 +154,7 @@ static int _text_export(const struct lv_segment *seg, struct formatter *f)
}
#ifdef DEVMAPPER_SUPPORT
static struct mirror_state *_init_target(struct dm_pool *mem,
static struct mirror_state *_mirrored_init_target(struct dm_pool *mem,
struct config_tree *cft)
{
struct mirror_state *mirr_state;
@ -172,7 +172,7 @@ static struct mirror_state *_init_target(struct dm_pool *mem,
return mirr_state;
}
static int _target_percent(void **target_state, struct dm_pool *mem,
static int _mirrored_target_percent(void **target_state, struct dm_pool *mem,
struct config_tree *cft, struct lv_segment *seg,
char *params, uint64_t *total_numerator,
uint64_t *total_denominator, float *percent)
@ -184,7 +184,7 @@ static int _target_percent(void **target_state, struct dm_pool *mem,
char *pos = params;
if (!*target_state)
*target_state = _init_target(mem, cft);
*target_state = _mirrored_init_target(mem, cft);
mirr_state = *target_state;
@ -251,7 +251,7 @@ static int _add_log(struct dev_manager *dm, struct lv_segment *seg,
return dm_tree_node_add_mirror_target_log(node, region_size, clustered, log_dlid, area_count, log_flags);
}
static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem,
static int _mirrored_add_target_line(struct dev_manager *dm, struct dm_pool *mem,
struct config_tree *cft, void **target_state,
struct lv_segment *seg,
struct dm_tree_node *node, uint64_t len,
@ -265,7 +265,7 @@ static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem,
int r;
if (!*target_state)
*target_state = _init_target(mem, cft);
*target_state = _mirrored_init_target(mem, cft);
mirr_state = *target_state;
@ -322,16 +322,16 @@ static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem,
return add_areas_line(dm, seg, node, start_area, area_count);
}
static int _target_present(void)
static int _mirrored_target_present(void)
{
static int checked = 0;
static int present = 0;
static int _mirrored_checked = 0;
static int _mirrored_present = 0;
uint32_t maj, min, patchlevel;
unsigned maj2, min2, patchlevel2;
char vsn[80];
if (!checked) {
present = target_present("mirror", 1);
if (!_mirrored_checked) {
_mirrored_present = target_present("mirror", 1);
/*
* block_on_error available with mirror target >= 1.1
@ -348,9 +348,9 @@ static int _target_present(void)
_block_on_error_available = 1;
}
checked = 1;
_mirrored_checked = 1;
return present;
return _mirrored_present;
}
#ifdef DMEVENTD
@ -436,27 +436,27 @@ static int _target_unregister_events(struct dm_pool *mem,
#endif /* DMEVENTD */
#endif /* DEVMAPPER_SUPPORT */
static void _destroy(const struct segment_type *segtype)
static void _mirrored_destroy(const struct segment_type *segtype)
{
dm_free((void *) segtype);
}
static struct segtype_handler _mirrored_ops = {
name:_name,
display:_display,
text_import_area_count:_text_import_area_count,
text_import:_text_import,
text_export:_text_export,
name:_mirrored_name,
display:_mirrored_display,
text_import_area_count:_mirrored_text_import_area_count,
text_import:_mirrored_text_import,
text_export:_mirrored_text_export,
#ifdef DEVMAPPER_SUPPORT
add_target_line:_add_target_line,
target_percent:_target_percent,
target_present:_target_present,
add_target_line:_mirrored_add_target_line,
target_percent:_mirrored_target_percent,
target_present:_mirrored_target_present,
#ifdef DMEVENTD
target_register_events:_target_register_events,
target_unregister_events:_target_unregister_events,
#endif
#endif
destroy:_destroy,
destroy:_mirrored_destroy,
};
#ifdef MIRRORED_INTERNAL

View File

@ -208,3 +208,27 @@ int split_dm_name(struct dm_pool *mem, const char *dmname,
return 1;
}
int validate_name(const char *n)
{
register char c;
register int len = 0;
if (!n || !*n)
return 0;
/* Hyphen used as VG-LV separator - ambiguity if LV starts with it */
if (*n == '-')
return 0;
if (!strcmp(n, ".") || !strcmp(n, ".."))
return 0;
while ((len++, c = *n++))
if (!isalnum(c) && c != '.' && c != '_' && c != '-' && c != '+')
return 0;
if (len > NAME_LEN)
return 0;
return 1;
}

View File

@ -19,6 +19,8 @@
#include <stdio.h>
#include <stdarg.h>
#define NAME_LEN 128
struct pool;
/*
@ -40,4 +42,6 @@ char *build_dm_name(struct dm_pool *mem, const char *vg,
int split_dm_name(struct dm_pool *mem, const char *dmname,
char **vgname, char **lvname, char **layer);
int validate_name(const char *n);
#endif

View File

@ -90,7 +90,7 @@ static void _release_memory(void)
}
/* Stop memory getting swapped out */
static void _lock_memory(void)
static void _lock_mem(void)
{
#ifdef MCL_CURRENT
if (mlockall(MCL_CURRENT | MCL_FUTURE))
@ -109,7 +109,7 @@ static void _lock_memory(void)
_default_priority, strerror(errno));
}
static void _unlock_memory(void)
static void _unlock_mem(void)
{
#ifdef MCL_CURRENT
if (munlockall())
@ -126,14 +126,14 @@ static void _unlock_memory(void)
void memlock_inc(void)
{
if (!_memlock_count++)
_lock_memory();
_lock_mem();
log_debug("memlock_count inc to %d", _memlock_count);
}
void memlock_dec(void)
{
if (_memlock_count && (!--_memlock_count))
_unlock_memory();
_unlock_mem();
log_debug("memlock_count dec to %d", _memlock_count);
}

View File

@ -166,7 +166,7 @@ static void _calc_functions(struct matcher *m)
}
}
static inline struct dfa_state *_create_dfa_state(struct dm_pool *mem)
static struct dfa_state *_create_dfa_state(struct dm_pool *mem)
{
return dm_pool_zalloc(mem, sizeof(struct dfa_state));
}
@ -337,8 +337,7 @@ struct matcher *matcher_create(struct dm_pool *mem, const char **patterns,
return NULL;
}
static inline struct dfa_state *_step_matcher(int c,
struct dfa_state *cs, int *r)
static struct dfa_state *_step_matcher(int c, struct dfa_state *cs, int *r)
{
if (!(cs = cs->lookup[(unsigned char) c]))
return NULL;

View File

@ -38,7 +38,7 @@ static void _single_char(struct parse_sp *ps, unsigned int c, const char *ptr)
* Get the next token from the regular expression.
* Returns: 1 success, 0 end of input, -1 error.
*/
static int _get_token(struct parse_sp *ps)
static int _rx_get_token(struct parse_sp *ps)
{
int neg = 0, range = 0;
char c, lc = 0;
@ -230,17 +230,17 @@ static struct rx_node *_term(struct parse_sp *ps)
}
dm_bit_copy(n->charset, ps->charset);
_get_token(ps); /* match charset */
_rx_get_token(ps); /* match charset */
break;
case '(':
_get_token(ps); /* match '(' */
_rx_get_token(ps); /* match '(' */
n = _or_term(ps);
if (ps->type != ')') {
log_error("missing ')' in regular expression");
return 0;
}
_get_token(ps); /* match ')' */
_rx_get_token(ps); /* match ')' */
break;
default:
@ -280,7 +280,7 @@ static struct rx_node *_closure_term(struct parse_sp *ps)
return NULL;
}
_get_token(ps);
_rx_get_token(ps);
l = n;
}
@ -316,7 +316,7 @@ static struct rx_node *_or_term(struct parse_sp *ps)
if (ps->type != '|')
return l;
_get_token(ps); /* match '|' */
_rx_get_token(ps); /* match '|' */
if (!(r = _or_term(ps))) {
log_error("Badly formed 'or' expression");
@ -344,7 +344,7 @@ struct rx_node *rx_parse_tok(struct dm_pool *mem,
ps->charset = dm_bitset_create(mem, 256);
ps->cursor = begin;
ps->rx_end = end;
_get_token(ps); /* load the first token */
_rx_get_token(ps); /* load the first token */
if (!(r = _or_term(ps))) {
log_error("Parse error in regex");

View File

@ -59,7 +59,7 @@ void *ttree_lookup(struct ttree *tt, unsigned *key)
return *c ? (*c)->data : NULL;
}
static struct node *_node(struct dm_pool *mem, unsigned int k)
static struct node *_tree_node(struct dm_pool *mem, unsigned int k)
{
struct node *n = dm_pool_zalloc(mem, sizeof(*n));
@ -86,7 +86,7 @@ int ttree_insert(struct ttree *tt, unsigned int *key, void *data)
count++;
while (count--) {
if (!(*c = _node(tt->mem, k))) {
if (!(*c = _tree_node(tt->mem, k))) {
stack;
return 0;
}

View File

@ -21,12 +21,12 @@
#include "config.h"
#include "activate.h"
static const char *_name(const struct lv_segment *seg)
static const char *_snap_name(const struct lv_segment *seg)
{
return seg->segtype->name;
}
static int _text_import(struct lv_segment *seg, const struct config_node *sn,
static int _snap_text_import(struct lv_segment *seg, const struct config_node *sn,
struct dm_hash_table *pv_hash)
{
uint32_t chunk_size;
@ -77,7 +77,7 @@ static int _text_import(struct lv_segment *seg, const struct config_node *sn,
return 1;
}
static int _text_export(const struct lv_segment *seg, struct formatter *f)
static int _snap_text_export(const struct lv_segment *seg, struct formatter *f)
{
outf(f, "chunk_size = %u", seg->chunk_size);
outf(f, "origin = \"%s\"", seg->origin->name);
@ -87,7 +87,7 @@ static int _text_export(const struct lv_segment *seg, struct formatter *f)
}
#ifdef DEVMAPPER_SUPPORT
static int _target_percent(void **target_state, struct dm_pool *mem,
static int _snap_target_percent(void **target_state, struct dm_pool *mem,
struct config_tree *cft, struct lv_segment *seg,
char *params, uint64_t *total_numerator,
uint64_t *total_denominator, float *percent)
@ -109,35 +109,35 @@ static int _target_percent(void **target_state, struct dm_pool *mem,
return 1;
}
static int _target_present(void)
static int _snap_target_present(void)
{
static int checked = 0;
static int present = 0;
static int _snap_checked = 0;
static int _snap_present = 0;
if (!checked)
present = target_present("snapshot", 1) &&
if (!_snap_checked)
_snap_present = target_present("snapshot", 1) &&
target_present("snapshot-origin", 0);
checked = 1;
_snap_checked = 1;
return present;
return _snap_present;
}
#endif
static void _destroy(const struct segment_type *segtype)
static void _snap_destroy(const struct segment_type *segtype)
{
dm_free((void *) segtype);
}
static struct segtype_handler _snapshot_ops = {
name:_name,
text_import:_text_import,
text_export:_text_export,
name:_snap_name,
text_import:_snap_text_import,
text_export:_snap_text_export,
#ifdef DEVMAPPER_SUPPORT
target_percent:_target_percent,
target_present:_target_present,
target_percent:_snap_target_percent,
target_present:_snap_target_present,
#endif
destroy:_destroy,
destroy:_snap_destroy,
};
#ifdef SNAPSHOT_INTERNAL

View File

@ -26,12 +26,12 @@
#include "activate.h"
#include "pv_alloc.h"
static const char *_name(const struct lv_segment *seg)
static const char *_striped_name(const struct lv_segment *seg)
{
return (seg->area_count == 1) ? "linear" : seg->segtype->name;
}
static void _display(const struct lv_segment *seg)
static void _striped_display(const struct lv_segment *seg)
{
uint32_t s;
@ -49,7 +49,7 @@ static void _display(const struct lv_segment *seg)
log_print(" ");
}
static int _text_import_area_count(struct config_node *sn, uint32_t *area_count)
static int _striped_text_import_area_count(struct config_node *sn, uint32_t *area_count)
{
if (!get_config_uint32(sn, "stripe_count", area_count)) {
log_error("Couldn't read 'stripe_count' for "
@ -60,7 +60,7 @@ static int _text_import_area_count(struct config_node *sn, uint32_t *area_count)
return 1;
}
static int _text_import(struct lv_segment *seg, const struct config_node *sn,
static int _striped_text_import(struct lv_segment *seg, const struct config_node *sn,
struct dm_hash_table *pv_hash)
{
struct config_node *cn;
@ -83,7 +83,7 @@ static int _text_import(struct lv_segment *seg, const struct config_node *sn,
return text_import_areas(seg, sn, cn, pv_hash, 0);
}
static int _text_export(const struct lv_segment *seg, struct formatter *f)
static int _striped_text_export(const struct lv_segment *seg, struct formatter *f)
{
outf(f, "stripe_count = %u%s", seg->area_count,
@ -99,7 +99,7 @@ static int _text_export(const struct lv_segment *seg, struct formatter *f)
/*
* Test whether two segments could be merged by the current merging code
*/
static int _segments_compatible(struct lv_segment *first,
static int _striped_segments_compatible(struct lv_segment *first,
struct lv_segment *second)
{
uint32_t width;
@ -132,11 +132,11 @@ static int _segments_compatible(struct lv_segment *first,
return 1;
}
static int _merge_segments(struct lv_segment *seg1, struct lv_segment *seg2)
static int _striped_merge_segments(struct lv_segment *seg1, struct lv_segment *seg2)
{
uint32_t s;
if (!_segments_compatible(seg1, seg2))
if (!_striped_segments_compatible(seg1, seg2))
return 0;
seg1->len += seg2->len;
@ -151,7 +151,7 @@ static int _merge_segments(struct lv_segment *seg1, struct lv_segment *seg2)
}
#ifdef DEVMAPPER_SUPPORT
static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem,
static int _striped_add_target_line(struct dev_manager *dm, struct dm_pool *mem,
struct config_tree *cft, void **target_state,
struct lv_segment *seg,
struct dm_tree_node *node, uint64_t len,
@ -172,37 +172,38 @@ static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem,
return add_areas_line(dm, seg, node, 0u, seg->area_count);
}
static int _target_present(void)
static int _striped_target_present(void)
{
static int checked = 0;
static int present = 0;
static int _striped_checked = 0;
static int _striped_present = 0;
if (!checked)
present = target_present("linear", 0) &&
if (!_striped_checked)
_striped_present = target_present("linear", 0) &&
target_present("striped", 0);
checked = 1;
return present;
_striped_checked = 1;
return _striped_present;
}
#endif
static void _destroy(const struct segment_type *segtype)
static void _striped_destroy(const struct segment_type *segtype)
{
dm_free((void *) segtype);
}
static struct segtype_handler _striped_ops = {
name:_name,
display:_display,
text_import_area_count:_text_import_area_count,
text_import:_text_import,
text_export:_text_export,
merge_segments:_merge_segments,
name:_striped_name,
display:_striped_display,
text_import_area_count:_striped_text_import_area_count,
text_import:_striped_text_import,
text_export:_striped_text_export,
merge_segments:_striped_merge_segments,
#ifdef DEVMAPPER_SUPPORT
add_target_line:_add_target_line,
target_present:_target_present,
add_target_line:_striped_add_target_line,
target_present:_striped_target_present,
#endif
destroy:_destroy,
destroy:_striped_destroy,
};
struct segment_type *init_striped_segtype(struct cmd_context *cmd)

View File

@ -24,12 +24,12 @@
#include "lvm-string.h"
#include "activate.h"
static const char *_name(const struct lv_segment *seg)
static const char *_zero_name(const struct lv_segment *seg)
{
return seg->segtype->name;
}
static int _merge_segments(struct lv_segment *seg1, struct lv_segment *seg2)
static int _zero_merge_segments(struct lv_segment *seg1, struct lv_segment *seg2)
{
seg1->len += seg2->len;
seg1->area_len += seg2->area_len;
@ -38,7 +38,7 @@ static int _merge_segments(struct lv_segment *seg1, struct lv_segment *seg2)
}
#ifdef DEVMAPPER_SUPPORT
static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem,
static int _zero_add_target_line(struct dev_manager *dm, struct dm_pool *mem,
struct config_tree *cft, void **target_state,
struct lv_segment *seg,
struct dm_tree_node *node, uint64_t len,
@ -47,32 +47,33 @@ static int _add_target_line(struct dev_manager *dm, struct dm_pool *mem,
return dm_tree_node_add_zero_target(node, len);
}
static int _target_present(void)
static int _zero_target_present(void)
{
static int checked = 0;
static int present = 0;
static int _zero_checked = 0;
static int _zero_present = 0;
if (!checked)
present = target_present("zero", 0);
if (!_zero_checked)
_zero_present = target_present("zero", 0);
checked = 1;
return present;
_zero_checked = 1;
return _zero_present;
}
#endif
static void _destroy(const struct segment_type *segtype)
static void _zero_destroy(const struct segment_type *segtype)
{
dm_free((void *) segtype);
}
static struct segtype_handler _zero_ops = {
name:_name,
merge_segments:_merge_segments,
name:_zero_name,
merge_segments:_zero_merge_segments,
#ifdef DEVMAPPER_SUPPORT
add_target_line:_add_target_line,
target_present:_target_present,
add_target_line:_zero_add_target_line,
target_present:_zero_target_present,
#endif
destroy:_destroy,
destroy:_zero_destroy,
};
struct segment_type *init_zero_segtype(struct cmd_context *cmd)

View File

@ -33,107 +33,61 @@ struct list {
* The list head's next and previous pointers point back to itself.
*/
#define LIST_INIT(name) struct list name = { &(name), &(name) }
static inline void list_init(struct list *head)
{
head->n = head->p = head;
}
void list_init(struct list *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 list_add(struct list *head, struct list *elem)
{
assert(head->n);
elem->n = head;
elem->p = head->p;
head->p->n = elem;
head->p = elem;
}
void list_add(struct list *head, struct list *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 list_add_h(struct list *head, struct list *elem)
{
assert(head->n);
elem->n = head->n;
elem->p = head;
head->n->p = elem;
head->n = elem;
}
void list_add_h(struct list *head, struct list *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 list_del(struct list *elem)
{
elem->n->p = elem->p;
elem->p->n = elem->n;
}
void list_del(struct list *elem);
/*
* Is the list empty?
*/
static inline int list_empty(struct list *head)
{
return head->n == head;
}
int list_empty(struct list *head);
/*
* Is this the first element of the list?
*/
static inline int list_start(struct list *head, struct list *elem)
{
return elem->p == head;
}
int list_start(struct list *head, struct list *elem);
/*
* Is this the last element of the list?
*/
static inline int list_end(struct list *head, struct list *elem)
{
return elem->n == head;
}
int list_end(struct list *head, struct list *elem);
/*
* Return first element of the list or NULL if empty
*/
static inline struct list *list_first(struct list *head)
{
return (list_empty(head) ? NULL : head->n);
}
struct list *list_first(struct list *head);
/*
* Return last element of the list or NULL if empty
*/
static inline struct list *list_last(struct list *head)
{
return (list_empty(head) ? NULL : head->p);
}
struct list *list_last(struct list *head);
/*
* Return the previous element of the list, or NULL if we've reached the start.
*/
static inline struct list *list_prev(struct list *head, struct list *elem)
{
return (list_start(head, elem) ? NULL : elem->p);
}
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.
*/
static inline struct list *list_next(struct list *head, struct list *elem)
{
return (list_end(head, elem) ? NULL : elem->n);
}
struct list *list_next(struct list *head, struct list *elem);
/*
* Given the address v of an instance of 'struct list' called 'head'
@ -244,15 +198,6 @@ static inline struct list *list_next(struct list *head, struct list *elem)
/*
* Return the number of elements in a list by walking it.
*/
static inline unsigned int list_size(const struct list *head)
{
unsigned int s = 0;
const struct list *v;
list_iterate(v, head)
s++;
return s;
}
unsigned int list_size(const struct list *head);
#endif

View File

@ -24,7 +24,7 @@ INSTALL = @INSTALL@
MSGFMT = @MSGFMT@
LN_S = @LN_S@
LIBS = @LIBS@
CFLAGS += @DEFS@
DEFS += @DEFS@ @LVM_DEFS@
CFLAGS += @CFLAGS@
CLDFLAGS += @CLDFLAGS@
LDDEPS += @LDDEPS@
@ -54,7 +54,7 @@ ifndef MAKEFLAGS
MAKEFLAGS = @JOBS@
endif
SUFFIXES = .c .d .o .so .a .po .pot .mo .dylib
.SUFFIXES: .c .d .o .so .a .po .pot .mo .dylib
CFLAGS += -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline
@ -63,18 +63,19 @@ CFLAGS += -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-pr
CFLAGS += @COPTIMISE_FLAG@
ifeq ("@DEBUG@", "yes")
CFLAGS += -g -fno-omit-frame-pointer -DDEBUG
CFLAGS += -DDEBUG_MEM
CFLAGS += -g -fno-omit-frame-pointer
DEFS += -DDEBUG
DEFS += -DDEBUG_MEM
endif
ifeq ("@INTL@", "yes")
CFLAGS += -DINTL_PACKAGE=\"@INTL_PACKAGE@\" -DLOCALEDIR=\"@LOCALEDIR@\"
DEFS += -DINTL_PACKAGE=\"@INTL_PACKAGE@\" -DLOCALEDIR=\"@LOCALEDIR@\"
endif
LDFLAGS += -L$(top_srcdir)/lib -L$(libdir)
#CFLAGS += -DDEBUG_POOL
#CFLAGS += -DBOUNDS_CHECK
#DEFS += -DDEBUG_POOL
#DEFS += -DBOUNDS_CHECK
#CFLAGS += -pg
#LDFLAGS += -pg
@ -98,13 +99,14 @@ DEPS = $(top_srcdir)/make.tmpl $(top_srcdir)/VERSION Makefile $(INC_LNS)
OBJECTS = $(SOURCES:%.c=%.o)
POTFILES = $(SOURCES:%.c=%.pot)
.PHONY: all install install_cluster pofile distclean clean
.PHONY: all install install_cluster pofile distclean clean cflow
.PHONY: $(SUBDIRS) $(SUBDIRS.install) $(SUBDIRS.clean) $(SUBDIRS.distclean)
.PHONY: $(SUBDIRS.pofile) $(SUBDIRS.install_cluster)
.PHONY: $(SUBDIRS.pofile) $(SUBDIRS.install_cluster) $(SUBDIRS.cflow)
SUBDIRS.install := $(SUBDIRS:=.install)
SUBDIRS.install_cluster := $(SUBDIRS:=.install_cluster)
SUBDIRS.pofile := $(SUBDIRS:=.pofile)
SUBDIRS.cflow := $(SUBDIRS:=.cflow)
SUBDIRS.clean := $(SUBDIRS:=.clean)
SUBDIRS.distclean := $(SUBDIRS:=.distclean)
@ -137,17 +139,24 @@ $(SUBDIRS.pofile):
$(MAKE) -C $(@:.pofile=) pofile
endif
ifneq ("@CFLOW_CMD@", "")
cflow: $(SUBDIRS.cflow)
$(SUBDIRS.cflow):
$(MAKE) -C $(@:.cflow=) cflow
endif
$(TARGETS): $(OBJECTS)
%.o: %.c
$(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@
$(CC) -c $(INCLUDES) $(DEFS) $(CFLAGS) $< -o $@
%.pot: %.c Makefile
$(CC) -E $(INCLUDES) -include $(top_srcdir)/include/pogen.h \
$(CFLAGS) $< > $@
$(DEFS) $(CFLAGS) $< > $@
%.so: %.o
$(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@
$(CC) -c $(INCLUDES) $(DEFS) $(CFLAGS) $< -o $@
ifeq ("@LIB_SUFFIX@","so")
$(LIB_SHARED): $(OBJECTS) $(LDDEPS)
@ -173,7 +182,7 @@ $(LIB_STATIC): $(OBJECTS)
set -e; \
FILE=`echo $@ | sed 's/\\//\\\\\\//g;s/\\.d//g'`; \
DEPS=`echo $(DEPS) | sed -e 's/\\//\\\\\\//g'`; \
$(CC) -MM $(INCLUDES) $(CFLAGS) $< | \
$(CC) -MM $(INCLUDES) $(DEFS) $(CFLAGS) $< | \
sed "s/\(.*\)\.o[ :]*/$$FILE.o $$FILE.d $$FILE.pot: $$DEPS /g" > $@; \
[ -s $@ ] || $(RM) $@

View File

@ -80,7 +80,7 @@ endif
LVMLIBS = -llvm
CLEAN_TARGETS = liblvm2cmd.so liblvm2cmd.a lvm lvm.static
CLEAN_TARGETS = liblvm2cmd.so liblvm2cmd.a lvm lvm.static lvm.cflow lvm.xref lvm.tree lvm.rxref lvm.rtree
ifeq ("@CMDLIB@", "yes")
TARGETS += liblvm2cmd.so
@ -95,7 +95,7 @@ ifeq ("@DEVMAPPER@", "yes")
LVMLIBS += -ldevmapper
endif
CFLAGS += -DLVM_SHARED_PATH=\"$(exec_prefix)/sbin/lvm\"
DEFS += -DLVM_SHARED_PATH=\"$(exec_prefix)/sbin/lvm\"
include $(top_srcdir)/make.tmpl
@ -119,6 +119,23 @@ liblvm2cmd.so: liblvm2cmd.a $(LDDEPS)
.PHONY: install_cmdlib_dynamic install_cmdlib_static \
install_tools_dynamic install_tools_static
ifneq ("@CFLOW_CMD@", "")
CFLOW_FLAGS += --cpp="$(CC) -E"
.PHONY: lvm.cflow
-include $(top_srcdir)/lib/liblvm.cflow
lvm.cflow: $(SOURCES)
@CFLOW_CMD@ -o$@ $(CFLOW_FLAGS) $(INCLUDES) $(DEFS) $(SOURCES)
lvm.rxref: $(SOURCES)
@CFLOW_CMD@ -o$@ --cpp="$(CC) -E" -r --omit-arguments -x $(INCLUDES) $(DEFS) $(SOURCES)
lvm.xref: $(SOURCES)
@CFLOW_CMD@ -o$@ --cpp="$(CC) -E" --omit-arguments -x $(INCLUDES) $(DEFS) $(SOURCES)
lvm.rtree: $(SOURCES)
@CFLOW_CMD@ -o$@ --cpp="$(CC) -E" -r --omit-arguments -T -b $(INCLUDES) $(DEFS) $(SOURCES)
lvm.tree: $(SOURCES)
@CFLOW_CMD@ -o$@ --cpp="$(CC) -E" --omit-arguments -T -b $(INCLUDES) $(DEFS) $(SOURCES)
cflow: lvm.cflow lvm.xref lvm.tree lvm.rtree lvm.rxref
endif
install_cmdlib_dynamic: liblvm2cmd.so
$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) liblvm2cmd.so \
$(libdir)/liblvm2cmd.so.$(LIB_VERSION)

View File

@ -38,8 +38,9 @@ struct lvconvert_params {
struct list *pvh;
};
static int _read_name_params(struct lvconvert_params *lp,
struct cmd_context *cmd, int *pargc, char ***pargv)
static int _lvconvert_name_params(struct lvconvert_params *lp,
struct cmd_context *cmd,
int *pargc, char ***pargv)
{
char *ptr;
const char *vg_name = NULL;
@ -194,7 +195,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
return 0;
}
if (!_read_name_params(lp, cmd, &argc, &argv))
if (!_lvconvert_name_params(lp, cmd, &argc, &argv))
return_0;
lp->pv_count = argc;

View File

@ -50,8 +50,9 @@ struct lvcreate_params {
char **pvs;
};
static int _read_name_params(struct lvcreate_params *lp,
struct cmd_context *cmd, int *pargc, char ***pargv)
static int _lvcreate_name_params(struct lvcreate_params *lp,
struct cmd_context *cmd,
int *pargc, char ***pargv)
{
int argc = *pargc;
char **argv = *pargv, *ptr;
@ -260,8 +261,8 @@ static int _read_mirror_params(struct lvcreate_params *lp,
return 1;
}
static int _read_params(struct lvcreate_params *lp, struct cmd_context *cmd,
int argc, char **argv)
static int _lvcreate_params(struct lvcreate_params *lp, struct cmd_context *cmd,
int argc, char **argv)
{
int contiguous;
@ -352,7 +353,7 @@ static int _read_params(struct lvcreate_params *lp, struct cmd_context *cmd,
return 0;
}
if (!_read_name_params(lp, cmd, &argc, &argv) ||
if (!_lvcreate_name_params(lp, cmd, &argc, &argv) ||
!_read_size_params(lp, cmd, &argc, &argv) ||
!_read_stripe_params(lp, cmd, &argc, &argv) ||
!_read_mirror_params(lp, cmd, &argc, &argv)) {
@ -755,7 +756,7 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
memset(&lp, 0, sizeof(lp));
if (!_read_params(&lp, cmd, argc, argv))
if (!_lvcreate_params(&lp, cmd, argc, argv))
return EINVALID_CMD_LINE;
if (!lock_vol(cmd, lp.vg_name, LCK_VG_WRITE)) {

View File

@ -45,8 +45,8 @@ struct lvresize_params {
char **argv;
};
static int _read_params(struct cmd_context *cmd, int argc, char **argv,
struct lvresize_params *lp)
static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
struct lvresize_params *lp)
{
const char *cmd_name;
char *st;
@ -561,7 +561,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
memset(&lp, 0, sizeof(lp));
if (!_read_params(cmd, argc, argv, &lp))
if (!_lvresize_params(cmd, argc, argv, &lp))
return EINVALID_CMD_LINE;
log_verbose("Finding volume group %s", lp.vg_name);

View File

@ -19,6 +19,62 @@
#include <sys/stat.h>
#include <sys/wait.h>
/* Command line args */
unsigned int arg_count(struct cmd_context *cmd, int a)
{
return cmd->args[a].count;
}
const char *arg_value(struct cmd_context *cmd, int a)
{
return cmd->args[a].value;
}
const char *arg_str_value(struct cmd_context *cmd, int a, const char *def)
{
return arg_count(cmd, a) ? cmd->args[a].value : def;
}
int32_t arg_int_value(struct cmd_context *cmd, int a, const int32_t def)
{
return arg_count(cmd, a) ? cmd->args[a].i_value : def;
}
uint32_t arg_uint_value(struct cmd_context *cmd, int a, const uint32_t def)
{
return arg_count(cmd, a) ? cmd->args[a].ui_value : def;
}
int64_t arg_int64_value(struct cmd_context *cmd, int a, const uint64_t def)
{
return arg_count(cmd, a) ? cmd->args[a].i64_value : def;
}
uint64_t arg_uint64_value(struct cmd_context *cmd, int a, const uint64_t def)
{
return arg_count(cmd, a) ? cmd->args[a].ui64_value : def;
}
const void *arg_ptr_value(struct cmd_context *cmd, int a, const void *def)
{
return arg_count(cmd, a) ? cmd->args[a].ptr : def;
}
sign_t arg_sign_value(struct cmd_context *cmd, int a, const sign_t def)
{
return arg_count(cmd, a) ? cmd->args[a].sign : def;
}
int arg_count_increment(struct cmd_context *cmd, int a)
{
return cmd->args[a].count++;
}
const char *command_name(struct cmd_context *cmd)
{
return cmd->command->name;
}
/*
* Metadata iteration functions
*/

View File

@ -138,67 +138,18 @@ 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 */
static inline unsigned int arg_count(struct cmd_context *cmd, int a)
{
return cmd->args[a].count;
}
unsigned int arg_count(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);
uint32_t arg_uint_value(struct cmd_context *cmd, int a, const uint32_t def);
int64_t arg_int64_value(struct cmd_context *cmd, int a, const uint64_t def);
uint64_t arg_uint64_value(struct cmd_context *cmd, int a, const uint64_t def);
const void *arg_ptr_value(struct cmd_context *cmd, int a, const void *def);
sign_t arg_sign_value(struct cmd_context *cmd, int a, const sign_t def);
int arg_count_increment(struct cmd_context *cmd, int a);
static inline const char *arg_value(struct cmd_context *cmd, int a)
{
return cmd->args[a].value;
}
static inline const char *arg_str_value(struct cmd_context *cmd, int a,
const char *def)
{
return arg_count(cmd, a) ? cmd->args[a].value : def;
}
static inline int32_t arg_int_value(struct cmd_context *cmd, int a,
const int32_t def)
{
return arg_count(cmd, a) ? cmd->args[a].i_value : def;
}
static inline uint32_t arg_uint_value(struct cmd_context *cmd, int a,
const uint32_t def)
{
return arg_count(cmd, a) ? cmd->args[a].ui_value : def;
}
static inline int64_t arg_int64_value(struct cmd_context *cmd, int a,
const uint64_t def)
{
return arg_count(cmd, a) ? cmd->args[a].i64_value : def;
}
static inline uint64_t arg_uint64_value(struct cmd_context *cmd, int a,
const uint64_t def)
{
return arg_count(cmd, a) ? cmd->args[a].ui64_value : def;
}
static inline const void *arg_ptr_value(struct cmd_context *cmd, int a,
const void *def)
{
return arg_count(cmd, a) ? cmd->args[a].ptr : def;
}
static inline sign_t arg_sign_value(struct cmd_context *cmd, int a,
const sign_t def)
{
return arg_count(cmd, a) ? cmd->args[a].sign : def;
}
static inline int arg_count_increment(struct cmd_context *cmd, int a)
{
return cmd->args[a].count++;
}
static inline const char *command_name(struct cmd_context *cmd)
{
return cmd->command->name;
}
const char *command_name(struct cmd_context *cmd);
int pvmove_poll(struct cmd_context *cmd, const char *pv, unsigned background);