Changes default Windows .conf location to the .exe dir.

This commit is contained in:
Andrea Mazzoleni 2014-03-18 00:00:53 +01:00
parent c72a1bbda1
commit a9428730b0
3 changed files with 38 additions and 17 deletions

10
HISTORY
View file

@ -1,8 +1,8 @@
SnapRAID HISTORY
================
6.0 2014/3 (BETA)
=================
6.0 2014/3
==========
* In "sync", even if a silent error is found, continue to update
the parity if it's possible to correct the error.
Note that the block will be marked bad, and the data
@ -24,9 +24,11 @@ SnapRAID HISTORY
* The options -p, --percentage and -o, --older-than now keep their
default value even if the other one is specified.
* Moved the .lock file in the same dir of the first specified content
file. This avoid to spin the parity disks in all commands.
file. This avoid to spin-up the parity disks in all commands.
* The "diff", "list", "dup", "status" and "pool" commands don't access
anymore the parity disks that can stay powered down.
anymore the parity disks that can now stay powered down.
* The default configuration file in Windows is now searched in the same
directory where the snapraid.exe file resides.
* New source code organization. The RAID engine is now
an external component usable also in other projects.

4
TODO
View file

@ -5,6 +5,10 @@ This is the list of TODO items for SnapRAID.
- Next
* Measures the time waited in blocking syscall for each disk,
and prints stats of the disk speeds when the command finish,
or when it's running.
* In status prints the allocated parity in each data disk.
In case, also takes into account the extra available space
in the parity disks.

View file

@ -27,15 +27,6 @@
/****************************************************************************/
/* main */
/**
* Default configuration file.
*/
#ifdef _WIN32
#define CONF PACKAGE ".conf"
#else
#define CONF "/etc/" PACKAGE ".conf"
#endif
void version(void)
{
printf(PACKAGE " v" VERSION " by Andrea Mazzoleni, " PACKAGE_URL "\n");
@ -58,7 +49,7 @@ void usage(void)
printf(" fix Fix the array of disks\n");
printf("\n");
printf("Options:\n");
printf(" " SWITCH_GETOPT_LONG("-c, --conf FILE ", "-c") " Configuration file (default " CONF ")\n");
printf(" " SWITCH_GETOPT_LONG("-c, --conf FILE ", "-c") " Configuration file\n");
printf(" " SWITCH_GETOPT_LONG("-f, --filter PATTERN ", "-f") " Process only files matching the pattern\n");
printf(" " SWITCH_GETOPT_LONG("-d, --filter-dist NAME", "-f") " Process only files in the specified disk\n");
printf(" " SWITCH_GETOPT_LONG("-m, --filter-missing ", "-m") " Process only missing/deleted files\n");
@ -188,6 +179,30 @@ void log_close(const char* log)
}
}
/****************************************************************************/
/* config */
void config(char* conf, size_t conf_size, const char* argv0)
{
#ifdef _WIN32
char* slash;
pathimport(conf, conf_size, argv0);
slash = strrchr(conf, '/');
if (slash) {
slash[1] = 0;
pathcat(conf, conf_size, PACKAGE ".conf");
} else {
pathcpy(conf, conf_size, PACKAGE ".conf");
}
#else
(void)argv0;
pathcpy(conf, conf_size, "/etc/" PACKAGE ".conf");
#endif
}
/****************************************************************************/
/* main */
@ -336,7 +351,7 @@ int main(int argc, char* argv[])
{
int c;
struct snapraid_option opt;
const char* conf;
char conf[PATH_MAX];
struct snapraid_state state;
int operation;
block_off_t blockstart;
@ -361,7 +376,7 @@ int main(int argc, char* argv[])
crc32c_init();
/* defaults */
conf = CONF;
config(conf, sizeof(conf), argv[0]);
memset(&opt, 0, sizeof(opt));
blockstart = 0;
blockcount = 0;
@ -387,7 +402,7 @@ int main(int argc, char* argv[])
!= EOF) {
switch (c) {
case 'c' :
conf = optarg;
pathimport(conf, sizeof(conf), optarg);
break;
case 'f' : {
struct snapraid_filter* filter = filter_alloc_file(1, optarg);