Skip to content
Snippets Groups Projects
runtime-config.c 832 B
Newer Older
struct config
{
    char * root_device;
    char * info_partition_device;
    char * data_partition_device;
    char * mapped_device_name;
    char * mapped_device_path;
    char * tmp_data_location;
};
extern struct config config;
struct config config;

void set_config_from_arguments(int argc, char ** argv)
{
    if (argc < 3)
    {
        printf("Not enough arguments. Usage:\n  cryptops-api ROOTDEV CRYPTNAME\n");
        exit(1);
    }

    config.root_device = argv[1];
    config.mapped_device_name = argv[2];

    asprintf(&config.info_partition_device, "%s1", config.root_device);
    asprintf(&config.data_partition_device, "%s2", config.root_device);
    asprintf(&config.mapped_device_path, "/dev/mapper/%s", config.mapped_device_name);
    asprintf(&config.tmp_data_location, "/tmp/%s", config.mapped_device_name);
}