X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Futils_dm.h;h=8af91e8dd76cefaae85f5f32228e7014e5927770;hb=83f02e66827fa6fa66f9b73a009d2ba51d22352d;hp=85e09414fc6c2fd4a53bc6ac90c7d3514b775286;hpb=4b0b82adc559659a723b00c5b93275aa2b960591;p=platform%2Fupstream%2Fcryptsetup.git diff --git a/lib/utils_dm.h b/lib/utils_dm.h index 85e0941..8af91e8 100644 --- a/lib/utils_dm.h +++ b/lib/utils_dm.h @@ -4,6 +4,7 @@ * Copyright (C) 2004, Christophe Saout * Copyright (C) 2004-2007, Clemens Fruhwirth * Copyright (C) 2009-2012, Red Hat, Inc. All rights reserved. + * Copyright (C) 2009-2012, Milan Broz * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -28,6 +29,7 @@ struct crypt_device; struct volume_key; struct crypt_params_verity; +struct device; /* Device mapper backend - kernel support flags */ #define DM_KEY_WIPE_SUPPORTED (1 << 0) /* key wipe message */ @@ -35,66 +37,66 @@ struct crypt_params_verity; #define DM_SECURE_SUPPORTED (1 << 2) /* wipe (secure) buffer flag */ #define DM_PLAIN64_SUPPORTED (1 << 3) /* plain64 IV */ #define DM_DISCARDS_SUPPORTED (1 << 4) /* discards/TRIM option is supported */ +#define DM_VERITY_SUPPORTED (1 << 5) /* dm-verity target supported */ uint32_t dm_flags(void); #define DM_ACTIVE_DEVICE (1 << 0) -#define DM_ACTIVE_CIPHER (1 << 1) -#define DM_ACTIVE_UUID (1 << 2) -#define DM_ACTIVE_KEYSIZE (1 << 3) -#define DM_ACTIVE_KEY (1 << 4) +#define DM_ACTIVE_UUID (1 << 1) -struct crypt_dm_active_device { - const char *device; - const char *cipher; - const char *uuid; +#define DM_ACTIVE_CRYPT_CIPHER (1 << 2) +#define DM_ACTIVE_CRYPT_KEYSIZE (1 << 3) +#define DM_ACTIVE_CRYPT_KEY (1 << 4) - /* Active key for device */ - struct volume_key *vk; +#define DM_ACTIVE_VERITY_ROOT_HASH (1 << 5) +#define DM_ACTIVE_VERITY_HASH_DEVICE (1 << 6) +#define DM_ACTIVE_VERITY_PARAMS (1 << 7) - /* struct crypt_active_device */ - uint64_t offset; /* offset in sectors */ - uint64_t iv_offset; /* IV initilisation sector */ +struct crypt_dm_active_device { + enum { DM_CRYPT = 0, DM_VERITY } target; uint64_t size; /* active device size */ uint32_t flags; /* activation flags */ -}; + const char *uuid; + struct device *data_device; + union { + struct { + const char *cipher; -struct crypt_dm_active_verity { - const char *data_device; - const char *hash_device; + /* Active key for device */ + struct volume_key *vk; - const char *root_hash; - size_t root_hash_size; + /* struct crypt_active_device */ + uint64_t offset; /* offset in sectors */ + uint64_t iv_offset; /* IV initilisation sector */ + } crypt; + struct { + struct device *hash_device; - uint64_t hash_offset; /* hash offset (not header) */ - uint64_t size; /* active device size */ - uint32_t flags; /* activation flags */ + const char *root_hash; + uint32_t root_hash_size; + + uint64_t hash_offset; /* hash offset in blocks (not header) */ + struct crypt_params_verity *vp; + } verity; + } u; }; +void dm_backend_init(void); +void dm_backend_exit(void); + +int dm_remove_device(struct crypt_device *cd, const char *name, + int force, uint64_t size); +int dm_status_device(struct crypt_device *cd, const char *name); +int dm_status_suspended(struct crypt_device *cd, const char *name); +int dm_status_verity_ok(struct crypt_device *cd, const char *name); +int dm_query_device(struct crypt_device *cd, const char *name, + uint32_t get_flags, struct crypt_dm_active_device *dmd); +int dm_create_device(struct crypt_device *cd, const char *name, + const char *type, struct crypt_dm_active_device *dmd, + int reload); +int dm_suspend_and_wipe_key(struct crypt_device *cd, const char *name); +int dm_resume_and_reinstate_key(struct crypt_device *cd, const char *name, + size_t key_size, const char *key); + 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_status_suspended(const char *name); -int dm_status_verity_ok(const char *name); -int dm_query_device(const char *name, uint32_t get_flags, - struct crypt_dm_active_device *dmd); -int dm_query_verity(const char *name, - struct crypt_dm_active_verity *dmd); -int dm_create_device(const char *name, - const char *type, - struct crypt_dm_active_device *dmd, - int reload); -int dm_create_verity(const char *name, - struct crypt_params_verity *params, - struct crypt_dm_active_verity *dmd); -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 *prefix, int major, int minor); -int dm_is_dm_device(int major, int minor); -int dm_is_dm_kernel_name(const char *name); -int dm_check_segment(const char *name, uint64_t offset, uint64_t size); #endif /* _UTILS_DM_H */