1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Add configure option --with-device-nodes-on

Make configurable default behaviour how to deal with device node creates.
With udev system natural options should be  'resume'.
For older systems where user expect there is node in /dev/mapper immediately
after  dmsetup create --notable  -  use 'create'

FIXME:
Code needs fixing passing this flag through udev cookie.
This commit is contained in:
Zdenek Kabelac 2011-02-04 22:17:54 +00:00
parent 6c7b95f281
commit d0df875d48
4 changed files with 66 additions and 8 deletions

26
configure vendored
View File

@ -788,6 +788,7 @@ with_group
with_device_uid with_device_uid
with_device_gid with_device_gid
with_device_mode with_device_mode
with_device_nodes_on
enable_lvm1_fallback enable_lvm1_fallback
with_lvm1 with_lvm1
with_pool with_pool
@ -1526,6 +1527,8 @@ Optional Packages:
--with-device-uid=UID set the owner used for new device nodes [[UID=0]] --with-device-uid=UID set the owner used for new device nodes [[UID=0]]
--with-device-gid=GID set the group used for new device nodes [[GID=0]] --with-device-gid=GID 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-device-nodes-on=ON
create nodes on resume or create [[ON=resume]]
--with-lvm1=TYPE LVM1 metadata support: internal/shared/none --with-lvm1=TYPE LVM1 metadata support: internal/shared/none
[[TYPE=internal]] [[TYPE=internal]]
--with-pool=TYPE GFS pool read-only support: internal/shared/none --with-pool=TYPE GFS pool read-only support: internal/shared/none
@ -6711,6 +6714,29 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $DM_DEVICE_MODE" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DM_DEVICE_MODE" >&5
$as_echo "$DM_DEVICE_MODE" >&6; } $as_echo "$DM_DEVICE_MODE" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking when to create device nodes" >&5
$as_echo_n "checking when to create device nodes... " >&6; }
# Check whether --with-device-nodes-on was given.
if test "${with_device_nodes_on+set}" = set; then :
withval=$with_device_nodes_on; ADD_NODE=$withval
else
ADD_NODE=resume
fi
case "$ADD_NODE" in
resume) add_on=DM_ADD_NODE_ON_RESUME;;
create) add_on=DM_ADD_NODE_ON_CREATE;;
*) as_fn_error $? "--with-device-nodes-on parameter invalid" "$LINENO" 5;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: on $ADD_NODE" >&5
$as_echo "on $ADD_NODE" >&6; }
cat >>confdefs.h <<_ACEOF
#define DEFAULT_DM_ADD_NODE $add_on
_ACEOF
################################################################################ ################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable lvm1 fallback" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable lvm1 fallback" >&5
$as_echo_n "checking whether to enable lvm1 fallback... " >&6; } $as_echo_n "checking whether to enable lvm1 fallback... " >&6; }

View File

@ -213,6 +213,19 @@ AC_ARG_WITH(device-mode,
DM_DEVICE_MODE=$withval, DM_DEVICE_MODE=0600) DM_DEVICE_MODE=$withval, DM_DEVICE_MODE=0600)
AC_MSG_RESULT($DM_DEVICE_MODE) AC_MSG_RESULT($DM_DEVICE_MODE)
AC_MSG_CHECKING(when to create device nodes)
AC_ARG_WITH(device-nodes-on,
AC_HELP_STRING([--with-device-nodes-on=ON],
[create nodes on resume or create [[ON=resume]]]),
ADD_NODE=$withval, ADD_NODE=resume)
case "$ADD_NODE" in
resume) add_on=DM_ADD_NODE_ON_RESUME;;
create) add_on=DM_ADD_NODE_ON_CREATE;;
*) AC_MSG_ERROR([--with-device-nodes-on parameter invalid]);;
esac
AC_MSG_RESULT(on $ADD_NODE)
AC_DEFINE_UNQUOTED([DEFAULT_DM_ADD_NODE], $add_on, [Define default node creation behavior with dmsetup create])
################################################################################ ################################################################################
dnl -- LVM1 tool fallback option dnl -- LVM1 tool fallback option
AC_MSG_CHECKING(whether to enable lvm1 fallback) AC_MSG_CHECKING(whether to enable lvm1 fallback)

View File

@ -35,6 +35,9 @@
/* Default data alignment. */ /* Default data alignment. */
#undef DEFAULT_DATA_ALIGNMENT #undef DEFAULT_DATA_ALIGNMENT
/* Define default node creation behavior with dmsetup create */
#undef DEFAULT_DM_ADD_NODE
/* Name of default locking directory. */ /* Name of default locking directory. */
#undef DEFAULT_LOCK_DIR #undef DEFAULT_LOCK_DIR

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
* Copyright (C) 2005-2007 NEC Corporation * Copyright (C) 2005-2007 NEC Corporation
* *
* This file is part of the device-mapper userspace tools. * This file is part of the device-mapper userspace tools.
@ -507,6 +507,22 @@ static int _set_task_device(struct dm_task *dmt, const char *name, int optional)
return 1; return 1;
} }
static int _set_task_add_node(struct dm_task *dmt)
{
if (!dm_task_set_add_node(dmt, DEFAULT_DM_ADD_NODE))
return 0;
if (_switches[ADD_NODE_ON_RESUME_ARG] &&
!dm_task_set_add_node(dmt, DM_ADD_NODE_ON_RESUME))
return 0;
if (_switches[ADD_NODE_ON_CREATE_ARG] &&
!dm_task_set_add_node(dmt, DM_ADD_NODE_ON_CREATE))
return 0;
return 1;
}
static int _load(int argc, char **argv, void *data __attribute__((unused))) static int _load(int argc, char **argv, void *data __attribute__((unused)))
{ {
int r = 0; int r = 0;
@ -626,12 +642,8 @@ static int _create(int argc, char **argv, void *data __attribute__((unused)))
udev_flags |= DM_UDEV_DISABLE_DM_RULES_FLAG | udev_flags |= DM_UDEV_DISABLE_DM_RULES_FLAG |
DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG; DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG;
if (_switches[ADD_NODE_ON_RESUME_ARG] &&
!dm_task_set_add_node(dmt, DM_ADD_NODE_ON_RESUME))
goto out;
if (_switches[ADD_NODE_ON_CREATE_ARG] && if (!_set_task_add_node(dmt))
!dm_task_set_add_node(dmt, DM_ADD_NODE_ON_CREATE))
goto out; goto out;
if (_udev_cookie) { if (_udev_cookie) {
@ -1206,6 +1218,10 @@ static int _simple(int task, const char *name, uint32_t event_nr, int display)
if (_switches[NOLOCKFS_ARG] && !dm_task_skip_lockfs(dmt)) if (_switches[NOLOCKFS_ARG] && !dm_task_skip_lockfs(dmt))
goto out; goto out;
/* FIXME: needs to coperate with udev */
if (!_set_task_add_node(dmt))
goto out;
if (_switches[READAHEAD_ARG] && if (_switches[READAHEAD_ARG] &&
!dm_task_set_read_ahead(dmt, _int_args[READAHEAD_ARG], !dm_task_set_read_ahead(dmt, _int_args[READAHEAD_ARG],
_read_ahead_flags)) _read_ahead_flags))
@ -2709,7 +2725,7 @@ static struct command _commands[] = {
{"remove", "[-f|--force] <device>", 0, 1, _remove}, {"remove", "[-f|--force] <device>", 0, 1, _remove},
{"remove_all", "[-f|--force]", 0, 0, _remove_all}, {"remove_all", "[-f|--force]", 0, 0, _remove_all},
{"suspend", "[--noflush] <device>", 0, 1, _suspend}, {"suspend", "[--noflush] <device>", 0, 1, _suspend},
{"resume", "<device>", 0, 1, _resume}, {"resume", "<device> [{--addnodeonresume|--addnodeoncreate}]", 0, 1, _resume},
{"load", "<device> [<table_file>]", 0, 2, _load}, {"load", "<device> [<table_file>]", 0, 2, _load},
{"clear", "<device>", 0, 1, _clear}, {"clear", "<device>", 0, 1, _clear},
{"reload", "<device> [<table_file>]", 0, 2, _load}, {"reload", "<device> [<table_file>]", 0, 2, _load},