r91 - in devmapper/upstream/current: . dmsetup include kernel/ioctl
lib lib/ioctl man
Bastian Blank
waldi at costa.debian.org
Thu Jul 21 12:48:13 UTC 2005
Author: waldi
Date: Tue Jun 14 11:02:01 2005
New Revision: 91
Modified:
devmapper/upstream/current/Makefile.in
devmapper/upstream/current/VERSION
devmapper/upstream/current/WHATS_NEW
devmapper/upstream/current/configure
devmapper/upstream/current/configure.in
devmapper/upstream/current/dmsetup/Makefile.in
devmapper/upstream/current/dmsetup/dmsetup.c
devmapper/upstream/current/include/list.h
devmapper/upstream/current/include/log.h
devmapper/upstream/current/kernel/ioctl/dm-ioctl.h
devmapper/upstream/current/lib/Makefile.in
devmapper/upstream/current/lib/ioctl/libdm-iface.c
devmapper/upstream/current/lib/libdevmapper.h
devmapper/upstream/current/lib/libdm-common.c
devmapper/upstream/current/lib/libdm-common.h.in
devmapper/upstream/current/lib/libdm-file.c
devmapper/upstream/current/make.tmpl.in
devmapper/upstream/current/man/dmsetup.8
Log:
Load device-mapper.1.01.00 into devmapper/upstream/current.
Modified: devmapper/upstream/current/Makefile.in
==============================================================================
--- devmapper/upstream/current/Makefile.in (original)
+++ devmapper/upstream/current/Makefile.in Tue Jun 14 11:02:01 2005
@@ -30,15 +30,21 @@
SUBDIRS += kernel po
endif
+ifeq ($(MAKECMDGOALS),distclean)
+ SUBDIRS += dmeventd
+endif
+
include make.tmpl
lib: include
dmsetup: lib
-po: dmsetup
+dmeventd: lib multilog
+po: dmsetup dmeventd
ifeq ("@INTL@", "yes")
lib.pofile: include.pofile
dmsetup.pofile: lib.pofile
+dmeventd.pofile: lib.pofile
po.pofile: dmsetup.pofile
pofile: po.pofile
endif
Modified: devmapper/upstream/current/VERSION
==============================================================================
--- devmapper/upstream/current/VERSION (original)
+++ devmapper/upstream/current/VERSION Tue Jun 14 11:02:01 2005
@@ -1 +1 @@
-1.01.00 (2005-01-17)
+1.01.03 (2005-06-13)
Modified: devmapper/upstream/current/WHATS_NEW
==============================================================================
--- devmapper/upstream/current/WHATS_NEW (original)
+++ devmapper/upstream/current/WHATS_NEW Tue Jun 14 11:02:01 2005
@@ -1,3 +1,22 @@
+Version 1.01.03 - 13 Jun 2005
+=============================
+ Use matchpathcon mode parameter.
+ Fix configure script to re-enable selinux.
+
+Version 1.01.02 - 17 May 2005
+=============================
+ Call dm_lib_exit() and dm_lib_release() automatically now.
+ Add --target <target_type> filter to dmsetup table/status/ls.
+ Add --exec <command> to dmsetup ls.
+ Fix dmsetup getopt_long usage.
+
+Version 1.01.01 - 29 Mar 2005
+=============================
+ Update dmsetup man page.
+ Drop-in devmap_name replacement.
+ Add option to compile without ioctl for testing.
+ Fix DM_LIB_VERSION sed.
+
Version 1.01.00 - 17 Jan 2005
=============================
Add dm_task_no_open_count() to skip getting open_count.
Modified: devmapper/upstream/current/configure
==============================================================================
--- devmapper/upstream/current/configure (original)
+++ devmapper/upstream/current/configure Tue Jun 14 11:02:01 2005
@@ -309,7 +309,7 @@
#endif"
ac_default_prefix=/usr
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os AWK CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S SET_MAKE RANLIB ac_ct_RANLIB LIBOBJS MSGFMT JOBS STATIC_LINK OWNER GROUP interface kerneldir missingkernel kernelvsn tmpdir COPTIMISE_FLAG CLDFLAGS LDDEPS SOFLAG DEBUG DM_LIB_VERSION COMPAT LOCALEDIR INTL_PACKAGE INTL DEVICE_UID DEVICE_GID DEVICE_MODE LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os AWK CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S SET_MAKE RANLIB ac_ct_RANLIB LIBOBJS MSGFMT JOBS STATIC_LINK OWNER GROUP interface kerneldir missingkernel kernelvsn tmpdir COPTIMISE_FLAG CLDFLAGS LDDEPS LIB_SUFFIX DEBUG DM_LIB_VERSION COMPAT DMIOCTLS LOCALEDIR INTL_PACKAGE INTL DEVICE_UID DEVICE_GID DEVICE_MODE LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -848,8 +848,10 @@
--enable-jobs=NUM Number of jobs to run simultaneously
--enable-debug Enable debugging
--enable-compat Enable support for old device-mapper versions
+ --disable-driver Disable calls to device-mapper in the kernel
--enable-static_link Use this to link the tools to their libraries
statically. Default is dynamic linking
+ --disable-selinux Disable selinux support
--enable-nls Enable Native Language Support
Optional Packages:
@@ -859,7 +861,7 @@
--with-group=GROUP Set the group owner of installed files [GROUP=root]
--with-device-uid=UID Set the owner used for new device nodes [UID=0]
--with-device-gid=UID Set the group used for new device nodes [GID=0]
- --with-device-mode=MODE Set the mode used for new device nodes [MODE=0600]
+ --with-device-mode=MODE Set the mode used for new device nodes [MODE=0600]
--with-optimisation=OPT C optimisation flag OPT=-O2
--with-localedir=DIR Translation files in DIR PREFIX/share/locale
--with-kernel-dir=DIR linux kernel source in DIR
@@ -1400,13 +1402,17 @@
COPTIMISE_FLAG="-O2"
CLDFLAGS="$CLDFLAGS -Wl,--version-script,.export.sym"
LDDEPS="$LDDEPS .export.sym"
- SOFLAG="-shared" ;;
+ LIB_SUFFIX="so"
+ DMIOCTLS="yes"
+ SELINUX="yes" ;;
darwin*)
CFLAGS="$CFLAGS -no-cpp-precomp -fno-common"
COPTIMISE_FLAG="-O2"
CLDFLAGS="$CLDFLAGS"
LDDEPS="$LDDEPS"
- SOFLAG="-dynamiclib" ;;
+ LIB_SUFFIX="dylib"
+ DMIOCTLS="no"
+ SELINUX="no" ;;
esac
################################################################################
@@ -4834,6 +4840,13 @@
fi;
################################################################################
+# Check whether --enable-ioctl or --disable-ioctl was given.
+if test "${enable_ioctl+set}" = set; then
+ enableval="$enable_ioctl"
+ DMIOCTLS=$enableval
+fi;
+
+################################################################################
# Check whether --enable-static_link or --disable-static_link was given.
if test "${enable_static_link+set}" = set; then
enableval="$enable_static_link"
@@ -4847,6 +4860,17 @@
then exec_prefix="";
fi;
+################################################################################dnl -- Disable selinux
+echo "$as_me:$LINENO: checking whether to enable selinux support" >&5
+echo $ECHO_N "checking whether to enable selinux support... $ECHO_C" >&6
+# Check whether --enable-selinux or --disable-selinux was given.
+if test "${enable_selinux+set}" = set; then
+ enableval="$enable_selinux"
+ SELINUX=$enableval
+fi;
+echo "$as_me:$LINENO: result: $SELINUX" >&5
+echo "${ECHO_T}$SELINUX" >&6
+
################################################################################
if test x$SELINUX = xyes; then
echo "$as_me:$LINENO: checking for is_selinux_enabled in -lselinux" >&5
@@ -5240,7 +5264,7 @@
echo "${ECHO_T}$interface" >&6
if test "-f VERSION" ; then
- DM_LIB_VERSION="\"`cat VERSION|sed -e \"s/[0-9.]*/\0-$interface/\"`\""
+ DM_LIB_VERSION="\"`cat VERSION|sed -e \"s/([0-9.]*)/\0-$interface/\"`\""
else
DM_LIB_VERSION="Unknown version ($interface)"
fi
@@ -5274,6 +5298,7 @@
+
################################################################################
ac_config_files="$ac_config_files Makefile make.tmpl include/Makefile dmsetup/Makefile lib/Makefile lib/libdm-common.h kernel/Makefile man/Makefile po/Makefile"
cat >confcache <<\_ACEOF
@@ -5961,10 +5986,11 @@
s, at COPTIMISE_FLAG@,$COPTIMISE_FLAG,;t t
s, at CLDFLAGS@,$CLDFLAGS,;t t
s, at LDDEPS@,$LDDEPS,;t t
-s, at SOFLAG@,$SOFLAG,;t t
+s, at LIB_SUFFIX@,$LIB_SUFFIX,;t t
s, at DEBUG@,$DEBUG,;t t
s, at DM_LIB_VERSION@,$DM_LIB_VERSION,;t t
s, at COMPAT@,$COMPAT,;t t
+s, at DMIOCTLS@,$DMIOCTLS,;t t
s, at LOCALEDIR@,$LOCALEDIR,;t t
s, at INTL_PACKAGE@,$INTL_PACKAGE,;t t
s, at INTL@,$INTL,;t t
Modified: devmapper/upstream/current/configure.in
==============================================================================
--- devmapper/upstream/current/configure.in (original)
+++ devmapper/upstream/current/configure.in Tue Jun 14 11:02:01 2005
@@ -33,13 +33,17 @@
COPTIMISE_FLAG="-O2"
CLDFLAGS="$CLDFLAGS -Wl,--version-script,.export.sym"
LDDEPS="$LDDEPS .export.sym"
- SOFLAG="-shared" ;;
+ LIB_SUFFIX="so"
+ DMIOCTLS="yes"
+ SELINUX="yes" ;;
darwin*)
CFLAGS="$CFLAGS -no-cpp-precomp -fno-common"
COPTIMISE_FLAG="-O2"
CLDFLAGS="$CLDFLAGS"
LDDEPS="$LDDEPS"
- SOFLAG="-dynamiclib" ;;
+ LIB_SUFFIX="dylib"
+ DMIOCTLS="no"
+ SELINUX="no" ;;
esac
################################################################################
@@ -136,7 +140,7 @@
AC_MSG_CHECKING(device node mode)
AC_ARG_WITH(device-mode,
- [ --with-device-mode=MODE Set the mode used for new device nodes [[MODE=0600]] ],
+ [ --with-device-mode=MODE Set the mode used for new device nodes [[MODE=0600]] ],
[ DEVICE_MODE="$withval" ], [ DEVICE_MODE="0600" ] )
AC_MSG_RESULT($DEVICE_MODE)
@@ -166,6 +170,11 @@
COMPAT=$enableval, COMPAT=no)
################################################################################
+dnl -- Disable ioctl
+AC_ARG_ENABLE(ioctl, [ --disable-driver Disable calls to device-mapper in the kernel],
+DMIOCTLS=$enableval)
+
+################################################################################
dnl -- Enables staticly-linked tools
AC_ARG_ENABLE(static_link, [ --enable-static_link Use this to link the tools to their libraries
statically. Default is dynamic linking], STATIC_LINK=$enableval, STATIC_LINK=no)
@@ -176,6 +185,12 @@
then exec_prefix="";
fi;
+################################################################################dnl -- Disable selinux
+AC_MSG_CHECKING(whether to enable selinux support)
+AC_ARG_ENABLE(selinux, [ --disable-selinux Disable selinux support],
+SELINUX=$enableval)
+AC_MSG_RESULT($SELINUX)
+
################################################################################
dnl -- Check for is_selinux_enabled
if test x$SELINUX = xyes; then
@@ -300,7 +315,7 @@
AC_MSG_RESULT($interface)
if test "-f VERSION" ; then
- DM_LIB_VERSION="\"`cat VERSION|sed -e \"s/[[0-9.]]*/\0-$interface/\"`\""
+ DM_LIB_VERSION="\"`cat VERSION|sed -e \"s/([[0-9.]]*)/\0-$interface/\"`\""
else
DM_LIB_VERSION="Unknown version ($interface)"
fi
@@ -321,10 +336,11 @@
AC_SUBST(COPTIMISE_FLAG)
AC_SUBST(CLDFLAGS)
AC_SUBST(LDDEPS)
-AC_SUBST(SOFLAG)
+AC_SUBST(LIB_SUFFIX)
AC_SUBST(DEBUG)
AC_SUBST(DM_LIB_VERSION)
AC_SUBST(COMPAT)
+AC_SUBST(DMIOCTLS)
AC_SUBST(MSGFMT)
AC_SUBST(LOCALEDIR)
AC_SUBST(INTL_PACKAGE)
Modified: devmapper/upstream/current/dmsetup/Makefile.in
==============================================================================
--- devmapper/upstream/current/dmsetup/Makefile.in (original)
+++ devmapper/upstream/current/dmsetup/Makefile.in Tue Jun 14 11:02:01 2005
@@ -29,7 +29,7 @@
include ../make.tmpl
-dmsetup: $(OBJECTS) $(interfacedir)/libdevmapper.so
+dmsetup: $(OBJECTS) $(interfacedir)/libdevmapper.$(LIB_SUFFIX)
$(CC) -o $@ $(OBJECTS) $(LDFLAGS) \
-L$(interfacedir) -L$(DESTDIR)/lib -ldevmapper $(LIBS)
Modified: devmapper/upstream/current/dmsetup/dmsetup.c
==============================================================================
--- devmapper/upstream/current/dmsetup/dmsetup.c (original)
+++ devmapper/upstream/current/dmsetup/dmsetup.c Tue Jun 14 11:02:01 2005
@@ -13,6 +13,9 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#define _GNU_SOURCE
+#define _FILE_OFFSET_BITS 64
+
#include "libdevmapper.h"
#include "log.h"
@@ -23,6 +26,10 @@
#include <dirent.h>
#include <errno.h>
#include <unistd.h>
+#include <libgen.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <sys/param.h>
#ifdef HAVE_GETOPTLONG
# include <getopt.h>
@@ -37,6 +44,15 @@
# define OPTIND_INIT 1
#endif
+#ifndef TEMP_FAILURE_RETRY
+# define TEMP_FAILURE_RETRY(expression) \
+ (__extension__ \
+ ({ long int __result; \
+ do __result = (long int) (expression); \
+ while (__result == -1L && errno == EINTR); \
+ __result; }))
+#endif
+
#ifdef linux
# include "kdev_t.h"
#else
@@ -46,6 +62,7 @@
#endif
#define LINE_SIZE 1024
+#define ARGS_MAX 256
#define err(msg, x...) fprintf(stderr, msg "\n", ##x)
@@ -55,11 +72,14 @@
enum {
READ_ONLY = 0,
COLS_ARG,
+ EXEC_ARG,
MAJOR_ARG,
MINOR_ARG,
NOHEADINGS_ARG,
NOOPENCOUNT_ARG,
NOTABLE_ARG,
+ OPTIONS_ARG,
+ TARGET_ARG,
UUID_ARG,
VERBOSE_ARG,
VERSION_ARG,
@@ -69,6 +89,9 @@
static int _switches[NUM_SWITCHES];
static int _values[NUM_SWITCHES];
static char *_uuid;
+static char *_fields;
+static char *_target;
+static char *_command;
/*
* Commands
@@ -137,15 +160,18 @@
uuid = dm_task_get_uuid(dmt);
- printf("%s:%d:%d:%s%s%s%s:%d:%d:%" PRIu32 ":%s\n",
- dm_task_get_name(dmt),
- info->major, info->minor,
- info->live_table ? "L" : "-",
- info->inactive_table ? "I" : "-",
- info->suspended ? "s" : "-",
- info->read_only ? "r" : "w",
- info->open_count, info->target_count, info->event_nr,
- uuid && *uuid ? uuid : "");
+ if (_switches[OPTIONS_ARG])
+ printf("%s\n", dm_task_get_name(dmt));
+ else
+ printf("%s:%d:%d:%s%s%s%s:%d:%d:%" PRIu32 ":%s\n",
+ dm_task_get_name(dmt),
+ info->major, info->minor,
+ info->live_table ? "L" : "-",
+ info->inactive_table ? "I" : "-",
+ info->suspended ? "s" : "-",
+ info->read_only ? "r" : "w",
+ info->open_count, info->target_count, info->event_nr,
+ uuid && *uuid ? uuid : "");
}
static void _display_info_cols(struct dm_task *dmt, struct dm_info *info)
@@ -159,24 +185,31 @@
}
if (!_headings) {
- printf("Name Maj Min Stat Open Targ Event UUID\n");
+ if (_switches[OPTIONS_ARG])
+ printf("Name\n");
+ else
+ printf("Name Maj Min Stat Open Targ "
+ "Event UUID\n");
_headings = 1;
}
- printf("%-16s ", dm_task_get_name(dmt));
-
- printf("%3d %3d %s%s%s%s %4d %4d %6" PRIu32 " ",
- info->major, info->minor,
- info->live_table ? "L" : "-",
- info->inactive_table ? "I" : "-",
- info->suspended ? "s" : "-",
- info->read_only ? "r" : "w",
- info->open_count, info->target_count, info->event_nr);
+ if (_switches[OPTIONS_ARG])
+ printf("%s\n", dm_task_get_name(dmt));
+ else {
+ printf("%-16s %3d %3d %s%s%s%s %4d %4d %6" PRIu32 " ",
+ dm_task_get_name(dmt),
+ info->major, info->minor,
+ info->live_table ? "L" : "-",
+ info->inactive_table ? "I" : "-",
+ info->suspended ? "s" : "-",
+ info->read_only ? "r" : "w",
+ info->open_count, info->target_count, info->event_nr);
- if ((uuid = dm_task_get_uuid(dmt)) && *uuid)
- printf("%s", uuid);
+ if ((uuid = dm_task_get_uuid(dmt)) && *uuid)
+ printf("%s", uuid);
- printf("\n");
+ printf("\n");
+ }
}
static void _display_info_long(struct dm_task *dmt, struct dm_info *info)
@@ -217,12 +250,12 @@
printf("\n");
}
-static void _display_info(struct dm_task *dmt)
+static int _display_info(struct dm_task *dmt)
{
struct dm_info info;
if (!dm_task_get_info(dmt, &info))
- return;
+ return 0;
if (!_switches[COLS_ARG])
_display_info_long(dmt, &info);
@@ -230,6 +263,8 @@
_display_info_cols_noheadings(dmt, &info);
else
_display_info_cols(dmt, &info);
+
+ return info.exists ? 1 : 0;
}
static int _set_task_device(struct dm_task *dmt, const char *name, int optional)
@@ -301,7 +336,7 @@
r = 1;
if (_switches[VERBOSE_ARG])
- _display_info(dmt);
+ r = _display_info(dmt);
out:
dm_task_destroy(dmt);
@@ -348,7 +383,7 @@
r = 1;
if (_switches[VERBOSE_ARG])
- _display_info(dmt);
+ r = _display_info(dmt);
out:
dm_task_destroy(dmt);
@@ -495,7 +530,7 @@
r = dm_task_run(dmt);
if (r && display && _switches[VERBOSE_ARG])
- _display_info(dmt);
+ r = _display_info(dmt);
out:
dm_task_destroy(dmt);
@@ -583,6 +618,102 @@
return r;
}
+static void _display_dev(struct dm_task *dmt, char *name)
+{
+ struct dm_info info;
+
+ if (dm_task_get_info(dmt, &info))
+ printf("%s\t(%u, %u)\n", name, info.major, info.minor);
+}
+
+static int _mknodes_single(char *name)
+{
+ struct dm_task *dmt;
+ int r = 0;
+
+ if (!(dmt = dm_task_create(DM_DEVICE_MKNODES)))
+ return 0;
+
+ if (!_set_task_device(dmt, name, 1))
+ goto out;
+
+ if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
+ goto out;
+
+ if (!dm_task_run(dmt))
+ goto out;
+
+ r = 1;
+
+ out:
+ dm_task_destroy(dmt);
+ return r;
+}
+
+static int _mknodes(int argc, char **argv, void *data)
+{
+ return _mknodes_single(argc > 1 ? argv[1] : NULL);
+}
+
+static int _exec_command(char *name)
+{
+ int n;
+ static char path[PATH_MAX];
+ static char *args[ARGS_MAX + 1];
+ static int argc = 0;
+ char *c;
+ pid_t pid;
+
+ if (argc < 0)
+ return 0;
+
+ if (!_mknodes_single(name))
+ return 0;
+
+ n = snprintf(path, sizeof(path), "%s/%s", dm_dir(), name);
+ if (n < 0 || n > sizeof(path) - 1)
+ return 0;
+
+ if (!argc) {
+ c = _command;
+ while (argc < ARGS_MAX) {
+ while (*c && isspace(*c))
+ c++;
+ if (!*c)
+ break;
+ args[argc++] = c;
+ while (*c && !isspace(*c))
+ c++;
+ if (*c)
+ *c++ = '\0';
+ }
+
+ if (!argc) {
+ argc = -1;
+ return 0;
+ }
+
+ if (argc == ARGS_MAX) {
+ err("Too many args to --exec\n");
+ argc = -1;
+ return 0;
+ }
+
+ args[argc++] = path;
+ args[argc] = NULL;
+ }
+
+ if (!(pid = fork())) {
+ execvp(args[0], args);
+ exit(127);
+ } else if (pid < (pid_t) 0)
+ return 0;
+
+ TEMP_FAILURE_RETRY(waitpid(pid, NULL, 0));
+
+ return 1;
+}
+
static int _status(int argc, char **argv, void *data)
{
int r = 0;
@@ -594,6 +725,8 @@
int cmd;
struct dm_names *names = (struct dm_names *) data;
char *name = NULL;
+ int matched = 0;
+ int ls_only = 0;
if (data)
name = names->name;
@@ -609,6 +742,9 @@
else
cmd = DM_DEVICE_STATUS;
+ if (!strcmp(argv[0], "ls"))
+ ls_only = 1;
+
if (!(dmt = dm_task_create(cmd)))
return 0;
@@ -621,31 +757,45 @@
if (!dm_task_run(dmt))
goto out;
- if (_switches[VERBOSE_ARG])
- _display_info(dmt);
-
/* Fetch targets and print 'em */
do {
next = dm_get_next_target(dmt, next, &start, &length,
&target_type, ¶ms);
- if (data && !_switches[VERBOSE_ARG])
- printf("%s: ", name);
- if (target_type) {
- printf("%" PRIu64 " %" PRIu64 " %s %s",
- start, length, target_type, params);
+ /* Skip if target type doesn't match */
+ if (_switches[TARGET_ARG] && target_type &&
+ strcmp(target_type, _target))
+ continue;
+ if (ls_only) {
+ if (!_switches[EXEC_ARG] || !_command ||
+ _switches[VERBOSE_ARG])
+ _display_dev(dmt, name);
+ next = NULL;
+ } else if (!_switches[EXEC_ARG] || !_command ||
+ _switches[VERBOSE_ARG]) {
+ if (!matched && _switches[VERBOSE_ARG])
+ _display_info(dmt);
+ if (data && !_switches[VERBOSE_ARG])
+ printf("%s: ", name);
+ if (target_type) {
+ printf("%" PRIu64 " %" PRIu64 " %s %s",
+ start, length, target_type, params);
+ }
+ printf("\n");
}
- printf("\n");
+ matched = 1;
} while (next);
- if (data && _switches[VERBOSE_ARG])
+ if (data && _switches[VERBOSE_ARG] && matched && !ls_only)
printf("\n");
+ if (matched && _switches[EXEC_ARG] && _command && !_exec_command(name))
+ goto out;
+
r = 1;
out:
dm_task_destroy(dmt);
return r;
-
}
/* Show target names and their version numbers */
@@ -682,30 +832,6 @@
}
-static int _mknodes(int argc, char **argv, void *data)
-{
- struct dm_task *dmt;
- int r = 0;
-
- if (!(dmt = dm_task_create(DM_DEVICE_MKNODES)))
- return 0;
-
- if (!_set_task_device(dmt, argc > 1 ? argv[1] : NULL, 1))
- goto out;
-
- if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt))
- goto out;
-
- if (!dm_task_run(dmt))
- goto out;
-
- r = 1;
-
- out:
- dm_task_destroy(dmt);
- return r;
-}
-
static int _info(int argc, char **argv, void *data)
{
int r = 0;
@@ -735,9 +861,7 @@
if (!dm_task_run(dmt))
goto out;
- _display_info(dmt);
-
- r = 1;
+ r = _display_info(dmt);
out:
dm_task_destroy(dmt);
@@ -822,7 +946,11 @@
static int _ls(int argc, char **argv, void *data)
{
- return _process_all(argc, argv, _display_name);
+ if ((_switches[TARGET_ARG] && _target) ||
+ (_switches[EXEC_ARG] && _command))
+ return _status(argc, argv, data);
+ else
+ return _process_all(argc, argv, _display_name);
}
/*
@@ -851,11 +979,11 @@
{"reload", "<device> [<table_file>]", 0, 2, _load},
{"rename", "<device> <new_name>", 1, 2, _rename},
{"message", "<device> <sector> <message>", 2, -1, _message},
- {"ls", "", 0, 0, _ls},
+ {"ls", "[--target <target_type>] [--exec <command>]", 0, 0, _ls},
{"info", "[<device>]", 0, 1, _info},
{"deps", "[<device>]", 0, 1, _deps},
- {"status", "[<device>]", 0, 1, _status},
- {"table", "[<device>]", 0, 1, _status},
+ {"status", "[<device>] [--target <target_type>]", 0, 1, _status},
+ {"table", "[<device>] [--target <target_type>]", 0, 1, _status},
{"wait", "<device> [<event_nr>]", 0, 2, _wait},
{"mknodes", "[<device>]", 0, 1, _mknodes},
{"targets", "", 0, 0, _targets},
@@ -891,21 +1019,25 @@
static int _process_switches(int *argc, char ***argv)
{
- int ind;
+ char *base, *namebase;
+ static int ind;
int c;
#ifdef HAVE_GETOPTLONG
static struct option long_options[] = {
- {"readonly", 0, NULL, READ_ONLY},
- {"columns", 0, NULL, COLS_ARG},
- {"major", 1, NULL, MAJOR_ARG},
- {"minor", 1, NULL, MINOR_ARG},
- {"noheadings", 0, NULL, NOHEADINGS_ARG},
- {"noopencount", 0, NULL, NOOPENCOUNT_ARG},
- {"notable", 0, NULL, NOTABLE_ARG},
- {"uuid", 1, NULL, UUID_ARG},
- {"verbose", 1, NULL, VERBOSE_ARG},
- {"version", 0, NULL, VERSION_ARG},
+ {"readonly", 0, &ind, READ_ONLY},
+ {"columns", 0, &ind, COLS_ARG},
+ {"exec", 1, &ind, EXEC_ARG},
+ {"major", 1, &ind, MAJOR_ARG},
+ {"minor", 1, &ind, MINOR_ARG},
+ {"noheadings", 0, &ind, NOHEADINGS_ARG},
+ {"noopencount", 0, &ind, NOOPENCOUNT_ARG},
+ {"notable", 0, &ind, NOTABLE_ARG},
+ {"options", 1, &ind, OPTIONS_ARG},
+ {"target", 1, &ind, TARGET_ARG},
+ {"uuid", 1, &ind, UUID_ARG},
+ {"verbose", 1, &ind, VERBOSE_ARG},
+ {"version", 0, &ind, VERSION_ARG},
{"", 0, NULL, 0}
};
#else
@@ -918,10 +1050,44 @@
memset(&_switches, 0, sizeof(_switches));
memset(&_values, 0, sizeof(_values));
+ namebase = strdup((*argv)[0]);
+ base = basename(namebase);
+
+ if (!strcmp(base, "devmap_name")) {
+ free(namebase);
+ _switches[COLS_ARG]++;
+ _switches[NOHEADINGS_ARG]++;
+ _switches[OPTIONS_ARG]++;
+ _switches[MAJOR_ARG]++;
+ _switches[MINOR_ARG]++;
+ _fields = (char *) "name";
+
+ if (*argc == 3) {
+ _values[MAJOR_ARG] = atoi((*argv)[1]);
+ _values[MINOR_ARG] = atoi((*argv)[2]);
+ *argc -= 2;
+ *argv += 2;
+ } else if ((*argc == 2) &&
+ (2 == sscanf((*argv)[1], "%i:%i",
+ &_values[MAJOR_ARG],
+ &_values[MINOR_ARG]))) {
+ *argc -= 1;
+ *argv += 1;
+ } else {
+ fprintf(stderr, "Usage: devmap_name <major> <minor>\n");
+ return 0;
+ }
+
+ (*argv)[0] = (char *) "info";
+ return 1;
+ }
+
+ free(namebase);
+
optarg = 0;
optind = OPTIND_INIT;
- while ((c = GETOPTLONG_FN(*argc, *argv, "cCj:m:nru:v",
- long_options, &ind)) != -1) {
+ while ((ind = -1, c = GETOPTLONG_FN(*argc, *argv, "cCj:m:no:ru:v",
+ long_options, NULL)) != -1) {
if (c == 'c' || c == 'C' || ind == COLS_ARG)
_switches[COLS_ARG]++;
if (c == 'r' || ind == READ_ONLY)
@@ -936,12 +1102,24 @@
}
if (c == 'n' || ind == NOTABLE_ARG)
_switches[NOTABLE_ARG]++;
+ if (c == 'o' || ind == OPTIONS_ARG) {
+ _switches[OPTIONS_ARG]++;
+ _fields = optarg;
+ }
if (c == 'v' || ind == VERBOSE_ARG)
_switches[VERBOSE_ARG]++;
if (c == 'u' || ind == UUID_ARG) {
_switches[UUID_ARG]++;
_uuid = optarg;
}
+ if ((ind == EXEC_ARG)) {
+ _switches[EXEC_ARG]++;
+ _command = optarg;
+ }
+ if ((ind == TARGET_ARG)) {
+ _switches[TARGET_ARG]++;
+ _target = optarg;
+ }
if ((ind == NOHEADINGS_ARG))
_switches[NOHEADINGS_ARG]++;
if ((ind == NOOPENCOUNT_ARG))
@@ -960,6 +1138,11 @@
return 0;
}
+ if (_switches[OPTIONS_ARG] && strcmp(_fields, "name")) {
+ fprintf(stderr, "Only -o name is supported so far.\n");
+ return 0;
+ }
+
*argv += optind;
*argc -= optind;
return 1;
@@ -970,7 +1153,7 @@
struct command *c;
if (!_process_switches(&argc, &argv)) {
- fprintf(stderr, "Couldn't process command line switches.\n");
+ fprintf(stderr, "Couldn't process command line.\n");
exit(1);
}
@@ -1003,8 +1186,5 @@
exit(1);
}
- dm_lib_release();
- dm_lib_exit();
-
return 0;
}
Modified: devmapper/upstream/current/include/list.h
==============================================================================
--- devmapper/upstream/current/include/list.h (original)
+++ devmapper/upstream/current/include/list.h Tue Jun 14 11:02:01 2005
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
*
* This file is part of the device-mapper userspace tools.
*
@@ -17,18 +17,32 @@
#define _LVM_LIST_H
#include <assert.h>
+#include <stdio.h>
+
+/*
+ * A list consists of a list head plus elements.
+ * Each element has 'next' and 'previous' pointers.
+ * The list head's pointers point to the first and the last element.
+ */
struct list {
struct list *n, *p;
};
+/*
+ * Initialise a list before use.
+ * The list head's next and previous pointers point back to itself.
+ */
#define LIST_INIT(name) struct list name = { &(name), &(name) }
-
static inline void list_init(struct list *head)
{
head->n = head->p = head;
}
+/*
+ * Insert an element before 'head'.
+ * If 'head' is the list head, this adds an element to the end of the list.
+ */
static inline void list_add(struct list *head, struct list *elem)
{
assert(head->n);
@@ -40,6 +54,10 @@
head->p = elem;
}
+/*
+ * Insert an element after 'head'.
+ * If 'head' is the list head, this adds an element to the front of the list.
+ */
static inline void list_add_h(struct list *head, struct list *elem)
{
assert(head->n);
@@ -51,36 +69,127 @@
head->n = elem;
}
+/*
+ * Delete an element from its list.
+ * Note that this doesn't change the element itself - it may still be safe
+ * to follow its pointers.
+ */
static inline void list_del(struct list *elem)
{
elem->n->p = elem->p;
elem->p->n = elem->n;
}
+/*
+ * Is the list empty?
+ */
static inline int list_empty(struct list *head)
{
return head->n == head;
}
+/*
+ * Is this the first element of the list?
+ */
+static inline int list_start(struct list *head, struct list *elem)
+{
+ return elem->p == head;
+}
+
+/*
+ * Is this the last element of the list?
+ */
static inline int list_end(struct list *head, struct list *elem)
{
return elem->n == head;
}
+/*
+ * Return the previous element of the list, or NULL if we've reached the start.
+ */
+static inline struct list *list_prev(struct list *head, struct list *elem)
+{
+ return (list_start(head, elem) ? NULL : elem->p);
+}
+
+/*
+ * Return the next element of the list, or NULL if we've reached the end.
+ */
static inline struct list *list_next(struct list *head, struct list *elem)
{
return (list_end(head, elem) ? NULL : elem->n);
}
+/*
+ * Given the address v of an instance of 'struct list' called 'head'
+ * contained in a structure of type t, return the containing structure.
+ */
+#define list_struct_base(v, t, head) \
+ ((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->head))
+
+/*
+ * Given the address v of an instance of 'struct list list' contained in
+ * a structure of type t, return the containing structure.
+ */
+#define list_item(v, t) list_struct_base((v), t, list)
+
+/*
+ * Given the address v of one known element e in a known structure of type t,
+ * return another element f.
+ */
+#define struct_field(v, t, e, f) \
+ (((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->e))->f)
+
+/*
+ * Given the address v of a known element e in a known structure of type t,
+ * return the list head 'list'
+ */
+#define list_head(v, t, e) struct_field(v, t, e, list)
+
+/*
+ * Set v to each element of a list in turn.
+ */
#define list_iterate(v, head) \
for (v = (head)->n; v != head; v = v->n)
+/*
+ * Set v to each element in a list in turn, starting from the element
+ * in front of 'start'.
+ * You can use this to 'unwind' a list_iterate and back out actions on
+ * already-processed elements.
+ * If 'start' is 'head' it walks the list backwards.
+ */
#define list_uniterate(v, head, start) \
for (v = (start)->p; v != head; v = v->p)
+/*
+ * A safe way to walk a list and delete and free some elements along
+ * the way.
+ * t must be defined as a temporary variable of the same type as v.
+ */
#define list_iterate_safe(v, t, head) \
for (v = (head)->n, t = v->n; v != head; v = t, t = v->n)
+/*
+ * Walk a list, setting 'v' in turn to the containing structure of each item.
+ * The containing structure should be the same type as 'v'.
+ * The 'struct list' variable within the containing structure is 'field'.
+ */
+#define list_iterate_items_gen(v, head, field) \
+ for (v = list_struct_base((head)->n, typeof(*v), field); \
+ &v->field != (head); \
+ v = list_struct_base(v->field.n, typeof(*v), field))
+
+/*
+ * Walk a list, setting 'v' in turn to the containing structure of each item.
+ * The containing structure should be the same type as 'v'.
+ * The list should be 'struct list list' within the containing structure.
+ */
+#define list_iterate_items(v, head) list_iterate_items_gen(v, (head), list)
+
+/*
+ * Return the number of elements in a list by walking it.
+ */
static inline unsigned int list_size(const struct list *head)
{
unsigned int s = 0;
@@ -92,17 +201,4 @@
return s;
}
-#define list_item(v, t) \
- ((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->list))
-
-#define list_struct_base(v, t, h) \
- ((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->h))
-
-/* Given a known element in a known structure, locate another */
-#define struct_field(v, t, e, f) \
- (((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->e))->f)
-
-/* Given a known element in a known structure, locate the list head */
-#define list_head(v, t, e) struct_field(v, t, e, list)
-
#endif
Modified: devmapper/upstream/current/include/log.h
==============================================================================
--- devmapper/upstream/current/include/log.h (original)
+++ devmapper/upstream/current/include/log.h Tue Jun 14 11:02:01 2005
@@ -35,4 +35,6 @@
#define log_very_verbose(x...) plog(_LOG_INFO, x)
#define log_debug(x...) plog(_LOG_DEBUG, x)
+#define stack log_debug("<backtrace>") /* Backtrace on error */
+
#endif
Modified: devmapper/upstream/current/kernel/ioctl/dm-ioctl.h
==============================================================================
--- devmapper/upstream/current/kernel/ioctl/dm-ioctl.h (original)
+++ devmapper/upstream/current/kernel/ioctl/dm-ioctl.h Tue Jun 14 11:02:01 2005
@@ -7,7 +7,9 @@
#ifndef _LINUX_DM_IOCTL_V4_H
#define _LINUX_DM_IOCTL_V4_H
-#include <linux/types.h>
+#ifdef linux
+# include <linux/types.h>
+#endif
#define DM_DIR "mapper" /* Slashes not supported */
#define DM_MAX_TYPE_NAME 16
Modified: devmapper/upstream/current/lib/Makefile.in
==============================================================================
--- devmapper/upstream/current/lib/Makefile.in (original)
+++ devmapper/upstream/current/lib/Makefile.in Tue Jun 14 11:02:01 2005
@@ -17,12 +17,25 @@
VPATH = @srcdir@
interface = @interface@
+ifeq ("@DMEVENTD@", "yes")
+ SUBDIRS += event
+endif
+
+ifeq ($(MAKECMDGOALS),distclean)
+ SUBDIRS += event
+endif
+
SOURCES = libdm-common.c libdm-file.c $(interface)/libdm-iface.c
INCLUDES = -I$(interface)
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@ \
-DDEVICE_MODE=@DEVICE_MODE@
@@ -41,7 +54,8 @@
install: $(INSTALL_TYPE)
install_dynamic: install_ at 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 \
$(includedir)/libdevmapper.h
@@ -50,13 +64,13 @@
$(INSTALL) -D $(OWNER) $(GROUP) -m 444 libdevmapper.h \
$(includedir)/libdevmapper.h
-install_fs: fs/libdevmapper.so
+install_fs: fs/libdevmapper.$(LIB_SUFFIX)
$(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) $< \
- $(libdir)/libdevmapper.so.$(LIB_VERSION)
+ $(libdir)/libdevmapper.$(LIB_SUFFIX).$(LIB_VERSION)
install_ioctl_static: ioctl/libdevmapper.a
$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \
Modified: devmapper/upstream/current/lib/ioctl/libdm-iface.c
==============================================================================
--- devmapper/upstream/current/lib/ioctl/libdm-iface.c (original)
+++ devmapper/upstream/current/lib/ioctl/libdm-iface.c Tue Jun 14 11:02:01 2005
@@ -30,13 +30,14 @@
#ifdef linux
# include "kdev_t.h"
# include <linux/limits.h>
-# include <linux/dm-ioctl.h>
#else
# define MAJOR(x) major((x))
# define MINOR(x) minor((x))
# define MKDEV(x,y) makedev((x),(y))
#endif
+#include <linux/dm-ioctl.h>
+
/*
* Ensure build compatibility.
* The hard-coded versions here are the highest present
@@ -116,6 +117,7 @@
return (void *) (((unsigned long) ptr + agn) & ~agn);
}
+#ifdef DM_IOCTLS
static int _get_proc_number(const char *file, const char *name,
uint32_t *number)
{
@@ -217,7 +219,7 @@
}
#ifdef HAVE_SELINUX
- if (!set_selinux_context(control)) {
+ if (!set_selinux_context(control, S_IFCHR)) {
stack;
return 0;
}
@@ -225,9 +227,11 @@
return 1;
}
+#endif
static int _open_control(void)
{
+#ifdef DM_IOCTLS
char control[PATH_MAX];
uint32_t major = 0, minor;
@@ -253,6 +257,9 @@
error:
log_error("Failure to communicate with kernel device-mapper driver.");
return 0;
+#else
+ return 1;
+#endif
}
void dm_task_destroy(struct dm_task *dmt)
@@ -608,7 +615,9 @@
if (dmt->type == DM_DEVICE_LIST) {
if (!_dm_names_v1(dmi))
goto bad;
- } else if (ioctl(_control_fd, command, dmi) < 0) {
+ }
+#ifdef DM_IOCTLS
+ else if (ioctl(_control_fd, command, dmi) < 0) {
if (_log_suppress)
log_verbose("device-mapper ioctl cmd %d failed: %s",
_IOC_NR(command), strerror(errno));
@@ -617,6 +626,8 @@
_IOC_NR(command), strerror(errno));
goto bad;
}
+#else /* Userspace alternative for testing */
+#endif
if (dmi->flags & DM_BUFFER_FULL_FLAG)
/* FIXME Increase buffer size and retry operation (if query) */
@@ -1313,22 +1324,26 @@
dmi->name, dmi->uuid, dmt->newname ? dmt->newname : "",
dmt->no_open_count ? 'N' : 'O',
dmt->sector, dmt->message ? dmt->message : "");
+#ifdef DM_IOCTLS
if (ioctl(_control_fd, command, dmi) < 0) {
if (errno == ENXIO && ((dmt->type == DM_DEVICE_INFO) ||
- (dmt->type == DM_DEVICE_MKNODES))) {
+ (dmt->type == DM_DEVICE_MKNODES)))
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) {
case DM_DEVICE_CREATE:
add_dev_node(dmt->dev_name, MAJOR(dmi->dev), MINOR(dmi->dev),
@@ -1383,10 +1398,7 @@
void dm_lib_exit(void)
{
- if (_control_fd != -1) {
- close(_control_fd);
- _control_fd = -1;
- }
+ dm_lib_release();
_version_ok = 1;
_version_checked = 0;
}
Modified: devmapper/upstream/current/lib/libdevmapper.h
==============================================================================
--- devmapper/upstream/current/lib/libdevmapper.h (original)
+++ devmapper/upstream/current/lib/libdevmapper.h Tue Jun 14 11:02:01 2005
@@ -166,6 +166,6 @@
/* Release library resources */
void dm_lib_release(void);
-void dm_lib_exit(void);
+void dm_lib_exit(void) __attribute((destructor));
#endif /* LIB_DEVICE_MAPPER_H */
Modified: devmapper/upstream/current/lib/libdm-common.c
==============================================================================
--- devmapper/upstream/current/lib/libdm-common.c (original)
+++ devmapper/upstream/current/lib/libdm-common.c Tue Jun 14 11:02:01 2005
@@ -21,6 +21,7 @@
#include <stdarg.h>
#include <sys/param.h>
+
#include <linux/dm-ioctl.h>
#ifdef HAVE_SELINUX
@@ -199,26 +200,28 @@
}
#ifdef HAVE_SELINUX
-int set_selinux_context(const char *path)
+int set_selinux_context(const char *path, mode_t mode)
{
security_context_t scontext;
- log_debug("Setting SELinux context for %s", path);
if (is_selinux_enabled() <= 0)
return 1;
- if (matchpathcon(path, 0, &scontext) < 0) {
- log_error("%s: matchpathcon failed: %s", path, strerror(errno));
+ if (matchpathcon(path, mode, &scontext) < 0) {
+ log_error("%s: matchpathcon %07o failed: %s", path, mode,
+ strerror(errno));
return 0;
}
+ log_debug("Setting SELinux context for %s to %s.", path, scontext);
+
if ((lsetfilecon(path, scontext) < 0) && (errno != ENOTSUP)) {
log_error("%s: lsetfilecon failed: %s", path, strerror(errno));
- free(scontext);
+ freecon(scontext);
return 0;
}
- free(scontext);
+ freecon(scontext);
return 1;
}
#endif
@@ -264,7 +267,7 @@
}
#ifdef HAVE_SELINUX
- if (!set_selinux_context(path))
+ if (!set_selinux_context(path, S_IFBLK))
return 0;
#endif
Modified: devmapper/upstream/current/lib/libdm-common.h.in
==============================================================================
--- devmapper/upstream/current/lib/libdm-common.h.in (original)
+++ devmapper/upstream/current/lib/libdm-common.h.in Tue Jun 14 11:02:01 2005
@@ -28,7 +28,7 @@
int rename_dev_node(const char *old_name, const char *new_name);
void update_devs(void);
-int set_selinux_context(const char *path);
+int set_selinux_context(const char *path, mode_t mode);
#define DM_LIB_VERSION @DM_LIB_VERSION@
Modified: devmapper/upstream/current/lib/libdm-file.c
==============================================================================
--- devmapper/upstream/current/lib/libdm-file.c (original)
+++ devmapper/upstream/current/lib/libdm-file.c Tue Jun 14 11:02:01 2005
@@ -19,7 +19,10 @@
#include <sys/file.h>
#include <fcntl.h>
#include <dirent.h>
-#include <malloc.h>
+
+#ifdef linux
+# include <malloc.h>
+#endif
static int _create_dir_recursive(const char *dir)
{
Modified: devmapper/upstream/current/make.tmpl.in
==============================================================================
--- devmapper/upstream/current/make.tmpl.in (original)
+++ devmapper/upstream/current/make.tmpl.in Tue Jun 14 11:02:01 2005
@@ -28,7 +28,7 @@
CLDFLAGS += @CLDFLAGS@
LDDEPS += @LDDEPS@
LDFLAGS += @LDFLAGS@
-SOFLAG += @SOFLAG@
+LIB_SUFFIX = @LIB_SUFFIX@
# Setup directory variables
prefix = @prefix@
@@ -54,7 +54,7 @@
MAKEFLAGS = @JOBS@
endif
-SUFFIXES = .c .d .o .so .a .po .pot .mo
+.SUFFIXES: .c .d .o .so .a .po .pot .mo .dylib
CFLAGS += -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline
@@ -76,6 +76,10 @@
CFLAGS += -DDM_COMPAT
endif
+ifeq ("@DMIOCTLS@", "yes")
+ CFLAGS += -DDM_IOCTLS
+endif
+
#CFLAGS += -pg
#LDFLAGS += -pg
@@ -148,9 +152,17 @@
%.so: %.o
$(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@
+ifeq ("@LIB_SUFFIX@","so")
$(LIB_SHARED): $(OBJECTS) $(LDDEPS)
- $(CC) $(SOFLAG) -Wl,-soname,$(notdir $@).$(LIB_VERSION) \
+ $(CC) -shared -Wl,-soname,$(notdir $@).$(LIB_VERSION) \
$(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@
+endif
+
+ifeq ("@LIB_SUFFIX@","dylib")
+$(LIB_SHARED): $(OBJECTS) $(LDDEPS)
+ $(CC) -dynamiclib -dylib_current_version,$(LIB_VERSION) \
+ $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@
+endif
$(LIB_STATIC): $(OBJECTS)
$(RM) $@
Modified: devmapper/upstream/current/man/dmsetup.8
==============================================================================
--- devmapper/upstream/current/man/dmsetup.8 (original)
+++ devmapper/upstream/current/man/dmsetup.8 Tue Jun 14 11:02:01 2005
@@ -29,18 +29,21 @@
.B dmsetup rename
.I device_name new_name
.br
-.B dmsetup ls
+.B dmsetup ls [--target target_type] [--exec command]
.br
-.B dmsetup info
+.B dmsetup info
+.I [device_name]
+.br
+.B dmsetup info -c|-C|--columns [--noheadings] [-o name]
.I [device_name]
.br
.B dmsetup deps
.I [device_name]
.br
-.B dmsetup status
+.B dmsetup status [--target target_type]
.I [device_name]
.br
-.B dmsetup table
+.B dmsetup table [--target target_type]
.I [device_name]
.br
.B dmsetup wait
@@ -53,6 +56,13 @@
.B dmsetup targets
.br
.B dmsetup version
+.br
+
+.B devmap_name
+.I major minor
+.br
+.B devmap_name
+.I major:minor
.ad b
.SH DESCRIPTION
dmsetup manages logical devices that use the device-mapper driver.
@@ -61,16 +71,38 @@
The first argument to dmsetup is a command.
The second argument is the logical device name or uuid.
+
+Invoking the command as \fBdevmap_name\fP is equivalent to
+.br
+\fBdmsetup info -c --noheadings -j \fImajor\fB -m \fIminor\fP.
.SH OPTIONS
+.IP \fB-c|-C|--columns
+.br
+Display output in columns rather than as Field: Value lines.
.IP \fB-j|--major\ \fImajor
.br
-Specify the major number to use on creation.
-.IP \fB-j|--minor\ \fIminor
+Specify the major number.
+.IP \fB-m|--minor\ \fIminor
+.br
+Specify the minor number.
+.IP \fB-n|--noheadings
+.br
+Suppress the headings line when using columnar output.
+.IP \fB--noopencount
.br
-Specify the minor number to use on creation.
+Tell the kernel not to supply the open reference count for the device.
+.IP \fB--notable
+.br
+When creating a device, don't load any table.
+.IP \fB-o|--options
+.br
+Specify which fields to display. Only \fB-o\ name\fP is supported.
.IP \fB-r|--readonly
.br
Set the table being loaded read-only.
+.IP \fB-u|--uuid
+.br
+Specify the uuid.
.IP \fB-v|--verbose [-v|--verbose]
.br
Produce additional output.
@@ -113,8 +145,12 @@
.br
UUID
.IP \fBls
+.I [--target target_type]
+.I [--exec command]
.br
-List device names.
+List device names. Optionally only list devices that have at least
+one target of the specified type. Optionally execute a command for
+each device. The device name is appended to the supplied command.
.IP \fBload|reload
.I device_name [table_file]
.br
@@ -140,9 +176,12 @@
If an inactive table has been loaded, it becomes live.
Postponed I/O then gets re-queued for processing.
.IP \fBstatus
+.I [--target target_type]
.I [device_name]
.br
Outputs status information for each of the device's targets.
+With --target, only information relating to the specified target type
+is displayed.
.IP \fBsuspend
.I device_name
.br
@@ -150,10 +189,13 @@
but has not yet completed will be flushed. Any further I/O to that
device will be postponed for as long as the device is suspended.
.IP \fBtable
+.I [--target target_type]
.I [device_name]
.br
Outputs the current table for the device in a format that can be fed
back in using the create or load commands.
+With --target, only information relating to the specified target type
+is displayed.
.IP \fBtargets
.br
Displays the names and versions of the currently-loaded targets.
More information about the pkg-lvm-commits
mailing list