+++ /dev/null
-diff --git a/dmsetup/dmsetup.c b/dmsetup/dmsetup.c
-index 25f14a6..b693008 100644
---- a/dmsetup/dmsetup.c
-+++ b/dmsetup/dmsetup.c
-@@ -995,6 +995,94 @@ static int _status(int argc, char **argv
- return r;
- }
-
-+static int _export(int argc, char **argv, void *data)
-+{
-+ int r = 0;
-+ struct dm_task *dmt = NULL;
-+ void *next = NULL;
-+ uint64_t start, length;
-+ char *target_type = NULL;
-+ char *params;
-+ struct dm_names *names = (struct dm_names *) data;
-+ const char *name = NULL;
-+ const char *uuid = NULL;
-+ struct dm_info info;
-+
-+ if (data)
-+ name = names->name;
-+ else if (argc == 2)
-+ name = argv[1];
-+
-+ if (!(dmt = dm_task_create(DM_DEVICE_STATUS)))
-+ goto out;
-+
-+ if (!_set_task_device(dmt, name, 0))
-+ goto out;
-+
-+ if (!dm_task_run(dmt))
-+ goto out;
-+
-+ if (!dm_task_get_info(dmt, &info) || !info.exists)
-+ goto out;
-+
-+ if (!name)
-+ name = dm_task_get_name(dmt);
-+
-+ uuid = dm_task_get_uuid(dmt);
-+ printf("DM_NAME=%s\n", name);
-+
-+ if ((uuid = dm_task_get_uuid(dmt)) && *uuid)
-+ printf("DM_UUID=%s\n", uuid);
-+
-+ if (!info.exists) {
-+ printf("DM_STATE=NOTPRESENT\n");
-+ goto out;
-+ }
-+
-+ printf("DM_STATE=%s\n",
-+ info.suspended ? "SUSPENDED" :
-+ (info.read_only ? " READONLY" : "ACTIVE"));
-+
-+ if (!info.live_table && !info.inactive_table)
-+ printf("DM_TABLE_STATE=NONE\n");
-+ else
-+ printf("DM_TABLE_STATE=%s%s%s\n",
-+ info.live_table ? "LIVE" : "",
-+ info.live_table && info.inactive_table ? "/" : "",
-+ info.inactive_table ? "INACTIVE" : "");
-+
-+ if (info.open_count != -1)
-+ printf("DM_OPENCOUNT=%d\n", info.open_count);
-+
-+ printf("DM_LAST_EVENT_NR=%" PRIu32 "\n", info.event_nr);
-+
-+ printf("DM_MAJOR=%d\n", info.major);
-+ printf("DM_MINOR=%d\n", info.minor);
-+
-+ if (info.target_count != -1)
-+ printf("DM_TARGET_COUNT=%d\n", info.target_count);
-+
-+ /* export all table types */
-+ next = dm_get_next_target(dmt, next, &start, &length,
-+ &target_type, ¶ms);
-+ if (target_type) {
-+ printf("DM_TARGET_TYPES=%s", target_type);
-+ while (next) {
-+ next = dm_get_next_target(dmt, next, &start, &length,
-+ &target_type, ¶ms);
-+ if (target_type)
-+ printf(",%s", target_type);
-+ }
-+ printf("\n");
-+ }
-+
-+ r = 1;
-+ out:
-+ if (dmt)
-+ dm_task_destroy(dmt);
-+ return r;
-+}
-+
- /* Show target names and their version numbers */
- static int _targets(int argc __attribute((unused)), char **argv __attribute((unused)), void *data __attribute((unused)))
- {
-@@ -1699,6 +1787,7 @@ static struct command _commands[] = {
- {"info", "[<device>]", 0, 1, _info},
- {"deps", "[<device>]", 0, 1, _deps},
- {"status", "[<device>] [--target <target_type>]", 0, 1, _status},
-+ {"export", "[<device>]", 0, 1, _export},
- {"table", "[<device>] [--target <target_type>] [--showkeys]", 0, 1, _status},
- {"wait", "<device> [<event_nr>]", 0, 2, _wait},
- {"mknodes", "[<device>]", 0, 1, _mknodes},
-diff --git a/man/dmsetup.8 b/man/dmsetup.8
-index 5b2ed9f..c4524aa 100644
---- a/man/dmsetup.8
-+++ b/man/dmsetup.8
-@@ -39,13 +39,16 @@ dmsetup \- low level logical volume mana
- .B dmsetup ls
- .I [--target target_type] [--exec command] [--tree [-o options]]
- .br
--.B dmsetup info
-+.B dmsetup info
- .I [device_name]
- .br
- .B dmsetup info -c|-C|--columns
- .I [--noheadings] [--separator separator] [-o fields] [-O|--sort sort_fields]
- .I [device_name]
- .br
-+.B dmsetup export
-+.I [device_name]
-+.br
- .B dmsetup deps
- .I [device_name]
- .br
-@@ -138,6 +141,10 @@ device_name in subsequent dmsetup comman
- If successful a device will appear as
- /dev/device-mapper/<device-name>.
- See below for information on the table format.
-+.IP \fBexport
-+.I [device_name]
-+.br
-+Outputs information in key/value format to be imported by other programs.
- .IP \fBdeps
- .I [device_name]
- .br
+++ /dev/null
-diff -Nur device-mapper.1.02.08/lib/ioctl/libdm-iface.c device-mapper.1.02.08.force-local-headers/lib/ioctl/libdm-iface.c
---- device-mapper.1.02.08/lib/ioctl/libdm-iface.c 2006-08-02 01:59:16.000000000 +0200
-+++ device-mapper.1.02.08.force-local-headers/lib/ioctl/libdm-iface.c 2006-08-02 01:59:17.000000000 +0200
-@@ -36,7 +36,7 @@
- # define MKDEV(x,y) makedev((x),(y))
- #endif
-
--#include <linux/dm-ioctl.h>
-+#include "../../kernel/ioctl/dm-ioctl.h"
-
- /*
- * Ensure build compatibility.
+++ /dev/null
---- device-mapper.1.02.07/configure.in.orig 2006-05-17 19:23:21.778894500 +0200
-+++ device-mapper.1.02.07/configure.in 2006-05-17 19:31:56.351053250 +0200
-@@ -230,8 +230,8 @@
- ################################################################################
- dnl -- getline included in recent libc
-
--AC_CHECK_LIB(c, getline, AC_DEFINE([HAVE_GETLINE], 1,
-- [Define to 1 if getline is available.]))
-+AC_CHECK_FUNC(getline, [AC_DEFINE([HAVE_GETLINE], 1,
-+ [Define to 1 if getline is available.])])
-
- ################################################################################
- dnl -- canonicalize_file_name included in recent libc
-@@ -240,7 +240,7 @@
-
- ################################################################################
- dnl -- Check for getopt
--AC_CHECK_HEADERS(getopt.h, AC_DEFINE([HAVE_GETOPTLONG], 1, [Define to 1 if getopt_long is available.]))
-+AC_CHECK_FUNC(getopt_long, [AC_DEFINE([HAVE_GETOPTLONG], 1, [Define to 1 if getopt_long is available.])])
-
- ################################################################################
- dnl -- Internationalisation stuff
+++ /dev/null
---- device-mapper/configure.in~ 2008-07-06 19:22:49.965050005 +0200
-+++ device-mapper/configure.in 2008-07-06 19:26:11.998363857 +0200
-@@ -107,7 +107,7 @@
-
- ################################################################################
- dnl -- Check for functions
--AC_CHECK_FUNCS([gethostname getpagesize memset mkdir rmdir munmap setlocale \
-+AC_CHECK_FUNCS([gethostname memset mkdir rmdir munmap \
- strcasecmp strchr strdup strncasecmp strerror strrchr strstr strtol strtoul \
- uname], , [AC_MSG_ERROR(bailing out)])
- AC_FUNC_ALLOCA
---- device-mapper.1.02.09.orig/configure.in 2006-09-27 18:22:22.000000000 +0000
-+++ device-mapper.1.02.09.klibc/configure.in 2006-09-27 18:22:22.000000000 +0000
-@@ -87,7 +87,7 @@
- AC_HEADER_SYS_WAIT
- AC_HEADER_TIME
-
--AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h getopt.h inttypes.h limits.h \
-+AC_CHECK_HEADERS([ctype.h dirent.h errno.h fcntl.h inttypes.h limits.h \
- stdarg.h stdio.h stdlib.h string.h sys/ioctl.h sys/param.h sys/stat.h \
- sys/types.h unistd.h], , [AC_MSG_ERROR(bailing out)])
- AC_CHECK_HEADERS(termios.h sys/statvfs.h)
---- device-mapper.1.02.09.orig/dmsetup/dmsetup.c 2006-08-10 20:53:21.000000000 +0000
-+++ device-mapper.1.02.09.klibc/dmsetup/dmsetup.c 2006-09-27 18:22:58.000000000 +0000
-@@ -31,12 +31,13 @@
- #include <dirent.h>
- #include <errno.h>
- #include <unistd.h>
--#include <libgen.h>
- #include <sys/wait.h>
- #include <unistd.h>
- #include <sys/param.h>
-+#ifndef __KLIBC__
- #include <locale.h>
- #include <langinfo.h>
-+#endif
-
- #ifdef HAVE_SYS_IOCTL_H
- # include <sys/ioctl.h>
-@@ -1547,9 +1548,11 @@
- int len;
-
- /* Symbol set default */
-+#ifndef __KLIBC__
- if (!strcmp(nl_langinfo(CODESET), "UTF-8"))
- _tsym = &_tsym_utf;
- else
-+#endif
- _tsym = &_tsym_ascii;
-
- /* Default */
-@@ -1647,7 +1650,9 @@
- memset(&_values, 0, sizeof(_values));
-
- namebase = strdup((*argv)[0]);
-- base = basename(namebase);
-+ base = strrchr(namebase,'/');
-+ if (base != NULL) *base++ = 0;
-+ else base = namebase;
-
- if (!strcmp(base, "devmap_name")) {
- free(namebase);
-@@ -1783,7 +1788,9 @@
- struct command *c;
- int r = 1;
-
-+#ifndef __KLIBC__
- (void) setlocale(LC_ALL, "");
-+#endif
-
- if (!_process_switches(&argc, &argv)) {
- fprintf(stderr, "Couldn't process command line.\n");
---- device-mapper.1.02.22/lib/ioctl/libdm-iface.c.orig 2007-08-21 18:26:07.000000000 +0200
-+++ device-mapper.1.02.22/lib/ioctl/libdm-iface.c 2007-09-09 23:59:33.337996036 +0200
-@@ -134,17 +134,25 @@
- uint32_t *number)
- {
- FILE *fl;
-- char nm[256];
-+ char nm[256], buf[300];
- int c;
-- uint32_t num;
-+ uint32_t num, size;
-
- if (!(fl = fopen(file, "r"))) {
- log_sys_error("fopen", file);
- return 0;
- }
-
-- while (!feof(fl)) {
-- if (fscanf(fl, "%d %255s\n", &num, &nm[0]) == 2) {
-+ /* Use fread+sscanf for klibc compatibility. */
-+ do {
-+ size = 0;
-+ do {
-+ num = fread(&buf[size], sizeof(char), 1, fl);
-+ if (num > 0)
-+ size++;
-+ } while (num > 0 && buf[size - 1] != '\n');
-+ buf[size] = '\0';
-+ if (sscanf(buf, "%d %255s\n", &num, &nm[0]) == 2) {
- if (!strcmp(name, nm)) {
- if (number) {
- *number = num;
-@@ -154,10 +162,9 @@
- }
- dm_bit_set(_dm_bitset, num);
- }
-- } else do {
-- c = fgetc(fl);
-- } while (c != EOF && c != '\n');
-- }
-+ }
-+ } while (size > 0);
-+
- if (fclose(fl))
- log_sys_error("fclose", file);
-
---- device-mapper.1.02.22/lib/libdm-file.c.orig 2007-08-21 18:26:06.000000000 +0200
-+++ device-mapper.1.02.22/lib/libdm-file.c 2007-09-10 00:20:00.475926641 +0200
-@@ -15,10 +15,16 @@
-
- #include "lib.h"
-
--#include <sys/file.h>
- #include <fcntl.h>
- #include <dirent.h>
-
-+#ifndef __KLIBC__
-+# include <sys/file.h>
-+# ifdef linux
-+# include <malloc.h>
-+# endif
-+#endif
-+
- static int _create_dir_recursive(const char *dir)
- {
- char *orig, *s;
-@@ -73,7 +79,11 @@
-
- int dm_fclose(FILE *stream)
- {
-+#ifdef __KLIBC__
-+ int prev_fail = 0;
-+#else
- int prev_fail = ferror(stream);
-+#endif
- int fclose_fail = fclose(stream);
-
- /* If there was a previous failure, but fclose succeeded,
+++ /dev/null
---- device-mapper.1.02.09/dmeventd/Makefile.in~ 2006-04-19 17:32:05.000000000 +0000
-+++ device-mapper.1.02.09/dmeventd/Makefile.in 2006-09-27 14:15:09.000000000 +0000
-@@ -31,7 +31,7 @@
- include ../make.tmpl
-
- LDFLAGS += -ldl -ldevmapper -lpthread
--CLDFLAGS += -ldl -ldevmapper -lpthread
-+LIBS += -ldl ../lib/ioctl/libdevmapper.so -lpthread
-
- dmeventd: $(LIB_SHARED) dmeventd.o
- $(CC) -o $@ dmeventd.o $(CFLAGS) $(LDFLAGS) \