From 9679fb7f256a1cf5ca1fe46baa6b19e7b9cdcb1b Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Mon, 18 Oct 2010 14:47:06 +0000 Subject: [PATCH] Add crypt_get_device_name() to API (get underlying device name). git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@342 36d66b0a-2a48-0410-832c-cd162a569da5 --- ChangeLog | 1 + lib/libcryptsetup.h | 2 ++ lib/libcryptsetup.sym | 1 + lib/setup.c | 8 ++++++++ tests/api-test.c | 3 ++- 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1580366..55e6ce9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ 2010-10-17 Milan Broz + * Add crypt_get_device_name() to API (get underlying device name). * Change detection for static libraries. * Fix pkg-config use in automake scripts. * Build statically linked binary (cryptsetup.static) together with shared build diff --git a/lib/libcryptsetup.h b/lib/libcryptsetup.h index c2cf5fb..0db338b 100644 --- a/lib/libcryptsetup.h +++ b/lib/libcryptsetup.h @@ -437,12 +437,14 @@ int crypt_dump(struct crypt_device *cd); * cipher - used cipher, e.g. "aes" or NULL otherwise * cipher_mode - used cipher mode including IV, e.g. "xts-plain" or NULL otherwise * uuid - device UUID or NULL if not set + * device_name - underlying device name or NULL if not yet set * data_offset - device offset in sectors where real data starts on underlying device) * volume_key_size - size (in bytes) of volume key for crypt device */ const char *crypt_get_cipher(struct crypt_device *cd); const char *crypt_get_cipher_mode(struct crypt_device *cd); const char *crypt_get_uuid(struct crypt_device *cd); +const char *crypt_get_device_name(struct crypt_device *cd); uint64_t crypt_get_data_offset(struct crypt_device *cd); int crypt_get_volume_key_size(struct crypt_device *cd); diff --git a/lib/libcryptsetup.sym b/lib/libcryptsetup.sym index d4ed0dc..61fd17a 100644 --- a/lib/libcryptsetup.sym +++ b/lib/libcryptsetup.sym @@ -35,6 +35,7 @@ CRYPTSETUP_1.0 { crypt_get_uuid; crypt_get_data_offset; crypt_get_volume_key_size; + crypt_get_device_name; crypt_keyslot_status; crypt_get_error; diff --git a/lib/setup.c b/lib/setup.c index bf9da03..2f7026e 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -2020,6 +2020,9 @@ int crypt_dump(struct crypt_device *cd) else log_std(cd, "Key Slot %d: DISABLED\n", i); } + + log_std(cd, "DNAME: %s\n", crypt_get_device_name(cd) ?: ""); + return 0; } @@ -2053,6 +2056,11 @@ const char *crypt_get_uuid(struct crypt_device *cd) return NULL; } +const char *crypt_get_device_name(struct crypt_device *cd) +{ + return cd->device; +} + int crypt_get_volume_key_size(struct crypt_device *cd) { if (isPLAIN(cd->type)) diff --git a/tests/api-test.c b/tests/api-test.c index 3063dce..6a967ed 100644 --- a/tests/api-test.c +++ b/tests/api-test.c @@ -1,7 +1,7 @@ /* * cryptsetup library API check functions * - * Copyright (C) 2009 Red Hat, Inc. All rights reserved. + * Copyright (C) 2009-2010 Red Hat, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -731,6 +731,7 @@ static void AddDeviceLuks(void) OK_(strcmp(cipher_mode, crypt_get_cipher_mode(cd))); EQ_(key_size, crypt_get_volume_key_size(cd)); EQ_(4096, crypt_get_data_offset(cd)); + OK_(strcmp(DEVICE_2, crypt_get_device_name(cd))); reset_log(); crypt_set_log_callback(cd, &new_log, NULL); -- 2.7.4