master - lvmdbusd: Handle missing lv_attr table lookups
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=51f08efaa7005507402...
Commit: 51f08efaa700550740254093bacea270325f2ccf
Parent: f1684bf8e89b87d7f04e0a963def66f76634766d
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Tue Dec 11 11:21:50 2018 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Fri Dec 14 08:28:02 2018 -0600
lvmdbusd: Handle missing lv_attr table lookups
If we don't know the meaning we will return the key with default text
instead of raising an exception and taking the daemon out in the
process.
Resolves: rhbz1657950
---
daemons/lvmdbusd/lv.py | 35 ++++++++++++++++++++++++-----------
1 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/daemons/lvmdbusd/lv.py b/daemons/lvmdbusd/lv.py
index ba9499f..a80675f 100644
--- a/daemons/lvmdbusd/lv.py
+++ b/daemons/lvmdbusd/lv.py
@@ -10,7 +10,7 @@
from .automatedproperties import AutomatedProperties
from . import utils
-from .utils import vg_obj_path_generate
+from .utils import vg_obj_path_generate, log_error
import dbus
from . import cmdhandler
from . import cfg
@@ -24,6 +24,8 @@ from . import background
from .utils import round_size, mt_remove_dbus_objects
from .job import JobState
+import traceback
+
# Try and build a key for a LV, so that we sort the LVs with least dependencies
# first. This may be error prone because of the flexibility LVM
@@ -291,6 +293,22 @@ class LvCommon(AutomatedProperties):
(lv_uuid, lv_name))
return dbo
+ def attr_struct(self, index, type_map, default='undisclosed'):
+ try:
+ if self.state.Attr[index] not in type_map:
+ log_error("LV %s %s with lv_attr %s, lv_attr[%d] = "
+ "'%s' is not known" %
+ (self.Uuid, self.Name, self.Attr, index,
+ self.state.Attr[index]))
+
+ return dbus.Struct((self.state.Attr[index],
+ type_map.get(self.state.Attr[index], default)),
+ signature="(ss)")
+ except BaseException:
+ st = traceback.format_exc()
+ log_error("attr_struct: \n%s" % st)
+ return dbus.Struct(('?', 'Unavailable'), signature="(ss)")
+
@property
def VolumeType(self):
type_map = {'C': 'Cache', 'm': 'mirrored',
@@ -304,16 +322,14 @@ class LvCommon(AutomatedProperties):
'V': 'thin Volume', 't': 'thin pool', 'T': 'Thin pool data',
'e': 'raid or pool metadata or pool metadata spare',
'-': 'Unspecified'}
- return dbus.Struct((self.state.Attr[0], type_map[self.state.Attr[0]]),
- signature="as")
+ return self.attr_struct(0, type_map)
@property
def Permissions(self):
type_map = {'w': 'writable', 'r': 'read-only',
'R': 'Read-only activation of non-read-only volume',
'-': 'Unspecified'}
- return dbus.Struct((self.state.Attr[1], type_map[self.state.Attr[1]]),
- signature="(ss)")
+ return self.attr_struct(1, type_map)
@property
def AllocationPolicy(self):
@@ -322,8 +338,7 @@ class LvCommon(AutomatedProperties):
'i': 'inherited', 'I': 'inherited locked',
'l': 'cling', 'L': 'cling locked',
'n': 'normal', 'N': 'normal locked', '-': 'Unspecified'}
- return dbus.Struct((self.state.Attr[2], type_map[self.state.Attr[2]]),
- signature="(ss)")
+ return self.attr_struct(2, type_map)
@property
def FixedMinor(self):
@@ -338,8 +353,7 @@ class LvCommon(AutomatedProperties):
'd': 'mapped device present without tables',
'i': 'mapped device present with inactive table',
'X': 'unknown', '-': 'Unspecified'}
- return dbus.Struct((self.state.Attr[4], type_map[self.state.Attr[4]]),
- signature="(ss)")
+ return self.attr_struct(4, type_map)
@property
def TargetType(self):
@@ -358,8 +372,7 @@ class LvCommon(AutomatedProperties):
type_map = {'p': 'partial', 'r': 'refresh',
'm': 'mismatches', 'w': 'writemostly',
'X': 'X unknown', '-': 'Unspecified'}
- return dbus.Struct((self.state.Attr[8], type_map[self.state.Attr[8]]),
- signature="(ss)")
+ return self.attr_struct(8, type_map)
@property
def SkipActivation(self):
5 years, 4 months
master - lvmanip: uninitialized members in struct pv_list (#10)
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=859feb81e5b61ac2109...
Commit: 859feb81e5b61ac2109b1d7850844ccf1ce3e5bf
Parent: db6d9e04af7277a5e2883743e0a9a1502d97249f
Author: Ming-Hung Tsai <notifications(a)github.com>
AuthorDate: Fri Dec 14 01:51:51 2018 -0800
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Dec 14 15:23:18 2018 +0100
lvmanip: uninitialized members in struct pv_list (#10)
Scenario: Given an existed LV `lvol0`, I want to create another LV
on the PVs used by `lvol0`.
I use `build_parallel_areas_from_lv()` to obtain the `pv_list` of each segments.
However, the returned `pv_list` is not properly initialized, which causes
segfault in subsequent operations.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6856d66..0b7f834 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.02 -
===================================
+ Fix missing proper initialization of pv_list struct when adding pv.
Fix (de)activation of RaidLVs with visible SubLVs
Prohibit mirrored 'mirror' log via lvcreate and lvconvert
Use sync io if async io_setup fails, or use_aio=0 is set in config.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 2c569d8..27c40d7 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -5962,7 +5962,7 @@ static int _add_pvs(struct cmd_context *cmd, struct pv_segment *peg,
if (find_pv_in_pv_list(&spvs->pvs, peg->pv))
return 1;
- if (!(pvl = dm_pool_alloc(cmd->mem, sizeof(*pvl)))) {
+ if (!(pvl = dm_pool_zalloc(cmd->mem, sizeof(*pvl)))) {
log_error("pv_list allocation failed");
return 0;
}
5 years, 4 months
master - debug: drop extra tracing
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=db6d9e04af7277a5e28...
Commit: db6d9e04af7277a5e2883743e0a9a1502d97249f
Parent: cc5cfb88d70ef7982e66e5ddf8a5fbd69d485fec
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Dec 1 21:39:42 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Dec 14 15:14:48 2018 +0100
debug: drop extra tracing
Stack tracing after log_error() is not needed.
---
device_mapper/libdm-deptree.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/device_mapper/libdm-deptree.c b/device_mapper/libdm-deptree.c
index c134489..7a7239e 100644
--- a/device_mapper/libdm-deptree.c
+++ b/device_mapper/libdm-deptree.c
@@ -2742,7 +2742,7 @@ static int _vdo_emit_segment_line(struct dm_task *dmt,
/* Unlike normal targets, current VDO requires device path */
if (dm_snprintf(data_dev, sizeof(data_dev), "/dev/dm-%u", seg->vdo_data->info.minor) < 0) {
log_error("Can create VDO data volume path for %s.", data);
- return_0;
+ return 0;
}
EMIT_PARAMS(pos, "%s %u %s " FMTu64 " " FMTu64 " %u on %s %s "
5 years, 4 months
master - cleanup: some local headers first
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=cc5cfb88d70ef7982e6...
Commit: cc5cfb88d70ef7982e66e5ddf8a5fbd69d485fec
Parent: 73bef5e3ddc962e462b3068fd0b1c7cbccad5176
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 14 13:10:25 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Dec 14 15:14:48 2018 +0100
cleanup: some local headers first
---
lib/device/dev-type.c | 7 +++----
lib/format_text/export.c | 2 +-
lib/format_text/format-text.c | 4 ++--
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 693550a..d96f00b 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -15,15 +15,13 @@
#include "base/memory/zalloc.h"
#include "lib/misc/lib.h"
#include "lib/device/dev-type.h"
+#include "lib/device/device-types.h"
#include "lib/mm/xlate.h"
#include "lib/config/config.h"
#include "lib/metadata/metadata.h"
#include "lib/device/bcache.h"
#include "lib/label/label.h"
-#include <libgen.h>
-#include <ctype.h>
-
#ifdef BLKID_WIPING_SUPPORT
#include <blkid.h>
#endif
@@ -33,7 +31,8 @@
#include "lib/device/dev-ext-udev-constants.h"
#endif
-#include "lib/device/device-types.h"
+#include <libgen.h>
+#include <ctype.h>
/*
* dev is pmem if /sys/dev/block/<major>:<minor>/queue/dax is 1
diff --git a/lib/format_text/export.c b/lib/format_text/export.c
index a9a7e15..48e4c9a 100644
--- a/lib/format_text/export.c
+++ b/lib/format_text/export.c
@@ -16,12 +16,12 @@
#include "base/memory/zalloc.h"
#include "lib/misc/lib.h"
#include "import-export.h"
+#include "lvm-version.h"
#include "lib/metadata/metadata.h"
#include "lib/display/display.h"
#include "lib/misc/lvm-string.h"
#include "lib/metadata/segtype.h"
#include "lib/format_text/text_export.h"
-#include "lvm-version.h"
#include "lib/commands/toolcontext.h"
#include "libdaemon/client/config-util.h"
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 92a1495..f5bbf9e 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -14,8 +14,9 @@
*/
#include "lib/misc/lib.h"
-#include "lib/format_text/format-text.h"
#include "import-export.h"
+#include "format-text.h"
+#include "layout.h"
#include "lib/device/device.h"
#include "lib/misc/lvm-file.h"
#include "lib/config/config.h"
@@ -23,7 +24,6 @@
#include "lib/commands/toolcontext.h"
#include "lib/misc/lvm-string.h"
#include "lib/uuid/uuid.h"
-#include "layout.h"
#include "lib/misc/crc.h"
#include "lib/mm/xlate.h"
#include "lib/label/label.h"
5 years, 4 months
master - makefiles: some leftovers from lvmetad
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=73bef5e3ddc962e462b...
Commit: 73bef5e3ddc962e462b3068fd0b1c7cbccad5176
Parent: 4801919b01de26df9c1940a997a54c47ca5fee5d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Dec 1 17:34:20 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Dec 14 15:14:48 2018 +0100
makefiles: some leftovers from lvmetad
---
libdm/make.tmpl.in | 2 +-
make.tmpl.in | 4 +---
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/libdm/make.tmpl.in b/libdm/make.tmpl.in
index c88505f..cc1642a 100644
--- a/libdm/make.tmpl.in
+++ b/libdm/make.tmpl.in
@@ -533,7 +533,7 @@ endif
ifeq ("@USE_TRACKING@","yes")
ifeq (,$(findstring $(MAKECMDGOALS),cscope.out cflow clean distclean lcov \
- help check check_local check_cluster check_lvmetad check_lvmpolld))
+ help check check_local check_cluster check_lvmpolld))
ifdef SOURCES
-include $(SOURCES:.c=.d) $(CXXSOURCES:.cpp=.d)
endif
diff --git a/make.tmpl.in b/make.tmpl.in
index e52827b..1a101fc 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -258,12 +258,10 @@ endif
ifneq ("@BUILD_DMEVENTD@", "yes")
ifneq ("@BUILD_LVMLOCKD@", "yes")
ifneq ("@BUILD_LVMPOLLD@", "yes")
- ifneq ("@BUILD_LVMETAD@", "yes")
DEFS += -DDEBUG_MEM
endif
endif
endif
- endif
endif
# end of fPIC protection
@@ -583,7 +581,7 @@ endif
ifeq ("$(USE_TRACKING)","yes")
ifeq (,$(findstring $(MAKECMDGOALS),cscope.out cflow clean distclean lcov \
- help check check_local check_cluster check_lvmetad check_lvmpolld))
+ help check check_local check_cluster check_lvmpolld))
ifdef SOURCES
-include $(SOURCES:.c=.d) $(CXXSOURCES:.cpp=.d)
endif
5 years, 4 months
master - makefiles: local headers first
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4801919b01de26df9c1...
Commit: 4801919b01de26df9c1940a997a54c47ca5fee5d
Parent: 454024f9576e83dde7c2c2df9a201c3e680bd864
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 14 13:13:45 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Dec 14 15:14:48 2018 +0100
makefiles: local headers first
---
make.tmpl.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/make.tmpl.in b/make.tmpl.in
index f52a65a..e52827b 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -309,7 +309,7 @@ LIB_VERSION_DM := $(shell $(AWK) -F '.' '{printf "%s.%s",$$1,$$2}' $(top_srcdir)
LIB_VERSION_APP := $(shell $(AWK) -F '[(). ]' '{printf "%s.%s",$$1,$$4}' $(top_srcdir)/VERSION)
-INCLUDES += -I$(top_srcdir) -I$(srcdir) -I$(top_builddir)/include
+INCLUDES += -I$(srcdir) -I$(top_srcdir) -I$(top_builddir)/include
#VDO_INCLUDES=-I@VDO_INCLUDE@
5 years, 4 months
master - makefiles: drop unneeded include path
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=454024f9576e83dde7c...
Commit: 454024f9576e83dde7c2c2df9a201c3e680bd864
Parent: 0f5bdd4d316c0651f170ba73eca244caf71d8e70
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 14 13:12:58 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Dec 14 15:14:48 2018 +0100
makefiles: drop unneeded include path
---
tools/Makefile.in | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/tools/Makefile.in b/tools/Makefile.in
index 4be1f72..7b29517 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -118,8 +118,6 @@ all: device-mapper
CFLAGS_lvm.o += $(EXTRA_EXEC_CFLAGS)
-INCLUDES += -I$(top_builddir)/tools
-
lvm: $(OBJECTS) lvm.o $(top_builddir)/lib/liblvm-internal.a $(INTERNAL_LIBS)
@echo " [CC] $@"
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) -o $@ $+ \
5 years, 4 months
master - makefiles: correct libdm dependency
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0f5bdd4d316c0651f17...
Commit: 0f5bdd4d316c0651f170ba73eca244caf71d8e70
Parent: 63b0f0dab8b9a86b5cae6592f8cbea2eac0b70a3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Dec 14 13:12:27 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Dec 14 15:14:32 2018 +0100
makefiles: correct libdm dependency
Correcting dependency tracking for libdm internal files.
---
libdm/make.tmpl.in | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/libdm/make.tmpl.in b/libdm/make.tmpl.in
index 451ef94..c88505f 100644
--- a/libdm/make.tmpl.in
+++ b/libdm/make.tmpl.in
@@ -277,11 +277,11 @@ LIB_VERSION_LVM := $(shell $(AWK) -F '.' '{printf "%s.%s",$$1,$$2}' $(top_srcdir
LIB_VERSION_DM := $(shell $(AWK) -F '.' '{printf "%s.%s",$$1,$$2}' $(top_srcdir)/VERSION_DM)
-INCLUDES += -I$(top_srcdir) -I$(srcdir) -I$(top_builddir)/include
+INCLUDES += -I$(srcdir) -I$(top_srcdir) -I$(top_builddir)/include
-DEPS = $(top_builddir)/make.tmpl $(top_srcdir)/VERSION \
- $(top_builddir)/Makefile
+DEPS = $(top_builddir)/libdm/make.tmpl $(top_srcdir)/VERSION \
+ $(top_builddir)/libdm/Makefile
OBJECTS = $(SOURCES:%.c=%.o) $(CXXSOURCES:%.cpp=%.o)
POTFILES = $(SOURCES:%.c=%.pot)
5 years, 4 months
master - headers: use full path header instead of -I directive
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=63b0f0dab8b9a86b5ca...
Commit: 63b0f0dab8b9a86b5cae6592f8cbea2eac0b70a3
Parent: 0b19387dae782b33bb341e58ab3c7ff804ca4f14
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Dec 3 18:15:44 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Dec 14 15:13:38 2018 +0100
headers: use full path header instead of -I directive
Replace Makefile -I with full path to headers like we use now
everywhere else.
---
daemons/dmeventd/plugins/mirror/Makefile.in | 1 -
daemons/dmeventd/plugins/mirror/dmeventd_mirror.c | 2 +-
daemons/dmeventd/plugins/raid/Makefile.in | 1 -
daemons/dmeventd/plugins/raid/dmeventd_raid.c | 4 ++--
daemons/dmeventd/plugins/snapshot/Makefile.in | 1 -
.../dmeventd/plugins/snapshot/dmeventd_snapshot.c | 2 +-
daemons/dmeventd/plugins/thin/Makefile.in | 1 -
daemons/dmeventd/plugins/thin/dmeventd_thin.c | 2 +-
daemons/dmeventd/plugins/vdo/Makefile.in | 1 -
daemons/dmeventd/plugins/vdo/dmeventd_vdo.c | 2 +-
10 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/daemons/dmeventd/plugins/mirror/Makefile.in b/daemons/dmeventd/plugins/mirror/Makefile.in
index a28b9e5..2c0d5d7 100644
--- a/daemons/dmeventd/plugins/mirror/Makefile.in
+++ b/daemons/dmeventd/plugins/mirror/Makefile.in
@@ -16,7 +16,6 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
-INCLUDES += -I$(top_srcdir)/daemons/dmeventd/plugins/lvm2
CLDFLAGS += -L$(top_builddir)/daemons/dmeventd/plugins/lvm2
SOURCES = dmeventd_mirror.c
diff --git a/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c b/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
index ca483fd..5f1db32 100644
--- a/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
+++ b/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
@@ -13,8 +13,8 @@
*/
#include "lib/misc/lib.h"
+#include "daemons/dmeventd/plugins/lvm2/dmeventd_lvm.h"
#include "daemons/dmeventd/libdevmapper-event.h"
-#include "dmeventd_lvm.h"
#include "lib/activate/activate.h"
/* FIXME Reformat to 80 char lines. */
diff --git a/daemons/dmeventd/plugins/raid/Makefile.in b/daemons/dmeventd/plugins/raid/Makefile.in
index d38ca15..c00e624 100644
--- a/daemons/dmeventd/plugins/raid/Makefile.in
+++ b/daemons/dmeventd/plugins/raid/Makefile.in
@@ -15,7 +15,6 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
-INCLUDES += -I$(top_srcdir)/daemons/dmeventd/plugins/lvm2
CLDFLAGS += -L$(top_builddir)/daemons/dmeventd/plugins/lvm2
SOURCES = dmeventd_raid.c
diff --git a/daemons/dmeventd/plugins/raid/dmeventd_raid.c b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
index 7871500..aa2b578 100644
--- a/daemons/dmeventd/plugins/raid/dmeventd_raid.c
+++ b/daemons/dmeventd/plugins/raid/dmeventd_raid.c
@@ -13,9 +13,9 @@
*/
#include "lib/misc/lib.h"
-#include "lib/config/defaults.h"
-#include "dmeventd_lvm.h"
+#include "daemons/dmeventd/plugins/lvm2/dmeventd_lvm.h"
#include "daemons/dmeventd/libdevmapper-event.h"
+#include "lib/config/defaults.h"
/* Hold enough elements for the mximum number of RAID images */
#define RAID_DEVS_ELEMS ((DEFAULT_RAID_MAX_IMAGES + 63) / 64)
diff --git a/daemons/dmeventd/plugins/snapshot/Makefile.in b/daemons/dmeventd/plugins/snapshot/Makefile.in
index ab46b43..adbb3e2 100644
--- a/daemons/dmeventd/plugins/snapshot/Makefile.in
+++ b/daemons/dmeventd/plugins/snapshot/Makefile.in
@@ -16,7 +16,6 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
-INCLUDES += -I$(top_srcdir)/daemons/dmeventd/plugins/lvm2
CLDFLAGS += -L$(top_builddir)/daemons/dmeventd/plugins/lvm2
SOURCES = dmeventd_snapshot.c
diff --git a/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c b/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
index 9e9053c..9c49a72 100644
--- a/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
+++ b/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c
@@ -13,7 +13,7 @@
*/
#include "lib/misc/lib.h"
-#include "dmeventd_lvm.h"
+#include "daemons/dmeventd/plugins/lvm2/dmeventd_lvm.h"
#include "daemons/dmeventd/libdevmapper-event.h"
#include <sys/sysmacros.h>
diff --git a/daemons/dmeventd/plugins/thin/Makefile.in b/daemons/dmeventd/plugins/thin/Makefile.in
index b1e3e1b..7968504 100644
--- a/daemons/dmeventd/plugins/thin/Makefile.in
+++ b/daemons/dmeventd/plugins/thin/Makefile.in
@@ -15,7 +15,6 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
-INCLUDES += -I$(top_srcdir)/daemons/dmeventd/plugins/lvm2
CLDFLAGS += -L$(top_builddir)/daemons/dmeventd/plugins/lvm2
SOURCES = dmeventd_thin.c
diff --git a/daemons/dmeventd/plugins/thin/dmeventd_thin.c b/daemons/dmeventd/plugins/thin/dmeventd_thin.c
index 64fe6ca..5ff5bb8 100644
--- a/daemons/dmeventd/plugins/thin/dmeventd_thin.c
+++ b/daemons/dmeventd/plugins/thin/dmeventd_thin.c
@@ -13,7 +13,7 @@
*/
#include "lib/misc/lib.h"
-#include "dmeventd_lvm.h"
+#include "daemons/dmeventd/plugins/lvm2/dmeventd_lvm.h"
#include "daemons/dmeventd/libdevmapper-event.h"
#include <sys/wait.h>
diff --git a/daemons/dmeventd/plugins/vdo/Makefile.in b/daemons/dmeventd/plugins/vdo/Makefile.in
index bda738a..8e90e27 100644
--- a/daemons/dmeventd/plugins/vdo/Makefile.in
+++ b/daemons/dmeventd/plugins/vdo/Makefile.in
@@ -15,7 +15,6 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
-INCLUDES += -I$(top_srcdir)/daemons/dmeventd/plugins/lvm2
CLDFLAGS += -L$(top_builddir)/daemons/dmeventd/plugins/lvm2
SOURCES = dmeventd_vdo.c
diff --git a/daemons/dmeventd/plugins/vdo/dmeventd_vdo.c b/daemons/dmeventd/plugins/vdo/dmeventd_vdo.c
index abed41e..b5e2766 100644
--- a/daemons/dmeventd/plugins/vdo/dmeventd_vdo.c
+++ b/daemons/dmeventd/plugins/vdo/dmeventd_vdo.c
@@ -13,7 +13,7 @@
*/
#include "lib/misc/lib.h"
-#include "dmeventd_lvm.h"
+#include "daemons/dmeventd/plugins/lvm2/dmeventd_lvm.h"
#include "daemons/dmeventd/libdevmapper-event.h"
#include "device_mapper/vdo/target.h"
5 years, 4 months
master - headers: use configure.h as 1st. header
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0b19387dae782b33bb3...
Commit: 0b19387dae782b33bb341e58ab3c7ff804ca4f14
Parent: 3c377643339be97940554323909d51b12c933f9e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Dec 3 18:14:26 2018 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Dec 14 15:09:13 2018 +0100
headers: use configure.h as 1st. header
Ensure configure.h is always 1st. included header.
Maybe we could eventually introduce gcc -include option, but for now
this better uses dependency tracking.
Also move _REENTRANT and _GNU_SOURCE into configure.h so it
doesn't need to be present in various source files.
This ensures consistent compilation of headers like stdio.h since
it may produce different declaration.
---
base/data-struct/radix-tree-adaptive.c | 1 +
base/data-struct/radix-tree.h | 2 ++
base/memory/zalloc.h | 2 +-
configure | 9 +++++++++
configure.ac | 5 +++++
daemons/cmirrord/logging.h | 2 --
daemons/lvmlockd/lvmlockd-core.c | 1 -
daemons/lvmpolld/lvmpolld-common.h | 2 --
device_mapper/all.h | 2 ++
device_mapper/ioctl/libdm-iface.c | 1 -
device_mapper/misc/dmlib.h | 5 -----
include/configure.h.in | 6 ++++++
lib/device/bcache.c | 2 --
lib/device/bcache.h | 1 -
lib/label/label.c | 2 --
lib/misc/lib.h | 9 ++-------
libdaemon/client/config-util.c | 4 +---
libdaemon/client/daemon-client.c | 6 ++----
libdaemon/client/daemon-io.c | 4 +---
libdaemon/server/daemon-log.c | 2 --
libdaemon/server/daemon-server.c | 4 +---
libdm/dm-tools/dmsetup.c | 2 --
libdm/misc/dmlib.h | 3 ---
test/lib/harness.c | 3 ++-
test/unit/bcache_utils_t.c | 2 --
test/unit/io_engine_t.c | 2 --
tools/tool.h | 6 ++----
27 files changed, 37 insertions(+), 53 deletions(-)
diff --git a/base/data-struct/radix-tree-adaptive.c b/base/data-struct/radix-tree-adaptive.c
index 5e065b6..b9ba417 100644
--- a/base/data-struct/radix-tree-adaptive.c
+++ b/base/data-struct/radix-tree-adaptive.c
@@ -18,6 +18,7 @@
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
//----------------------------------------------------------------
diff --git a/base/data-struct/radix-tree.h b/base/data-struct/radix-tree.h
index 5d4d04c..685b828 100644
--- a/base/data-struct/radix-tree.h
+++ b/base/data-struct/radix-tree.h
@@ -13,6 +13,8 @@
#ifndef BASE_DATA_STRUCT_RADIX_TREE_H
#define BASE_DATA_STRUCT_RADIX_TREE_H
+#include "configure.h"
+
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
diff --git a/base/memory/zalloc.h b/base/memory/zalloc.h
index 4f6df54..069c599 100644
--- a/base/memory/zalloc.h
+++ b/base/memory/zalloc.h
@@ -13,8 +13,8 @@
#ifndef BASE_MEMORY_ZALLOC_H
#define BASE_MEMORY_ZALLOC_H
+#include "configure.h"
#include <stdlib.h>
-#include <string.h>
//----------------------------------------------------------------
diff --git a/configure b/configure
index 66acdb2..53f5023 100755
--- a/configure
+++ b/configure
@@ -6623,6 +6623,15 @@ fi
+
+
+$as_echo "#define _GNU_SOURCE 1" >>confdefs.h
+
+
+$as_echo "#define _REENTRANT 1" >>confdefs.h
+
+
+
################################################################################
for ac_func in ftruncate gethostname getpagesize gettimeofday localtime_r \
memchr memset mkdir mkfifo munmap nl_langinfo realpath rmdir setenv \
diff --git a/configure.ac b/configure.ac
index 2b29210..2ece3f9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -144,6 +144,11 @@ AC_TYPE_UINT64_T
AX_GCC_BUILTIN([__builtin_clz])
AX_GCC_BUILTIN([__builtin_clzll])
+
+AC_DEFINE([_GNU_SOURCE], 1, [Define to get access to GNU/Linux extension])
+AC_DEFINE([_REENTRANT], 1, [Define to use re-entrant thread safe versions])
+
+
################################################################################
dnl -- Check for functions
AC_CHECK_FUNCS([ftruncate gethostname getpagesize gettimeofday localtime_r \
diff --git a/daemons/cmirrord/logging.h b/daemons/cmirrord/logging.h
index 13e6b39..5f640cf 100644
--- a/daemons/cmirrord/logging.h
+++ b/daemons/cmirrord/logging.h
@@ -13,8 +13,6 @@
#ifndef _LVM_CLOG_LOGGING_H
#define _LVM_CLOG_LOGGING_H
-#define _GNU_SOURCE
-
#include "configure.h"
#include <stdio.h>
#include <stdint.h>
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 5bdbefe..dd52270 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -10,7 +10,6 @@
#define _XOPEN_SOURCE 500 /* pthread */
#define _ISOC99_SOURCE
-#define _REENTRANT
#include "tools/tool.h"
diff --git a/daemons/lvmpolld/lvmpolld-common.h b/daemons/lvmpolld/lvmpolld-common.h
index 4ada581..ccd9b13 100644
--- a/daemons/lvmpolld/lvmpolld-common.h
+++ b/daemons/lvmpolld/lvmpolld-common.h
@@ -18,8 +18,6 @@
#ifndef _LVM_LVMPOLLD_COMMON_H
#define _LVM_LVMPOLLD_COMMON_H
-#define _REENTRANT
-
#include "tools/tool.h"
#include "lvmpolld-cmd-utils.h"
diff --git a/device_mapper/all.h b/device_mapper/all.h
index 0c1dc29..8c17c09 100644
--- a/device_mapper/all.h
+++ b/device_mapper/all.h
@@ -17,6 +17,8 @@
#ifndef LIB_DEVICE_MAPPER_H
#define LIB_DEVICE_MAPPER_H
+#include "configure.h"
+
#include "base/data-struct/list.h"
#include "base/data-struct/hash.h"
#include "vdo/target.h"
diff --git a/device_mapper/ioctl/libdm-iface.c b/device_mapper/ioctl/libdm-iface.c
index f86d3b3..d333426 100644
--- a/device_mapper/ioctl/libdm-iface.c
+++ b/device_mapper/ioctl/libdm-iface.c
@@ -19,7 +19,6 @@
#include "device_mapper/ioctl/libdm-targets.h"
#include "device_mapper/libdm-common.h"
-#include <stdio.h> /* getline() */
#include <stddef.h>
#include <fcntl.h>
#include <dirent.h>
diff --git a/device_mapper/misc/dmlib.h b/device_mapper/misc/dmlib.h
index fe64bd7..51fe5a3 100644
--- a/device_mapper/misc/dmlib.h
+++ b/device_mapper/misc/dmlib.h
@@ -21,11 +21,6 @@
// FIXME: get rid of this whole file
-#include "configure.h"
-
-#define _REENTRANT
-#define _GNU_SOURCE
-
#include "device_mapper/all.h"
#include "lib/misc/util.h"
#include "dm-logging.h"
diff --git a/include/configure.h.in b/include/configure.h.in
index c66b37b..dde55fe 100644
--- a/include/configure.h.in
+++ b/include/configure.h.in
@@ -669,6 +669,12 @@
/* Define to 1 to include built-in support for writecache. */
#undef WRITECACHE_INTERNAL
+/* Define to get access to GNU/Linux extension */
+#undef _GNU_SOURCE
+
+/* Define to use re-entrant thread safe versions */
+#undef _REENTRANT
+
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index 18ffcf0..d646d2b 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -12,8 +12,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _GNU_SOURCE
-
#include "lib/device/bcache.h"
#include "base/data-struct/radix-tree.h"
diff --git a/lib/device/bcache.h b/lib/device/bcache.h
index 2edc54a..8c16caa 100644
--- a/lib/device/bcache.h
+++ b/lib/device/bcache.h
@@ -15,7 +15,6 @@
#ifndef BCACHE_H
#define BCACHE_H
-#include "configure.h"
#include "device_mapper/all.h"
#include <linux/fs.h>
diff --git a/lib/label/label.c b/lib/label/label.c
index 0517312..6fe1e41 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -13,8 +13,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _GNU_SOURCE
-
#include "base/memory/zalloc.h"
#include "lib/misc/lib.h"
#include "lib/label/label.h"
diff --git a/lib/misc/lib.h b/lib/misc/lib.h
index f7baf9d..c14f437 100644
--- a/lib/misc/lib.h
+++ b/lib/misc/lib.h
@@ -19,11 +19,6 @@
#ifndef _LVM_LIB_H
#define _LVM_LIB_H
-#include "configure.h"
-
-#define _REENTRANT
-#define _GNU_SOURCE
-
/*
* Symbol export control macros
*
@@ -78,10 +73,10 @@
#endif
-#include "lib/misc/intl.h"
#include "device_mapper/all.h"
-#include "lib/misc/util.h"
#include "base/memory/zalloc.h"
+#include "lib/misc/intl.h"
+#include "lib/misc/util.h"
#ifdef DM
# include "libdm/misc/dm-logging.h"
diff --git a/libdaemon/client/config-util.c b/libdaemon/client/config-util.c
index bdbdd3a..3f27f31 100644
--- a/libdaemon/client/config-util.c
+++ b/libdaemon/client/config-util.c
@@ -12,11 +12,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _REENTRANT
-
#include "tools/tool.h"
-#include "libdaemon/client/daemon-io.h"
+#include "daemon-io.h"
#include "device_mapper/misc/dm-logging.h"
#include <math.h> /* fabs() */
diff --git a/libdaemon/client/daemon-client.c b/libdaemon/client/daemon-client.c
index 53f4495..8049686 100644
--- a/libdaemon/client/daemon-client.c
+++ b/libdaemon/client/daemon-client.c
@@ -12,12 +12,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _REENTRANT
-
#include "tools/tool.h"
-#include "libdaemon/client/daemon-io.h"
-#include "libdaemon/client/daemon-client.h"
+#include "daemon-io.h"
+#include "daemon-client.h"
#include "device_mapper/misc/dm-logging.h"
#include <sys/un.h>
diff --git a/libdaemon/client/daemon-io.c b/libdaemon/client/daemon-io.c
index bd24cdb..1f9d840 100644
--- a/libdaemon/client/daemon-io.c
+++ b/libdaemon/client/daemon-io.c
@@ -12,11 +12,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _REENTRANT
-
#include "tools/tool.h"
-#include "libdaemon/client/daemon-io.h"
+#include "daemon-io.h"
#include <errno.h>
diff --git a/libdaemon/server/daemon-log.c b/libdaemon/server/daemon-log.c
index 864f504..7198c29 100644
--- a/libdaemon/server/daemon-log.c
+++ b/libdaemon/server/daemon-log.c
@@ -10,8 +10,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _REENTRANT
-
#include "tools/tool.h"
#include "daemon-server.h"
diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c
index 78c8221..a2216ac 100644
--- a/libdaemon/server/daemon-server.c
+++ b/libdaemon/server/daemon-server.c
@@ -10,13 +10,11 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _REENTRANT
-
#include "tools/tool.h"
-#include "libdaemon/client/daemon-io.h"
#include "daemon-server.h"
#include "daemon-log.h"
+#include "libdaemon/client/daemon-io.h"
#include <dlfcn.h>
#include <errno.h>
diff --git a/libdm/dm-tools/dmsetup.c b/libdm/dm-tools/dmsetup.c
index 4b14a23..efeb978 100644
--- a/libdm/dm-tools/dmsetup.c
+++ b/libdm/dm-tools/dmsetup.c
@@ -17,8 +17,6 @@
*/
// For canonicalize_file_name()
-#define _GNU_SOURCE
-
#include "configure.h"
#include "libdm/misc/dm-logging.h"
#include "libdm/dm-tools/util.h"
diff --git a/libdm/misc/dmlib.h b/libdm/misc/dmlib.h
index 4c6bcfc..60787fe 100644
--- a/libdm/misc/dmlib.h
+++ b/libdm/misc/dmlib.h
@@ -21,9 +21,6 @@
#include "configure.h"
-#define _REENTRANT
-#define _GNU_SOURCE
-
/*
* Symbol export control macros
*
diff --git a/test/lib/harness.c b/test/lib/harness.c
index ace3f5a..d1274ed 100644
--- a/test/lib/harness.c
+++ b/test/lib/harness.c
@@ -12,7 +12,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _GNU_SOURCE
+#include "configure.h"
+
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
diff --git a/test/unit/bcache_utils_t.c b/test/unit/bcache_utils_t.c
index 2e08320..d022c51 100644
--- a/test/unit/bcache_utils_t.c
+++ b/test/unit/bcache_utils_t.c
@@ -12,8 +12,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _GNU_SOURCE
-
#include "units.h"
#include "lib/device/bcache.h"
diff --git a/test/unit/io_engine_t.c b/test/unit/io_engine_t.c
index bac9c38..44e93e0 100644
--- a/test/unit/io_engine_t.c
+++ b/test/unit/io_engine_t.c
@@ -12,8 +12,6 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define _GNU_SOURCE
-
#include "units.h"
#include "lib/device/bcache.h"
diff --git a/tools/tool.h b/tools/tool.h
index fb6cab8..6fd4da0 100644
--- a/tools/tool.h
+++ b/tools/tool.h
@@ -18,14 +18,12 @@
#ifndef _LVM_TOOL_H
#define _LVM_TOOL_H
-#define _GNU_SOURCE
-
#include "configure.h"
-#include <unistd.h>
-
#include "base/memory/zalloc.h"
#include "device_mapper/all.h"
#include "lib/misc/util.h"
+#include <unistd.h>
+
#endif /* _LVM_TOOL_H */
5 years, 4 months