From 0524829af69935070b7b15c1bede8f7f4afc9a13 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 14 Jun 2018 13:08:33 +0100 Subject: [PATCH] dmsetup: move to libdm/dm-tools/dmsetup links against libdevmapper again. no longer includes code from lvm. --- configure | 6 +-- configure.ac | 1 + libdm/Makefile.in | 2 + libdm/dm-tools/.gitignore | 1 + libdm/dm-tools/Makefile.in | 69 +++++++++++++++++++++++++ {tools => libdm/dm-tools}/dmsetup.c | 27 +++++----- libdm/dm-tools/util.h | 79 +++++++++++++++++++++++++++++ tools/Makefile.in | 40 ++------------- 8 files changed, 175 insertions(+), 50 deletions(-) create mode 100644 libdm/dm-tools/.gitignore create mode 100644 libdm/dm-tools/Makefile.in rename {tools => libdm/dm-tools}/dmsetup.c (99%) create mode 100644 libdm/dm-tools/util.h diff --git a/configure b/configure index 323ab4a8e..ed3a3156c 100755 --- a/configure +++ b/configure @@ -11527,7 +11527,7 @@ if ${am_cv_pathless_PYTHON+:} false; then : $as_echo_n "(cached) " >&6 else - for am_cv_pathless_PYTHON in python python2 python3 python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do + for am_cv_pathless_PYTHON in python python2 python3 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 none; do test "$am_cv_pathless_PYTHON" = none && break prog="import sys # split strings by '.' and convert to numeric. Append some zeros @@ -13611,7 +13611,7 @@ _ACEOF ################################################################################ -ac_config_files="$ac_config_files Makefile make.tmpl libdm/make.tmpl daemons/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/dmeventd/plugins/thin/Makefile daemons/dmfilemapd/Makefile daemons/lvmdbusd/Makefile daemons/lvmdbusd/lvmdbusd daemons/lvmdbusd/lvmdb.py daemons/lvmdbusd/lvm_shell_proxy.py daemons/lvmdbusd/path.py daemons/lvmetad/Makefile daemons/lvmpolld/Makefile daemons/lvmlockd/Makefile conf/Makefile conf/example.conf conf/lvmlocal.conf conf/command_profile_template.profile conf/metadata_profile_template.profile include/Makefile lib/Makefile include/lvm-version.h libdaemon/Makefile libdaemon/client/Makefile libdaemon/server/Makefile libdm/Makefile libdm/libdevmapper.pc man/Makefile po/Makefile scripts/blkdeactivate.sh scripts/blk_availability_init_red_hat scripts/blk_availability_systemd_red_hat.service scripts/cmirrord_init_red_hat scripts/com.redhat.lvmdbus1.service scripts/dm_event_systemd_red_hat.service scripts/dm_event_systemd_red_hat.socket scripts/lvm2_cmirrord_systemd_red_hat.service scripts/lvm2_lvmdbusd_systemd_red_hat.service scripts/lvm2_lvmetad_init_red_hat scripts/lvm2_lvmetad_systemd_red_hat.service scripts/lvm2_lvmetad_systemd_red_hat.socket scripts/lvm2_lvmpolld_init_red_hat scripts/lvm2_lvmpolld_systemd_red_hat.service scripts/lvm2_lvmpolld_systemd_red_hat.socket scripts/lvm2_lvmlockd_systemd_red_hat.service scripts/lvm2_lvmlocking_systemd_red_hat.service scripts/lvm2_monitoring_init_red_hat scripts/lvm2_monitoring_systemd_red_hat.service scripts/lvm2_pvscan_systemd_red_hat@.service scripts/lvm2_tmpfiles_red_hat.conf scripts/lvmdump.sh scripts/Makefile test/Makefile tools/Makefile udev/Makefile" +ac_config_files="$ac_config_files Makefile make.tmpl libdm/make.tmpl daemons/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/dmeventd/plugins/thin/Makefile daemons/dmfilemapd/Makefile daemons/lvmdbusd/Makefile daemons/lvmdbusd/lvmdbusd daemons/lvmdbusd/lvmdb.py daemons/lvmdbusd/lvm_shell_proxy.py daemons/lvmdbusd/path.py daemons/lvmetad/Makefile daemons/lvmpolld/Makefile daemons/lvmlockd/Makefile conf/Makefile conf/example.conf conf/lvmlocal.conf conf/command_profile_template.profile conf/metadata_profile_template.profile include/Makefile lib/Makefile include/lvm-version.h libdaemon/Makefile libdaemon/client/Makefile libdaemon/server/Makefile libdm/Makefile libdm/dm-tools/Makefile libdm/libdevmapper.pc man/Makefile po/Makefile scripts/blkdeactivate.sh scripts/blk_availability_init_red_hat scripts/blk_availability_systemd_red_hat.service scripts/cmirrord_init_red_hat scripts/com.redhat.lvmdbus1.service scripts/dm_event_systemd_red_hat.service scripts/dm_event_systemd_red_hat.socket scripts/lvm2_cmirrord_systemd_red_hat.service scripts/lvm2_lvmdbusd_systemd_red_hat.service scripts/lvm2_lvmetad_init_red_hat scripts/lvm2_lvmetad_systemd_red_hat.service scripts/lvm2_lvmetad_systemd_red_hat.socket scripts/lvm2_lvmpolld_init_red_hat scripts/lvm2_lvmpolld_systemd_red_hat.service scripts/lvm2_lvmpolld_systemd_red_hat.socket scripts/lvm2_lvmlockd_systemd_red_hat.service scripts/lvm2_monitoring_init_red_hat scripts/lvm2_monitoring_systemd_red_hat.service scripts/lvm2_pvscan_systemd_red_hat@.service scripts/lvm2_tmpfiles_red_hat.conf scripts/lvmdump.sh scripts/Makefile test/Makefile tools/Makefile udev/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -14340,6 +14340,7 @@ do "libdaemon/client/Makefile") CONFIG_FILES="$CONFIG_FILES libdaemon/client/Makefile" ;; "libdaemon/server/Makefile") CONFIG_FILES="$CONFIG_FILES libdaemon/server/Makefile" ;; "libdm/Makefile") CONFIG_FILES="$CONFIG_FILES libdm/Makefile" ;; + "libdm/dm-tools/Makefile") CONFIG_FILES="$CONFIG_FILES libdm/dm-tools/Makefile" ;; "libdm/libdevmapper.pc") CONFIG_FILES="$CONFIG_FILES libdm/libdevmapper.pc" ;; "man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;; "po/Makefile") CONFIG_FILES="$CONFIG_FILES po/Makefile" ;; @@ -14359,7 +14360,6 @@ do "scripts/lvm2_lvmpolld_systemd_red_hat.service") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_lvmpolld_systemd_red_hat.service" ;; "scripts/lvm2_lvmpolld_systemd_red_hat.socket") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_lvmpolld_systemd_red_hat.socket" ;; "scripts/lvm2_lvmlockd_systemd_red_hat.service") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_lvmlockd_systemd_red_hat.service" ;; - "scripts/lvm2_lvmlocking_systemd_red_hat.service") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_lvmlocking_systemd_red_hat.service" ;; "scripts/lvm2_monitoring_init_red_hat") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_monitoring_init_red_hat" ;; "scripts/lvm2_monitoring_systemd_red_hat.service") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_monitoring_systemd_red_hat.service" ;; "scripts/lvm2_pvscan_systemd_red_hat@.service") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_pvscan_systemd_red_hat@.service" ;; diff --git a/configure.ac b/configure.ac index 4c431e4b3..42f19fd6e 100644 --- a/configure.ac +++ b/configure.ac @@ -1785,6 +1785,7 @@ libdaemon/Makefile libdaemon/client/Makefile libdaemon/server/Makefile libdm/Makefile +libdm/dm-tools/Makefile libdm/libdevmapper.pc man/Makefile po/Makefile diff --git a/libdm/Makefile.in b/libdm/Makefile.in index eeef0801d..6472da74c 100644 --- a/libdm/Makefile.in +++ b/libdm/Makefile.in @@ -16,6 +16,8 @@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ +SUBDIRS=dm-tools + SOURCES =\ datastruct/bitset.c \ datastruct/hash.c \ diff --git a/libdm/dm-tools/.gitignore b/libdm/dm-tools/.gitignore new file mode 100644 index 000000000..c42a5e05a --- /dev/null +++ b/libdm/dm-tools/.gitignore @@ -0,0 +1 @@ +dmsetup diff --git a/libdm/dm-tools/Makefile.in b/libdm/dm-tools/Makefile.in new file mode 100644 index 000000000..b8d83ac6e --- /dev/null +++ b/libdm/dm-tools/Makefile.in @@ -0,0 +1,69 @@ +# +# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. +# Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved. +# +# This file is part of LVM2. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions +# of the GNU General Public License v.2. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ + +SOURCES=\ + +SOURCES2=\ + dmsetup.c + +TARGETS_DM = dmsetup + +INSTALL_DMSETUP_TARGETS = install_dmsetup_dynamic + +ifeq ("@STATIC_LINK@", "yes") + TARGETS_DM += dmsetup.static + INSTALL_DMSETUP_TARGETS += install_dmsetup_static +endif + +CLEAN_TARGETS = $(TARGETS_DM) \ + dmsetup.static \ + $(LDDEPS) .exported_symbols_generated + +include $(top_builddir)/libdm/make.tmpl + +device-mapper: $(TARGETS_DM) + +CFLAGS_dmsetup.o += $(UDEV_CFLAGS) $(EXTRA_EXEC_CFLAGS) + +dmsetup: dmsetup.o + @echo " [CC] $@" + $(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) \ + -o $@ $+ $(LIBS) -L$(top_builddir)/libdm -ldevmapper -lm + +dmsetup.static: dmsetup.o $(INTERNAL_LIBS) + @echo " [CC] $@" + $(Q) $(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) \ + -o $@ $+ $(M_LIBS) $(PTHREAD_LIBS) $(STATIC_LIBS) $(LIBS) + +all: device-mapper + +.PHONY: install_dmsetup_dynamic install_dmsetup_static + +install_dmsetup_dynamic: dmsetup + @echo " [INSTALL] $<" + $(Q) $(INSTALL_PROGRAM) -D $< $(sbindir)/$( + +#include "libdm/misc/dm-logging.h" +#include "libdm/dm-tools/util.h" +#include "configure.h" #include #include -#include -#include -#include -#include -#include - #include +#include +#include +#include +#include #include +#include +#include +#include #ifdef UDEV_SYNC_SUPPORT # include @@ -64,8 +69,6 @@ #else struct option { }; -extern int optind; -extern char *optarg; # define GETOPTLONG_FN(a, b, c, d, e) getopt((a), (b), (c)) # define OPTIND_INIT 1 #endif @@ -1530,7 +1533,7 @@ static int _message(CMD_ARGS) for (i = 0; i < argc; i++) sz += strlen(argv[i]) + 1; - if (!(str = zalloc(sz))) { + if (!(str = dm_zalloc(sz))) { log_error("Message string allocation failed."); goto out; } diff --git a/libdm/dm-tools/util.h b/libdm/dm-tools/util.h new file mode 100644 index 000000000..730b90370 --- /dev/null +++ b/libdm/dm-tools/util.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2007 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _LVM_UTIL_H +#define _LVM_UTIL_H + +#include + +#define min(a, b) ({ typeof(a) _a = (a); \ + typeof(b) _b = (b); \ + (void) (&_a == &_b); \ + _a < _b ? _a : _b; }) + +#define max(a, b) ({ typeof(a) _a = (a); \ + typeof(b) _b = (b); \ + (void) (&_a == &_b); \ + _a > _b ? _a : _b; }) + +#define is_power_of_2(n) ((n) && !((n) & ((n) - 1))) + +#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 6) +#define uninitialized_var(x) x +#else +#define uninitialized_var(x) x = x +#endif + +#define KERNEL_VERSION(major, minor, release) (((major) << 16) + ((minor) << 8) + (release)) + +/* Define some portable printing types */ +#define PRIsize_t "zu" +#define PRIssize_t "zd" +#define PRIptrdiff_t "td" +#define PRIpid_t PRId32 + +/* For convenience */ +#define FMTsize_t "%" PRIsize_t +#define FMTssize_t "%" PRIssize_t +#define FMTptrdiff_t "%" PRIptrdiff_t +#define FMTpid_t "%" PRIpid_t + +#define FMTd8 "%" PRId8 +#define FMTd16 "%" PRId16 +#define FMTd32 "%" PRId32 +#define FMTd64 "%" PRId64 + +#define FMTi8 "%" PRIi8 +#define FMTi16 "%" PRIi16 +#define FMTi32 "%" PRIi32 +#define FMTi64 "%" PRIi64 + +#define FMTo8 "%" PRIo8 +#define FMTo16 "%" PRIo16 +#define FMTo32 "%" PRIo32 +#define FMTo64 "%" PRIo64 + +#define FMTu8 "%" PRIu8 +#define FMTu16 "%" PRIu16 +#define FMTu32 "%" PRIu32 +#define FMTu64 "%" PRIu64 + +#define FMTx8 "%" PRIx8 +#define FMTx16 "%" PRIx16 +#define FMTx32 "%" PRIx32 +#define FMTx64 "%" PRIx64 + +#define FMTVGID "%." DM_TO_STRING(ID_LEN) "s" + +#endif diff --git a/tools/Makefile.in b/tools/Makefile.in index 3785b508d..7d9dd93da 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -67,7 +67,6 @@ SOURCES =\ vgsplit.c SOURCES2 =\ - dmsetup.c \ lvm.c \ lvm2cmd-static.c \ lvm2cmd.c \ @@ -80,17 +79,13 @@ TARGETS =\ lvm \ man-generator -TARGETS_DM = dmsetup - INSTALL_LVM_TARGETS = install_tools_dynamic -INSTALL_DMSETUP_TARGETS = install_dmsetup_dynamic +INSTALL_DMSETUP_TARGETS = INSTALL_CMDLIB_TARGETS = install_cmdlib_dynamic install_cmdlib_include ifeq ("@STATIC_LINK@", "yes") TARGETS += lvm.static - TARGETS_DM += dmsetup.static INSTALL_LVM_TARGETS += install_tools_static - INSTALL_DMSETUP_TARGETS += install_dmsetup_static INSTALL_CMDLIB_TARGETS += install_cmdlib_static endif @@ -99,7 +94,7 @@ LIB_VERSION = $(LIB_VERSION_LVM) CLEAN_TARGETS = liblvm2cmd.$(LIB_SUFFIX) $(TARGETS_DM) \ liblvm2cmd.$(LIB_SUFFIX).$(LIB_VERSION) lvm-static.o \ - liblvm2cmd-static.a dmsetup.static lvm.static \ + liblvm2cmd-static.a lvm.static \ $(LDDEPS) .exported_symbols_generated \ cmds.h command-lines-input.h command-count.h man-generator.c @@ -117,19 +112,7 @@ CFLOW_TARGET = lvm include $(top_builddir)/make.tmpl -device-mapper: $(TARGETS_DM) - -CFLAGS_dmsetup.o += $(UDEV_CFLAGS) $(EXTRA_EXEC_CFLAGS) - -dmsetup: dmsetup.o $(INTERNAL_LIBS) - @echo " [CC] $@" - $(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) \ - -o $@ $+ $(LIBS) -lm - -dmsetup.static: dmsetup.o $(INTERNAL_LIBS) - @echo " [CC] $@" - $(Q) $(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) \ - -o $@ $+ $(M_LIBS) $(PTHREAD_LIBS) $(STATIC_LIBS) $(LIBS) +device-mapper: all: device-mapper @@ -225,8 +208,7 @@ CFLOW_SOURCES = $(addprefix $(srcdir)/, $(SOURCES)) endif .PHONY: install_cmdlib_dynamic install_cmdlib_static install_cmdlib_include \ - install_tools_dynamic install_tools_static \ - install_dmsetup_dynamic install_dmsetup_static + install_tools_dynamic install_tools_static install_cmdlib_include: $(srcdir)/lvm2cmd.h @echo " [INSTALL] $<" @@ -255,18 +237,6 @@ install_tools_static: lvm.static @echo " [INSTALL] $<" $(Q) $(INSTALL_PROGRAM) -D $< $(staticdir)/$(