diff --git a/lib/Makefile.am b/lib/Makefile.am index d59f0be7..6d766377 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -54,6 +54,7 @@ libcryptsetup_la_SOURCES = \ utils_loop.h \ utils_devpath.c \ libdevmapper.c \ + utils_dm.h \ volumekey.c \ random.c \ crypt_plain.c diff --git a/lib/internal.h b/lib/internal.h index 04a5e678..07e7db29 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -13,6 +13,7 @@ #include "nls.h" #include "utils_crypt.h" #include "utils_loop.h" +#include "utils_dm.h" #define SECTOR_SHIFT 9 #define SECTOR_SIZE (1 << SECTOR_SHIFT) @@ -30,19 +31,6 @@ struct crypt_device; -struct hash_type { - char *name; - void *private; - int (*fn)(void *data, int size, char *key, - int sizep, const char *passphrase); -}; - -struct hash_backend { - const char *name; - struct hash_type * (*get_hashes)(void); - void (*free_hashes)(struct hash_type *hashes); -}; - struct volume_key { size_t keylength; char key[]; @@ -58,41 +46,6 @@ void set_error_va(const char *fmt, va_list va); void set_error(const char *fmt, ...); const char *get_error(void); -/* Device mapper backend - kernel support flags */ -#define DM_KEY_WIPE_SUPPORTED (1 << 0) /* key wipe message */ -#define DM_LMK_SUPPORTED (1 << 1) /* lmk mode */ -#define DM_SECURE_SUPPORTED (1 << 2) /* wipe (secure) buffer flag */ -#define DM_PLAIN64_SUPPORTED (1 << 3) /* plain64 IV */ -uint32_t dm_flags(void); - -const char *dm_get_dir(void); -int dm_init(struct crypt_device *context, int check_kernel); -void dm_exit(void); -int dm_remove_device(const char *name, int force, uint64_t size); -int dm_status_device(const char *name); -int dm_query_device(const char *name, - char **device, - uint64_t *size, - uint64_t *skip, - uint64_t *offset, - char **cipher, - int *key_size, - char **key, - int *read_only, - int *suspended, - char **uuid); -int dm_create_device(const char *name, const char *device, const char *cipher, - const char *type, const char *uuid, - uint64_t size, uint64_t skip, uint64_t offset, - size_t key_size, const char *key, - int read_only, int reload); -int dm_suspend_and_wipe_key(const char *name); -int dm_resume_and_reinstate_key(const char *name, - size_t key_size, - const char *key); -char *dm_device_path(const char *dev_id); -int dm_is_dm_device(int major); - char *crypt_lookup_dev(const char *dev_id); int sector_size_for_device(const char *device); diff --git a/lib/utils_devpath.c b/lib/utils_devpath.c index f397f7c2..35b639ed 100644 --- a/lib/utils_devpath.c +++ b/lib/utils_devpath.c @@ -79,6 +79,9 @@ static char *__lookup_dev(char *path, dev_t dev, int dir_level, const int max_le return result; } +/* + * Non-udev systemd need to scan for device here. + */ static char *lookup_dev_old(const char *dev_id) { int major, minor; diff --git a/lib/utils_dm.h b/lib/utils_dm.h new file mode 100644 index 00000000..6cbd732c --- /dev/null +++ b/lib/utils_dm.h @@ -0,0 +1,41 @@ +#ifndef _UTILS_DM_H +#define _UTILS_DM_H + +/* device-mapper library helpers */ + +/* Device mapper backend - kernel support flags */ +#define DM_KEY_WIPE_SUPPORTED (1 << 0) /* key wipe message */ +#define DM_LMK_SUPPORTED (1 << 1) /* lmk mode */ +#define DM_SECURE_SUPPORTED (1 << 2) /* wipe (secure) buffer flag */ +#define DM_PLAIN64_SUPPORTED (1 << 3) /* plain64 IV */ +uint32_t dm_flags(void); + +const char *dm_get_dir(void); +int dm_init(struct crypt_device *context, int check_kernel); +void dm_exit(void); +int dm_remove_device(const char *name, int force, uint64_t size); +int dm_status_device(const char *name); +int dm_query_device(const char *name, + char **device, + uint64_t *size, + uint64_t *skip, + uint64_t *offset, + char **cipher, + int *key_size, + char **key, + int *read_only, + int *suspended, + char **uuid); +int dm_create_device(const char *name, const char *device, const char *cipher, + const char *type, const char *uuid, + uint64_t size, uint64_t skip, uint64_t offset, + size_t key_size, const char *key, + int read_only, int reload); +int dm_suspend_and_wipe_key(const char *name); +int dm_resume_and_reinstate_key(const char *name, + size_t key_size, + const char *key); +char *dm_device_path(const char *dev_id); +int dm_is_dm_device(int major); + +#endif /* _UTILS_DM_H */