1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

Add option to compile without ioctl for testing.

This commit is contained in:
Alasdair Kergon 2005-01-27 16:16:54 +00:00
parent 939d24cce5
commit 2bfd64c3c9
5 changed files with 43 additions and 19 deletions

View File

@ -1,5 +1,6 @@
Version 1.01.01 - Version 1.01.01 -
============================= =============================
Add option to compile without ioctl for testing.
Fix DM_LIB_VERSION sed. Fix DM_LIB_VERSION sed.
Version 1.01.00 - 17 Jan 2005 Version 1.01.00 - 17 Jan 2005

View File

@ -22,7 +22,12 @@ SOURCES = libdm-common.c libdm-file.c $(interface)/libdm-iface.c
INCLUDES = -I$(interface) INCLUDES = -I$(interface)
LIB_STATIC = $(interface)/libdevmapper.a LIB_STATIC = $(interface)/libdevmapper.a
LIB_SHARED = $(interface)/libdevmapper.so
ifeq ("@LIB_SUFFIX@","dylib")
LIB_SHARED = $(interface)/libdevmapper.dylib
else
LIB_SHARED = $(interface)/libdevmapper.so
endif
CFLAGS += -DDEVICE_UID=@DEVICE_UID@ -DDEVICE_GID=@DEVICE_GID@ \ CFLAGS += -DDEVICE_UID=@DEVICE_UID@ -DDEVICE_GID=@DEVICE_GID@ \
-DDEVICE_MODE=@DEVICE_MODE@ -DDEVICE_MODE=@DEVICE_MODE@
@ -41,7 +46,8 @@ endif
install: $(INSTALL_TYPE) install: $(INSTALL_TYPE)
install_dynamic: install_@interface@ install_dynamic: install_@interface@
$(LN_S) -f libdevmapper.so.$(LIB_VERSION) $(libdir)/libdevmapper.so $(LN_S) -f libdevmapper.$(LIB_SUFFIX).$(LIB_VERSION) \
$(libdir)/libdevmapper.$(LIB_SUFFIX)
$(INSTALL) -D $(OWNER) $(GROUP) -m 444 libdevmapper.h \ $(INSTALL) -D $(OWNER) $(GROUP) -m 444 libdevmapper.h \
$(includedir)/libdevmapper.h $(includedir)/libdevmapper.h
@ -50,13 +56,13 @@ install_static: install_@interface@_static
$(INSTALL) -D $(OWNER) $(GROUP) -m 444 libdevmapper.h \ $(INSTALL) -D $(OWNER) $(GROUP) -m 444 libdevmapper.h \
$(includedir)/libdevmapper.h $(includedir)/libdevmapper.h
install_fs: fs/libdevmapper.so install_fs: fs/libdevmapper.$(LIB_SUFFIX)
$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \ $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \
$(libdir)/libdevmapper.so.$(LIB_VERSION) $(libdir)/libdevmapper.$(LIB_SUFFIX).$(LIB_VERSION)
install_ioctl: ioctl/libdevmapper.so install_ioctl: ioctl/libdevmapper.$(LIB_SUFFIX)
$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \ $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \
$(libdir)/libdevmapper.so.$(LIB_VERSION) $(libdir)/libdevmapper.$(LIB_SUFFIX).$(LIB_VERSION)
install_ioctl_static: ioctl/libdevmapper.a install_ioctl_static: ioctl/libdevmapper.a
$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \ $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \

View File

@ -30,13 +30,14 @@
#ifdef linux #ifdef linux
# include "kdev_t.h" # include "kdev_t.h"
# include <linux/limits.h> # include <linux/limits.h>
# include <linux/dm-ioctl.h>
#else #else
# define MAJOR(x) major((x)) # define MAJOR(x) major((x))
# define MINOR(x) minor((x)) # define MINOR(x) minor((x))
# define MKDEV(x,y) makedev((x),(y)) # define MKDEV(x,y) makedev((x),(y))
#endif #endif
#include <linux/dm-ioctl.h>
/* /*
* Ensure build compatibility. * Ensure build compatibility.
* The hard-coded versions here are the highest present * The hard-coded versions here are the highest present
@ -228,6 +229,7 @@ static int _create_control(const char *control, uint32_t major, uint32_t minor)
static int _open_control(void) static int _open_control(void)
{ {
#ifdef DM_IOCTLS
char control[PATH_MAX]; char control[PATH_MAX];
uint32_t major = 0, minor; uint32_t major = 0, minor;
@ -253,6 +255,9 @@ static int _open_control(void)
error: error:
log_error("Failure to communicate with kernel device-mapper driver."); log_error("Failure to communicate with kernel device-mapper driver.");
return 0; return 0;
#else
return 1;
#endif
} }
void dm_task_destroy(struct dm_task *dmt) void dm_task_destroy(struct dm_task *dmt)
@ -608,7 +613,9 @@ static int _dm_task_run_v1(struct dm_task *dmt)
if (dmt->type == DM_DEVICE_LIST) { if (dmt->type == DM_DEVICE_LIST) {
if (!_dm_names_v1(dmi)) if (!_dm_names_v1(dmi))
goto bad; goto bad;
} else if (ioctl(_control_fd, command, dmi) < 0) { }
#ifdef DM_IOCTLS
else if (ioctl(_control_fd, command, dmi) < 0) {
if (_log_suppress) if (_log_suppress)
log_verbose("device-mapper ioctl cmd %d failed: %s", log_verbose("device-mapper ioctl cmd %d failed: %s",
_IOC_NR(command), strerror(errno)); _IOC_NR(command), strerror(errno));
@ -617,6 +624,8 @@ static int _dm_task_run_v1(struct dm_task *dmt)
_IOC_NR(command), strerror(errno)); _IOC_NR(command), strerror(errno));
goto bad; goto bad;
} }
#else /* Userspace alternative for testing */
#endif
if (dmi->flags & DM_BUFFER_FULL_FLAG) if (dmi->flags & DM_BUFFER_FULL_FLAG)
/* FIXME Increase buffer size and retry operation (if query) */ /* FIXME Increase buffer size and retry operation (if query) */
@ -1313,22 +1322,26 @@ int dm_task_run(struct dm_task *dmt)
dmi->name, dmi->uuid, dmt->newname ? dmt->newname : "", dmi->name, dmi->uuid, dmt->newname ? dmt->newname : "",
dmt->no_open_count ? 'N' : 'O', dmt->no_open_count ? 'N' : 'O',
dmt->sector, dmt->message ? dmt->message : ""); dmt->sector, dmt->message ? dmt->message : "");
#ifdef DM_IOCTLS
if (ioctl(_control_fd, command, dmi) < 0) { if (ioctl(_control_fd, command, dmi) < 0) {
if (errno == ENXIO && ((dmt->type == DM_DEVICE_INFO) || if (errno == ENXIO && ((dmt->type == DM_DEVICE_INFO) ||
(dmt->type == DM_DEVICE_MKNODES))) { (dmt->type == DM_DEVICE_MKNODES)))
dmi->flags &= ~DM_EXISTS_FLAG; /* FIXME */ dmi->flags &= ~DM_EXISTS_FLAG; /* FIXME */
goto ignore_error; else {
if (_log_suppress)
log_verbose("device-mapper ioctl "
"cmd %d failed: %s",
_IOC_NR(command), strerror(errno));
else
log_error("device-mapper ioctl "
"cmd %d failed: %s",
_IOC_NR(command), strerror(errno));
goto bad;
} }
if (_log_suppress)
log_verbose("device-mapper ioctl cmd %d failed: %s",
_IOC_NR(command), strerror(errno));
else
log_error("device-mapper ioctl cmd %d failed: %s",
_IOC_NR(command), strerror(errno));
goto bad;
} }
#else /* Userspace alternative for testing */
#endif
ignore_error:
switch (dmt->type) { switch (dmt->type) {
case DM_DEVICE_CREATE: case DM_DEVICE_CREATE:
add_dev_node(dmt->dev_name, MAJOR(dmi->dev), MINOR(dmi->dev), add_dev_node(dmt->dev_name, MAJOR(dmi->dev), MINOR(dmi->dev),

View File

@ -21,6 +21,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <sys/param.h> #include <sys/param.h>
#include <linux/dm-ioctl.h> #include <linux/dm-ioctl.h>
#ifdef HAVE_SELINUX #ifdef HAVE_SELINUX

View File

@ -19,7 +19,10 @@
#include <sys/file.h> #include <sys/file.h>
#include <fcntl.h> #include <fcntl.h>
#include <dirent.h> #include <dirent.h>
#include <malloc.h>
#ifdef linux
# include <malloc.h>
#endif
static int _create_dir_recursive(const char *dir) static int _create_dir_recursive(const char *dir)
{ {