mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Merge branch 'b4'
Conflicts: HISTORY configure.ac
This commit is contained in:
commit
31b8abb9bd
7 changed files with 124 additions and 7 deletions
4
HISTORY
4
HISTORY
|
|
@ -15,6 +15,10 @@ SnapRAID HISTORY
|
|||
=================
|
||||
* If the underline filesystem doesn't support the FIEMAP command,
|
||||
fallback to use the inode number for sorting files.
|
||||
This happens with reiserfs in Linux.
|
||||
* Added a new -C, --gen-conf option to generate a dummy configuration
|
||||
file from the info in the content file.
|
||||
Just in case that you lose everything, except the content file.
|
||||
|
||||
4.0 2013/9
|
||||
==========
|
||||
|
|
|
|||
11
snapraid.1
11
snapraid.1
|
|
@ -43,7 +43,7 @@ snapraid [\(hyc, \(hy\(hyconf CONFIG]
|
|||
.PP
|
||||
.PD
|
||||
.PP
|
||||
snapraid [\(hyV, \(hy\(hyversion] [\(hyh, \(hy\(hyhelp]
|
||||
snapraid [\(hyV, \(hy\(hyversion] [\(hyh, \(hy\(hyhelp] [\(hyC, \(hy\(hygen\(hyconf CONTENT]
|
||||
.PD 0
|
||||
.PP
|
||||
.PD
|
||||
|
|
@ -689,6 +689,15 @@ It\(cqs present mainly for advanced manual recovering.
|
|||
Processes only the specified number of blocks.
|
||||
It\(cqs present mainly for advanced manual recovering.
|
||||
.TP
|
||||
.B \(hyC, \(hy\(hygen\(hyconf CONTENT_FILE
|
||||
Generates a dummy configuration file from an existing
|
||||
content file.
|
||||
The configuration file is written in the standard output,
|
||||
and it doesn\(cqt overwrite an existing one.
|
||||
This configuration file also contains the information
|
||||
needed to reconstruct the disk mount points, in case you
|
||||
lose the entire system.
|
||||
.TP
|
||||
.B \(hyv, \(hy\(hyverbose
|
||||
Prints more information in the processing.
|
||||
.TP
|
||||
|
|
|
|||
19
snapraid.c
19
snapraid.c
|
|
@ -119,6 +119,7 @@ struct option long_options[] = {
|
|||
{ "find-by-name", 0, 0, 'N' }, /* deprecated in SnapRAID 4.0 */
|
||||
{ "audit-only", 0, 0, 'a' },
|
||||
{ "speed-test", 0, 0, 'T' },
|
||||
{ "gen-conf", 1, 0, 'C' },
|
||||
{ "verbose", 0, 0, 'v' },
|
||||
{ "gui", 0, 0, 'G' }, /* undocumented GUI interface command */
|
||||
{ "help", 0, 0, 'h' },
|
||||
|
|
@ -181,7 +182,7 @@ struct option long_options[] = {
|
|||
};
|
||||
#endif
|
||||
|
||||
#define OPTIONS "c:f:d:mep:o:s:t:i:l:ZEUDNaTvhVG"
|
||||
#define OPTIONS "c:f:d:mep:o:s:t:i:l:ZEUDNaTC:vhVG"
|
||||
|
||||
volatile int global_interrupt = 0;
|
||||
|
||||
|
|
@ -228,8 +229,11 @@ int main(int argc, char* argv[])
|
|||
const char* import;
|
||||
const char* log;
|
||||
int lock;
|
||||
const char* gen_conf;
|
||||
|
||||
os_init();
|
||||
raid_init();
|
||||
crc32c_init();
|
||||
|
||||
/* defaults */
|
||||
conf = CONF;
|
||||
|
|
@ -246,6 +250,7 @@ int main(int argc, char* argv[])
|
|||
import = 0;
|
||||
log = 0;
|
||||
lock = 0;
|
||||
gen_conf = 0;
|
||||
|
||||
opterr = 0;
|
||||
while ((c =
|
||||
|
|
@ -356,6 +361,9 @@ int main(int argc, char* argv[])
|
|||
case 'T' :
|
||||
speed();
|
||||
exit(EXIT_SUCCESS);
|
||||
case 'C' :
|
||||
gen_conf = optarg;
|
||||
break;
|
||||
case OPT_TEST_KILL_AFTER_SYNC :
|
||||
opt.kill_after_sync = 1;
|
||||
break;
|
||||
|
|
@ -419,6 +427,12 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if (gen_conf != 0) {
|
||||
generate_configuration(gen_conf);
|
||||
os_done();
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (optind + 1 != argc) {
|
||||
usage();
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
@ -505,9 +519,6 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
}
|
||||
|
||||
raid_init();
|
||||
crc32c_init();
|
||||
|
||||
/* open the log file */
|
||||
if (log == 0)
|
||||
log = "2";
|
||||
|
|
|
|||
11
snapraid.d
11
snapraid.d
|
|
@ -13,7 +13,7 @@ Synopsis
|
|||
: [-s, --start BLKSTART] [-t, --count BLKCOUNT]
|
||||
: sync|status|scrub|diff|dup|pool|check|fix|rehash
|
||||
|
||||
:snapraid [-V, --version] [-h, --help]
|
||||
:snapraid [-V, --version] [-h, --help] [-C, --gen-conf CONTENT]
|
||||
|
||||
Description
|
||||
SnapRAID is a backup program for disk arrays. It stores redundancy
|
||||
|
|
@ -513,6 +513,15 @@ Options
|
|||
Processes only the specified number of blocks.
|
||||
It's present mainly for advanced manual recovering.
|
||||
|
||||
-C, --gen-conf CONTENT_FILE
|
||||
Generates a dummy configuration file from an existing
|
||||
content file.
|
||||
The configuration file is written in the standard output,
|
||||
and it doesn't overwrite an existing one.
|
||||
This configuration file also contains the information
|
||||
needed to reconstruct the disk mount points, in case you
|
||||
lose the entire system.
|
||||
|
||||
-v, --verbose
|
||||
Prints more information in the processing.
|
||||
|
||||
|
|
|
|||
11
snapraid.txt
11
snapraid.txt
|
|
@ -17,7 +17,7 @@ snapraid [-c, --conf CONFIG]
|
|||
[-s, --start BLKSTART] [-t, --count BLKCOUNT]
|
||||
sync|status|scrub|diff|dup|pool|check|fix|rehash
|
||||
|
||||
snapraid [-V, --version] [-h, --help]
|
||||
snapraid [-V, --version] [-h, --help] [-C, --gen-conf CONTENT]
|
||||
|
||||
|
||||
2 DESCRIPTION
|
||||
|
|
@ -556,6 +556,15 @@ SnapRAID provides the following options:
|
|||
Processes only the specified number of blocks.
|
||||
It's present mainly for advanced manual recovering.
|
||||
|
||||
-C, --gen-conf CONTENT_FILE
|
||||
Generates a dummy configuration file from an existing
|
||||
content file.
|
||||
The configuration file is written in the standard output,
|
||||
and it doesn't overwrite an existing one.
|
||||
This configuration file also contains the information
|
||||
needed to reconstruct the disk mount points, in case you
|
||||
lose the entire system.
|
||||
|
||||
-v, --verbose
|
||||
Prints more information in the processing.
|
||||
|
||||
|
|
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
9
state.h
9
state.h
|
|
@ -109,6 +109,7 @@ struct snapraid_state {
|
|||
time_t progress_last; /**< Last update of progress visualization. */
|
||||
time_t progress_interruption; /**< Start of the measure interruption. */
|
||||
time_t progress_subtract; /**< Time to subtract for the interruptions. */
|
||||
int no_conf; /**< Automatically add missing info. Used to load content without a configuration file. */
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -214,5 +215,13 @@ void state_progress_stop(struct snapraid_state* state);
|
|||
*/
|
||||
void state_progress_restart(struct snapraid_state* state);
|
||||
|
||||
/****************************************************************************/
|
||||
/* misc */
|
||||
|
||||
/**
|
||||
* Generate a dummy configuration file from a content file.
|
||||
*/
|
||||
void generate_configuration(const char* content);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue