From be3448fb8a408258565de17613b7350205e19064 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Sat, 12 Mar 2011 20:23:16 +0000 Subject: [PATCH] Separate loop handling from internal code. git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@444 36d66b0a-2a48-0410-832c-cd162a569da5 --- lib/Makefile.am | 1 + lib/internal.h | 6 ------ lib/setup.c | 4 ++-- lib/utils_loop.c | 5 ++--- lib/utils_loop.h | 13 +++++++++++++ 5 files changed, 18 insertions(+), 11 deletions(-) create mode 100644 lib/utils_loop.h diff --git a/lib/Makefile.am b/lib/Makefile.am index d136642f..2eb01a80 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -52,6 +52,7 @@ libcryptsetup_la_SOURCES = \ utils_crypt.h \ utils_debug.c \ utils_loop.c \ + utils_loop.h \ libdevmapper.c \ volumekey.c \ random.c \ diff --git a/lib/internal.h b/lib/internal.h index 9484ad32..7b42082d 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -106,12 +106,6 @@ int device_check_and_adjust(struct crypt_device *cd, int *read_only); int wipe_device_header(const char *device, int sectors); -/* loopback device helpers */ -char *crypt_loop_get_device(void); -char *crypt_loop_backing_file(const char *loop); -int crypt_loop_device(const char *loop); -int crypt_loop_attach(const char *loop, const char *file, int offset, int *readonly); - void logger(struct crypt_device *cd, int class, const char *file, int line, const char *format, ...); #define log_dbg(x...) logger(NULL, CRYPT_LOG_DEBUG, __FILE__, __LINE__, x) #define log_std(c, x...) logger(c, CRYPT_LOG_NORMAL, __FILE__, __LINE__, x) diff --git a/lib/setup.c b/lib/setup.c index cc7423b5..909d5e3a 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -434,7 +434,7 @@ static int key_from_terminal(struct crypt_device *cd, char *msg, char **key, *key = NULL; if(!msg && asprintf(&prompt, _("Enter passphrase for %s: "), - crypt_get_device_name(cd)) < 0) + cd->backing_file ?: cd->device) < 0) return -ENOMEM; if (!msg) @@ -2350,7 +2350,7 @@ const char *crypt_get_uuid(struct crypt_device *cd) const char *crypt_get_device_name(struct crypt_device *cd) { - return cd->backing_file ?: cd->device; + return cd->device; } int crypt_get_volume_key_size(struct crypt_device *cd) diff --git a/lib/utils_loop.c b/lib/utils_loop.c index d59ca075..3a8df472 100644 --- a/lib/utils_loop.c +++ b/lib/utils_loop.c @@ -19,15 +19,14 @@ #include #include +#include #include #include #include #include #include -#include "internal.h" - -#define LOOP_DEV_MAJOR 7 +#include "utils_loop.h" char *crypt_loop_get_device(void) { diff --git a/lib/utils_loop.h b/lib/utils_loop.h new file mode 100644 index 00000000..54b533e6 --- /dev/null +++ b/lib/utils_loop.h @@ -0,0 +1,13 @@ +#ifndef _UTILS_LOOP_H +#define _UTILS_LOOP_H + +/* loopback device helpers */ + +#define LOOP_DEV_MAJOR 7 + +char *crypt_loop_get_device(void); +char *crypt_loop_backing_file(const char *loop); +int crypt_loop_device(const char *loop); +int crypt_loop_attach(const char *loop, const char *file, int offset, int *readonly); + +#endif /* _UTILS_CRYPT_H */