From 13f4feaaf7d19654a2b1932bc77a160ac2d4debc Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Sat, 12 Mar 2011 20:23:25 +0000 Subject: [PATCH] Add backing device info into status. git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@445 36d66b0a-2a48-0410-832c-cd162a569da5 --- ChangeLog | 1 + lib/internal.h | 1 + src/Makefile.am | 1 + src/cryptsetup.c | 10 +++++++++- src/cryptsetup.h | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f75f0952..8c08ecab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2011-04-11 Milan Broz * Add loop manipulation code and support mapping of images in file. + * Add backing device loop info into status message. 2011-04-05 Milan Broz * Add exception to COPYING for binary distribution linked with OpenSSL library. diff --git a/lib/internal.h b/lib/internal.h index 7b42082d..0afdd0f3 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -12,6 +12,7 @@ #include "nls.h" #include "utils_crypt.h" +#include "utils_loop.h" #define SECTOR_SHIFT 9 #define SECTOR_SIZE (1 << SECTOR_SHIFT) diff --git a/src/Makefile.am b/src/Makefile.am index 917adf3e..5f2524cd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,6 +11,7 @@ INCLUDES = \ cryptsetup_SOURCES = \ $(top_builddir)/lib/utils_crypt.c \ + $(top_builddir)/lib/utils_loop.c \ cryptsetup.c \ cryptsetup.h diff --git a/src/cryptsetup.c b/src/cryptsetup.c index adcbf16e..317715eb 100644 --- a/src/cryptsetup.c +++ b/src/cryptsetup.c @@ -319,6 +319,8 @@ static int action_status(int arg) crypt_status_info ci; struct crypt_active_device cad; struct crypt_device *cd = NULL; + char *backing_file; + const char *device; int r = 0; ci = crypt_status(NULL, action_argv[0]); @@ -345,7 +347,13 @@ static int action_status(int arg) log_std(" cipher: %s-%s\n", crypt_get_cipher(cd), crypt_get_cipher_mode(cd)); log_std(" keysize: %d bits\n", crypt_get_volume_key_size(cd) * 8); - log_std(" device: %s\n", crypt_get_device_name(cd)); + device = crypt_get_device_name(cd); + log_std(" device: %s\n", device); + if (crypt_loop_device(device)) { + backing_file = crypt_loop_backing_file(device); + log_std(" loop: %s\n", backing_file); + free(backing_file); + } log_std(" offset: %" PRIu64 " sectors\n", cad.offset); log_std(" size: %" PRIu64 " sectors\n", cad.size); if (cad.iv_offset) diff --git a/src/cryptsetup.h b/src/cryptsetup.h index 56e17c38..5970fd34 100644 --- a/src/cryptsetup.h +++ b/src/cryptsetup.h @@ -7,6 +7,7 @@ #include "lib/nls.h" #include "lib/utils_crypt.h" +#include "lib/utils_loop.h" #define DEFAULT_CIPHER(type) (DEFAULT_##type##_CIPHER "-" DEFAULT_##type##_MODE)