From 0ac25b6c830e683caf553d46b9c5102745483c43 Mon Sep 17 00:00:00 2001 From: Clemens Fruhwirth Date: Thu, 11 Sep 2008 09:10:55 +0000 Subject: [PATCH] Check device mapper communication and warn user in case the communication fails. Thanks to Milan Broz. git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@31 36d66b0a-2a48-0410-832c-cd162a569da5 --- lib/libdevmapper.c | 7 +++++++ lib/setup.c | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/libdevmapper.c b/lib/libdevmapper.c index c8ab4557..07f0a6a8 100644 --- a/lib/libdevmapper.c +++ b/lib/libdevmapper.c @@ -38,9 +38,16 @@ static void set_dm_error(int level, const char *file, int line, va_end(va); } +static int _dm_simple(int task, const char *name); + static int dm_init(void) { dm_log_init(set_dm_error); + if (!_dm_simple(DM_DEVICE_LIST_VERSIONS, "test")) { + set_error("Cannot communicate with device-mapper. Is the dm_mod module loaded?"); + return -1; + } + return 1; /* unsafe memory */ } diff --git a/lib/setup.c b/lib/setup.c index ca157c68..db4af13a 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -705,7 +705,10 @@ static int crypt_job(int (*job)(int arg, struct setup_backend *backend, backend = get_setup_backend(default_backend); - setup_enter(backend,options->icb->log); + if (setup_enter(backend,options->icb->log) < 0) { + r = -ENOSYS; + goto out; + } if (!backend) { set_error("No setup backend available");