From e8c4bf56fed345507ebf5bed266c525c9cbab3a4 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Mon, 24 Mar 2003 18:08:53 +0000 Subject: [PATCH] Tidy various pre-processing incl. making libdl optional. --- configure | 60 ++++++++++++++++++++++++++++++---- configure.in | 8 +++++ lib/Makefile.in | 6 +++- lib/activate/activate.c | 1 - lib/activate/dev_manager.c | 4 +-- lib/activate/dev_manager.h | 3 +- lib/cache/cache.c | 2 -- lib/cache/cache.h | 3 -- lib/commands/toolcontext.c | 23 +++++++++---- lib/config/config.c | 5 ++- lib/config/config.h | 3 -- lib/config/defaults.h | 2 +- lib/datastruct/bitset.h | 1 - lib/datastruct/btree.h | 1 - lib/datastruct/hash.h | 2 -- lib/datastruct/list.h | 2 ++ lib/datastruct/lvm-types.h | 8 ++--- lib/device/dev-cache.c | 3 +- lib/device/dev-cache.h | 1 - lib/device/device.c | 1 - lib/device/device.h | 2 -- lib/display/display.c | 18 +++++----- lib/filters/filter.c | 2 -- lib/filters/filter.h | 3 ++ lib/format1/disk-rep.c | 4 +-- lib/format1/import-export.c | 2 +- lib/format_text/format-text.c | 2 +- lib/label/label.c | 4 +-- lib/label/label.h | 1 - lib/locking/external_locking.c | 2 -- lib/locking/locking.c | 2 ++ lib/log/log.h | 8 ++--- lib/metadata/metadata.c | 4 +-- lib/metadata/metadata.h | 6 +--- lib/misc/crc.h | 2 -- lib/misc/lib.h | 2 -- lib/misc/sharedlib.h | 1 + lib/mm/dbg_malloc.h | 2 +- lib/report/report.c | 8 ++--- lib/uuid/uuid.h | 2 -- libdm/datastruct/list.h | 2 ++ make.tmpl.in | 4 +++ tools/Makefile.in | 2 +- tools/archive.c | 4 +-- tools/lvcreate.c | 4 +-- tools/lvm.c | 2 +- tools/lvmdiskscan.c | 2 +- tools/pvcreate.c | 4 +-- tools/vgconvert.c | 2 +- tools/vgreduce.c | 2 +- tools/vgremove.c | 2 +- 51 files changed, 145 insertions(+), 101 deletions(-) diff --git a/configure b/configure index 3c94eb3b5..844bac9fa 100755 --- a/configure +++ b/configure @@ -2005,9 +2005,55 @@ Note: (n)curses also seems to work as a substitute for termcap. This was fi fi +echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 +echo "configure:2010: checking for dlopen in -ldl" >&5 +ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldl $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + HAVE_LIBDL=yes +else + echo "$ac_t""no" 1>&6 +HAVE_LIBDL=no +fi + + +if test x$HAVE_LIBDL = xyes; then + LIBS="-ldl $LIBS" +fi + if test x$READLINE = xyes; then echo $ac_n "checking for readline in -lreadline""... $ac_c" 1>&6 -echo "configure:2011: checking for readline in -lreadline" >&5 +echo "configure:2057: checking for readline in -lreadline" >&5 ac_lib_var=`echo readline'_'readline | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2015,7 +2061,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lreadline $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2076: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2063,12 +2109,12 @@ package as well (which may be called readline-devel or something similar). fi echo $ac_n "checking for rl_completion_matches""... $ac_c" 1>&6 -echo "configure:2067: checking for rl_completion_matches" >&5 +echo "configure:2113: checking for rl_completion_matches" >&5 if eval "test \"`echo '$''{'ac_cv_func_rl_completion_matches'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2141: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_rl_completion_matches=yes" else @@ -2130,6 +2176,7 @@ fi + trap '' 1 2 15 cat > confcache <<\EOF # This file is a shell script that caches the results of configure @@ -2308,6 +2355,7 @@ s%@GROUP@%$GROUP%g s%@LVM_VERSION@%$LVM_VERSION%g s%@DEBUG@%$DEBUG%g s%@DEVMAPPER@%$DEVMAPPER%g +s%@HAVE_LIBDL@%$HAVE_LIBDL%g CEOF EOF diff --git a/configure.in b/configure.in index f570f516e..b993b6a8a 100644 --- a/configure.in +++ b/configure.in @@ -121,6 +121,13 @@ Note: (n)curses also seems to work as a substitute for termcap. This was ) fi +dnl Check for dlopen +AC_CHECK_LIB(dl, dlopen, HAVE_LIBDL=yes, HAVE_LIBDL=no) + +if test x$HAVE_LIBDL = xyes; then + LIBS="-ldl $LIBS" +fi + dnl Check for readline (Shamelessly copied from parted 1.4.17) if test x$READLINE = xyes; then AC_CHECK_LIB(readline, readline, , @@ -155,6 +162,7 @@ AC_SUBST(LIBS) AC_SUBST(LVM_VERSION) AC_SUBST(DEBUG) AC_SUBST(DEVMAPPER) +AC_SUBST(HAVE_LIBDL) dnl First and last lines should not contain files to generate in order to dnl keep utility scripts running properly AC_OUTPUT( \ diff --git a/lib/Makefile.in b/lib/Makefile.in index 433dccc9c..880ecc6fd 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -36,7 +36,6 @@ SOURCES=\ format_text/import_vsn1.c \ format_text/text_label.c \ label/label.c \ - locking/external_locking.c \ locking/file_locking.c \ locking/locking.c \ locking/no_locking.c \ @@ -79,6 +78,11 @@ ifeq ("@DEVMAPPER@", "yes") activate/fs.c endif +ifeq ("@HAVE_LIBDL@", "yes") + SOURCES+=\ + locking/external_locking.c +endif + TARGETS=liblvm.a include ../make.tmpl diff --git a/lib/activate/activate.c b/lib/activate/activate.c index 53675bb6c..ec623f3fc 100644 --- a/lib/activate/activate.c +++ b/lib/activate/activate.c @@ -15,7 +15,6 @@ #include "dev_manager.h" #include -#include #include #define _skip(fmt, args...) log_very_verbose("Skipping: " fmt , ## args) diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c index adcf12635..6e8e851d8 100644 --- a/lib/activate/dev_manager.c +++ b/lib/activate/dev_manager.c @@ -671,7 +671,7 @@ static int _populate_origin(struct dev_manager *dm, log_debug("Adding target: 0 %" PRIu64 " snapshot-origin %s", dl->lv->size, params); - if (!dm_task_add_target(dmt, __UINT64_C(0), dl->lv->size, + if (!dm_task_add_target(dmt, UINT64_C(0), dl->lv->size, "snapshot-origin", params)) { stack; return 0; @@ -712,7 +712,7 @@ static int _populate_snapshot(struct dev_manager *dm, log_debug("Adding target: 0 %" PRIu64 " snapshot %s", s->origin->size, params); if (!dm_task_add_target - (dmt, __UINT64_C(0), s->origin->size, "snapshot", params)) { + (dmt, UINT64_C(0), s->origin->size, "snapshot", params)) { stack; return 0; } diff --git a/lib/activate/dev_manager.h b/lib/activate/dev_manager.h index cbbd758fd..ccf956001 100644 --- a/lib/activate/dev_manager.h +++ b/lib/activate/dev_manager.h @@ -9,9 +9,8 @@ #include "metadata.h" -#include - struct dev_manager; +struct dm_info; /* * Constructor and destructor. diff --git a/lib/cache/cache.c b/lib/cache/cache.c index 63cabe284..a3b5eccc1 100644 --- a/lib/cache/cache.c +++ b/lib/cache/cache.c @@ -13,8 +13,6 @@ #include "metadata.h" #include "filter.h" -#include - static struct hash_table *_pvid_hash = NULL; static struct hash_table *_vgid_hash = NULL; static struct hash_table *_vgname_hash = NULL; diff --git a/lib/cache/cache.h b/lib/cache/cache.h index 446e8ebbc..e790d302d 100644 --- a/lib/cache/cache.h +++ b/lib/cache/cache.h @@ -9,13 +9,10 @@ #define _LVM_CACHE_H #include "dev-cache.h" -#include "list.h" #include "uuid.h" #include "label.h" #include "metadata.h" -#include - #define ORPHAN "" #define CACHE_INVALID 0x00000001 diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c index 3427888c3..889815f57 100644 --- a/lib/commands/toolcontext.c +++ b/lib/commands/toolcontext.c @@ -19,9 +19,12 @@ #include "label.h" #include "lvm-file.h" #include "format-text.h" -#include "sharedlib.h" #include "display.h" +#ifdef HAVE_LIBDL +#include "sharedlib.h" +#endif + #ifdef LVM1_INTERNAL #include "format1.h" #endif @@ -29,7 +32,6 @@ #include #include #include -#include #include static FILE *_log; @@ -332,12 +334,10 @@ static int _init_formats(struct cmd_context *cmd) struct format_type *fmt; struct list *fmth; + +#ifdef HAVE_LIBDL struct config_node *cn; - struct config_value *cv; - - struct format_type *(*init_format_fn) (struct cmd_context *); - - void *lib; +#endif label_init(); @@ -348,9 +348,15 @@ static int _init_formats(struct cmd_context *cmd) list_add(&cmd->formats, &fmt->list); #endif +#ifdef HAVE_LIBDL /* Load any formats in shared libs */ if ((cn = find_config_node(cmd->cf->root, "global/format_libraries", '/'))) { + + struct config_value *cv; + struct format_type *(*init_format_fn) (struct cmd_context *); + void *lib; + for (cv = cn->v; cv; cv = cv->next) { if (cv->type != CFG_STRING) { log_error("Invalid string in config file: " @@ -376,6 +382,7 @@ static int _init_formats(struct cmd_context *cmd) list_add(&cmd->formats, &fmt->list); } } +#endif if (!(fmt = create_text_format(cmd))) return 0; @@ -469,8 +476,10 @@ static void _destroy_formats(struct list *formats) list_del(&fmt->list); lib = fmt->library; fmt->ops->destroy(fmt); +#ifdef HAVE_LIBDL if (lib) dlclose(lib); +#endif } } diff --git a/lib/config/config.c b/lib/config/config.c index a40877a98..034b9b284 100644 --- a/lib/config/config.c +++ b/lib/config/config.c @@ -15,7 +15,6 @@ #include #include #include -#include enum { TOK_INT, @@ -128,7 +127,7 @@ int read_config_fd(struct config_tree *cf, int fd, const char *file, if (size2) { /* FIXME Attempt adjacent mmaps MAP_FIXED into malloced space - * one PAGE_SIZE larger than required... + * one page size larger than required... */ if (!(p->fb = dbg_malloc(size + size2))) { stack; @@ -151,7 +150,7 @@ int read_config_fd(struct config_tree *cf, int fd, const char *file, goto out; } } else { - mmap_offset = offset % PAGE_SIZE; + mmap_offset = offset % getpagesize(); /* memory map the file */ p->fb = mmap((caddr_t) 0, size + mmap_offset, PROT_READ, MAP_PRIVATE, fd, offset - mmap_offset); diff --git a/lib/config/config.h b/lib/config/config.h index 3e9c095f2..872d07e1a 100644 --- a/lib/config/config.h +++ b/lib/config/config.h @@ -7,9 +7,6 @@ #ifndef _LVM_CONFIG_H #define _LVM_CONFIG_H -#include -#include - enum { CFG_STRING, CFG_FLOAT, diff --git a/lib/config/defaults.h b/lib/config/defaults.h index 8369507d5..7961645e2 100644 --- a/lib/config/defaults.h +++ b/lib/config/defaults.h @@ -34,7 +34,7 @@ #define DEFAULT_STRIPESIZE 64 /* KB */ #define DEFAULT_PVMETADATASIZE 255 #define DEFAULT_PVMETADATACOPIES 1 -#define DEFAULT_LABELSECTOR __UINT64_C(1) +#define DEFAULT_LABELSECTOR UINT64_C(1) #define DEFAULT_MSG_PREFIX " " #define DEFAULT_CMD_NAME 0 diff --git a/lib/datastruct/bitset.h b/lib/datastruct/bitset.h index 9943809cb..54693bbba 100644 --- a/lib/datastruct/bitset.h +++ b/lib/datastruct/bitset.h @@ -7,7 +7,6 @@ #ifndef _LVM_BITSET_H #define _LVM_BITSET_H -#include "lvm-types.h" #include "pool.h" #include diff --git a/lib/datastruct/btree.h b/lib/datastruct/btree.h index 4ae8770cd..79e2b3967 100644 --- a/lib/datastruct/btree.h +++ b/lib/datastruct/btree.h @@ -7,7 +7,6 @@ #ifndef _LVM_BTREE_H #define _LVM_BTREE_H -#include "lvm-types.h" #include "pool.h" struct btree; diff --git a/lib/datastruct/hash.h b/lib/datastruct/hash.h index 787c9806d..bbf0697a9 100644 --- a/lib/datastruct/hash.h +++ b/lib/datastruct/hash.h @@ -7,8 +7,6 @@ #ifndef _LVM_HASH_H #define _LVM_HASH_H -#include "lvm-types.h" - struct hash_table; struct hash_node; diff --git a/lib/datastruct/list.h b/lib/datastruct/list.h index 48ec81bf8..0c6ca405b 100644 --- a/lib/datastruct/list.h +++ b/lib/datastruct/list.h @@ -7,6 +7,8 @@ #ifndef _LVM_LIST_H #define _LVM_LIST_H +#include + struct list { struct list *n, *p; }; diff --git a/lib/datastruct/lvm-types.h b/lib/datastruct/lvm-types.h index bba936c48..006916f8c 100644 --- a/lib/datastruct/lvm-types.h +++ b/lib/datastruct/lvm-types.h @@ -13,10 +13,10 @@ #include /* Define some portable printing types */ -#if __WORDSIZE == 64 -#define PRIsize_t "lu" -#else -#define PRIsize_t "u" +#if (SIZE_MAX == UINT64_MAX) +#define PRIsize_t PRIu64 +#elif (SIZE_MAX == UINT32_MAX) +#define PRIsize_t PRIu32 #endif struct str_list { diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c index b16528599..37644ef46 100644 --- a/lib/device/dev-cache.c +++ b/lib/device/dev-cache.c @@ -11,12 +11,11 @@ #include "list.h" #include "lvm-types.h" #include "btree.h" +#include "filter.h" -#include #include #include #include -#include struct dev_iter { struct btree_iter *current; diff --git a/lib/device/dev-cache.h b/lib/device/dev-cache.h index 257c5ca9d..e867ce921 100644 --- a/lib/device/dev-cache.h +++ b/lib/device/dev-cache.h @@ -7,7 +7,6 @@ #ifndef _LVM_DEV_CACHE_H #define _LVM_DEV_CACHE_H -#include #include "lvm-types.h" #include "device.h" diff --git a/lib/device/device.c b/lib/device/device.c index 938974c8b..8c28a6a4a 100644 --- a/lib/device/device.c +++ b/lib/device/device.c @@ -18,7 +18,6 @@ */ #if 0 -#include #include #include #include diff --git a/lib/device/device.h b/lib/device/device.h index 1e1d555de..9576cef7f 100644 --- a/lib/device/device.h +++ b/lib/device/device.h @@ -7,8 +7,6 @@ #ifndef _LVM_DEVICE_H #define _LVM_DEVICE_H -#include "lvm-types.h" -#include "list.h" #include "uuid.h" #define DEV_ACCESSED_W 0x00000001 /* Device written to? */ diff --git a/lib/display/display.c b/lib/display/display.c index 10bc66965..7c78fc0d6 100644 --- a/lib/display/display.c +++ b/lib/display/display.c @@ -70,16 +70,16 @@ uint64_t units_to_bytes(const char *units, char *unit_type) switch (*units) { case 'h': case 'H': - v = __UINT64_C(1); + v = UINT64_C(1); *unit_type = *units; break; case 's': v *= SECTOR_SIZE; case 'b': case 'B': - v *= __UINT64_C(1); + v *= UINT64_C(1); break; -#define KILO __UINT64_C(1024) +#define KILO UINT64_C(1024) case 'k': v *= KILO; case 'm': @@ -92,7 +92,7 @@ uint64_t units_to_bytes(const char *units, char *unit_type) v *= KILO * KILO * KILO * KILO; break; #undef KILO -#define KILO __UINT64_C(1000) +#define KILO UINT64_C(1000) case 'K': v *= KILO; break; @@ -167,7 +167,7 @@ const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl) int s; int suffix = 1; uint64_t byte; - uint64_t units = __UINT64_C(1024); + uint64_t units = UINT64_C(1024); char *size_buf = NULL; const char *size_str[][3] = { {" Terabyte", " TB", "T"}, @@ -193,20 +193,20 @@ const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl) *size_str[s][2]) break; - if (size == __UINT64_C(0)) { + if (size == UINT64_C(0)) { sprintf(size_buf, "0%s", suffix ? size_str[s][sl] : ""); return size_buf; } if (s < 8) { byte = cmd->current_settings.unit_factor; - size *= __UINT64_C(1024); + size *= UINT64_C(1024); } else { suffix = 1; if (cmd->current_settings.unit_type == 'H') - units = __UINT64_C(1000); + units = UINT64_C(1000); else - units = __UINT64_C(1024); + units = UINT64_C(1024); byte = units * units * units; s = 0; while (size_str[s] && size < byte) diff --git a/lib/filters/filter.c b/lib/filters/filter.c index baf245b2e..01cf80de6 100644 --- a/lib/filters/filter.c +++ b/lib/filters/filter.c @@ -25,11 +25,9 @@ #include "config.h" #include -#include #include #include #include -#include #define NUMBER_OF_MAJORS 256 diff --git a/lib/filters/filter.h b/lib/filters/filter.h index f262d0964..8c6bd9838 100644 --- a/lib/filters/filter.h +++ b/lib/filters/filter.h @@ -23,6 +23,9 @@ #include "config.h" +#include +#include + struct dev_filter *lvm_type_filter_create(const char *proc, struct config_node *cn); diff --git a/lib/format1/disk-rep.c b/lib/format1/disk-rep.c index afc55493f..a7aef0bdd 100644 --- a/lib/format1/disk-rep.c +++ b/lib/format1/disk-rep.c @@ -11,9 +11,7 @@ #include "filter.h" #include "cache.h" -#include #include -#include #define fail do {stack; return 0;} while(0) #define xx16(v) disk->v = xlate16(disk->v) @@ -132,7 +130,7 @@ static int _munge_formats(struct pv_disk *pvd) static int _read_pvd(struct device *dev, struct pv_disk *pvd) { - if (dev_read(dev, __UINT64_C(0), sizeof(*pvd), pvd) != sizeof(*pvd)) { + if (dev_read(dev, UINT64_C(0), sizeof(*pvd), pvd) != sizeof(*pvd)) { log_very_verbose("Failed to read PV data from %s", dev_name(dev)); return 0; diff --git a/lib/format1/import-export.c b/lib/format1/import-export.c index eeafbe2e8..0fb5f3d79 100644 --- a/lib/format1/import-export.c +++ b/lib/format1/import-export.c @@ -12,10 +12,10 @@ #include "hash.h" #include "list.h" #include "lvm-string.h" +#include "filter.h" #include #include -#include static int _check_vg_name(const char *name) { diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c index 4956b9b96..7ca9264ee 100644 --- a/lib/format_text/format-text.c +++ b/lib/format_text/format-text.c @@ -1027,7 +1027,7 @@ static int _pv_write(const struct format_type *fmt, struct physical_volume *pv, } if (!add_da (fmt, NULL, &info->das, pv->pe_start << SECTOR_SHIFT, - __UINT64_C(0))) { + UINT64_C(0))) { stack; return 0; } diff --git a/lib/label/label.c b/lib/label/label.c index 437828d8e..1af5443da 100644 --- a/lib/label/label.c +++ b/lib/label/label.c @@ -117,7 +117,7 @@ static struct labeller *_find_labeller(struct device *dev, char *buf, return NULL; } - if (dev_read(dev, __UINT64_C(0), LABEL_SCAN_SIZE, readbuf) != + if (dev_read(dev, UINT64_C(0), LABEL_SCAN_SIZE, readbuf) != LABEL_SCAN_SIZE) { log_debug("%s: Failed to read label area", dev_name(dev)); goto out; @@ -205,7 +205,7 @@ int label_remove(struct device *dev) return 0; } - if (dev_read(dev, __UINT64_C(0), LABEL_SCAN_SIZE, readbuf) != + if (dev_read(dev, UINT64_C(0), LABEL_SCAN_SIZE, readbuf) != LABEL_SCAN_SIZE) { log_debug("%s: Failed to read label area", dev_name(dev)); goto out; diff --git a/lib/label/label.h b/lib/label/label.h index 20d825c08..b2dbc825f 100644 --- a/lib/label/label.h +++ b/lib/label/label.h @@ -8,7 +8,6 @@ #define _LVM_LABEL_H #include "cache.h" -#include "lvm-types.h" #include "uuid.h" #include "device.h" diff --git a/lib/locking/external_locking.c b/lib/locking/external_locking.c index 0dcc84069..718e179f1 100644 --- a/lib/locking/external_locking.c +++ b/lib/locking/external_locking.c @@ -10,8 +10,6 @@ #include "defaults.h" #include "sharedlib.h" -#include - static void *_locking_lib = NULL; static void (*_end_fn) (void) = NULL; static int (*_lock_fn) (struct cmd_context * cmd, const char *resource, diff --git a/lib/locking/locking.c b/lib/locking/locking.c index 6fecec61d..363ec843a 100644 --- a/lib/locking/locking.c +++ b/lib/locking/locking.c @@ -107,11 +107,13 @@ int init_locking(int type, struct config_tree *cf) log_very_verbose("File-based locking enabled."); return 1; +#ifdef HAVE_LIBDL case 2: if (!init_external_locking(&_locking, cf)) break; log_very_verbose("External locking enabled."); return 1; +#endif default: log_error("Unknown locking type requested."); diff --git a/lib/log/log.h b/lib/log/log.h index d46a2a861..f2d87c849 100644 --- a/lib/log/log.h +++ b/lib/log/log.h @@ -78,10 +78,10 @@ void print_log(int level, const char *file, int line, const char *format, ...) #define stack log_debug("") /* Backtrace on error */ -#define log_error(fmt, args...) log_err(fmt , ## args) -#define log_print(fmt, args...) log_warn(fmt , ## args) -#define log_verbose(fmt, args...) log_notice(fmt , ## args) -#define log_very_verbose(fmt, args...) log_info(fmt , ## args) +#define log_error(args...) log_err(args) +#define log_print(args...) log_warn(args) +#define log_verbose(args...) log_notice(args) +#define log_very_verbose(args...) log_info(args) /* Two System call equivalents */ #define log_sys_error(x, y) \ diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index a2c7835ed..b0545ee5d 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -68,8 +68,8 @@ static int _add_pv_to_vg(struct format_instance *fid, struct volume_group *vg, pv->pe_alloc_count = 0; - if (!fid->fmt->ops->pv_setup(fid->fmt, __UINT64_C(0), 0, - vg->extent_size, 0, __UINT64_C(0), + if (!fid->fmt->ops->pv_setup(fid->fmt, UINT64_C(0), 0, + vg->extent_size, 0, UINT64_C(0), &fid->metadata_areas, pv, vg)) { log_error("Format-specific setup of physical volume '%s' " "failed.", pv_name); diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h index 5973d989c..a99c7c37e 100644 --- a/lib/metadata/metadata.h +++ b/lib/metadata/metadata.h @@ -12,17 +12,13 @@ #include "ctype.h" #include "dev-cache.h" -#include "list.h" #include "uuid.h" -#include -#include - #define NAME_LEN 128 #define MAX_STRIPES 128 #define SECTOR_SHIFT 9L #define SECTOR_SIZE ( 1L << SECTOR_SHIFT ) -#define STRIPE_SIZE_MIN ( PAGE_SIZE >> SECTOR_SHIFT) /* PAGESIZE in sectors */ +#define STRIPE_SIZE_MIN ( getpagesize() >> SECTOR_SHIFT) /* PAGESIZE in sectors */ #define STRIPE_SIZE_MAX ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */ #define PV_MIN_SIZE ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */ #define PE_ALIGN (65536UL >> SECTOR_SHIFT) /* PE alignment */ diff --git a/lib/misc/crc.h b/lib/misc/crc.h index fcef90824..752187b7b 100644 --- a/lib/misc/crc.h +++ b/lib/misc/crc.h @@ -7,8 +7,6 @@ #ifndef _LVM_CRC_H #define _LVM_CRC_H -#include "lvm-types.h" - #define INITIAL_CRC 0xf597a6cf uint32_t calc_crc(uint32_t initial, void *buf, uint32_t size); diff --git a/lib/misc/lib.h b/lib/misc/lib.h index 9f6c92381..2462e15a9 100644 --- a/lib/misc/lib.h +++ b/lib/misc/lib.h @@ -15,6 +15,4 @@ #include "log.h" #include "dbg_malloc.h" -#include - #endif diff --git a/lib/misc/sharedlib.h b/lib/misc/sharedlib.h index 407527564..da50174b1 100644 --- a/lib/misc/sharedlib.h +++ b/lib/misc/sharedlib.h @@ -6,6 +6,7 @@ */ #include "config.h" +#include void *load_shared_library(struct config_tree *cf, const char *libname, const char *what); diff --git a/lib/mm/dbg_malloc.h b/lib/mm/dbg_malloc.h index 35c22a437..be27f5017 100644 --- a/lib/mm/dbg_malloc.h +++ b/lib/mm/dbg_malloc.h @@ -7,9 +7,9 @@ #ifndef _LVM_DBG_MALLOC_H #define _LVM_DBG_MALLOC_H +#include "lvm-types.h" #include #include -#include #ifdef DEBUG_MEM void *malloc_aux(size_t s, const char *file, int line); diff --git a/lib/report/report.c b/lib/report/report.c index 74beea21c..65ea8e13a 100644 --- a/lib/report/report.c +++ b/lib/report/report.c @@ -27,8 +27,6 @@ #include "display.h" #include "activate.h" -#include - /* * For macro use */ @@ -566,14 +564,14 @@ static int _snpercent_disp(struct report_handle *rh, struct field *field, if (!(snap = find_cow(lv))) { field->report_string = ""; - *sortval = __UINT64_C(0); + *sortval = UINT64_C(0); field->sort_value = sortval; return 1; } if (!lv_snapshot_percent(snap->cow, &snap_percent) || snap_percent < 0) { field->report_string = "100.00"; - *sortval = __UINT64_C(100); + *sortval = UINT64_C(100); field->sort_value = sortval; return 1; } @@ -591,7 +589,7 @@ static int _snpercent_disp(struct report_handle *rh, struct field *field, return 0; } - *sortval = snap_percent * __UINT64_C(1000); + *sortval = snap_percent * UINT64_C(1000); field->sort_value = sortval; field->report_string = repstr; diff --git a/lib/uuid/uuid.h b/lib/uuid/uuid.h index d06157fdb..aa25773d7 100644 --- a/lib/uuid/uuid.h +++ b/lib/uuid/uuid.h @@ -7,8 +7,6 @@ #ifndef _LVM_UUID_H #define _LVM_UUID_H -#include "lvm-types.h" - #define ID_LEN 32 #define ID_LEN_S "32" diff --git a/libdm/datastruct/list.h b/libdm/datastruct/list.h index 48ec81bf8..0c6ca405b 100644 --- a/libdm/datastruct/list.h +++ b/libdm/datastruct/list.h @@ -7,6 +7,8 @@ #ifndef _LVM_LIST_H #define _LVM_LIST_H +#include + struct list { struct list *n, *p; }; diff --git a/make.tmpl.in b/make.tmpl.in index 01debe4ef..9d3a905b3 100644 --- a/make.tmpl.in +++ b/make.tmpl.in @@ -93,6 +93,10 @@ ifeq ("@HAVE_RL_COMPLETION_MATCHES@", "yes") CFLAGS += -DHAVE_RL_COMPLETION_MATCHES endif +ifeq ("@HAVE_LIBDL@", "yes") + CFLAGS += -DHAVE_LIBDL +endif + ifeq ("@LVM1@", "internal") CFLAGS += -DLVM1_INTERNAL endif diff --git a/tools/Makefile.in b/tools/Makefile.in index d3df40750..8886d7107 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -72,7 +72,7 @@ include ../make.tmpl lvm: $(OBJECTS) $(top_srcdir)/lib/liblvm.a $(CC) -o lvm $(OBJECTS) $(LD_FLAGS) -L$(top_srcdir)/lib \ - -L$(DESTDIR)/lib $(LVMLIBS) $(LIBS) -ldl -rdynamic + -L$(DESTDIR)/lib $(LVMLIBS) $(LIBS) -rdynamic .commands: commands.h cmdnames.h Makefile $(CC) -E -P cmdnames.h | egrep -v '(help|version)' > .commands diff --git a/tools/archive.c b/tools/archive.c index bd8ef4c89..9e37ee5d4 100644 --- a/tools/archive.c +++ b/tools/archive.c @@ -262,8 +262,8 @@ int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg) return 0; } if (!vg->fid->fmt->ops-> - pv_setup(vg->fid->fmt, __UINT64_C(0), 0, 0, 0, - __UINT64_C(0), &vg->fid->metadata_areas, pv, vg)) { + pv_setup(vg->fid->fmt, UINT64_C(0), 0, 0, 0, + UINT64_C(0), &vg->fid->metadata_areas, pv, vg)) { log_error("Format-specific setup for %s failed", dev_name(pv->dev)); return 0; diff --git a/tools/lvcreate.c b/tools/lvcreate.c index 74d21caad..1b92fc7f4 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -150,7 +150,7 @@ static int _read_size_params(struct lvcreate_params *lp, /* Size returned in kilobyte units; held in sectors */ if (arg_count(cmd, size_ARG)) - lp->size = arg_uint64_value(cmd, size_ARG, __UINT64_C(0)) * 2; + lp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0)) * 2; return 1; } @@ -317,7 +317,7 @@ static int _zero_lv(struct cmd_context *cmd, struct logical_volume *lv) if (!(dev_open(dev, O_WRONLY))) return 0; - dev_zero(dev, __UINT64_C(0), (size_t) 4096); + dev_zero(dev, UINT64_C(0), (size_t) 4096); dev_close(dev); return 1; diff --git a/tools/lvm.c b/tools/lvm.c index cd0ea9899..b94e98a0d 100644 --- a/tools/lvm.c +++ b/tools/lvm.c @@ -30,7 +30,7 @@ */ struct arg the_args[ARG_COUNT + 1] = { -#define arg(a, b, c, d) {b, "--" c, d, 0, NULL, 0, 0, __INT64_C(0), __UINT64_C(0), 0, NULL}, +#define arg(a, b, c, d) {b, "--" c, d, 0, NULL, 0, 0, INT64_C(0), UINT64_C(0), 0, NULL}, #include "args.h" #undef arg diff --git a/tools/lvmdiskscan.c b/tools/lvmdiskscan.c index e83a82de1..80efb63ba 100644 --- a/tools/lvmdiskscan.c +++ b/tools/lvmdiskscan.c @@ -67,7 +67,7 @@ static int _check_device(struct cmd_context *cmd, struct device *dev) if (!dev_open(dev, 0)) { return 0; } - if (dev_read(dev, __UINT64_C(0), (size_t) 1, &buffer) != 1) { + if (dev_read(dev, UINT64_C(0), (size_t) 1, &buffer) != 1) { dev_close(dev); return 0; } diff --git a/tools/pvcreate.c b/tools/pvcreate.c index c0b98d347..5211b2da4 100644 --- a/tools/pvcreate.c +++ b/tools/pvcreate.c @@ -129,9 +129,9 @@ static void pvcreate_single(struct cmd_context *cmd, const char *pv_name, if (!pvcreate_check(cmd, pv_name)) goto error; - size = arg_uint64_value(cmd, physicalvolumesize_ARG, __UINT64_C(0)) * 2; + size = arg_uint64_value(cmd, physicalvolumesize_ARG, UINT64_C(0)) * 2; - pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, __UINT64_C(0)) + pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, UINT64_C(0)) * 2; if (!pvmetadatasize) pvmetadatasize = find_config_int(cmd->cf->root, diff --git a/tools/vgconvert.c b/tools/vgconvert.c index 16c5e575e..b67ba1a33 100644 --- a/tools/vgconvert.c +++ b/tools/vgconvert.c @@ -63,7 +63,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name, if (cmd->fmt->features & FMT_MDAS) { pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, - __UINT64_C(0)) * 2; + UINT64_C(0)) * 2; if (!pvmetadatasize) pvmetadatasize = find_config_int(cmd->cf->root, diff --git a/tools/vgreduce.c b/tools/vgreduce.c index 24f12b03e..d9ad696fc 100644 --- a/tools/vgreduce.c +++ b/tools/vgreduce.c @@ -205,7 +205,7 @@ static int _vgreduce_single(struct cmd_context *cmd, struct volume_group *vg, return ECMD_FAILED; } - if (!pv_write(cmd, pv, NULL, __INT64_C(-1))) { + if (!pv_write(cmd, pv, NULL, INT64_C(-1))) { log_error("Failed to clear metadata from physical " "volume \"%s\" " "after removal from \"%s\"", name, vg->name); diff --git a/tools/vgremove.c b/tools/vgremove.c index 2e9744742..1d2d2a9f6 100644 --- a/tools/vgremove.c +++ b/tools/vgremove.c @@ -65,7 +65,7 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name, "volume group \"%s\"", dev_name(pv->dev), vg_name); pv->vg_name = ORPHAN; /* FIXME Write to same sector label was read from */ - if (!pv_write(cmd, pv, NULL, __INT64_C(-1))) { + if (!pv_write(cmd, pv, NULL, INT64_C(-1))) { log_error("Failed to remove physical volume \"%s\"" " from volume group \"%s\"", dev_name(pv->dev), vg_name);