diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2011-02-04 22:17:54 +0000 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2011-02-04 22:17:54 +0000 |
commit | d0df875d48f571f5e1e9c919cd520124304e2e84 (patch) | |
tree | 1cce8c308504f37968c0c5b9c3776864bc716404 /tools/dmsetup.c | |
parent | 6c7b95f281253368a04582e243a9cede0d698c45 (diff) | |
download | lvm2-d0df875d48f571f5e1e9c919cd520124304e2e84.tar.gz lvm2-d0df875d48f571f5e1e9c919cd520124304e2e84.tar.xz lvm2-d0df875d48f571f5e1e9c919cd520124304e2e84.zip |
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.
Diffstat (limited to 'tools/dmsetup.c')
-rw-r--r-- | tools/dmsetup.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/tools/dmsetup.c b/tools/dmsetup.c index 85d2060d..86937f00 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -1,6 +1,6 @@ /* * 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 * * 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; } +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))) { int r = 0; @@ -626,13 +642,9 @@ static int _create(int argc, char **argv, void *data __attribute__((unused))) udev_flags |= DM_UDEV_DISABLE_DM_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] && - !dm_task_set_add_node(dmt, DM_ADD_NODE_ON_CREATE)) - goto out; + if (!_set_task_add_node(dmt)) + goto out; if (_udev_cookie) { cookie = _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)) goto out; + /* FIXME: needs to coperate with udev */ + if (!_set_task_add_node(dmt)) + goto out; + if (_switches[READAHEAD_ARG] && !dm_task_set_read_ahead(dmt, _int_args[READAHEAD_ARG], _read_ahead_flags)) @@ -2709,7 +2725,7 @@ static struct command _commands[] = { {"remove", "[-f|--force] <device>", 0, 1, _remove}, {"remove_all", "[-f|--force]", 0, 0, _remove_all}, {"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}, {"clear", "<device>", 0, 1, _clear}, {"reload", "<device> [<table_file>]", 0, 2, _load}, |