mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-04 13:50:09 -05:00
Merge branch 'b4'
Conflicts: HISTORY configure.ac
This commit is contained in:
commit
31b8abb9bd
7 changed files with 124 additions and 7 deletions
66
state.c
66
state.c
|
|
@ -66,6 +66,7 @@ void state_init(struct snapraid_state* state)
|
|||
state->lockfile[0] = 0;
|
||||
state->level = 1; /* default is the lowest protection */
|
||||
state->loaded_blockmax = 0;
|
||||
state->no_conf = 0;
|
||||
|
||||
tommy_list_init(&state->disklist);
|
||||
tommy_list_init(&state->maplist);
|
||||
|
|
@ -875,6 +876,17 @@ static struct snapraid_disk* find_disk(struct snapraid_state* state, const char*
|
|||
return disk;
|
||||
}
|
||||
|
||||
if (state->no_conf) {
|
||||
/* without a configuration file, add disks automatically */
|
||||
struct snapraid_disk* disk;
|
||||
|
||||
disk = disk_alloc(name, "DUMMY/", -1);
|
||||
|
||||
tommy_list_insert_tail(&state->disklist, &disk->node, disk);
|
||||
|
||||
return disk;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -3479,3 +3491,57 @@ int state_progress(struct snapraid_state* state, block_off_t blockpos, block_off
|
|||
return 0;
|
||||
}
|
||||
|
||||
void generate_configuration(const char* path)
|
||||
{
|
||||
struct snapraid_state state;
|
||||
struct snapraid_content* content;
|
||||
unsigned i;
|
||||
tommy_node* j;
|
||||
|
||||
state_init(&state);
|
||||
|
||||
/* mark that we are without a configuration file */
|
||||
state.no_conf = 1;
|
||||
|
||||
/* create the dummy content entry */
|
||||
content = content_alloc(path, -1);
|
||||
|
||||
/* adds the content entry */
|
||||
tommy_list_insert_tail(&state.contentlist, &content->node, content);
|
||||
|
||||
/* read the content file */
|
||||
state_read(&state);
|
||||
|
||||
/* output a dummy configuration file */
|
||||
printf("# Configuration file generated from %s\n", path);
|
||||
printf("\n");
|
||||
printf("# Use this blocksize\n");
|
||||
printf("block_size %u\n", state.block_size / 1024);
|
||||
printf("\n");
|
||||
for(i=0;i<LEV_MAX;++i) {
|
||||
printf("# Set the correct path for the %s file%s\n", lev_name(i), i != 0 ? " (if used)" : "");
|
||||
printf("%s ENTER_HERE_THE_PARITY_FILE\n", lev_config_name(i));
|
||||
printf("\n");
|
||||
}
|
||||
printf("# Add any other content file\n");
|
||||
printf("content %s\n", path);
|
||||
printf("\n");
|
||||
for(j=state.maplist;j;j=j->next) {
|
||||
struct snapraid_map* map = j->data;
|
||||
struct snapraid_disk* disk;
|
||||
printf("# Set the correct dir for disk '%s'\n", map->name);
|
||||
printf("# Disk '%s' is the one with system id '%s'\n", map->name, map->uuid);
|
||||
disk = find_disk(&state, map->name);
|
||||
if (disk && disk->filelist) {
|
||||
struct snapraid_file* file = disk->filelist->data;
|
||||
if (file) {
|
||||
printf("# and containing: %s\n", file->sub);
|
||||
}
|
||||
}
|
||||
printf("disk %s ENTER_HERE_THE_DIR\n", map->name);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
state_done(&state);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue