diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index fe3b5de42..728290fa4 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.102 - ================================ + Include tool.h for default non-library use. Introduce format macros with embedded % such as FMTu64. Version 1.02.101 - 3rd July 2015 diff --git a/daemons/clvmd/clvmd-common.h b/daemons/clvmd/clvmd-common.h index 3070e495d..6df1eb200 100644 --- a/daemons/clvmd/clvmd-common.h +++ b/daemons/clvmd/clvmd-common.h @@ -18,15 +18,10 @@ #ifndef _LVM_CLVMD_COMMON_H #define _LVM_CLVMD_COMMON_H -#include "configure.h" - #define _REENTRANT -#define _GNU_SOURCE -#define _FILE_OFFSET_BITS 64 -#include "libdevmapper.h" +#include "tool.h" + #include "lvm-logging.h" -#include - #endif diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c index fcfa42362..1ff5bf9ec 100644 --- a/daemons/dmeventd/dmeventd.c +++ b/daemons/dmeventd/dmeventd.c @@ -16,26 +16,21 @@ * dmeventd - dm event daemon to monitor active mapped devices */ -#define _GNU_SOURCE -#define _FILE_OFFSET_BITS 64 +#include "tool.h" -#include "configure.h" -#include "libdevmapper.h" -#include "libdevmapper-event.h" -#include "dmeventd.h" //#include "libmultilog.h" #include "dm-logging.h" -#include +#include "libdevmapper-event.h" +#include "dmeventd.h" + #include -#include #include #include #include #include #include #include -#include #include #include /* for htonl, ntohl */ #include /* for musl libc */ @@ -1567,9 +1562,6 @@ static void _process_request(struct dm_event_fifos *fifos) { int die; struct dm_event_daemon_message msg = { 0 }; -#ifdef DEBUG - const char *cmd; -#endif /* * Read the request from the client (client_read, client_write diff --git a/daemons/dmeventd/libdevmapper-event.c b/daemons/dmeventd/libdevmapper-event.c index 6e41b0a12..81f18c9c4 100644 --- a/daemons/dmeventd/libdevmapper-event.c +++ b/daemons/dmeventd/libdevmapper-event.c @@ -17,15 +17,10 @@ //#include "libmultilog.h" #include "dmeventd.h" -#include #include -#include -#include -#include #include #include #include -#include #include #include /* for htonl, ntohl */ diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c index 7f2405c23..f4e77b7e8 100644 --- a/daemons/lvmetad/lvmetad-core.c +++ b/daemons/lvmetad/lvmetad-core.c @@ -14,17 +14,17 @@ #define _XOPEN_SOURCE 500 /* pthread */ -#include "configure.h" +#define _REENTRANT + +#include "tool.h" + #include "daemon-io.h" -#include "config-util.h" #include "daemon-server.h" #include "daemon-log.h" #include "lvm-version.h" #include #include -#include -#include #define LVMETAD_SOCKET DEFAULT_RUN_DIR "/lvmetad.socket" diff --git a/daemons/lvmetad/testclient.c b/daemons/lvmetad/testclient.c index 8ea068d09..fbf7b6509 100644 --- a/daemons/lvmetad/testclient.c +++ b/daemons/lvmetad/testclient.c @@ -1,3 +1,18 @@ +/* + * Copyright (C) 2011-2014 Red Hat, Inc. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "tool.h" + #include "lvmetad-client.h" #include "label.h" #include "lvmcache.h" diff --git a/daemons/lvmlockd/lvmlockctl.c b/daemons/lvmlockd/lvmlockctl.c index 9349cedcf..5a4f3f55d 100644 --- a/daemons/lvmlockd/lvmlockctl.c +++ b/daemons/lvmlockd/lvmlockctl.c @@ -8,21 +8,15 @@ * of the GNU Lesser General Public License v.2.1. */ -#define _GNU_SOURCE -#include "configure.h" +#include "tool.h" + #include "lvmlockd-client.h" -#include -#include #include -#include -#include #include -#include #include #include #include -#include #include #include #include diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c index 87daaaf36..649c9aab6 100644 --- a/daemons/lvmlockd/lvmlockd-core.c +++ b/daemons/lvmlockd/lvmlockd-core.c @@ -10,25 +10,22 @@ #define _XOPEN_SOURCE 500 /* pthread */ #define _ISOC99_SOURCE -#define _GNU_SOURCE +#define _REENTRANT + +#include "tool.h" -#include "configure.h" #include "daemon-io.h" #include "daemon-server.h" #include "daemon-log.h" -#include "config-util.h" #include "lvm-version.h" #include "lvmetad-client.h" #include "lvmlockd-client.h" -#include -#include -#include -#include -#include -#include -#include +/* #include */ #include +#include +#include +#include #include #include #include diff --git a/daemons/lvmlockd/lvmlockd-dlm.c b/daemons/lvmlockd/lvmlockd-dlm.c index 4b4f43315..de1953296 100644 --- a/daemons/lvmlockd/lvmlockd-dlm.c +++ b/daemons/lvmlockd/lvmlockd-dlm.c @@ -10,28 +10,9 @@ #define _XOPEN_SOURCE 500 /* pthread */ #define _ISOC99_SOURCE -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "tool.h" -#include "configure.h" #include "daemon-server.h" #include "daemon-log.h" #include "xlate.h" @@ -45,6 +26,17 @@ */ #include "libdlm.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + struct lm_dlm { dlm_lshandle_t *dh; }; diff --git a/daemons/lvmlockd/lvmlockd-sanlock.c b/daemons/lvmlockd/lvmlockd-sanlock.c index 5a31eddf6..f52528f64 100644 --- a/daemons/lvmlockd/lvmlockd-sanlock.c +++ b/daemons/lvmlockd/lvmlockd-sanlock.c @@ -10,23 +10,9 @@ #define _XOPEN_SOURCE 500 /* pthread */ #define _ISOC99_SOURCE -#define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "tool.h" -#include "configure.h" #include "daemon-server.h" #include "daemon-log.h" #include "xlate.h" @@ -39,6 +25,13 @@ #include "sanlock_admin.h" #include "sanlock_resource.h" +#include +#include +#include +#include +#include +#include + /* * If access to the pv containing the vg's leases is lost, sanlock cannot renew * the leases we have acquired for locked LVs. This means that we could soon diff --git a/daemons/lvmpolld/lvmpolld-common.h b/daemons/lvmpolld/lvmpolld-common.h index 81423f014..16f764240 100644 --- a/daemons/lvmpolld/lvmpolld-common.h +++ b/daemons/lvmpolld/lvmpolld-common.h @@ -18,19 +18,14 @@ #ifndef _LVM_LVMPOLLD_COMMON_H #define _LVM_LVMPOLLD_COMMON_H -#include "configure.h" - #define _REENTRANT -#define _GNU_SOURCE -#define _FILE_OFFSET_BITS 64 -#include "libdevmapper.h" +#include "tool.h" #include "lvmpolld-cmd-utils.h" #include "lvmpolld-protocol.h" #include #include -#include #endif /* _LVM_LVMPOLLD_COMMON_H */ diff --git a/include/.symlinks.in b/include/.symlinks.in index dc4456a3b..e78072a1d 100644 --- a/include/.symlinks.in +++ b/include/.symlinks.in @@ -76,3 +76,4 @@ @top_srcdir@/libdm/misc/kdev_t.h @top_srcdir@/po/pogen.h @top_srcdir@/tools/lvm2cmd.h +@top_srcdir@/tools/tool.h diff --git a/lib/log/log.h b/lib/log/log.h index 79e7d77c5..cb6b0bca6 100644 --- a/lib/log/log.h +++ b/lib/log/log.h @@ -37,8 +37,6 @@ * */ -#include /* FILE */ -#include /* strerror() */ #include #define EUNCLASSIFIED -1 /* Generic error code */ diff --git a/libdaemon/client/config-util.c b/libdaemon/client/config-util.c index c417def36..895815c31 100644 --- a/libdaemon/client/config-util.c +++ b/libdaemon/client/config-util.c @@ -12,14 +12,12 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#define _REENTRANT + +#include "tool.h" + #include "daemon-io.h" #include "dm-logging.h" -#include "util.h" - -#include -#include -#include -#include #include /* fabs() */ #include /* DBL_EPSILON */ diff --git a/libdaemon/client/config-util.h b/libdaemon/client/config-util.h index 3e0a23f17..0e7de7ead 100644 --- a/libdaemon/client/config-util.h +++ b/libdaemon/client/config-util.h @@ -15,10 +15,6 @@ #ifndef _LVM_DAEMON_CONFIG_UTIL_H #define _LVM_DAEMON_CONFIG_UTIL_H -#include "libdevmapper.h" - -#include - struct buffer { int allocated; int used; diff --git a/libdaemon/client/daemon-client.c b/libdaemon/client/daemon-client.c index 991bf8a0a..39a640108 100644 --- a/libdaemon/client/daemon-client.c +++ b/libdaemon/client/daemon-client.c @@ -12,16 +12,16 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#define _REENTRANT + +#include "tool.h" + #include "daemon-io.h" #include "daemon-client.h" #include "dm-logging.h" #include #include -#include -#include -#include -#include // ENOMEM daemon_handle daemon_open(daemon_info i) { diff --git a/libdaemon/client/daemon-client.h b/libdaemon/client/daemon-client.h index e1445c11b..7f8d2d4d7 100644 --- a/libdaemon/client/daemon-client.h +++ b/libdaemon/client/daemon-client.h @@ -15,7 +15,6 @@ #ifndef _LVM_DAEMON_CLIENT_H #define _LVM_DAEMON_CLIENT_H -#include "libdevmapper.h" #include "config-util.h" typedef struct { diff --git a/libdaemon/client/daemon-io.c b/libdaemon/client/daemon-io.c index 5ce9dde83..a9da68f42 100644 --- a/libdaemon/client/daemon-io.c +++ b/libdaemon/client/daemon-io.c @@ -12,13 +12,13 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#define _REENTRANT + +#include "tool.h" + #include "daemon-io.h" -#include "libdevmapper.h" #include -#include -#include -#include /* * Read a single message from a (socket) filedescriptor. Messages are delimited diff --git a/libdaemon/client/daemon-io.h b/libdaemon/client/daemon-io.h index b48accac0..482f03388 100644 --- a/libdaemon/client/daemon-io.h +++ b/libdaemon/client/daemon-io.h @@ -15,12 +15,6 @@ #ifndef _LVM_DAEMON_IO_H #define _LVM_DAEMON_IO_H -#include "configure.h" - -#define _REENTRANT -#define _GNU_SOURCE -#define _FILE_OFFSET_BITS 64 - #include "config-util.h" /* TODO function names */ diff --git a/libdaemon/server/daemon-log.c b/libdaemon/server/daemon-log.c index c1765de3f..5ea5cdc76 100644 --- a/libdaemon/server/daemon-log.c +++ b/libdaemon/server/daemon-log.c @@ -1,5 +1,22 @@ +/* + * Copyright (C) 2011-2012 Red Hat, Inc. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#define _REENTRANT + +#include "tool.h" + #include "daemon-server.h" #include "daemon-log.h" + #include struct backend { diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c index 8eda8cfb8..4f34aaf8d 100644 --- a/libdaemon/server/daemon-server.c +++ b/libdaemon/server/daemon-server.c @@ -10,6 +10,10 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#define _REENTRANT + +#include "tool.h" + #include "daemon-io.h" #include "daemon-server.h" #include "daemon-log.h" @@ -78,8 +82,6 @@ static void _exit_handler(int sig __attribute__((unused))) # define SD_LISTEN_FDS_START 3 # define SD_FD_SOCKET_SERVER SD_LISTEN_FDS_START -# include - static int _is_idle(daemon_state s) { return s.idle && s.idle->is_idle && !s.threads->next; diff --git a/tools/dmsetup.c b/tools/dmsetup.c index 067a6772b..e6cc44f5f 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -16,19 +16,12 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#define _GNU_SOURCE -#define _FILE_OFFSET_BITS 64 +#include "tool.h" -#include "configure.h" -#include "util.h" #include "dm-logging.h" -#include -#include -#include #include #include -#include #include #include #include diff --git a/tools/lvchange.c b/tools/lvchange.c index 2a57abb16..939614e0a 100644 --- a/tools/lvchange.c +++ b/tools/lvchange.c @@ -14,6 +14,7 @@ */ #include "tools.h" + #include "memlock.h" static int _lvchange_permission(struct cmd_context *cmd, diff --git a/tools/lvconvert.c b/tools/lvconvert.c index f967ae47c..c7e797b9c 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -13,6 +13,7 @@ */ #include "tools.h" + #include "polldaemon.h" #include "lv_alloc.h" #include "lvconvert_poll.h" diff --git a/tools/lvconvert_poll.c b/tools/lvconvert_poll.c index 72c8df8c7..e3a370986 100644 --- a/tools/lvconvert_poll.c +++ b/tools/lvconvert_poll.c @@ -12,10 +12,10 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "libdevmapper.h" -#include "lvconvert_poll.h" #include "tools.h" +#include "lvconvert_poll.h" + int lvconvert_mirror_finish(struct cmd_context *cmd, struct volume_group *vg, struct logical_volume *lv, diff --git a/tools/lvm-static.c b/tools/lvm-static.c index 1be4c2416..920127bec 100644 --- a/tools/lvm-static.c +++ b/tools/lvm-static.c @@ -14,6 +14,7 @@ */ #include "tools.h" + #include "lvm2cmdline.h" int main(int argc, char **argv) diff --git a/tools/lvm.c b/tools/lvm.c index f9ab438b2..63cc0b4ad 100644 --- a/tools/lvm.c +++ b/tools/lvm.c @@ -14,6 +14,7 @@ */ #include "tools.h" + #include "lvm2cmdline.h" int main(int argc, char **argv) diff --git a/tools/lvmcmdlib.c b/tools/lvmcmdlib.c index 6b641c239..76576c2fe 100644 --- a/tools/lvmcmdlib.c +++ b/tools/lvmcmdlib.c @@ -14,6 +14,7 @@ */ #include "tools.h" + #include "lvm2cmdline.h" #include "label.h" #include "memlock.h" diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c index 7808c12c3..c4a78b0c2 100644 --- a/tools/lvmcmdline.c +++ b/tools/lvmcmdline.c @@ -14,6 +14,7 @@ */ #include "tools.h" + #include "lvm2cmdline.h" #include "label.h" #include "lvm-version.h" diff --git a/tools/lvpoll.c b/tools/lvpoll.c index 178392e7f..c040b6050 100644 --- a/tools/lvpoll.c +++ b/tools/lvpoll.c @@ -13,6 +13,7 @@ */ #include "tools.h" + #include "polldaemon.h" #include "pvmove_poll.h" #include "lvconvert_poll.h" diff --git a/tools/polldaemon.c b/tools/polldaemon.c index d7ba417d4..da890dc19 100644 --- a/tools/polldaemon.c +++ b/tools/polldaemon.c @@ -13,13 +13,14 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include - #include "tools.h" + #include "polldaemon.h" #include "lvm2cmdline.h" #include "lvmpolld-client.h" +#include + #define WAIT_AT_LEAST_NANOSECS 100000 progress_t poll_mirror_progress(struct cmd_context *cmd, diff --git a/tools/pvmove.c b/tools/pvmove.c index 8efa6b099..17416d42b 100644 --- a/tools/pvmove.c +++ b/tools/pvmove.c @@ -14,6 +14,7 @@ */ #include "tools.h" + #include "polldaemon.h" #include "display.h" #include "pvmove_poll.h" diff --git a/tools/pvmove_poll.c b/tools/pvmove_poll.c index df896b504..0f071dc93 100644 --- a/tools/pvmove_poll.c +++ b/tools/pvmove_poll.c @@ -13,9 +13,10 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "pvmove_poll.h" #include "tools.h" +#include "pvmove_poll.h" + static int _is_pvmove_image_removable(struct logical_volume *mimage_lv, void *baton) { diff --git a/tools/reporter.c b/tools/reporter.c index c7a927b46..8f7a2723a 100644 --- a/tools/reporter.c +++ b/tools/reporter.c @@ -14,6 +14,7 @@ */ #include "tools.h" + #include "report.h" static int _process_each_devtype(struct cmd_context *cmd, int argc, diff --git a/tools/tool.h b/tools/tool.h new file mode 100644 index 000000000..04c51eeaa --- /dev/null +++ b/tools/tool.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. + * Copyright (C) 2004-2015 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* Most source files should include this file or lib.h or dmlib.h */ + +#ifndef _LVM_TOOL_H +#define _LVM_TOOL_H + +#define _GNU_SOURCE +#define _FILE_OFFSET_BITS 64 + +#include "configure.h" + +#include + +#include "libdevmapper.h" +#include "util.h" + +#endif /* _LVM_TOOL_H */ diff --git a/tools/toollib.c b/tools/toollib.c index 6b8ce220d..15bfa513a 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -14,6 +14,7 @@ */ #include "tools.h" + #include #include #include diff --git a/tools/tools.h b/tools/tools.h index 675867de2..5ee5786d2 100644 --- a/tools/tools.h +++ b/tools/tools.h @@ -16,14 +16,10 @@ #ifndef _LVM_TOOLS_H #define _LVM_TOOLS_H -#define _GNU_SOURCE -#define _FILE_OFFSET_BITS 64 - -#include "configure.h" -#include -#include "libdevmapper.h" +#include "tool.h" #include "lvm-logging.h" + #include "activate.h" #include "archiver.h" #include "lvmcache.h" @@ -47,11 +43,7 @@ #include "toolcontext.h" #include "toollib.h" -#include -#include #include -#include -#include #include #define CMD_LEN 256