Don't print disk dir in info

This commit is contained in:
Andrea Mazzoleni 2016-05-29 19:23:42 +02:00
parent dd87022490
commit b3cc9192cd
9 changed files with 48 additions and 28 deletions

View file

@ -17,6 +17,7 @@ SnapRAID HISTORY
* In Linux added the missing support for Btrfs file-systems. Note that
to have full support you need also the 'libblkid' library, otherwise
you won't get the UUIDs.
* In informative messages does't print the disk directory in file path.
* In Windows allows to use the escape char '^' to handle file patterns
containing real characters matching the globbing '*?[]' ones. In Unix
it was already possible to do the same escaping with '\'.

View file

@ -680,7 +680,7 @@ static int file_post(struct snapraid_state* state, int fix, unsigned i, struct s
}
log_tag("status:unrecoverable:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer));
msg_info("unrecoverable %s\n", path);
msg_info("unrecoverable %s\n", fmt_term(disk, file->sub, esc_buffer));
/* and do not set the time if damaged */
goto close_and_continue;
@ -718,7 +718,7 @@ static int file_post(struct snapraid_state* state, int fix, unsigned i, struct s
}
log_tag("status:recovered:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer));
msg_info("recovered %s\n", path);
msg_info("recovered %s\n", fmt_term(disk, file->sub, esc_buffer));
inode = handle[j].st.st_ino;
@ -758,19 +758,19 @@ static int file_post(struct snapraid_state* state, int fix, unsigned i, struct s
if (file_flag_has(file, FILE_IS_DAMAGED)) {
if (state->opt.auditonly) {
log_tag("status:damaged:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer));
msg_info("damaged %s\n", path);
msg_info("damaged %s\n", fmt_term(disk, file->sub, esc_buffer));
} else {
log_tag("status:unrecoverable:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer));
msg_info("unrecoverable %s\n", path);
msg_info("unrecoverable %s\n", fmt_term(disk, file->sub, esc_buffer));
}
} else if (file_flag_has(file, FILE_IS_FIXED)) {
log_tag("status:recoverable:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer));
msg_info("recoverable %s\n", path);
msg_info("recoverable %s\n", fmt_term(disk, file->sub, esc_buffer));
} else {
/* we don't use msg_verbose() because it also goes into the log */
if (msg_level >= MSG_VERBOSE) {
log_tag("status:correct:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer));
msg_info("correct %s\n", path);
msg_info("correct %s\n", fmt_term(disk, file->sub, esc_buffer));
}
}
}
@ -1512,7 +1512,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
++recovered_error;
log_tag("status:recovered:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer));
msg_info("recovered %s%s\n", disk->dir, file->sub);
msg_info("recovered %s\n", fmt_term(disk, file->sub, esc_buffer));
}
}
@ -1683,7 +1683,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
}
log_tag("status:recovered:%s:%s\n", disk->name, esc_tag(slink->sub, esc_buffer));
msg_info("recovered %s%s\n", disk->dir, slink->sub);
msg_info("recovered %s\n", fmt_term(disk, slink->sub, esc_buffer));
}
}
@ -1753,7 +1753,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
++recovered_error;
log_tag("status:recovered:%s:%s\n", disk->name, esc_tag(dir->sub, esc_buffer));
msg_info("recovered %s%s\n", disk->dir, dir->sub);
msg_info("recovered %s\n", fmt_term(disk, dir->sub, esc_buffer));
}
}
}

View file

@ -130,7 +130,7 @@ void state_dup(struct snapraid_state* state)
++count;
size += found->file->size;
log_tag("dup:%s:%s:%s:%s:%" PRIu64 ": dup\n", disk->name, esc_tag(file->sub, esc_buffer), found->disk->name, esc_tag(found->file->sub, esc_buffer_alt), found->file->size);
printf("%12" PRIu64 " %s%s = %s%s\n", file->size, disk->dir, file->sub, found->disk->dir, found->file->sub);
printf("%12" PRIu64 " %s = %s\n", file->size, fmt_term(disk, file->sub, esc_buffer), fmt_term(found->disk, found->file->sub, esc_buffer_alt));
hash_free(hash);
} else {
tommy_hashdyn_insert(&hashset, &hash->node, hash, hash32);

View file

@ -1210,5 +1210,23 @@ static inline snapraid_info info_get(tommy_arrayblkof* array, block_off_t pos)
*/
int time_compare(const void* void_a, const void* void_b);
/**
* Format a file path for poll reference
*/
static inline const char* fmt_poll(const struct snapraid_disk* disk, const char* str, char* buffer)
{
(void)disk;
return esc_shell(str, buffer);
}
/**
* Format a path name for terminal reference
*/
static inline const char* fmt_term(const struct snapraid_disk* disk, const char* str, char* buffer)
{
(void)disk;
return esc_shell(str, buffer);
}
#endif

View file

@ -77,7 +77,7 @@ void state_list(struct snapraid_state* state)
printf(":%02u.%03u", tm->tm_sec, file->mtime_nsec / 1000000);
printf(" ");
}
printf("%s%s\n", disk->dir, file->sub);
printf("%s\n", fmt_term(disk, file->sub, esc_buffer));
}
/* sort by name */
@ -106,7 +106,7 @@ void state_list(struct snapraid_state* state)
printf(" ");
if (msg_level >= MSG_VERBOSE)
printf(" ");
printf("%s%s -> %s%s\n", disk->dir, slink->sub, disk->dir, slink->linkto);
printf("%s -> %s\n", fmt_term(disk, slink->sub, esc_buffer), fmt_term(disk, slink->linkto, esc_buffer_alt));
}
}

View file

@ -122,7 +122,7 @@ static void scan_link(struct snapraid_scan* scan, int is_diff, const char* sub,
log_tag("scan:update:%s:%s\n", disk->name, esc_tag(slink->sub, esc_buffer));
if (is_diff) {
printf("update %s%s\n", disk->dir, slink->sub);
printf("update %s\n", fmt_term(disk, slink->sub, esc_buffer));
}
/* update it */
@ -139,7 +139,7 @@ static void scan_link(struct snapraid_scan* scan, int is_diff, const char* sub,
log_tag("scan:add:%s:%s\n", disk->name, esc_tag(sub, esc_buffer));
if (is_diff) {
printf("add %s%s\n", disk->dir, sub);
printf("add %s\n", fmt_term(disk, sub, esc_buffer));
}
/* and continue to insert it */
@ -699,7 +699,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
log_tag("scan:move:%s:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer), esc_tag(sub, esc_buffer_alt));
if (is_diff) {
printf("move %s%s -> %s%s\n", disk->dir, file->sub, disk->dir, sub);
printf("move %s -> %s\n", fmt_term(disk, file->sub, esc_buffer), fmt_term(disk, sub, esc_buffer_alt));
}
/* remove from the name set */
@ -836,7 +836,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
log_tag("scan:restore:%s:%s\n", disk->name, esc_tag(sub, esc_buffer));
if (is_diff) {
printf("restore %s%s\n", disk->dir, sub);
printf("restore %s\n", fmt_term(disk, sub, esc_buffer));
}
/* remove from the inode set */
@ -902,7 +902,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
/* LCOV_EXCL_START */
log_fatal("The file '%s%s' has unexpected zero size!\n", disk->dir, sub);
log_fatal("It's possible that after a kernel crash this file was lost,\n");
log_fatal("and you can use 'snapraid fix -f /%s' to recover it.\n", esc_shell(sub, esc_buffer));
log_fatal("and you can use 'snapraid fix -f /%s' to recover it.\n", fmt_poll(disk, sub, esc_buffer));
if (!is_diff) {
log_fatal("If this an expected condition you can '%s' anyway using 'snapraid --force-zero %s'\n", state->command, state->command);
exit(EXIT_FAILURE);
@ -951,7 +951,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
log_tag("scan:copy:%s:%s:%s:%s\n", other_disk->name, esc_tag(other_file->sub, esc_buffer), disk->name, esc_tag(file->sub, esc_buffer_alt));
if (is_diff) {
printf("copy %s%s -> %s%s\n", other_disk->dir, other_file->sub, disk->dir, file->sub);
printf("copy %s -> %s\n", fmt_term(other_disk, other_file->sub, esc_buffer), fmt_term(disk, file->sub, esc_buffer_alt));
}
/* mark it as reported */
@ -975,14 +975,14 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
);
if (is_diff) {
printf("update %s%s\n", disk->dir, sub);
printf("update %s\n", fmt_term(disk, sub, esc_buffer));
}
} else {
++scan->count_insert;
log_tag("scan:add:%s:%s\n", disk->name, esc_tag(sub, esc_buffer));
if (is_diff) {
printf("add %s%s\n", disk->dir, sub);
printf("add %s\n", fmt_term(disk, sub, esc_buffer));
}
}
}
@ -1528,7 +1528,7 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
log_tag("scan:remove:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer));
if (is_diff) {
printf("remove %s%s\n", disk->dir, file->sub);
printf("remove %s\n", fmt_term(disk, file->sub, esc_buffer));
}
scan_file_remove(scan, file);
@ -1549,7 +1549,7 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
log_tag("scan:remove:%s:%s\n", disk->name, esc_tag(slink->sub, esc_buffer));
if (is_diff) {
printf("remove %s%s\n", disk->dir, slink->sub);
printf("remove %s\n", fmt_term(disk, slink->sub, esc_buffer));
}
scan_link_remove(scan, slink);

View file

@ -4555,6 +4555,7 @@ void generate_configuration(const char* path)
{
struct snapraid_state state;
struct snapraid_content* content;
char esc_buffer[ESC_MAX];
unsigned l, s;
tommy_node* j;
@ -4622,7 +4623,7 @@ void generate_configuration(const char* path)
if (disk && disk->filelist) {
struct snapraid_file* file = disk->filelist->data;
if (file) {
printf("# and containing: %s\n", file->sub);
printf("# and containing: %s\n", fmt_poll(disk, file->sub, esc_buffer));
}
}
printf("data %s ENTER_HERE_THE_DIR\n", map->name);

View file

@ -195,7 +195,7 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
log_tag("error:%u:%s:%s: Open error. %s\n", i, disk->name, esc_tag(file->sub, esc_buffer), strerror(errno));
log_fatal("WARNING! Unexpected open error in a data disk, it isn't possible to sync.\n");
log_fatal("Ensure that file '%s' can be accessed.\n", handle[j].path);
log_fatal("Stopping to allow recovery. Try with 'snapraid check -f /%s'\n", esc_shell(file->sub, esc_buffer));
log_fatal("Stopping to allow recovery. Try with 'snapraid check -f /%s'\n", fmt_poll(disk, file->sub, esc_buffer));
++error;
goto bail;
/* LCOV_EXCL_STOP */
@ -239,7 +239,7 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
log_tag("error:%u:%s:%s: Read error at position %u. %s\n", i, disk->name, esc_tag(file->sub, esc_buffer), file_pos, strerror(errno));
log_fatal("WARNING! Unexpected read error in a data disk, it isn't possible to sync.\n");
log_fatal("Ensure that file '%s' can be read.\n", handle[j].path);
log_fatal("Stopping to allow recovery. Try with 'snapraid check -f /%s'\n", esc_shell(file->sub, esc_buffer));
log_fatal("Stopping to allow recovery. Try with 'snapraid check -f /%s'\n", fmt_poll(disk, file->sub, esc_buffer));
++error;
goto bail;
/* LCOV_EXCL_STOP */
@ -571,7 +571,7 @@ static void sync_data_reader(struct snapraid_worker* worker, struct snapraid_tas
log_tag("error:%u:%s:%s: Open error. %s\n", blockcur, disk->name, esc_tag(task->file->sub, esc_buffer), strerror(errno));
log_fatal("WARNING! Unexpected open error in a data disk, it isn't possible to sync.\n");
log_fatal("Ensure that file '%s' can be accessed.\n", handle->path);
log_fatal("Stopping to allow recovery. Try with 'snapraid check -f /%s'\n", esc_shell(task->file->sub, esc_buffer));
log_fatal("Stopping to allow recovery. Try with 'snapraid check -f /%s'\n", fmt_poll(disk, task->file->sub, esc_buffer));
task->state = TASK_STATE_ERROR;
return;
/* LCOV_EXCL_STOP */
@ -613,7 +613,7 @@ static void sync_data_reader(struct snapraid_worker* worker, struct snapraid_tas
log_tag("error:%u:%s:%s: Read error at position %u. %s\n", blockcur, disk->name, esc_tag(task->file->sub, esc_buffer), task->file_pos, strerror(errno));
log_fatal("WARNING! Unexpected read error in a data disk, it isn't possible to sync.\n");
log_fatal("Ensure that file '%s' can be read.\n", handle->path);
log_fatal("Stopping to allow recovery. Try with 'snapraid check -f /%s'\n", esc_shell(task->file->sub, esc_buffer));
log_fatal("Stopping to allow recovery. Try with 'snapraid check -f /%s'\n", fmt_poll(disk, task->file->sub, esc_buffer));
task->state = TASK_STATE_ERROR;
return;
/* LCOV_EXCL_STOP */

View file

@ -138,7 +138,7 @@ void state_touch(struct snapraid_state* state)
state->need_write = 1;
log_tag("touch:%s:%s: %" PRIu64 ".%d\n", disk->name, esc_tag(file->sub, esc_buffer), (uint64_t)st.st_mtime, (int)STAT_NSEC(&st));
msg_info("touch %s%s\n", disk->dir, file->sub);
msg_info("touch %s\n", fmt_term(disk, file->sub, esc_buffer));
}
}
}