mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Allow 'smart' without a configuration file
This commit is contained in:
parent
9d3773a2d4
commit
adbf4f25c2
8 changed files with 32 additions and 9 deletions
2
HISTORY
2
HISTORY
|
|
@ -15,6 +15,8 @@ SnapRAID HISTORY
|
|||
having verified all the hashes. This allows recovering of moved
|
||||
files in case a silent error is found during the hash verification
|
||||
check.
|
||||
* Allows to run the 'smart' command without a configuration file.
|
||||
In such case it operates on all the disks of the machine.
|
||||
* In the configuration file 'data' is now a synonymous of 'disk'.
|
||||
* Adds the 'touch' command intended to arbitrarely set all the zero
|
||||
subsecond timestamps. This improves the SnapRAID capabilities to
|
||||
|
|
|
|||
|
|
@ -984,10 +984,13 @@ void state_device(struct snapraid_state* state, int operation)
|
|||
tommy_list_insert_tail(&high, &entry->node, entry);
|
||||
}
|
||||
|
||||
if (state->opt.fake_device)
|
||||
if (state->opt.fake_device) {
|
||||
ret = devtest(&low, operation);
|
||||
else
|
||||
ret = devquery(&high, &low, operation);
|
||||
} else {
|
||||
int others = operation == DEVICE_SMART;
|
||||
|
||||
ret = devquery(&high, &low, operation, others);
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
const char* ope = 0;
|
||||
|
|
|
|||
|
|
@ -2433,7 +2433,7 @@ static int device_thread(tommy_list* list, void* (*func)(void* arg))
|
|||
return 0;
|
||||
}
|
||||
|
||||
int devquery(tommy_list* high, tommy_list* low, int operation)
|
||||
int devquery(tommy_list* high, tommy_list* low, int operation, int others)
|
||||
{
|
||||
tommy_node* i;
|
||||
void* (*func)(void* arg) = 0;
|
||||
|
|
@ -2478,7 +2478,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation)
|
|||
}
|
||||
|
||||
/* add other devices */
|
||||
if (operation == DEVICE_SMART) {
|
||||
if (others) {
|
||||
if (devscan(low) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to list other devices.\n");
|
||||
|
|
|
|||
|
|
@ -446,7 +446,7 @@ typedef struct devinfo_struct devinfo_t;
|
|||
*
|
||||
* The passed "low" device list must be already initialized.
|
||||
*/
|
||||
int devquery(tommy_list* high, tommy_list* low, int operation);
|
||||
int devquery(tommy_list* high, tommy_list* low, int operation, int others);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1030,6 +1030,13 @@ int main(int argc, char* argv[])
|
|||
break;
|
||||
}
|
||||
|
||||
switch (operation) {
|
||||
case OPERATION_SMART :
|
||||
/* allow to run without configuration file */
|
||||
opt.auto_conf = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* open the log file */
|
||||
log_open(log_file);
|
||||
|
||||
|
|
|
|||
|
|
@ -525,12 +525,20 @@ void state_config(struct snapraid_state* state, const char* path, const char* co
|
|||
/* store current command */
|
||||
state->command = command;
|
||||
|
||||
log_tag("conf:%s\n", path);
|
||||
log_tag("conf:file:%s\n", path);
|
||||
|
||||
f = sopen_read(path);
|
||||
if (!f) {
|
||||
/* LCOV_EXCL_START */
|
||||
if (errno == ENOENT) {
|
||||
if (state->opt.auto_conf) {
|
||||
log_tag("conf:missing:\n");
|
||||
/* mark that we are without a configuration file */
|
||||
state->no_conf = 1;
|
||||
state->level = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
log_fatal("No configuration file found at '%s'\n", path);
|
||||
} else if (errno == EACCES) {
|
||||
log_fatal("You do not have rights to access the configuration file '%s'\n", path);
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ struct snapraid_option {
|
|||
int match_first_uuid; /**< Force the matching of the first UUID. */
|
||||
int force_parity_update; /**< Force parity update even if data is not changed. */
|
||||
unsigned io_cache; /**< Number of IO buffers to use. 0 for default. */
|
||||
int auto_conf; /**< Allow to run without configuration file. */
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1054,7 +1054,7 @@ static int device_thread(tommy_list* list, void* (*func)(void* arg))
|
|||
return 0;
|
||||
}
|
||||
|
||||
int devquery(tommy_list* high, tommy_list* low, int operation)
|
||||
int devquery(tommy_list* high, tommy_list* low, int operation, int others)
|
||||
{
|
||||
tommy_node* i;
|
||||
void* (*func)(void* arg) = 0;
|
||||
|
|
@ -1118,7 +1118,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation)
|
|||
|
||||
#if HAVE_LINUX_DEVICE
|
||||
/* add other devices */
|
||||
if (operation == DEVICE_SMART) {
|
||||
if (others) {
|
||||
if (devscan(low) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to list other devices.\n");
|
||||
|
|
@ -1126,6 +1126,8 @@ int devquery(tommy_list* high, tommy_list* low, int operation)
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void)others;
|
||||
#endif
|
||||
|
||||
switch (operation) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue