Check device mapper communication and warn user in case the communication fails....
authorClemens Fruhwirth <clemens@endorphin.org>
Thu, 11 Sep 2008 09:10:55 +0000 (09:10 +0000)
committerClemens Fruhwirth <clemens@endorphin.org>
Thu, 11 Sep 2008 09:10:55 +0000 (09:10 +0000)
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@31 36d66b0a-2a48-0410-832c-cd162a569da5

lib/libdevmapper.c
lib/setup.c

index c8ab455..07f0a6a 100644 (file)
@@ -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 */
 }
 
index ca157c6..db4af13 100644 (file)
@@ -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");