1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
#pragma once
#include <glib.h>
typedef enum _RaucDMType {
RAUC_DM_VERITY,
RAUC_DM_CRYPT,
} RaucDMType;
typedef struct _RaucDM {
RaucDMType type;
/* common variables */
gchar *uuid;
gchar *lower_dev;
gchar *upper_dev;
guint64 data_size;
/* dm-verity variables */
gchar *root_digest;
gchar *salt;
/* dm-crypt variables */
gchar *key;
} RaucDM;
/**
* Allocates a new RaucDMVerity with uuid set.
*
* @return a pointer to the new RaucDMVerity
*/
RaucDM *r_dm_new_verity(void);
/**
* Allocates a new RaucDMCrypt with uuid set.
*
* Free with r_dm_free_crypt.
*
* @return a pointer to the new RaucDMCrypt
*/
RaucDM *r_dm_new_crypt(void);
/**
* Frees the memory allocated by a RaucDMVerity.
*
* @param dm_verity struct to free
*/
void r_dm_free(RaucDM *dm_verity);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(RaucDM, r_dm_free);
/**
* Configure a dm-verity target in the kernel using the provided parameters and
* return the resulting device name in the struct.
*
* @param dm_verity struct with configuration
* @param error Return location for a GError
*
* @return TRUE on success, FALSE if an error occurred
*/
gboolean r_dm_setup(RaucDM *dm_verity, GError **error);
/**
* Remove a previously configured dm-verity target from the kernel.
*
* @param dm_verity struct with configuration
* @param deferred TRUE if the kernel should remove the target when unused
* @param error Return location for a GError
*
* @return TRUE on success, FALSE if an error occurred
*/
gboolean r_dm_remove(RaucDM *dm_verity, gboolean deferred, GError **error);
|