mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 10:51:54 -04:00
Differentiate messages in the log files if they are caused by an hardware issue
This commit is contained in:
parent
85f3f0217c
commit
d3f7bf64c1
33 changed files with 934 additions and 886 deletions
102
cmdline/check.c
102
cmdline/check.c
|
|
@ -42,13 +42,13 @@ static const char* es(int err)
|
|||
static void log_fatal_errno(int err, const char* name)
|
||||
{
|
||||
if (err == EIO) {
|
||||
log_fatal("DANGER! Unexpected input/output error in disk %s. It isn't possible to continue.\n", name);
|
||||
log_fatal(err, "DANGER! Unexpected input/output error in disk %s. It isn't possible to continue.\n", name);
|
||||
} else if (err == EACCES) {
|
||||
log_fatal("WARNING! Grant permission in the disk %s. It isn't possible to continue.\n", name);
|
||||
log_fatal(err, "WARNING! Grant permission in the disk %s. It isn't possible to continue.\n", name);
|
||||
} else if (err == ENOSPC) {
|
||||
log_fatal("WARNING! Ensure there is free space on the disk %s. It isn't possible to continue.\n", name);
|
||||
log_fatal(err, "WARNING! Ensure there is free space on the disk %s. It isn't possible to continue.\n", name);
|
||||
} else {
|
||||
log_fatal("WARNING! Without a working %s disk, it isn't possible to continue.\n", name);
|
||||
log_fatal(err, "WARNING! Without a working %s disk, it isn't possible to continue.\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -691,7 +691,7 @@ static int file_post(struct snapraid_state* state, int fix, unsigned i, struct s
|
|||
ret = rename(path, path_to);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error renaming '%s%s'. %s.\n", disk->dir, file->sub, strerror(errno));
|
||||
log_fatal(errno, "Error renaming '%s%s'. %s.\n", disk->dir, file->sub, strerror(errno));
|
||||
log_tag("%s:%u:%s:%s: Rename error. %s.\n", es(errno), i, disk->name, esc_tag(file->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
return -1;
|
||||
|
|
@ -1080,7 +1080,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
/* LCOV_EXCL_START */
|
||||
log_tag("%s:%u:%s:%s: Close error. %s.\n", es(errno), i, disk->name, esc_tag(report->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping at block %u\n", i);
|
||||
log_fatal(errno, "Stopping at block %u\n", i);
|
||||
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1095,7 +1095,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
/* LCOV_EXCL_START */
|
||||
log_tag("%s:%u:%s:%s: Create error. %s.\n", es(errno), i, disk->name, esc_tag(file->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping at block %u\n", i);
|
||||
log_fatal(errno, "Stopping at block %u\n", i);
|
||||
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1165,7 +1165,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
&& !(state->opt.syncedonly && file_flag_has(file, FILE_IS_UNSYNCED))
|
||||
&& handle[j].st.st_size > file->size
|
||||
) {
|
||||
log_error("File '%s' is larger than expected.\n", handle[j].path);
|
||||
log_error(ESOFT, "File '%s' is larger than expected.\n", handle[j].path);
|
||||
log_tag("error:%u:%s:%s: Size error\n", i, disk->name, esc_tag(file->sub, esc_buffer));
|
||||
++soft_error;
|
||||
|
||||
|
|
@ -1175,7 +1175,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
/* LCOV_EXCL_START */
|
||||
log_tag("%s:%u:%s:%s: Truncate error. %s.\n", es(errno), i, disk->name, esc_tag(file->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping at block %u\n", i);
|
||||
log_fatal(errno, "Stopping at block %u\n", i);
|
||||
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1407,7 +1407,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
/* LCOV_EXCL_START */
|
||||
log_tag("%s:%u:%s:%s: Write error. %s.\n", es(errno), i, failed[j].disk->name, esc_tag(failed[j].file->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, failed[j].disk->name);
|
||||
log_fatal("Stopping at block %u\n", i);
|
||||
log_fatal(errno, "Stopping at block %u\n", i);
|
||||
|
||||
/* mark the file as damaged */
|
||||
file_flag_set(failed[j].file, FILE_IS_DAMAGED);
|
||||
|
|
@ -1457,7 +1457,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
/* LCOV_EXCL_START */
|
||||
log_tag("%s:%u:%s: Write error. %s.\n", es(errno), i, lev_config_name(l), strerror(errno));
|
||||
log_fatal_errno(errno, lev_config_name(l));
|
||||
log_fatal("Stopping at block %u\n", i);
|
||||
log_fatal(errno, "Stopping at block %u\n", i);
|
||||
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1493,7 +1493,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
ret = file_post(state, fix, i, handle, diskmax);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Stopping at block %u\n", i);
|
||||
log_fatal(errno, "Stopping at block %u\n", i);
|
||||
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1562,7 +1562,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
if (ret == -1) {
|
||||
unsuccessful = 1;
|
||||
|
||||
log_error("Error stating empty file '%s'. %s.\n", path, strerror(errno));
|
||||
log_error(errno, "Error stating empty file '%s'. %s.\n", path, strerror(errno));
|
||||
log_tag("empty_%s:%s:%s: Empty file stat error\n", es(errno), disk->name, esc_tag(file->sub, esc_buffer));
|
||||
|
||||
if (errno == EIO) {
|
||||
|
|
@ -1573,13 +1573,13 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
} else if (!S_ISREG(st.st_mode)) {
|
||||
unsuccessful = 1;
|
||||
|
||||
log_error("Error stating empty file '%s' for not regular file.\n", path);
|
||||
log_error(ESOFT, "Error stating empty file '%s' for not regular file.\n", path);
|
||||
log_tag("empty_error:%s:%s: Empty file error for not regular file\n", disk->name, esc_tag(file->sub, esc_buffer));
|
||||
++soft_error;
|
||||
} else if (st.st_size != 0) {
|
||||
unsuccessful = 1;
|
||||
|
||||
log_error("Error stating empty file '%s' for not empty file.\n", path);
|
||||
log_error(ESOFT, "Error stating empty file '%s' for not empty file.\n", path);
|
||||
log_tag("empty_error:%s:%s: Empty file error for size '%" PRIu64 "'\n", disk->name, esc_tag(file->sub, esc_buffer), (uint64_t)st.st_size);
|
||||
++soft_error;
|
||||
}
|
||||
|
|
@ -1591,10 +1591,10 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
ret = mkancestor(path);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error creating ancestor '%s%s'. %s.\n", disk->dir, file->sub, strerror(errno));
|
||||
log_fatal(errno, "Error creating ancestor '%s%s'. %s.\n", disk->dir, file->sub, strerror(errno));
|
||||
log_tag("empty_%s:%u:%s:%s: Create ancestor error. %s.\n", es(errno), i, disk->name, esc_tag(file->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping\n");
|
||||
log_fatal(errno, "Stopping\n");
|
||||
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1606,10 +1606,10 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
f = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_NOFOLLOW, 0600);
|
||||
if (f == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error creating '%s%s'. %s.\n", disk->dir, file->sub, strerror(errno));
|
||||
log_fatal(errno, "Error creating '%s%s'. %s.\n", disk->dir, file->sub, strerror(errno));
|
||||
log_tag("empty_%s:%u:%s:%s: Create error. %s.\n", es(errno), i, disk->name, esc_tag(file->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping\n");
|
||||
log_fatal(errno, "Stopping\n");
|
||||
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1620,10 +1620,10 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
ret = fmtime(f, file->mtime_sec, file->mtime_nsec);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error timing '%s%s'. %s.\n", disk->dir, file->sub, strerror(errno));
|
||||
log_fatal(errno, "Error timing '%s%s'. %s.\n", disk->dir, file->sub, strerror(errno));
|
||||
log_tag("empty_%s:%u:%s:%s: Time error. %s.\n", es(errno), i, disk->name, esc_tag(file->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping\n");
|
||||
log_fatal(errno, "Stopping\n");
|
||||
|
||||
close(f);
|
||||
|
||||
|
|
@ -1636,10 +1636,10 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
ret = close(f);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error closing '%s%s'. %s.\n", disk->dir, file->sub, strerror(errno));
|
||||
log_fatal(errno, "Error closing '%s%s'. %s.\n", disk->dir, file->sub, strerror(errno));
|
||||
log_tag("empty_%s:%u:%s:%s: Close error. %s.\n", es(errno), i, disk->name, esc_tag(file->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping\n");
|
||||
log_fatal(errno, "Stopping\n");
|
||||
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1682,7 +1682,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
if (ret == -1) {
|
||||
unsuccessful = 1;
|
||||
|
||||
log_error("Error stating hardlink '%s'. %s.\n", path, strerror(errno));
|
||||
log_error(errno, "Error stating hardlink '%s'. %s.\n", path, strerror(errno));
|
||||
log_tag("hardlink_%s:%s:%s:%s: Hardlink stat error. %s.\n", es(errno), disk->name, esc_tag(slink->sub, esc_buffer), esc_tag(slink->linkto, esc_buffer_alt), strerror(errno));
|
||||
|
||||
if (errno == EIO) {
|
||||
|
|
@ -1693,7 +1693,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
} else if (!S_ISREG(st.st_mode)) {
|
||||
unsuccessful = 1;
|
||||
|
||||
log_error("Error stating hardlink '%s' for not regular file.\n", path);
|
||||
log_error(ESOFT, "Error stating hardlink '%s' for not regular file.\n", path);
|
||||
log_tag("hardlink_error:%s:%s:%s: Hardlink error for not regular file\n", disk->name, esc_tag(slink->sub, esc_buffer), esc_tag(slink->linkto, esc_buffer_alt));
|
||||
++soft_error;
|
||||
}
|
||||
|
|
@ -1716,7 +1716,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
}
|
||||
}
|
||||
|
||||
log_error("Error stating hardlink-to '%s'. %s.\n", pathto, strerror(errno));
|
||||
log_error(errno, "Error stating hardlink-to '%s'. %s.\n", pathto, strerror(errno));
|
||||
log_tag("hardlink_%s:%s:%s:%s: Hardlink to stat error. %s.\n", es(errno), disk->name, esc_tag(slink->sub, esc_buffer), esc_tag(slink->linkto, esc_buffer_alt), strerror(errno));
|
||||
|
||||
if (errno == EIO) {
|
||||
|
|
@ -1727,13 +1727,13 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
} else if (!S_ISREG(stto.st_mode)) {
|
||||
unsuccessful = 1;
|
||||
|
||||
log_error("Error stating hardlink-to '%s' for not regular file.\n", path);
|
||||
log_error(ESOFT, "Error stating hardlink-to '%s' for not regular file.\n", path);
|
||||
log_tag("hardlink_error:%s:%s:%s: Hardlink-to error for not regular file\n", disk->name, esc_tag(slink->sub, esc_buffer), esc_tag(slink->linkto, esc_buffer_alt));
|
||||
++soft_error;
|
||||
} else if (!unsuccessful && st.st_ino != stto.st_ino) {
|
||||
unsuccessful = 1;
|
||||
|
||||
log_error("Mismatch hardlink '%s' and '%s'. Different inode.\n", path, pathto);
|
||||
log_error(ESOFT, "Mismatch hardlink '%s' and '%s'. Different inode.\n", path, pathto);
|
||||
log_tag("hardlink_error:%s:%s:%s: Hardlink mismatch for different inode\n", disk->name, esc_tag(slink->sub, esc_buffer), esc_tag(slink->linkto, esc_buffer_alt));
|
||||
++soft_error;
|
||||
}
|
||||
|
|
@ -1744,7 +1744,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
if (ret < 0) {
|
||||
unsuccessful = 1;
|
||||
|
||||
log_error("Error reading symlink '%s'. %s.\n", path, strerror(errno));
|
||||
log_error(errno, "Error reading symlink '%s'. %s.\n", path, strerror(errno));
|
||||
log_tag("symlink_%s:%s:%s: Symlink read error. %s.\n", es(errno), disk->name, esc_tag(slink->sub, esc_buffer), strerror(errno));
|
||||
|
||||
if (errno == EIO) {
|
||||
|
|
@ -1755,7 +1755,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
} else if (ret >= PATH_MAX) {
|
||||
unsuccessful = 1;
|
||||
|
||||
log_error("Error reading symlink '%s'. Symlink too long.\n", path);
|
||||
log_error(ESOFT, "Error reading symlink '%s'. Symlink too long.\n", path);
|
||||
log_tag("symlink_error:%s:%s: Symlink too long\n", disk->name, esc_tag(slink->sub, esc_buffer));
|
||||
++soft_error;
|
||||
} else {
|
||||
|
|
@ -1777,10 +1777,10 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
ret = mkancestor(path);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error creating ancestor '%s%s'. %s.\n", disk->dir, slink->sub, strerror(errno));
|
||||
log_fatal(errno, "Error creating ancestor '%s%s'. %s.\n", disk->dir, slink->sub, strerror(errno));
|
||||
log_tag("%slink_%s:%u:%s:%s: Create ancestor error. %s.\n", link, es(errno), i, disk->name, esc_tag(slink->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping\n");
|
||||
log_fatal(errno, "Stopping\n");
|
||||
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1791,10 +1791,10 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
ret = remove(path);
|
||||
if (ret != 0 && errno != ENOENT) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error removing '%s%s'. %s.\n", disk->dir, slink->sub, strerror(errno));
|
||||
log_fatal(errno, "Error removing '%s%s'. %s.\n", disk->dir, slink->sub, strerror(errno));
|
||||
log_tag("%slink_%s:%u:%s:%s: Remove error. %s.\n", link, es(errno), i, disk->name, esc_tag(slink->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping\n");
|
||||
log_fatal(errno, "Stopping\n");
|
||||
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1806,10 +1806,10 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
ret = hardlink(pathto, path);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error writing hardlink '%s' to '%s'. %s.\n", path, pathto, strerror(errno));
|
||||
log_fatal(errno, "Error writing hardlink '%s' to '%s'. %s.\n", path, pathto, strerror(errno));
|
||||
log_tag("hardlink_%s:%u:%s:%s: Hardlink error. %s.\n", es(errno), i, disk->name, esc_tag(slink->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping\n");
|
||||
log_fatal(errno, "Stopping\n");
|
||||
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1822,10 +1822,10 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
ret = symlink(slink->linkto, path);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error writing symlink '%s' to '%s'. %s.\n", path, slink->linkto, strerror(errno));
|
||||
log_fatal(errno, "Error writing symlink '%s' to '%s'. %s.\n", path, slink->linkto, strerror(errno));
|
||||
log_tag("symlink_%s:%u:%s:%s: Hardlink error. %s.\n", es(errno), i, disk->name, esc_tag(slink->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping\n");
|
||||
log_fatal(errno, "Stopping\n");
|
||||
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1864,7 +1864,7 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
if (ret == -1) {
|
||||
unsuccessful = 1;
|
||||
|
||||
log_error("Error stating dir '%s'. %s.\n", path, strerror(errno));
|
||||
log_error(errno, "Error stating dir '%s'. %s.\n", path, strerror(errno));
|
||||
log_tag("dir_%s:%s:%s: Dir stat error. %s.\n", es(errno), disk->name, esc_tag(dir->sub, esc_buffer), strerror(errno));
|
||||
|
||||
if (errno == EIO) {
|
||||
|
|
@ -1884,10 +1884,10 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
ret = mkancestor(path);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error creating ancestor '%s%s'. %s.\n", disk->dir, dir->sub, strerror(errno));
|
||||
log_fatal(errno, "Error creating ancestor '%s%s'. %s.\n", disk->dir, dir->sub, strerror(errno));
|
||||
log_tag("dir_%s:%u:%s:%s: Create ancestor error. %s.\n", es(errno), i, disk->name, esc_tag(dir->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping\n");
|
||||
log_fatal(errno, "Stopping\n");
|
||||
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1898,10 +1898,10 @@ static int state_check_process(struct snapraid_state* state, int fix, struct sna
|
|||
ret = mkdir(path, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error creating directory '%s%s'. %s.\n", disk->dir, dir->sub, strerror(errno));
|
||||
log_fatal(errno, "Error creating directory '%s%s'. %s.\n", disk->dir, dir->sub, strerror(errno));
|
||||
log_tag("dir_%s:%u:%s:%s: Create directory error. %s.\n", es(errno), i, disk->name, esc_tag(dir->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping\n");
|
||||
log_fatal(errno, "Stopping\n");
|
||||
|
||||
++unrecoverable_error;
|
||||
goto bail;
|
||||
|
|
@ -1978,7 +1978,7 @@ bail:
|
|||
ret = remove(path);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error removing '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error removing '%s'. %s.\n", path, strerror(errno));
|
||||
log_tag("%s:%u:%s:%s: Close error. %s.\n", es(errno), blockmax, disk->name, esc_tag(file->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
|
||||
|
|
@ -2011,10 +2011,16 @@ bail:
|
|||
msg_status("Everything OK\n");
|
||||
}
|
||||
|
||||
if ((soft_error || io_error || silent_error) && !fix)
|
||||
log_fatal("WARNING! There are errors!\n");
|
||||
if ((soft_error || io_error || silent_error) && !fix) {
|
||||
if (soft_error)
|
||||
log_fatal(ESOFT, "WARNING! There are soft errors!\n");
|
||||
if (io_error)
|
||||
log_fatal(EIO, "DANGER! Unexpected input/output errors!\n");
|
||||
if (silent_error)
|
||||
log_fatal(EDATA, "DANGER! Unexpected silent data errors!\n");
|
||||
}
|
||||
if (unrecoverable_error)
|
||||
log_fatal("DANGER! Unrecoverable errors detected!\n");
|
||||
log_fatal(ESOFT, "DANGER! Unrecoverable errors detected!\n");
|
||||
|
||||
log_tag("summary:error_soft:%u\n", soft_error);
|
||||
log_tag("summary:error_io:%u\n", io_error);
|
||||
|
|
@ -2100,7 +2106,7 @@ int state_check(struct snapraid_state* state, int fix, block_off_t blockstart, b
|
|||
|
||||
if (blockstart > blockmax) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in the specified starting block %u. It's larger than the parity size %u.\n", blockstart, blockmax);
|
||||
log_fatal(EUSER, "Error in the specified starting block %u. It's larger than the parity size %u.\n", blockstart, blockmax);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1013,7 +1013,7 @@ void state_device(struct snapraid_state* state, int operation, tommy_list* filte
|
|||
case DEVICE_PROBE : ope = "Probe"; break;
|
||||
case DEVICE_DOWNIFUP : ope = "Spindown"; break;
|
||||
}
|
||||
log_fatal("%s is unsupported in this platform.\n", ope);
|
||||
log_fatal(ESOFT, "%s is unsupported in this platform.\n", ope);
|
||||
} else {
|
||||
if (operation == DEVICE_LIST) {
|
||||
for (i = tommy_list_head(&low); i != 0; i = i->next) {
|
||||
|
|
|
|||
|
|
@ -39,20 +39,20 @@ static const char* es(int err)
|
|||
static void log_fatal_errno(int err, const char* name)
|
||||
{
|
||||
if (err == EIO) {
|
||||
log_fatal("DANGER! Unexpected input/output error in disk %s. It isn't possible to continue.\n", name);
|
||||
log_fatal(err, "DANGER! Unexpected input/output error in disk %s. It isn't possible to continue.\n", name);
|
||||
} else if (err == EACCES) {
|
||||
log_fatal("WARNING! Grant permission in the disk %s. It isn't possible to continue.\n", name);
|
||||
log_fatal(err, "WARNING! Grant permission in the disk %s. It isn't possible to continue.\n", name);
|
||||
} else if (err == ENOSPC) {
|
||||
log_fatal("WARNING! Ensure there is free space on the disk %s. It isn't possible to continue.\n", name);
|
||||
log_fatal(err, "WARNING! Ensure there is free space on the disk %s. It isn't possible to continue.\n", name);
|
||||
} else {
|
||||
log_fatal("WARNING! Without a working %s disk, it isn't possible to continue.\n", name);
|
||||
log_fatal(err, "WARNING! Without a working %s disk, it isn't possible to continue.\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
static void log_error_errno(int err, const char* name)
|
||||
{
|
||||
if (err == EIO) {
|
||||
log_fatal("DANGER! Unexpected input/output error in disk %s.\n", name);
|
||||
log_fatal(err, "DANGER! Unexpected input/output error in disk %s.\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ static void dry_data_reader(struct snapraid_worker* worker, struct snapraid_task
|
|||
/* and closing a descriptor should never fail */
|
||||
log_tag("%s:%u:%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(report->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
|
||||
if (errno == EIO) {
|
||||
task->state = TASK_STATE_IOERROR;
|
||||
|
|
@ -118,7 +118,7 @@ static void dry_data_reader(struct snapraid_worker* worker, struct snapraid_task
|
|||
if (errno == EIO) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
task->state = TASK_STATE_IOERROR;
|
||||
return;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -290,8 +290,8 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit
|
|||
++io_error;
|
||||
if (io_error >= state->opt.io_error_limit) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("DANGER! Too many input/output errors in the %s disk. It isn't possible to continue.\n", disk->dir);
|
||||
log_fatal("Stopping at block %u\n", blockcur);
|
||||
log_fatal(EIO, "DANGER! Too many input/output errors in the %s disk. It isn't possible to continue.\n", disk->dir);
|
||||
log_fatal(EIO, "Stopping at block %u\n", blockcur);
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -301,7 +301,7 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit
|
|||
}
|
||||
if (task->state != TASK_STATE_DONE) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency in task state\n");
|
||||
log_fatal(EINTERNAL, "Internal inconsistency in task state\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -343,8 +343,8 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit
|
|||
++io_error;
|
||||
if (io_error >= state->opt.io_error_limit) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("DANGER! Too many input/output errors in the %s disk. It isn't possible to continue.\n", lev_name(levcur));
|
||||
log_fatal("Stopping at block %u\n", blockcur);
|
||||
log_fatal(EIO, "DANGER! Too many input/output errors in the %s disk. It isn't possible to continue.\n", lev_name(levcur));
|
||||
log_fatal(EIO, "Stopping at block %u\n", blockcur);
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -352,7 +352,7 @@ static int state_dry_process(struct snapraid_state* state, struct snapraid_parit
|
|||
}
|
||||
if (task->state != TASK_STATE_DONE) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency in task state\n");
|
||||
log_fatal(EINTERNAL, "Internal inconsistency in task state\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -421,9 +421,9 @@ bail:
|
|||
}
|
||||
|
||||
if (soft_error)
|
||||
log_fatal("DANGER! Unexpected errors!\n");
|
||||
log_fatal(ESOFT, "DANGER! Unexpected errors!\n");
|
||||
if (io_error)
|
||||
log_fatal("DANGER! Unexpected input/output errors!\n");
|
||||
log_fatal(EIO, "DANGER! Unexpected input/output errors!\n");
|
||||
|
||||
log_tag("summary:error_soft:%u\n", soft_error);
|
||||
log_tag("summary:error_io:%u\n", io_error);
|
||||
|
|
@ -456,7 +456,7 @@ int state_dry(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
|
||||
if (blockstart > blockmax) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in the specified starting block %u. It's larger than the parity size %u.\n", blockstart, blockmax);
|
||||
log_fatal(EUSER, "Error in the specified starting block %u. It's larger than the parity size %u.\n", blockstart, blockmax);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ int filter_existence(int filter_missing, const char* dir, const char* sub)
|
|||
if (errno == ENOENT)
|
||||
return 0;
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in stat file '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error in stat file '%s'. %s.\n", path, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -420,21 +420,21 @@ void file_copy(struct snapraid_file* src_file, struct snapraid_file* dst_file)
|
|||
|
||||
if (src_file->size != dst_file->size) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Copy file with different size\n");
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Copy file with different size\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (src_file->mtime_sec != dst_file->mtime_sec) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Copy file with different mtime_sec\n");
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Copy file with different mtime_sec\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (src_file->mtime_nsec != dst_file->mtime_nsec) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Copy file with different mtime_nsec\n");
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Copy file with different mtime_nsec\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -484,7 +484,7 @@ int file_block_is_last(struct snapraid_file* file, block_off_t file_pos)
|
|||
|
||||
if (file_pos >= file->blockmax) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: File block position over the max\n");
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: File block position over the max\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -605,13 +605,13 @@ struct snapraid_extent* extent_alloc(block_off_t parity_pos, struct snapraid_fil
|
|||
|
||||
if (count == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Allocating empty extent for file '%s' at position '%u/%u'\n", file->sub, file_pos, file->blockmax);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Allocating empty extent for file '%s' at position '%u/%u'\n", file->sub, file_pos, file->blockmax);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (file_pos + count > file->blockmax) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Allocating overflowing extent for file '%s' at position '%u:%u/%u'\n", file->sub, file_pos, count, file->blockmax);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Allocating overflowing extent for file '%s' at position '%u:%u/%u'\n", file->sub, file_pos, count, file->blockmax);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -928,7 +928,7 @@ static void extent_parity_check_foreach_unlock(void* void_arg, void* void_obj)
|
|||
|
||||
if (obj->count == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Parity count zero for file '%s' at '%u'\n",
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Parity count zero for file '%s' at '%u'\n",
|
||||
obj->file->sub, obj->parity_pos);
|
||||
++arg->result;
|
||||
return;
|
||||
|
|
@ -942,7 +942,7 @@ static void extent_parity_check_foreach_unlock(void* void_arg, void* void_obj)
|
|||
/* check the order */
|
||||
if (prev->parity_pos >= obj->parity_pos) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Parity order for files '%s' at '%u:%u' and '%s' at '%u:%u'\n",
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Parity order for files '%s' at '%u:%u' and '%s' at '%u:%u'\n",
|
||||
prev->file->sub, prev->parity_pos, prev->count, obj->file->sub, obj->parity_pos, obj->count);
|
||||
++arg->result;
|
||||
return;
|
||||
|
|
@ -952,7 +952,7 @@ static void extent_parity_check_foreach_unlock(void* void_arg, void* void_obj)
|
|||
/* check that the extents don't overlap */
|
||||
if (prev->parity_pos + prev->count > obj->parity_pos) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Parity overlap for files '%s' at '%u:%u' and '%s' at '%u:%u'\n",
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Parity overlap for files '%s' at '%u:%u' and '%s' at '%u:%u'\n",
|
||||
prev->file->sub, prev->parity_pos, prev->count, obj->file->sub, obj->parity_pos, obj->count);
|
||||
++arg->result;
|
||||
return;
|
||||
|
|
@ -978,7 +978,7 @@ static void extent_file_check_foreach_unlock(void* void_arg, void* void_obj)
|
|||
|
||||
if (obj->count == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: File count zero for file '%s' at '%u'\n",
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: File count zero for file '%s' at '%u'\n",
|
||||
obj->file->sub, obj->file_pos);
|
||||
++arg->result;
|
||||
return;
|
||||
|
|
@ -994,7 +994,7 @@ static void extent_file_check_foreach_unlock(void* void_arg, void* void_obj)
|
|||
/* check that the extent doesn't overflow the file */
|
||||
if (prev->file_pos + prev->count > prev->file->blockmax) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Delete end for file '%s' at '%u:%u' overflowing size '%u'\n",
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Delete end for file '%s' at '%u:%u' overflowing size '%u'\n",
|
||||
prev->file->sub, prev->file_pos, prev->count, prev->file->blockmax);
|
||||
++arg->result;
|
||||
return;
|
||||
|
|
@ -1004,7 +1004,7 @@ static void extent_file_check_foreach_unlock(void* void_arg, void* void_obj)
|
|||
/* check that the extent ends the file */
|
||||
if (prev->file_pos + prev->count != prev->file->blockmax) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: File end for file '%s' at '%u:%u' instead of size '%u'\n",
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: File end for file '%s' at '%u:%u' instead of size '%u'\n",
|
||||
prev->file->sub, prev->file_pos, prev->count, prev->file->blockmax);
|
||||
++arg->result;
|
||||
return;
|
||||
|
|
@ -1017,7 +1017,7 @@ static void extent_file_check_foreach_unlock(void* void_arg, void* void_obj)
|
|||
/* check that the extent doesn't overflow the file */
|
||||
if (obj->file_pos + obj->count > obj->file->blockmax) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Delete start for file '%s' at '%u:%u' overflowing size '%u'\n",
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Delete start for file '%s' at '%u:%u' overflowing size '%u'\n",
|
||||
obj->file->sub, obj->file_pos, obj->count, obj->file->blockmax);
|
||||
++arg->result;
|
||||
return;
|
||||
|
|
@ -1027,7 +1027,7 @@ static void extent_file_check_foreach_unlock(void* void_arg, void* void_obj)
|
|||
/* check that the extent starts the file */
|
||||
if (obj->file_pos != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: File start for file '%s' at '%u:%u'\n",
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: File start for file '%s' at '%u:%u'\n",
|
||||
obj->file->sub, obj->file_pos, obj->count);
|
||||
++arg->result;
|
||||
return;
|
||||
|
|
@ -1038,7 +1038,7 @@ static void extent_file_check_foreach_unlock(void* void_arg, void* void_obj)
|
|||
/* check the order */
|
||||
if (prev->file_pos >= obj->file_pos) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: File order for file '%s' at '%u:%u' and at '%u:%u'\n",
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: File order for file '%s' at '%u:%u' and at '%u:%u'\n",
|
||||
prev->file->sub, prev->file_pos, prev->count, obj->file_pos, obj->count);
|
||||
++arg->result;
|
||||
return;
|
||||
|
|
@ -1049,7 +1049,7 @@ static void extent_file_check_foreach_unlock(void* void_arg, void* void_obj)
|
|||
/* check that the extents don't overlap */
|
||||
if (prev->file_pos + prev->count > obj->file_pos) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Delete sequence for file '%s' at '%u:%u' and at '%u:%u'\n",
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Delete sequence for file '%s' at '%u:%u' and at '%u:%u'\n",
|
||||
prev->file->sub, prev->file_pos, prev->count, obj->file_pos, obj->count);
|
||||
++arg->result;
|
||||
return;
|
||||
|
|
@ -1059,7 +1059,7 @@ static void extent_file_check_foreach_unlock(void* void_arg, void* void_obj)
|
|||
/* check that the extents are sequential */
|
||||
if (prev->file_pos + prev->count != obj->file_pos) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: File sequence for file '%s' at '%u:%u' and at '%u:%u'\n",
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: File sequence for file '%s' at '%u:%u' and at '%u:%u'\n",
|
||||
prev->file->sub, prev->file_pos, prev->count, obj->file_pos, obj->count);
|
||||
++arg->result;
|
||||
return;
|
||||
|
|
@ -1257,7 +1257,7 @@ void fs_allocate(struct snapraid_disk* disk, block_off_t parity_pos, struct snap
|
|||
/* ensure that we are extending the extent at the end */
|
||||
if (file_pos != extent->file_pos + extent->count) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Allocating file '%s' at position '%u/%u' in the middle of extent '%u:%u' in disk '%s'\n", file->sub, file_pos, file->blockmax, extent->file_pos, extent->count, disk->name);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Allocating file '%s' at position '%u/%u' in the middle of extent '%u:%u' in disk '%s'\n", file->sub, file_pos, file->blockmax, extent->file_pos, extent->count, disk->name);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1279,7 +1279,7 @@ void fs_allocate(struct snapraid_disk* disk, block_off_t parity_pos, struct snap
|
|||
|
||||
if (parity_extent != extent || file_extent != extent) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Allocating file '%s' at position '%u/%u' for existing extent '%u:%u' in disk '%s'\n", file->sub, file_pos, file->blockmax, extent->file_pos, extent->count, disk->name);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Allocating file '%s' at position '%u/%u' for existing extent '%u:%u' in disk '%s'\n", file->sub, file_pos, file->blockmax, extent->file_pos, extent->count, disk->name);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1303,7 +1303,7 @@ void fs_deallocate(struct snapraid_disk* disk, block_off_t parity_pos)
|
|||
extent = fs_par2extent_get_unlock(disk, &disk->fs_last, parity_pos);
|
||||
if (!extent) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Deallocating parity position '%u' for not existing extent in disk '%s'\n", parity_pos, disk->name);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Deallocating parity position '%u' for not existing extent in disk '%s'\n", parity_pos, disk->name);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1358,7 +1358,7 @@ void fs_deallocate(struct snapraid_disk* disk, block_off_t parity_pos)
|
|||
|
||||
if (parity_extent != second_extent || file_extent != second_extent) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Deallocating parity position '%u' for splitting extent '%u:%u' in disk '%s'\n", parity_pos, second_extent->file_pos, second_extent->count, disk->name);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Deallocating parity position '%u' for splitting extent '%u:%u' in disk '%s'\n", parity_pos, second_extent->file_pos, second_extent->count, disk->name);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1373,7 +1373,7 @@ struct snapraid_block* fs_file2block_get(struct snapraid_file* file, block_off_t
|
|||
{
|
||||
if (file_pos >= file->blockmax) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Dereferencing file '%s' at position '%u/%u'\n", file->sub, file_pos, file->blockmax);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Dereferencing file '%s' at position '%u/%u'\n", file->sub, file_pos, file->blockmax);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1062,7 +1062,7 @@ static inline struct snapraid_file* fs_par2file_get(struct snapraid_disk* disk,
|
|||
ret = fs_par2file_find(disk, parity_pos, file_pos);
|
||||
if (ret == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Deresolving parity to file at position '%u' in disk '%s'\n", parity_pos, disk->name);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Deresolving parity to file at position '%u' in disk '%s'\n", parity_pos, disk->name);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1086,7 +1086,7 @@ static inline block_off_t fs_file2par_get(struct snapraid_disk* disk, struct sna
|
|||
ret = fs_file2par_find(disk, file, file_pos);
|
||||
if (ret == POS_NULL) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Resolving file '%s' at position '%u/%u' in disk '%s'\n", file->sub, file_pos, file->blockmax, disk->name);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Resolving file '%s' at position '%u/%u' in disk '%s'\n", file->sub, file_pos, file->blockmax, disk->name);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1110,7 +1110,7 @@ static inline struct snapraid_block* fs_par2block_get(struct snapraid_disk* disk
|
|||
ret = fs_par2block_find(disk, parity_pos);
|
||||
if (ret == BLOCK_NULL) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency: Deresolving parity to block at position '%u' in disk '%s'\n", parity_pos, disk->name);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency: Deresolving parity to block at position '%u' in disk '%s'\n", parity_pos, disk->name);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file, in
|
|||
handle->f = -1;
|
||||
handle->valid_size = 0;
|
||||
|
||||
log_fatal("Error opening file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
log_fatal(errno, "Error opening file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file, in
|
|||
ret = fstat(handle->f, &handle->st);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error accessing file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
log_fatal(errno, "Error accessing file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -111,7 +111,7 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file, in
|
|||
ret = advise_open(&handle->advise, handle->f);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error advising file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
log_fatal(errno, "Error advising file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -127,9 +127,9 @@ int handle_truncate(struct snapraid_handle* handle, struct snapraid_file* file)
|
|||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
if (errno == EACCES) {
|
||||
log_fatal("Failed to truncate file '%s' for missing write permission.\n", handle->path);
|
||||
log_fatal(errno, "Failed to truncate file '%s' for missing write permission.\n", handle->path);
|
||||
} else {
|
||||
log_fatal("Error truncating file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
log_fatal(errno, "Error truncating file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
}
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -141,7 +141,7 @@ int handle_truncate(struct snapraid_handle* handle, struct snapraid_file* file)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int mode, fptr* out, fptr* out_missing)
|
||||
int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int mode, log_ptr* out, log_ptr* out_missing)
|
||||
{
|
||||
int ret;
|
||||
int flags;
|
||||
|
|
@ -174,11 +174,11 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int
|
|||
handle->valid_size = 0;
|
||||
|
||||
if (errno == ENOENT)
|
||||
out_missing("Missing file '%s'.\n", handle->path);
|
||||
out_missing(errno, "Missing file '%s'.\n", handle->path);
|
||||
else if (errno == EACCES)
|
||||
out("Permission denied for file '%s'.\n", handle->path);
|
||||
out(errno, "Permission denied for file '%s'.\n", handle->path);
|
||||
else
|
||||
out("Error opening file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
out(errno, "Error opening file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int
|
|||
ret = fstat(handle->f, &handle->st);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
out("Error accessing file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
out(errno, "Error accessing file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -200,7 +200,7 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int
|
|||
ret = advise_open(&handle->advise, handle->f);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
out("Error advising file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
out(errno, "Error advising file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -217,7 +217,7 @@ int handle_close(struct snapraid_handle* handle)
|
|||
ret = close(handle->f);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error closing file '%s'. %s.\n", handle->file->sub, strerror(errno));
|
||||
log_fatal(errno, "Error closing file '%s'. %s.\n", handle->file->sub, strerror(errno));
|
||||
|
||||
/* invalidate for error */
|
||||
handle->file = 0;
|
||||
|
|
@ -236,7 +236,7 @@ int handle_close(struct snapraid_handle* handle)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned char* block_buffer, unsigned block_size, fptr* out, fptr* out_missing)
|
||||
int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned char* block_buffer, unsigned block_size, log_ptr* out, log_ptr* out_missing)
|
||||
{
|
||||
ssize_t read_ret;
|
||||
data_off_t offset;
|
||||
|
|
@ -253,15 +253,15 @@ int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned c
|
|||
if (offset >= handle->valid_size) {
|
||||
/* if the file is missing, it's at 0 size, or it's rebuilt while reading */
|
||||
if (offset == handle->valid_size || handle->valid_size == 0) {
|
||||
if (offset == 0) {
|
||||
out_missing("Missing file '%s'.\n", handle->path);
|
||||
} else {
|
||||
out_missing("Missing data in file '%s' at offset %" PRIu64 ".\n", handle->path, offset);
|
||||
}
|
||||
errno = ENOENT;
|
||||
if (offset == 0) {
|
||||
out_missing(errno, "Missing file '%s'.\n", handle->path);
|
||||
} else {
|
||||
out_missing(errno, "Missing data in file '%s' at offset %" PRIu64 ".\n", handle->path, offset);
|
||||
}
|
||||
} else {
|
||||
out("Reading over the end from file '%s' at offset %" PRIu64 ".\n", handle->path, offset);
|
||||
errno = ENXIO;
|
||||
out(errno, "Reading over the end from file '%s' at offset %" PRIu64 ".\n", handle->path, offset);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -276,15 +276,15 @@ int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned c
|
|||
read_ret = pread(handle->f, block_buffer + count, block_size - count, offset + count);
|
||||
if (read_ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
out("Error reading file '%s' at offset %" PRIu64 " for size %u. %s.\n", handle->path, offset + count, block_size - count, strerror(errno));
|
||||
out(errno, "Error reading file '%s' at offset %" PRIu64 " for size %u. %s.\n", handle->path, offset + count, block_size - count, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (read_ret == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
out("Unexpected end of file '%s' at offset %" PRIu64 ". %s.\n", handle->path, offset, strerror(errno));
|
||||
if (errno == 0)
|
||||
errno = ENXIO;
|
||||
out(errno, "Unexpected end of file '%s' at offset %" PRIu64 ". %s.\n", handle->path, offset, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -300,7 +300,7 @@ int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned c
|
|||
ret = advise_read(&handle->advise, handle->f, offset, block_size);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
out("Error advising file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
out(errno, "Error advising file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -327,14 +327,14 @@ int handle_write(struct snapraid_handle* handle, block_off_t file_pos, unsigned
|
|||
write_ret = pwrite(handle->f, block_buffer + count, write_size - count, offset + count);
|
||||
if (write_ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error writing file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
log_fatal(errno, "Error writing file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (write_ret == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Unexpected 0 write to file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
errno = ENXIO;
|
||||
log_fatal(errno, "Unexpected 0 write to file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -350,7 +350,7 @@ int handle_write(struct snapraid_handle* handle, block_off_t file_pos, unsigned
|
|||
ret = advise_write(&handle->advise, handle->f, offset, block_size);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error advising file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
log_fatal(errno, "Error advising file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -370,7 +370,7 @@ int handle_utime(struct snapraid_handle* handle)
|
|||
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error timing file '%s'. %s.\n", handle->file->sub, strerror(errno));
|
||||
log_fatal(errno, "Error timing file '%s'. %s.\n", handle->file->sub, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -420,7 +420,7 @@ struct snapraid_handle* handle_mapping(struct snapraid_state* state, unsigned* h
|
|||
}
|
||||
if (!map) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal error for inconsistent disk mapping.\n");
|
||||
log_fatal(EINTERNAL, "Internal error for inconsistent disk mapping.\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ int handle_truncate(struct snapraid_handle* handle, struct snapraid_file* file);
|
|||
* Open a file.
|
||||
* The file is opened for reading.
|
||||
*/
|
||||
int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int mode, fptr* out, fptr* out_missing);
|
||||
int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int mode, log_ptr* out, log_ptr* out_missing);
|
||||
|
||||
/**
|
||||
* Close a file.
|
||||
|
|
@ -67,7 +67,7 @@ int handle_close(struct snapraid_handle* handle);
|
|||
* Read a block from a file.
|
||||
* If the read block is shorter, it's padded with 0.
|
||||
*/
|
||||
int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned char* block_buffer, unsigned block_size, fptr* out, fptr* out_missing);
|
||||
int handle_read(struct snapraid_handle* handle, block_off_t file_pos, unsigned char* block_buffer, unsigned block_size, log_ptr* out, log_ptr* out_missing);
|
||||
|
||||
/**
|
||||
* Write a block to a file.
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ static void import_file(struct snapraid_state* state, const char* path, uint64_t
|
|||
f = open(path, flags);
|
||||
if (f == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error opening file '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error opening file '%s'. %s.\n", path, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ static void import_file(struct snapraid_state* state, const char* path, uint64_t
|
|||
ret = advise_open(&advise, f);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error advising file '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error advising file '%s'. %s.\n", path, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ static void import_file(struct snapraid_state* state, const char* path, uint64_t
|
|||
ret = read(f, buffer, read_size);
|
||||
if (ret < 0 || (unsigned)ret != read_size) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error reading file '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error reading file '%s'. %s.\n", path, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ static void import_file(struct snapraid_state* state, const char* path, uint64_t
|
|||
ret = close(f);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error closing file '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error closing file '%s'. %s.\n", path, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -171,10 +171,10 @@ int state_import_fetch(struct snapraid_state* state, int rehash, struct snapraid
|
|||
if (f == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
if (errno == ENOENT) {
|
||||
log_fatal("DANGER! file '%s' disappeared.\n", path);
|
||||
log_fatal("If you moved it, please rerun the same command.\n");
|
||||
log_fatal(errno, "DANGER! file '%s' disappeared.\n", path);
|
||||
log_fatal(errno, "If you moved it, please rerun the same command.\n");
|
||||
} else {
|
||||
log_fatal("Error opening file '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error opening file '%s'. %s.\n", path, strerror(errno));
|
||||
}
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -183,7 +183,7 @@ int state_import_fetch(struct snapraid_state* state, int rehash, struct snapraid
|
|||
ret = pread(f, buffer, read_size, block->offset);
|
||||
if (ret < 0 || (unsigned)ret != read_size) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error reading file '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error reading file '%s'. %s.\n", path, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -191,7 +191,7 @@ int state_import_fetch(struct snapraid_state* state, int rehash, struct snapraid
|
|||
ret = close(f);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error closing file '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error closing file '%s'. %s.\n", path, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -209,8 +209,8 @@ int state_import_fetch(struct snapraid_state* state, int rehash, struct snapraid
|
|||
|
||||
if (memcmp(buffer_hash, hash, BLOCK_HASH_SIZE) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in data reading file '%s'.\n", path);
|
||||
log_fatal("Please don't change imported files while running.\n");
|
||||
log_fatal(EUSER, "Mismatch in data reading file '%s'.\n", path);
|
||||
log_fatal(EUSER, "Please don't change imported files while running.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -225,7 +225,7 @@ static void import_dir(struct snapraid_state* state, const char* dir)
|
|||
d = opendir(dir);
|
||||
if (!d) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error opening directory '%s'. %s.\n", dir, strerror(errno));
|
||||
log_fatal(errno, "Error opening directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -241,7 +241,7 @@ static void import_dir(struct snapraid_state* state, const char* dir)
|
|||
dd = readdir(d);
|
||||
if (dd == 0 && errno != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error reading directory '%s'. %s.\n", dir, strerror(errno));
|
||||
log_fatal(errno, "Error reading directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -268,7 +268,7 @@ static void import_dir(struct snapraid_state* state, const char* dir)
|
|||
if (st.st_mode == 0) {
|
||||
if (lstat(path_next, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal(errno, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -277,7 +277,7 @@ static void import_dir(struct snapraid_state* state, const char* dir)
|
|||
/* get lstat info about the file */
|
||||
if (lstat(path_next, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal(errno, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -293,7 +293,7 @@ static void import_dir(struct snapraid_state* state, const char* dir)
|
|||
|
||||
if (closedir(d) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error closing directory '%s'. %s.\n", dir, strerror(errno));
|
||||
log_fatal(errno, "Error closing directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -308,7 +308,7 @@ void state_import(struct snapraid_state* state, const char* dir)
|
|||
/* if the hash is not full */
|
||||
if (BLOCK_HASH_SIZE != HASH_MAX) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You cannot import files when using a reduced hash.\n");
|
||||
log_fatal(EUSER, "You cannot import files when using a reduced hash.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,31 +132,31 @@ void os_init(int opt)
|
|||
|
||||
/* initialize the thread local storage for strerror(), using free() as destructor */
|
||||
if (windows_key_create(&last_error, free) != 0) {
|
||||
log_fatal("Error calling windows_key_create().\n");
|
||||
log_fatal(EEXTERNAL, "Error calling windows_key_create().\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
tick_last = 0;
|
||||
if (windows_mutex_init(&tick_lock, 0) != 0) {
|
||||
log_fatal("Error calling windows_mutex_init().\n");
|
||||
log_fatal(EEXTERNAL, "Error calling windows_mutex_init().\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
ntdll = GetModuleHandle("NTDLL.DLL");
|
||||
if (!ntdll) {
|
||||
log_fatal("Error loading the NTDLL module.\n");
|
||||
log_fatal(EEXTERNAL, "Error loading the NTDLL module.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
kernel32 = GetModuleHandle("KERNEL32.DLL");
|
||||
if (!kernel32) {
|
||||
log_fatal("Error loading the KERNEL32 module.\n");
|
||||
log_fatal(EEXTERNAL, "Error loading the KERNEL32 module.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
dll_advapi32 = LoadLibrary("ADVAPI32.DLL");
|
||||
if (!dll_advapi32) {
|
||||
log_fatal("Error loading the ADVAPI32 module.\n");
|
||||
log_fatal(EEXTERNAL, "Error loading the ADVAPI32 module.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -260,7 +260,7 @@ static wchar_t* u8tou16(wchar_t* conv_buf, const char* src)
|
|||
ret = MultiByteToWideChar(CP_UTF8, 0, src, -1, conv_buf, CONV_MAX);
|
||||
|
||||
if (ret <= 0) {
|
||||
log_fatal("Error converting name '%s' from UTF-8 to UTF-16\n", src);
|
||||
log_fatal(EINTERNAL, "Error converting name '%s' from UTF-8 to UTF-16\n", src);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -276,7 +276,7 @@ static char* u16tou8ex(char* conv_buf, const wchar_t* src, size_t number_of_wcha
|
|||
|
||||
ret = WideCharToMultiByte(CP_UTF8, 0, src, number_of_wchar, conv_buf, CONV_MAX, 0, 0);
|
||||
if (ret <= 0) {
|
||||
log_fatal("Error converting from UTF-16 to UTF-8\n");
|
||||
log_fatal(EINTERNAL, "Error converting from UTF-16 to UTF-8\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -368,7 +368,7 @@ static wchar_t* convert_arg(wchar_t* conv_buf, const char* src, int only_if_requ
|
|||
ret = MultiByteToWideChar(CP_UTF8, 0, src, -1, dst, CONV_MAX - count);
|
||||
|
||||
if (ret <= 0) {
|
||||
log_fatal("Error converting name '%s' from UTF-8 to UTF-16\n", src);
|
||||
log_fatal(EINTERNAL, "Error converting name '%s' from UTF-8 to UTF-16\n", src);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -528,8 +528,8 @@ static int windows_info2stat(const BY_HANDLE_FILE_INFORMATION* info, const FILE_
|
|||
* "FILE_INVALID_FILE_ID, the identifier may only be described in 128 bit form."
|
||||
*/
|
||||
if (st->st_ino == (uint64_t)FILE_INVALID_FILE_ID) {
|
||||
log_fatal("Invalid inode number! Is this ReFS?\n");
|
||||
errno = EINVAL;
|
||||
log_fatal(errno, "Invalid inode number! Is this ReFS?\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -573,8 +573,8 @@ static int windows_stream2stat(const BY_HANDLE_FILE_INFORMATION* info, const FIL
|
|||
|
||||
/* in ReFS the IDs are 128 bit, and the 64 bit interface may fail */
|
||||
if (st->st_ino == (uint64_t)FILE_INVALID_FILE_ID) {
|
||||
log_fatal("Invalid inode number! Is this ReFS?\n");
|
||||
errno = EINVAL;
|
||||
log_fatal(errno, "Invalid inode number! Is this ReFS?\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -630,7 +630,7 @@ static void windows_finddata2dirent(const WIN32_FIND_DATAW* info, struct windows
|
|||
name = u16tou8ex(conv_buf, info->cFileName, wcslen(info->cFileName), &len);
|
||||
|
||||
if (len + 1 >= sizeof(dirent->d_name)) {
|
||||
log_fatal("Name too long\n");
|
||||
log_fatal(EINTERNAL, "Name too long\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -649,7 +649,7 @@ static int windows_stream2dirent(const BY_HANDLE_FILE_INFORMATION* info, const F
|
|||
name = u16tou8ex(conv_buf, stream->FileName, stream->FileNameLength / 2, &len);
|
||||
|
||||
if (len + 1 >= sizeof(dirent->d_name)) {
|
||||
log_fatal("Name too long\n");
|
||||
log_fatal(EINTERNAL, "Name too long\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -707,8 +707,8 @@ static void windows_errno(DWORD error)
|
|||
errno = EIO;
|
||||
break;
|
||||
default :
|
||||
log_fatal("Unexpected Windows error %lu.\n", error);
|
||||
errno = EIO;
|
||||
errno = ENXIO;
|
||||
log_fatal(errno, "Unexpected Windows error %lu.\n", error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1021,11 +1021,9 @@ int windows_fsync(int fd)
|
|||
* this error, but not enough sure to ignore it.
|
||||
* So, we use now an extended error reporting.
|
||||
*/
|
||||
log_fatal("Unexpected Windows INVALID_HANDLE error in FlushFileBuffers().\n");
|
||||
log_fatal("Are you using ATA-over-Ethernet ? Please report it.\n");
|
||||
|
||||
/* normal error processing */
|
||||
windows_errno(error);
|
||||
log_fatal(errno, "Unexpected Windows INVALID_HANDLE error in FlushFileBuffers().\n");
|
||||
log_fatal(errno, "Are you using ATA-over-Ethernet ? Please report it.\n");
|
||||
return -1;
|
||||
|
||||
case ERROR_ACCESS_DENIED :
|
||||
|
|
@ -1080,11 +1078,9 @@ static int windows_vsync(const wchar_t* volume)
|
|||
* this error, but not enough sure to ignore it.
|
||||
* So, we use now an extended error reporting.
|
||||
*/
|
||||
log_fatal("Unexpected Windows INVALID_HANDLE error in FlushFileBuffers().\n");
|
||||
log_fatal("Are you using ATA-over-Ethernet ? Please report it.\n");
|
||||
|
||||
/* normal error processing */
|
||||
windows_errno(error);
|
||||
log_fatal(errno, "Unexpected Windows INVALID_HANDLE error in FlushFileBuffers().\n");
|
||||
log_fatal(errno, "Are you using ATA-over-Ethernet ? Please report it.\n");
|
||||
return -1;
|
||||
|
||||
case ERROR_ACCESS_DENIED :
|
||||
|
|
@ -1443,7 +1439,7 @@ static windows_dir* windows_opendir_find(const char* dir)
|
|||
|
||||
dirstream = malloc(sizeof(windows_dir));
|
||||
if (!dirstream) {
|
||||
log_fatal("Low memory\n");
|
||||
log_fatal(EFAULT, "Low memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -1577,7 +1573,7 @@ static windows_dir* windows_opendir_stream(const char* dir)
|
|||
|
||||
dirstream = malloc(sizeof(windows_dir));
|
||||
if (!dirstream) {
|
||||
log_fatal("Low memory\n");
|
||||
log_fatal(EFAULT, "Low memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -1587,7 +1583,7 @@ static windows_dir* windows_opendir_stream(const char* dir)
|
|||
dirstream->buffer_size = 64 * 1024;
|
||||
dirstream->buffer = malloc(dirstream->buffer_size);
|
||||
if (!dirstream->buffer) {
|
||||
log_fatal("Low memory\n");
|
||||
log_fatal(EFAULT, "Low memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
|
@ -2148,7 +2144,7 @@ retry:
|
|||
* https://sourceforge.net/p/snapraid/discussion/1677233/thread/a7c25ba9/
|
||||
*/
|
||||
if (err == ERROR_NO_SYSTEM_RESOURCES) {
|
||||
log_fatal("Unexpected Windows ERROR_NO_SYSTEM_RESOURCES in pread(), retrying...\n");
|
||||
log_fatal(EEXTERNAL, "Unexpected Windows ERROR_NO_SYSTEM_RESOURCES in pread(), retrying...\n");
|
||||
Sleep(50);
|
||||
goto retry;
|
||||
}
|
||||
|
|
@ -2186,7 +2182,7 @@ retry:
|
|||
DWORD err = GetLastError();
|
||||
/* See windows_pread() for comments on this error management */
|
||||
if (err == ERROR_NO_SYSTEM_RESOURCES) {
|
||||
log_fatal("Unexpected Windows ERROR_NO_SYSTEM_RESOURCES in pwrite(), retrying...\n");
|
||||
log_fatal(EEXTERNAL, "Unexpected Windows ERROR_NO_SYSTEM_RESOURCES in pwrite(), retrying...\n");
|
||||
Sleep(50);
|
||||
goto retry;
|
||||
}
|
||||
|
|
@ -2475,7 +2471,7 @@ static int devscan(tommy_list* list)
|
|||
f = _wpopen(cmd, L"rt");
|
||||
if (!f) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to run '%s' (from popen).\n", u16tou8(conv_buf, cmd));
|
||||
log_fatal(errno, "Failed to run '%s' (from popen).\n", u16tou8(conv_buf, cmd));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -2493,13 +2489,13 @@ static int devscan(tommy_list* list)
|
|||
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to run '%s' (from pclose).\n", u16tou8(conv_buf, cmd));
|
||||
log_fatal(errno, "Failed to run '%s' (from pclose).\n", u16tou8(conv_buf, cmd));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to run '%s' with return code %xh.\n", u16tou8(conv_buf, cmd), ret);
|
||||
log_fatal(errno, "Failed to run '%s' with return code %xh.\n", u16tou8(conv_buf, cmd), ret);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -2539,7 +2535,7 @@ retry:
|
|||
if (!f) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("device:%s:%s:shell\n", file, name);
|
||||
log_fatal("Failed to run '%s' (from popen).\n", u16tou8(conv_buf, cmd));
|
||||
log_fatal(errno, "Failed to run '%s' (from popen).\n", u16tou8(conv_buf, cmd));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -2559,7 +2555,7 @@ retry:
|
|||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("device:%s:%s:shell\n", file, name);
|
||||
log_fatal("Failed to run '%s' (from pclose).\n", u16tou8(conv_buf, cmd));
|
||||
log_fatal(errno, "Failed to run '%s' (from pclose).\n", u16tou8(conv_buf, cmd));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -2771,7 +2767,7 @@ retry:
|
|||
if (!f) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("device:%s:%s:shell\n", file, name);
|
||||
log_fatal("Failed to run '%s' (from popen).\n", u16tou8(conv_buf, cmd));
|
||||
log_fatal(errno, "Failed to run '%s' (from popen).\n", u16tou8(conv_buf, cmd));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -2791,7 +2787,7 @@ retry:
|
|||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("device:%s:%s:shell\n", file, name);
|
||||
log_fatal("Failed to run '%s' (from pclose).\n", u16tou8(conv_buf, cmd));
|
||||
log_fatal(errno, "Failed to run '%s' (from pclose).\n", u16tou8(conv_buf, cmd));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -2861,7 +2857,7 @@ retry:
|
|||
if (!f) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("device:%s:%s:shell\n", file, name);
|
||||
log_fatal("Failed to run '%s' (from popen).\n", u16tou8(conv_buf, cmd));
|
||||
log_fatal(errno, "Failed to run '%s' (from popen).\n", u16tou8(conv_buf, cmd));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -2881,7 +2877,7 @@ retry:
|
|||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("device:%s:%s:shell\n", file, name);
|
||||
log_fatal("Failed to run '%s' (from pclose).\n", u16tou8(conv_buf, cmd));
|
||||
log_fatal(errno, "Failed to run '%s' (from pclose).\n", u16tou8(conv_buf, cmd));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -2908,7 +2904,7 @@ retry:
|
|||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("device:%s:%s:exit:%d\n", file, name, ret);
|
||||
log_fatal("Failed to run '%s' with return code %xh.\n", u16tou8(conv_buf, cmd), ret);
|
||||
log_fatal(errno, "Failed to run '%s' with return code %xh.\n", u16tou8(conv_buf, cmd), ret);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -3157,7 +3153,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation, int others)
|
|||
|
||||
if (devresolve(devinfo->mount, devinfo->file, sizeof(devinfo->file), devinfo->wfile, sizeof(devinfo->wfile)) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to resolve path '%s'.\n", devinfo->mount);
|
||||
log_fatal(EEXTERNAL, "Failed to resolve path '%s'.\n", devinfo->mount);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -3165,7 +3161,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation, int others)
|
|||
/* expand the tree of devices */
|
||||
if (devtree(devinfo, low) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to expand device '%s'.\n", devinfo->file);
|
||||
log_fatal(EEXTERNAL, "Failed to expand device '%s'.\n", devinfo->file);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -3175,7 +3171,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation, int others)
|
|||
if (others) {
|
||||
if (devscan(low) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to list other devices.\n");
|
||||
log_fatal(EEXTERNAL, "Failed to list other devices.\n");
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ void cmd_generate_file(const char* path, int size)
|
|||
if (remove(path) != 0) {
|
||||
if (errno != ENOENT) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error removing file %s\n", path);
|
||||
log_fatal(errno, "Error removing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -173,21 +173,21 @@ void cmd_generate_file(const char* path, int size)
|
|||
f = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_NOFOLLOW, 0600);
|
||||
if (f < 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error creating file %s\n", path);
|
||||
log_fatal(errno, "Error creating file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (write(f, data, size) != size) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error writing file %s\n", path);
|
||||
log_fatal(errno, "Error writing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (close(f) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error closing file %s\n", path);
|
||||
log_fatal(errno, "Error closing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -205,7 +205,7 @@ void cmd_generate_symlink(const char* path, const char* linkto)
|
|||
if (remove(path) != 0) {
|
||||
if (errno != ENOENT) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error removing file %s\n", path);
|
||||
log_fatal(errno, "Error removing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -213,7 +213,7 @@ void cmd_generate_symlink(const char* path, const char* linkto)
|
|||
|
||||
if (symlink(linkto, path) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error writing symlink %s\n", path);
|
||||
log_fatal(errno, "Error writing symlink %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -238,7 +238,7 @@ void cmd_generate(int disk, int size)
|
|||
if (mkdir(path, 0777) != 0) {
|
||||
if (errno != EEXIST) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error creating directory %s\n", path);
|
||||
log_fatal(errno, "Error creating directory %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -296,7 +296,7 @@ void cmd_write(const char* path, int size)
|
|||
|
||||
if (lstat(path, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error accessing %s\n", path);
|
||||
log_fatal(errno, "Error accessing %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -323,28 +323,28 @@ void cmd_write(const char* path, int size)
|
|||
f = open(path, O_WRONLY | O_BINARY | O_NOFOLLOW);
|
||||
if (f < 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error creating file %s\n", path);
|
||||
log_fatal(errno, "Error creating file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (lseek(f, off, SEEK_SET) != off) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error seeking file %s\n", path);
|
||||
log_fatal(errno, "Error seeking file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (write(f, data, size) != size) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error writing file %s\n", path);
|
||||
log_fatal(errno, "Error writing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (close(f) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error closing file %s\n", path);
|
||||
log_fatal(errno, "Error closing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -372,7 +372,7 @@ void cmd_damage(const char* path, int size)
|
|||
|
||||
if (lstat(path, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error accessing %s\n", path);
|
||||
log_fatal(errno, "Error accessing %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -400,21 +400,21 @@ void cmd_damage(const char* path, int size)
|
|||
f = open(path, O_RDWR | O_BINARY | O_NOFOLLOW);
|
||||
if (f < 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error creating file %s\n", path);
|
||||
log_fatal(errno, "Error creating file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (lseek(f, off, SEEK_SET) != off) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error seeking file %s\n", path);
|
||||
log_fatal(errno, "Error seeking file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (read(f, data, size) != size) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error writing file %s\n", path);
|
||||
log_fatal(errno, "Error writing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -423,28 +423,28 @@ void cmd_damage(const char* path, int size)
|
|||
|
||||
if (lseek(f, off, SEEK_SET) != off) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error seeking file %s\n", path);
|
||||
log_fatal(errno, "Error seeking file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (write(f, data, size) != size) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error writing file %s\n", path);
|
||||
log_fatal(errno, "Error writing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (fallback(f, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error setting time for file %s\n", path);
|
||||
log_fatal(errno, "Error setting time for file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (close(f) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error closing file %s\n", path);
|
||||
log_fatal(errno, "Error closing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -464,7 +464,7 @@ void cmd_append(const char* path, int size)
|
|||
|
||||
if (lstat(path, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error accessing %s\n", path);
|
||||
log_fatal(errno, "Error accessing %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -480,21 +480,21 @@ void cmd_append(const char* path, int size)
|
|||
f = open(path, O_WRONLY | O_APPEND | O_BINARY | O_NOFOLLOW);
|
||||
if (f < 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error opening file %s\n", path);
|
||||
log_fatal(errno, "Error opening file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (write(f, data, size) != size) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error writing file %s\n", path);
|
||||
log_fatal(errno, "Error writing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (close(f) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error closing file %s\n", path);
|
||||
log_fatal(errno, "Error closing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -515,7 +515,7 @@ void cmd_truncate(const char* path, int size)
|
|||
|
||||
if (lstat(path, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error accessing %s\n", path);
|
||||
log_fatal(errno, "Error accessing %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -538,21 +538,21 @@ void cmd_truncate(const char* path, int size)
|
|||
f = open(path, O_WRONLY | O_BINARY | O_NOFOLLOW);
|
||||
if (f < 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error opening file %s\n", path);
|
||||
log_fatal(errno, "Error opening file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (ftruncate(f, off) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error truncating file %s\n", path);
|
||||
log_fatal(errno, "Error truncating file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (close(f) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error closing file %s\n", path);
|
||||
log_fatal(errno, "Error closing file %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -567,7 +567,7 @@ void cmd_delete(const char* path)
|
|||
{
|
||||
if (remove(path) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error removing %s\n", path);
|
||||
log_fatal(errno, "Error removing %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -586,7 +586,7 @@ void cmd_change(const char* path, int size)
|
|||
|
||||
if (lstat(path, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error accessing %s\n", path);
|
||||
log_fatal(errno, "Error accessing %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -597,7 +597,7 @@ void cmd_change(const char* path, int size)
|
|||
/* delete */
|
||||
if (remove(path) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error removing %s\n", path);
|
||||
log_fatal(errno, "Error removing %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -607,7 +607,7 @@ void cmd_change(const char* path, int size)
|
|||
|
||||
if (remove(path) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error removing %s\n", path);
|
||||
log_fatal(errno, "Error removing %s\n", path);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,15 +145,15 @@ void parity_overflow(struct snapraid_state* state, data_off_t size)
|
|||
if (parity_pos >= blockalloc) {
|
||||
found = 1;
|
||||
log_tag("outofparity:%s:%s\n", disk->name, esc_tag(file->sub, esc_buffer));
|
||||
log_fatal("outofparity %s%s\n", disk->dir, file->sub);
|
||||
log_fatal(ESOFT, "outofparity %s%s\n", disk->dir, file->sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
log_fatal("\nInsufficient parity space. Data requires more parity than available.\n");
|
||||
log_fatal("Move the 'outofparity' files to a larger disk.\n");
|
||||
log_fatal(ESOFT, "\nInsufficient parity space. Data requires more parity than available.\n");
|
||||
log_fatal(ESOFT, "Move the 'outofparity' files to a larger disk.\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -200,7 +200,7 @@ int parity_create(struct snapraid_parity_handle* handle, const struct snapraid_p
|
|||
split->f = open(split->path, flags, 0600);
|
||||
if (split->f == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error opening parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
log_fatal(errno, "Error opening parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -212,7 +212,7 @@ int parity_create(struct snapraid_parity_handle* handle, const struct snapraid_p
|
|||
ret = fstat(split->f, &split->st);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error accessing parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
log_fatal(errno, "Error accessing parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -231,7 +231,7 @@ int parity_create(struct snapraid_parity_handle* handle, const struct snapraid_p
|
|||
/* ensure that the resulting size if block aligned */
|
||||
if ((split->size & block_mask) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in preallocated size of parity file '%s' with size %" PRIu64 " and block %u .\n", split->path, split->size, block_size);
|
||||
log_fatal(ESOFT, "Error in preallocated size of parity file '%s' with size %" PRIu64 " and block %u .\n", split->path, split->size, block_size);
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -240,7 +240,7 @@ int parity_create(struct snapraid_parity_handle* handle, const struct snapraid_p
|
|||
ret = advise_open(&split->advise, split->f);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error advising parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
log_fatal(errno, "Error advising parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -397,28 +397,28 @@ static int parity_handle_fill(struct snapraid_split_handle* split, data_off_t si
|
|||
|
||||
spaceholder_f = open(spaceholder_path, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0600);
|
||||
if (spaceholder_f == -1) {
|
||||
log_fatal("Failed to create space holder file '%s'.\n", spaceholder_path);
|
||||
log_fatal(errno, "Failed to create space holder file '%s'.\n", spaceholder_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* note that in Windows ftruncate is really allocating space */
|
||||
if (ftruncate(spaceholder_f, WINDOWS_SPACEHOLDER_SIZE) != 0) {
|
||||
log_fatal("WARNING Failed to resize the space holder file '%s' to %u bytes.\n", spaceholder_path, WINDOWS_SPACEHOLDER_SIZE);
|
||||
log_fatal("Assuming that no more space is available.\n");
|
||||
log_fatal(errno, "WARNING Failed to resize the space holder file '%s' to %u bytes.\n", spaceholder_path, WINDOWS_SPACEHOLDER_SIZE);
|
||||
log_fatal(errno, "Assuming that no more space is available.\n");
|
||||
close(spaceholder_f);
|
||||
remove(spaceholder_path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fsync(spaceholder_f) != 0) {
|
||||
log_fatal("Failed to sync the space holder file '%s'.\n", spaceholder_path);
|
||||
log_fatal(errno, "Failed to sync the space holder file '%s'.\n", spaceholder_path);
|
||||
close(spaceholder_f);
|
||||
remove(spaceholder_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (close(spaceholder_f) != 0) {
|
||||
log_fatal("Failed to close the space holder file '%s'.\n", spaceholder_path);
|
||||
log_fatal(errno, "Failed to close the space holder file '%s'.\n", spaceholder_path);
|
||||
remove(spaceholder_path);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -468,7 +468,7 @@ static int parity_handle_fill(struct snapraid_split_handle* split, data_off_t si
|
|||
/* ensure that the resulting size if block aligned */
|
||||
if ((base & block_mask) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency in requested parity size %" PRIu64 " with block %u\n", base, block_size);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency in requested parity size %" PRIu64 " with block %u\n", base, block_size);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -476,8 +476,8 @@ static int parity_handle_fill(struct snapraid_split_handle* split, data_off_t si
|
|||
#ifdef _WIN32
|
||||
/* now delete the spaceholder file */
|
||||
if (remove(spaceholder_path) != 0) {
|
||||
log_fatal("WARNING Failed to remove the space holder file '%s'.\n", spaceholder_path);
|
||||
log_fatal("Continuing anyway.\n");
|
||||
log_error(errno, "WARNING Failed to remove the space holder file '%s'.\n", spaceholder_path);
|
||||
log_error(errno, "Continuing anyway.\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -511,7 +511,7 @@ static int parity_handle_chsize(struct snapraid_split_handle* split, data_off_t
|
|||
ret = fstat(split->f, &split->st);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error accessing parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
log_fatal(errno, "Error accessing parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -521,12 +521,12 @@ static int parity_handle_chsize(struct snapraid_split_handle* split, data_off_t
|
|||
/* LCOV_EXCL_START */
|
||||
if (f_dir > 0) {
|
||||
if (f_errno == ENOSPC) {
|
||||
log_fatal("Failed to grow parity file '%s' to size %" PRIu64 " due lack of space.\n", split->path, size);
|
||||
log_fatal(errno, "Failed to grow parity file '%s' to size %" PRIu64 " due lack of space.\n", split->path, size);
|
||||
} else {
|
||||
log_fatal("Error growing parity file '%s' to size %" PRIu64 ". Do you have enough space? %s.\n", split->path, size, strerror(f_errno));
|
||||
log_fatal(errno, "Error growing parity file '%s' to size %" PRIu64 ". Do you have enough space? %s.\n", split->path, size, strerror(f_errno));
|
||||
}
|
||||
} else {
|
||||
log_fatal("Error truncating parity file '%s' to size %" PRIu64 ". %s.\n", split->path, size, strerror(f_errno));
|
||||
log_fatal(errno, "Error truncating parity file '%s' to size %" PRIu64 ". %s.\n", split->path, size, strerror(f_errno));
|
||||
}
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -590,8 +590,8 @@ int parity_chsize(struct snapraid_parity_handle* handle, struct snapraid_parity*
|
|||
|
||||
if ((run & block_mask) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency in split '%s' size with extra '%" PRIu64 "' bytes.\n", split->path, run & block_mask);
|
||||
errno = ENXIO;
|
||||
log_fatal(EINTERNAL, "Internal inconsistency in split '%s' size with extra '%" PRIu64 "' bytes.\n", split->path, run & block_mask);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -610,14 +610,14 @@ int parity_chsize(struct snapraid_parity_handle* handle, struct snapraid_parity*
|
|||
|
||||
if (split->st.st_size > run) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Unexpected over resizing parity file '%s' to size %" PRIu64 " resulting in size %" PRIu64 ".\n", split->path, run, (uint64_t)split->st.st_size);
|
||||
errno = ENXIO;
|
||||
log_fatal(errno, "Unexpected over resizing parity file '%s' to size %" PRIu64 " resulting in size %" PRIu64 ".\n", split->path, run, (uint64_t)split->st.st_size);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
} else if (is_fixed && split->st.st_size < run) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed restoring parity file '%s' to size %" PRIu64 " resulting in size %" PRIu64 ".\n", split->path, run, (uint64_t)split->st.st_size);
|
||||
errno = ENXIO;
|
||||
log_fatal(errno, "Failed restoring parity file '%s' to size %" PRIu64 " resulting in size %" PRIu64 ".\n", split->path, run, (uint64_t)split->st.st_size);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
} else {
|
||||
|
|
@ -626,7 +626,7 @@ int parity_chsize(struct snapraid_parity_handle* handle, struct snapraid_parity*
|
|||
|
||||
if ((run & block_mask) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency in final parity size %" PRIu64 " with block size %u\n", run, block_size);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency in final parity size %" PRIu64 " with block size %u\n", run, block_size);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -642,8 +642,8 @@ int parity_chsize(struct snapraid_parity_handle* handle, struct snapraid_parity*
|
|||
/* if we cannot allocate all the space */
|
||||
if (size != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to allocate all the required parity space. You miss %" PRIu64 " bytes.\n", size);
|
||||
errno = ENXIO;
|
||||
log_fatal(errno, "Failed to allocate all the required parity space. You miss %" PRIu64 " bytes.\n", size);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -693,7 +693,7 @@ int parity_open(struct snapraid_parity_handle* handle, const struct snapraid_par
|
|||
split->f = open_noatime(split->path, flags);
|
||||
if (split->f == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error opening parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
log_fatal(errno, "Error opening parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -705,7 +705,7 @@ int parity_open(struct snapraid_parity_handle* handle, const struct snapraid_par
|
|||
ret = fstat(split->f, &split->st);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error accessing parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
log_fatal(errno, "Error accessing parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -724,7 +724,7 @@ int parity_open(struct snapraid_parity_handle* handle, const struct snapraid_par
|
|||
/* ensure that the resulting size if block aligned */
|
||||
if ((split->size & block_mask) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in preallocated size of parity file '%s' with size %" PRIu64 " and block %u .\n", split->path, split->size, block_size);
|
||||
log_fatal(ESOFT, "Error in preallocated size of parity file '%s' with size %" PRIu64 " and block %u .\n", split->path, split->size, block_size);
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -733,7 +733,7 @@ int parity_open(struct snapraid_parity_handle* handle, const struct snapraid_par
|
|||
ret = advise_open(&split->advise, split->f);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error advising parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
log_fatal(errno, "Error advising parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -767,7 +767,7 @@ int parity_sync(struct snapraid_parity_handle* handle)
|
|||
ret = fsync(split->f);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error syncing parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
log_fatal(errno, "Error syncing parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -790,7 +790,7 @@ int parity_truncate(struct snapraid_parity_handle* handle)
|
|||
ret = ftruncate(split->f, split->valid_size);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error truncating the parity file '%s' to size %" PRIu64 ". %s.\n", split->path, split->valid_size, strerror(errno));
|
||||
log_fatal(errno, "Error truncating the parity file '%s' to size %" PRIu64 ". %s.\n", split->path, split->valid_size, strerror(errno));
|
||||
f_ret = -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
||||
|
|
@ -816,7 +816,7 @@ int parity_close(struct snapraid_parity_handle* handle)
|
|||
/* This is a serious error, as it may be the result of a failed write */
|
||||
/* identified at later time. */
|
||||
/* In a normal file-system (not NFS) it should never happen */
|
||||
log_fatal("Error closing parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
log_fatal(errno, "Error closing parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
f_ret = -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
||||
|
|
@ -862,7 +862,8 @@ int parity_write(struct snapraid_parity_handle* handle, block_off_t pos, unsigne
|
|||
split = parity_split_find(handle, &offset);
|
||||
if (!split) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Writing parity data outside range at extra offset %" PRIu64 ".\n", offset);
|
||||
errno = ENXIO;
|
||||
log_fatal(errno, "Writing parity data outside range at extra offset %" PRIu64 ".\n", offset);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -879,17 +880,17 @@ int parity_write(struct snapraid_parity_handle* handle, block_off_t pos, unsigne
|
|||
if (write_ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
if (errno == ENOSPC) {
|
||||
log_fatal("Failed to grow parity file '%s' using write due lack of space.\n", split->path);
|
||||
log_fatal(errno, "Failed to grow parity file '%s' using write due lack of space.\n", split->path);
|
||||
} else {
|
||||
log_fatal("Error writing parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
log_fatal(errno, "Error writing parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
}
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (write_ret == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Unexpected 0 write to file '%s'. %s.\n", split->path, strerror(errno));
|
||||
errno = ENXIO;
|
||||
log_fatal(errno, "Unexpected 0 write to file '%s'. %s.\n", split->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -900,7 +901,7 @@ int parity_write(struct snapraid_parity_handle* handle, block_off_t pos, unsigne
|
|||
ret = advise_write(&split->advise, split->f, offset, block_size);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error advising parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
log_fatal(errno, "Error advising parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -908,7 +909,7 @@ int parity_write(struct snapraid_parity_handle* handle, block_off_t pos, unsigne
|
|||
return 0;
|
||||
}
|
||||
|
||||
int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned char* block_buffer, unsigned block_size, fptr* out)
|
||||
int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned char* block_buffer, unsigned block_size, log_ptr* out)
|
||||
{
|
||||
ssize_t read_ret;
|
||||
data_off_t offset;
|
||||
|
|
@ -921,7 +922,8 @@ int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned
|
|||
split = parity_split_find(handle, &offset);
|
||||
if (!split) {
|
||||
/* LCOV_EXCL_START */
|
||||
out("Reading parity data outside range at extra offset %" PRIu64 ".\n", offset);
|
||||
errno = ENXIO;
|
||||
out(errno, "Reading parity data outside range at extra offset %" PRIu64 ".\n", offset);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -929,7 +931,8 @@ int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned
|
|||
/* if read is completely out of the valid range */
|
||||
if (offset >= split->valid_size) {
|
||||
/* LCOV_EXCL_START */
|
||||
out("Reading over the end from parity file '%s' at offset %" PRIu64 " for size %u.\n", split->path, offset, block_size);
|
||||
errno = ENXIO;
|
||||
out(errno, "Reading over the end from parity file '%s' at offset %" PRIu64 " for size %u.\n", split->path, offset, block_size);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -942,15 +945,15 @@ int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned
|
|||
read_ret = pread(split->f, block_buffer + count, block_size - count, offset + count);
|
||||
if (read_ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
out("Error reading parity file '%s' at offset %" PRIu64 " for size %u. %s.\n", split->path, offset + count, block_size - count, strerror(errno));
|
||||
out(errno, "Error reading parity file '%s' at offset %" PRIu64 " for size %u. %s.\n", split->path, offset + count, block_size - count, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (read_ret == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
out("Unexpected end of parity file '%s' at offset %" PRIu64 ". %s.\n", split->path, offset, strerror(errno));
|
||||
if (errno == 0)
|
||||
errno = ENXIO;
|
||||
out(errno, "Unexpected end of parity file '%s' at offset %" PRIu64 ". %s.\n", split->path, offset, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -961,7 +964,7 @@ int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned
|
|||
ret = advise_read(&split->advise, split->f, offset, block_size);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
out("Error advising parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
out(errno, "Error advising parity file '%s'. %s.\n", split->path, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ int parity_close(struct snapraid_parity_handle* handle);
|
|||
/**
|
||||
* Read a block from the parity file.
|
||||
*/
|
||||
int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned char* block_buffer, unsigned block_size, fptr* out);
|
||||
int parity_read(struct snapraid_parity_handle* handle, block_off_t pos, unsigned char* block_buffer, unsigned block_size, log_ptr* out);
|
||||
|
||||
/**
|
||||
* Write a block in the parity file.
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ static int clean_dir(const char* dir)
|
|||
d = opendir(dir);
|
||||
if (!d) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error opening pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
log_fatal(errno, "Error opening pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ static int clean_dir(const char* dir)
|
|||
dd = readdir(d);
|
||||
if (dd == 0 && errno != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error reading pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
log_fatal(errno, "Error reading pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ static int clean_dir(const char* dir)
|
|||
if (st.st_mode == 0) {
|
||||
if (lstat(path_next, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal(errno, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -123,7 +123,7 @@ static int clean_dir(const char* dir)
|
|||
/* get lstat info about the file */
|
||||
if (lstat(path_next, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal(errno, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -143,13 +143,13 @@ static int clean_dir(const char* dir)
|
|||
/* in Windows just ignore EACCES errors removing directories */
|
||||
/* because it could happen that the directory is in use */
|
||||
/* and it cannot be removed */
|
||||
log_fatal("Directory '%s' not removed because it's in use.\n", path_next);
|
||||
log_fatal(errno, "Directory '%s' not removed because it's in use.\n", path_next);
|
||||
full = 1;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error removing pool directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal(errno, "Error removing pool directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -166,7 +166,7 @@ static int clean_dir(const char* dir)
|
|||
|
||||
if (closedir(d) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error closing pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
log_fatal(errno, "Error closing pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -186,7 +186,7 @@ static void read_dir(tommy_hashdyn* poolset, const char* base_dir, const char* s
|
|||
d = opendir(dir);
|
||||
if (!d) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error opening pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
log_fatal(errno, "Error opening pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -202,7 +202,7 @@ static void read_dir(tommy_hashdyn* poolset, const char* base_dir, const char* s
|
|||
dd = readdir(d);
|
||||
if (dd == 0 && errno != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error reading pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
log_fatal(errno, "Error reading pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -226,7 +226,7 @@ static void read_dir(tommy_hashdyn* poolset, const char* base_dir, const char* s
|
|||
if (st.st_mode == 0) {
|
||||
if (lstat(path_next, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal(errno, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -235,7 +235,7 @@ static void read_dir(tommy_hashdyn* poolset, const char* base_dir, const char* s
|
|||
/* get lstat info about the file */
|
||||
if (lstat(path_next, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal(errno, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -249,7 +249,7 @@ static void read_dir(tommy_hashdyn* poolset, const char* base_dir, const char* s
|
|||
ret = readlink(path_next, linkto, sizeof(linkto));
|
||||
if (ret < 0 || ret >= PATH_MAX) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in readlink symlink '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal(errno, "Error in readlink symlink '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -271,7 +271,7 @@ static void read_dir(tommy_hashdyn* poolset, const char* base_dir, const char* s
|
|||
|
||||
if (closedir(d) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error closing pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
log_fatal(errno, "Error closing pool directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -293,7 +293,7 @@ static void remove_link(void* void_arg, void* void_pool)
|
|||
ret = remove(path);
|
||||
if (ret < 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error removing symlink '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error removing symlink '%s'. %s.\n", path, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -342,7 +342,7 @@ static void make_link(tommy_hashdyn* poolset, const char* pool_dir, const char*
|
|||
ret = remove(path);
|
||||
if (ret < 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error removing symlink '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error removing symlink '%s'. %s.\n", path, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -365,17 +365,17 @@ static void make_link(tommy_hashdyn* poolset, const char* pool_dir, const char*
|
|||
ret = symlink(linkto_exported, path);
|
||||
if (ret != 0) {
|
||||
if (errno == EEXIST) {
|
||||
log_fatal("WARNING! Duplicate pooling for '%s'\n", path);
|
||||
log_fatal(errno, "WARNING! Duplicate pooling for '%s'\n", path);
|
||||
#ifdef _WIN32
|
||||
} else if (errno == EPERM) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You must run as Administrator to be able to create symlinks.\n");
|
||||
log_fatal(errno, "You must run as Administrator to be able to create symlinks.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
#endif
|
||||
} else {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error writing symlink '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error writing symlink '%s'. %s.\n", path, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -385,7 +385,7 @@ static void make_link(tommy_hashdyn* poolset, const char* pool_dir, const char*
|
|||
ret = lmtime(path, mtime_sec, mtime_nsec);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error setting time to symlink '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error setting time to symlink '%s'. %s.\n", path, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -404,7 +404,7 @@ void state_pool(struct snapraid_state* state)
|
|||
|
||||
if (state->pool[0] == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("To use the 'pool' command you must set the pool directory in the configuration file\n");
|
||||
log_fatal(EUSER, "To use the 'pool' command you must set the pool directory in the configuration file\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -578,5 +578,16 @@ extern volatile int global_interrupt;
|
|||
*/
|
||||
#define WINDOWS_SPACEHOLDER_SIZE (256 * 1024 * 1024)
|
||||
|
||||
/**
|
||||
* Generic errors
|
||||
*/
|
||||
#define EINTERNAL EFAULT /**< Internal assertion failed. */
|
||||
#define EDATA EIO /**< Silent data corruption. */
|
||||
#define ESOFT EINVAL /**< Software error, like permission denied. */
|
||||
#define EUSER EINVAL /**< Invalid value specified by the user. */
|
||||
#define EEXTERNAL EINVAL /**< Invalid external interface behaviour. */
|
||||
#define ECONTENT EINVAL /**< Invalid content file. */
|
||||
#define EENVIRONMENT EINVAL /**< Invalid physical environment, like temperature too high. */
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ void state_rehash(struct snapraid_state* state)
|
|||
if (state->prevhash != HASH_UNDEFINED) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("summary:exit:already_in_progress\n");
|
||||
log_fatal("You already have a rehash in progress.\n");
|
||||
log_fatal(EUSER, "You already have a rehash in progress.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ void state_rehash(struct snapraid_state* state)
|
|||
if (state->hash == state->besthash) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("summary:exit:not_required\n");
|
||||
log_fatal("You are already using the best hash for your platform.\n");
|
||||
log_fatal(EUSER, "You are already using the best hash for your platform.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -60,7 +60,7 @@ void state_rehash(struct snapraid_state* state)
|
|||
state->hash = state->besthash;
|
||||
if (randomize(state->hashseed, HASH_MAX) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to get random values.\n");
|
||||
log_fatal(errno, "Failed to get random values.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ void state_rehash(struct snapraid_state* state)
|
|||
|
||||
if (info_get_rehash(info)) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency for a rehash already in progress\n");
|
||||
log_fatal(EINTERNAL, "Internal inconsistency for a rehash already in progress\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
124
cmdline/scan.c
124
cmdline/scan.c
|
|
@ -161,7 +161,7 @@ static void scan_link(struct snapraid_scan* scan, int is_diff, const char* sub,
|
|||
/* check if multiple files have the same name */
|
||||
if (link_flag_has(slink, FILE_IS_PRESENT)) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency for link '%s%s'\n", disk->dir, sub);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency for link '%s%s'\n", disk->dir, sub);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -340,7 +340,7 @@ static void scan_file_deallocate(struct snapraid_scan* scan, struct snapraid_fil
|
|||
/* so at this point ::first_free_block is always at 0, and we don't need to update it */
|
||||
if (disk->first_free_block != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency for first free position at '%u' deallocating file '%s'\n", disk->first_free_block, file->sub);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency for first free position at '%u' deallocating file '%s'\n", disk->first_free_block, file->sub);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -380,7 +380,7 @@ static void scan_file_deallocate(struct snapraid_scan* scan, struct snapraid_fil
|
|||
break;
|
||||
default :
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency in file '%s' deallocating block '%u:%u' state %u\n", file->sub, i, file->blockmax, block_state);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency in file '%s' deallocating block '%u:%u' state %u\n", file->sub, i, file->blockmax, block_state);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -411,7 +411,7 @@ static void scan_file_delayed_allocate(struct snapraid_scan* scan, struct snapra
|
|||
|
||||
if (filephy(path_next, file->size, &file->physical) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in getting the physical offset of file '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal(errno, "Error in getting the physical offset of file '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -552,7 +552,7 @@ static void scan_file_refresh(struct snapraid_scan* scan, const char* sub, struc
|
|||
|
||||
if (lstat_sync(path_next, &synced_st, physical) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in stat file '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal(errno, "Error in stat file '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -574,9 +574,9 @@ static void scan_file_refresh(struct snapraid_scan* scan, const char* sub, struc
|
|||
* Why is the file size reported incorrectly for files that are still being written to?
|
||||
* http://blogs.msdn.com/b/oldnewthing/archive/2011/12/26/10251026.aspx
|
||||
*/
|
||||
log_fatal("WARNING! Detected uncached time change from %" PRIu64 ".%09u to %" PRIu64 ".%09u for file '%s'\n",
|
||||
log_fatal(ESOFT, "WARNING! Detected uncached time change from %" PRIu64 ".%09u to %" PRIu64 ".%09u for file '%s'\n",
|
||||
(uint64_t)st->st_mtime, (uint32_t)st->st_mtimensec, (uint64_t)synced_st.st_mtime, (uint32_t)synced_st.st_mtimensec, sub);
|
||||
log_fatal("It's better if you run SnapRAID without other processes running.\n");
|
||||
log_fatal(ESOFT, "It's better if you run SnapRAID without other processes running.\n");
|
||||
#endif
|
||||
st->st_mtime = synced_st.st_mtime;
|
||||
st->st_mtimensec = synced_st.st_mtimensec;
|
||||
|
|
@ -584,26 +584,26 @@ static void scan_file_refresh(struct snapraid_scan* scan, const char* sub, struc
|
|||
|
||||
if (st->st_size != synced_st.st_size) {
|
||||
#ifndef _WIN32
|
||||
log_fatal("WARNING! Detected uncached size change from %" PRIu64 " to %" PRIu64 " for file '%s'\n",
|
||||
log_fatal(ESOFT, "WARNING! Detected uncached size change from %" PRIu64 " to %" PRIu64 " for file '%s'\n",
|
||||
(uint64_t)st->st_size, (uint64_t)synced_st.st_size, sub);
|
||||
log_fatal("It's better if you run SnapRAID without other processes running.\n");
|
||||
log_fatal(ESOFT, "It's better if you run SnapRAID without other processes running.\n");
|
||||
#endif
|
||||
st->st_size = synced_st.st_size;
|
||||
}
|
||||
|
||||
if (st->st_nlink != synced_st.st_nlink) {
|
||||
#ifndef _WIN32
|
||||
log_fatal("WARNING! Detected uncached nlink change from %u to %u for file '%s'\n",
|
||||
log_fatal(ESOFT, "WARNING! Detected uncached nlink change from %u to %u for file '%s'\n",
|
||||
(uint32_t)st->st_nlink, (uint32_t)synced_st.st_nlink, sub);
|
||||
log_fatal("It's better if you run SnapRAID without other processes running.\n");
|
||||
log_fatal(ESOFT, "It's better if you run SnapRAID without other processes running.\n");
|
||||
#endif
|
||||
st->st_nlink = synced_st.st_nlink;
|
||||
}
|
||||
|
||||
if (st->st_ino != synced_st.st_ino) {
|
||||
log_fatal("DANGER! Detected uncached inode change from %" PRIu64 " to %" PRIu64 " for file '%s'\n",
|
||||
log_fatal(ESOFT, "DANGER! Detected uncached inode change from %" PRIu64 " to %" PRIu64 " for file '%s'\n",
|
||||
(uint64_t)st->st_ino, (uint64_t)synced_st.st_ino, sub);
|
||||
log_fatal("It's better if you run SnapRAID without other processes running.\n");
|
||||
log_fatal(ESOFT, "It's better if you run SnapRAID without other processes running.\n");
|
||||
/* at this point, it's too late to change inode */
|
||||
/* and having inconsistent inodes may result to internal failures */
|
||||
/* so, it's better to abort */
|
||||
|
|
@ -756,7 +756,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
|
|||
/* if has_volatile_hardlinks is true, the nlink value is not reliable */
|
||||
if (!disk->has_volatile_hardlinks && st->st_nlink == 1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inode '%" PRIu64 "' inconsistency for file '%s%s' already present\n", (uint64_t)st->st_ino, disk->dir, sub);
|
||||
log_fatal(EINTERNAL, "Internal inode '%" PRIu64 "' inconsistency for file '%s%s' already present\n", (uint64_t)st->st_ino, disk->dir, sub);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -839,7 +839,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
|
|||
/* if has_volatile_hardlinks is true, the nlink value is not reliable */
|
||||
if (!disk->has_volatile_hardlinks && st->st_nlink == 1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inode '%" PRIu64 "' inconsistency for files '%s%s' and '%s%s' with same inode but different attributes: size %" PRIu64 "?%" PRIu64 ", sec %" PRIu64 "?%" PRIu64 ", nsec %d?%d\n",
|
||||
log_fatal(EINTERNAL, "Internal inode '%" PRIu64 "' inconsistency for files '%s%s' and '%s%s' with same inode but different attributes: size %" PRIu64 "?%" PRIu64 ", sec %" PRIu64 "?%" PRIu64 ", nsec %d?%d\n",
|
||||
file->inode, disk->dir, sub, disk->dir, file->sub,
|
||||
file->size, (uint64_t)st->st_size,
|
||||
file->mtime_sec, (uint64_t)st->st_mtime,
|
||||
|
|
@ -900,7 +900,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
|
|||
/* here the inode has to be different, otherwise we would have found it before */
|
||||
if (file->inode == st->st_ino) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency in inode '%" PRIu64 "' for files '%s%s' as unexpected matching\n", file->inode, disk->dir, sub);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency in inode '%" PRIu64 "' for files '%s%s' as unexpected matching\n", file->inode, disk->dir, sub);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -909,7 +909,7 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
|
|||
/* for sure it cannot be already present */
|
||||
if (file_flag_has(file, FILE_IS_PRESENT)) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency in path for file '%s%s' matching and already present\n", disk->dir, sub);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency in path for file '%s%s' matching and already present\n", disk->dir, sub);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1013,11 +1013,11 @@ static void scan_file(struct snapraid_scan* scan, int is_diff, const char* sub,
|
|||
if (is_original_file_size_different_than_zero && st->st_size == 0) {
|
||||
if (!state->opt.force_zero) {
|
||||
/* 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", fmt_poll(disk, sub, esc_buffer));
|
||||
log_fatal(ESOFT, "The file '%s%s' has unexpected zero size!\n", disk->dir, sub);
|
||||
log_fatal(ESOFT, "It's possible that after a kernel crash this file was lost,\n");
|
||||
log_fatal(ESOFT, "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);
|
||||
log_fatal(ESOFT, "If this an expected condition you can '%s' anyway using 'snapraid --force-zero %s'\n", state->command, state->command);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -1153,7 +1153,7 @@ static void scan_emptydir(struct snapraid_scan* scan, const char* sub)
|
|||
/* check if multiple files have the same name */
|
||||
if (dir_flag_has(dir, FILE_IS_PRESENT)) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency for dir '%s%s'\n", disk->dir, sub);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency for dir '%s%s'\n", disk->dir, sub);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1231,7 +1231,7 @@ struct stat* dstat(const char* file, struct stat* st)
|
|||
{
|
||||
if (lstat(file, st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in stat file/directory '%s'. %s.\n", file, strerror(errno));
|
||||
log_fatal(errno, "Error in stat file/directory '%s'. %s.\n", file, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1262,11 +1262,11 @@ static int scan_sub(struct snapraid_scan* scan, int level, int is_diff, char* pa
|
|||
d = opendir(path_next);
|
||||
if (!d) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error opening directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal(errno, "Error opening directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
if (level == 0)
|
||||
log_fatal("If this is the disk mount point, remember to create it manually\n");
|
||||
log_fatal(errno, "If this is the disk mount point, remember to create it manually\n");
|
||||
else
|
||||
log_fatal("If it's a permission problem, you can exclude it in the config file with:\n\texclude /%s\n", sub_next);
|
||||
log_fatal(errno, "If it's a permission problem, you can exclude it in the config file with:\n\texclude /%s\n", sub_next);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1292,8 +1292,8 @@ static int scan_sub(struct snapraid_scan* scan, int level, int is_diff, char* pa
|
|||
/* restore removing additions */
|
||||
path_next[path_len] = 0;
|
||||
sub_next[sub_len] = 0;
|
||||
log_fatal("Error reading directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal("You can exclude it in the config file with:\n\texclude /%s\n", sub_next);
|
||||
log_fatal(errno, "Error reading directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal(errno, "You can exclude it in the config file with:\n\texclude /%s\n", sub_next);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1311,7 +1311,7 @@ static int scan_sub(struct snapraid_scan* scan, int level, int is_diff, char* pa
|
|||
/* check for not supported file names */
|
||||
if (name[0] == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Unsupported name '%s' in file '%s'.\n", name, path_next);
|
||||
log_fatal(ESOFT, "Unsupported name '%s' in file '%s'.\n", name, path_next);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1358,7 +1358,7 @@ static int scan_sub(struct snapraid_scan* scan, int level, int is_diff, char* pa
|
|||
/* LCOV_EXCL_START */
|
||||
/* restore removing additions */
|
||||
path_next[path_len] = 0;
|
||||
log_fatal("Error closing directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal(errno, "Error closing directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1422,7 +1422,7 @@ static int scan_sub(struct snapraid_scan* scan, int level, int is_diff, char* pa
|
|||
if (st->st_mode == 0) {
|
||||
if (lstat(path_next, st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal(errno, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1453,7 +1453,7 @@ static int scan_sub(struct snapraid_scan* scan, int level, int is_diff, char* pa
|
|||
if (st->st_ino == 0 || st->st_nlink == 0) {
|
||||
if (lstat_sync(path_next, st, 0) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in stat file '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal(errno, "Error in stat file '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1473,18 +1473,18 @@ static int scan_sub(struct snapraid_scan* scan, int level, int is_diff, char* pa
|
|||
ret = readlink(path_next, tmp, PATH_MAX);
|
||||
if (ret >= PATH_MAX) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in readlink file '%s'. Symlink too long.\n", path_next);
|
||||
log_fatal(EINTERNAL, "Error in readlink file '%s'. Symlink too long.\n", path_next);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (ret < 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in readlink file '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal(errno, "Error in readlink file '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (ret == 0)
|
||||
log_fatal("WARNING! Empty symbolic link '%s'.\n", path_next);
|
||||
log_fatal(ESOFT, "WARNING! Empty symbolic link '%s'.\n", path_next);
|
||||
|
||||
/* readlink doesn't put the final 0 */
|
||||
tmp[ret] = 0;
|
||||
|
|
@ -1506,7 +1506,7 @@ static int scan_sub(struct snapraid_scan* scan, int level, int is_diff, char* pa
|
|||
/* in Unix don't follow mount points in different devices */
|
||||
/* in Windows we are already skipping them reporting them as special files */
|
||||
if ((uint64_t)st->st_dev != disk->device) {
|
||||
log_fatal("WARNING! Ignoring mount point '%s' because it appears to be in a different device\n", path_next);
|
||||
log_fatal(ESOFT, "WARNING! Ignoring mount point '%s' because it appears to be in a different device\n", path_next);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
|
@ -1532,7 +1532,7 @@ static int scan_sub(struct snapraid_scan* scan, int level, int is_diff, char* pa
|
|||
if (!st)
|
||||
st = DSTAT(path_next, dd, &st_buf);
|
||||
|
||||
log_fatal("WARNING! Ignoring special '%s' file '%s'\n", stat_desc(st), path_next);
|
||||
log_fatal(ESOFT, "WARNING! Ignoring special '%s' file '%s'\n", stat_desc(st), path_next);
|
||||
} else {
|
||||
msg_verbose("Excluding special file '%s' for rule '%s'\n", path_next, filter_type(reason, tmp, PATH_MAX));
|
||||
}
|
||||
|
|
@ -1578,7 +1578,7 @@ static void* scan_disk(void* arg)
|
|||
ret = fsinfo(disk->dir, &has_persistent_inodes, &has_syncronized_hardlinks, 0, 0, 0, 0, 0, 0);
|
||||
if (ret < 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error accessing disk '%s' to get file-system info. %s.\n", disk->dir, strerror(errno));
|
||||
log_fatal(errno, "Error accessing disk '%s' to get file-system info. %s.\n", disk->dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1628,7 +1628,7 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
|
|||
tommy_node* j;
|
||||
tommy_list scanlist;
|
||||
int done;
|
||||
fptr* msg;
|
||||
msg_ptr* msg;
|
||||
struct snapraid_scan total;
|
||||
int no_difference;
|
||||
char esc_buffer[ESC_MAX];
|
||||
|
|
@ -1781,7 +1781,7 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
|
|||
/* if verbose, print the list of duplicates real offsets */
|
||||
/* other cases are for offsets not supported, so we don't need to report them file by file */
|
||||
if (phy_last >= FILEPHY_REAL_OFFSET) {
|
||||
log_fatal("WARNING! Files '%s%s' and '%s%s' share the same physical offset %" PRId64 ".\n", disk->dir, phy_file_last->sub, disk->dir, file->sub, phy_last);
|
||||
log_fatal(ESOFT, "WARNING! Files '%s%s' and '%s%s' share the same physical offset %" PRId64 ".\n", disk->dir, phy_file_last->sub, disk->dir, file->sub, phy_last);
|
||||
}
|
||||
++phy_dup;
|
||||
}
|
||||
|
|
@ -1851,9 +1851,9 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
|
|||
) {
|
||||
if (!done) {
|
||||
done = 1;
|
||||
log_fatal("WARNING! All the files previously present in disk '%s' at dir '%s'", disk->name, disk->dir);
|
||||
log_fatal(ESOFT, "WARNING! All the files previously present in disk '%s' at dir '%s'", disk->name, disk->dir);
|
||||
} else {
|
||||
log_fatal(", disk '%s' at dir '%s'", disk->name, disk->dir);
|
||||
log_fatal(ESOFT, ", disk '%s' at dir '%s'", disk->name, disk->dir);
|
||||
}
|
||||
|
||||
/* detect the special condition of all files missing */
|
||||
|
|
@ -1866,17 +1866,17 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
|
|||
}
|
||||
}
|
||||
if (done) {
|
||||
log_fatal("\nare now missing or have been rewritten!\n");
|
||||
log_fatal(ESOFT, "\nare now missing or have been rewritten!\n");
|
||||
if (all_rewritten) {
|
||||
log_fatal("This could occur when restoring a disk from a backup\n");
|
||||
log_fatal("program that is not setting correctly the timestamps.\n");
|
||||
log_fatal(ESOFT, "This could occur when restoring a disk from a backup\n");
|
||||
log_fatal(ESOFT, "program that is not setting correctly the timestamps.\n");
|
||||
}
|
||||
if (all_missing) {
|
||||
log_fatal("This could occur when some disks are not mounted\n");
|
||||
log_fatal("in the expected directory.\n");
|
||||
log_fatal(ESOFT, "This could occur when some disks are not mounted\n");
|
||||
log_fatal(ESOFT, "in the expected directory.\n");
|
||||
}
|
||||
if (!is_diff) {
|
||||
log_fatal("If you want to '%s' anyway, use 'snapraid --force-empty %s'.\n", state->command, state->command);
|
||||
log_fatal(ESOFT, "If you want to '%s' anyway, use 'snapraid --force-empty %s'.\n", state->command, state->command);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
@ -1891,14 +1891,14 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
|
|||
if (disk->has_unreliable_physical) {
|
||||
if (!done) {
|
||||
done = 1;
|
||||
log_fatal("WARNING! Physical offsets not supported for disk '%s'", disk->name);
|
||||
log_fatal(ESOFT, "WARNING! Physical offsets not supported for disk '%s'", disk->name);
|
||||
} else {
|
||||
log_fatal(", '%s'", disk->name);
|
||||
log_fatal(ESOFT, ", '%s'", disk->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (done) {
|
||||
log_fatal(". The order of files won't be optimal.\n");
|
||||
log_fatal(ESOFT, ". The order of files won't be optimal.\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1910,14 +1910,14 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
|
|||
if (disk->has_volatile_inodes) {
|
||||
if (!done) {
|
||||
done = 1;
|
||||
log_fatal("WARNING! Inodes are not persistent for disks: '%s'", disk->name);
|
||||
log_fatal(ESOFT, "WARNING! Inodes are not persistent for disks: '%s'", disk->name);
|
||||
} else {
|
||||
log_fatal(", '%s'", disk->name);
|
||||
log_fatal(ESOFT, ", '%s'", disk->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (done) {
|
||||
log_fatal(". Inodes are not used to detect move operations.\n");
|
||||
log_fatal(ESOFT, ". Inodes are not used to detect move operations.\n");
|
||||
}
|
||||
|
||||
/* check for disks with changed UUID */
|
||||
|
|
@ -1932,14 +1932,14 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
|
|||
if (disk->has_different_uuid && !disk->had_empty_uuid) {
|
||||
if (!done) {
|
||||
done = 1;
|
||||
log_fatal("WARNING! UUID is changed for disks: '%s'", disk->name);
|
||||
log_fatal(ESOFT, "WARNING! UUID is changed for disks: '%s'", disk->name);
|
||||
} else {
|
||||
log_fatal(", '%s'", disk->name);
|
||||
log_fatal(ESOFT, ", '%s'", disk->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (done) {
|
||||
log_fatal(". Inodes are not used to detect move operations.\n");
|
||||
log_fatal(ESOFT, ". Inodes are not used to detect move operations.\n");
|
||||
}
|
||||
|
||||
/* check for disks with unsupported UUID */
|
||||
|
|
@ -1950,17 +1950,17 @@ static int state_diffscan(struct snapraid_state* state, int is_diff)
|
|||
if (disk->has_unsupported_uuid) {
|
||||
if (!done) {
|
||||
done = 1;
|
||||
log_fatal("WARNING! UUID is unsupported for disks: '%s'", disk->name);
|
||||
log_fatal(ESOFT, "WARNING! UUID is unsupported for disks: '%s'", disk->name);
|
||||
} else {
|
||||
log_fatal(", '%s'", disk->name);
|
||||
log_fatal(ESOFT, ", '%s'", disk->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (done) {
|
||||
log_fatal(". Not using inodes to detect move operations.\n");
|
||||
log_fatal(ESOFT, ". Not using inodes to detect move operations.\n");
|
||||
#if defined(_linux) && !HAVE_BLKID
|
||||
log_fatal("The 'blkid' library is not linked in SnapRAID!\n");
|
||||
log_fatal("Try rebuilding it after installing the libblkid-dev or libblkid-devel package.\n");
|
||||
log_fatal(ESOFT, "The 'blkid' library is not linked in SnapRAID!\n");
|
||||
log_fatal(ESOFT, "Try rebuilding it after installing the libblkid-dev or libblkid-devel package.\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,20 +39,20 @@ static const char* es(int err)
|
|||
static void log_fatal_errno(int err, const char* name)
|
||||
{
|
||||
if (err == EIO) {
|
||||
log_fatal("DANGER! Unexpected input/output error in disk %s. It isn't possible to continue.\n", name);
|
||||
log_fatal(err, "DANGER! Unexpected input/output error in disk %s. It isn't possible to continue.\n", name);
|
||||
} else if (err == EACCES) {
|
||||
log_fatal("WARNING! Grant permission in the disk %s. It isn't possible to continue.\n", name);
|
||||
log_fatal(err, "WARNING! Grant permission in the disk %s. It isn't possible to continue.\n", name);
|
||||
} else if (err == ENOSPC) {
|
||||
log_fatal("WARNING! Ensure there is free space on the disk %s. It isn't possible to continue.\n", name);
|
||||
log_fatal(err, "WARNING! Ensure there is free space on the disk %s. It isn't possible to continue.\n", name);
|
||||
} else {
|
||||
log_fatal("WARNING! Without a working %s disk, it isn't possible to continue.\n", name);
|
||||
log_fatal(err, "WARNING! Without a working %s disk, it isn't possible to continue.\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
static void log_error_errno(int err, const char* name)
|
||||
{
|
||||
if (err == EIO) {
|
||||
log_fatal("DANGER! Unexpected input/output error in disk %s.\n", name);
|
||||
log_fatal(err, "DANGER! Unexpected input/output error in disk %s.\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -172,7 +172,7 @@ static void scrub_data_reader(struct snapraid_worker* worker, struct snapraid_ta
|
|||
/* and closing a descriptor should never fail */
|
||||
log_tag("%s:%u:%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(report->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
|
||||
if (errno == EIO) {
|
||||
task->state = TASK_STATE_IOERROR;
|
||||
|
|
@ -190,7 +190,7 @@ static void scrub_data_reader(struct snapraid_worker* worker, struct snapraid_ta
|
|||
if (errno == EIO) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
task->state = TASK_STATE_IOERROR;
|
||||
return;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -466,8 +466,8 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
|
|||
++io_error;
|
||||
if (io_error >= state->opt.io_error_limit) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("DANGER! Too many input/output errors in the %s disk. It isn't possible to continue.\n", disk->dir);
|
||||
log_fatal("Stopping at block %u\n", blockcur);
|
||||
log_fatal(EIO, "DANGER! Too many input/output errors in the %s disk. It isn't possible to continue.\n", disk->dir);
|
||||
log_fatal(EIO, "Stopping at block %u\n", blockcur);
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -478,7 +478,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
|
|||
}
|
||||
if (task->state != TASK_STATE_DONE) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency in task state\n");
|
||||
log_fatal(EINTERNAL, "Internal inconsistency in task state\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -511,7 +511,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
|
|||
error_on_this_block = 1;
|
||||
} else {
|
||||
log_tag("error_data:%u:%s:%s: Data error at position %u, diff hash bits %u/%u\n", blockcur, disk->name, esc_tag(file->sub, esc_buffer), file_pos, diff, BLOCK_HASH_SIZE * 8);
|
||||
log_error("Data error in file '%s' at position '%u', diff hash bits %u/%u\n", task->path, file_pos, diff, BLOCK_HASH_SIZE * 8);
|
||||
log_error(EDATA, "Data error in file '%s' at position '%u', diff hash bits %u/%u\n", task->path, file_pos, diff, BLOCK_HASH_SIZE * 8);
|
||||
++silent_error;
|
||||
silent_error_on_this_block = 1;
|
||||
}
|
||||
|
|
@ -564,8 +564,8 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
|
|||
++io_error;
|
||||
if (io_error >= state->opt.io_error_limit) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("DANGER! Too many input/output errors in the %s disk. It isn't possible to continue.\n", lev_name(levcur));
|
||||
log_fatal("Stopping at block %u\n", blockcur);
|
||||
log_fatal(EIO, "DANGER! Too many input/output errors in the %s disk. It isn't possible to continue.\n", lev_name(levcur));
|
||||
log_fatal(EIO, "Stopping at block %u\n", blockcur);
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -579,7 +579,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
|
|||
}
|
||||
if (task->state != TASK_STATE_DONE) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency in task state\n");
|
||||
log_fatal(EINTERNAL, "Internal inconsistency in task state\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -603,7 +603,7 @@ static int state_scrub_process(struct snapraid_state* state, struct snapraid_par
|
|||
error_on_this_block = 1;
|
||||
} else {
|
||||
log_tag("parity_error_data:%u:%s: Data error, diff parity bits %u/%u\n", blockcur, lev_config_name(l), diff, state->block_size * 8);
|
||||
log_error("Data error in parity '%s' at position '%u', diff parity bits %u/%u\n", lev_config_name(l), blockcur, diff, state->block_size * 8);
|
||||
log_error(EDATA, "Data error in parity '%s' at position '%u', diff parity bits %u/%u\n", lev_config_name(l), blockcur, diff, state->block_size * 8);
|
||||
++silent_error;
|
||||
silent_error_on_this_block = 1;
|
||||
}
|
||||
|
|
@ -706,15 +706,15 @@ end:
|
|||
}
|
||||
|
||||
if (soft_error)
|
||||
log_fatal("WARNING! Unexpected soft errors!\n");
|
||||
log_fatal(ESOFT, "WARNING! Unexpected soft errors!\n");
|
||||
if (io_error)
|
||||
log_fatal("DANGER! Unexpected input/output errors! The failing blocks are now marked as bad!\n");
|
||||
log_fatal(EIO, "DANGER! Unexpected input/output errors! The failing blocks are now marked as bad!\n");
|
||||
if (silent_error)
|
||||
log_fatal("DANGER! Unexpected data errors! The failing blocks are now marked as bad!\n");
|
||||
log_fatal(EDATA, "DANGER! Unexpected data errors! The failing blocks are now marked as bad!\n");
|
||||
if (io_error || silent_error) {
|
||||
log_fatal("Use 'snapraid status' to list the bad blocks.\n");
|
||||
log_fatal("Use 'snapraid -e fix' to recover them.\n");
|
||||
log_fatal("Use 'snapraid -p bad scrub' to recheck after fixing to clear the bad state.\n");
|
||||
log_fatal(ESOFT, "Use 'snapraid status' to list the bad blocks.\n");
|
||||
log_fatal(ESOFT, "Use 'snapraid -e fix' to recover them.\n");
|
||||
log_fatal(ESOFT, "Use 'snapraid -p bad scrub' to recheck after fixing to clear the bad state.\n");
|
||||
}
|
||||
|
||||
log_tag("summary:error_soft:%u\n", soft_error);
|
||||
|
|
@ -804,7 +804,7 @@ int state_scrub(struct snapraid_state* state, int plan, int olderthan)
|
|||
if ((plan == SCRUB_BAD || plan == SCRUB_NEW || plan == SCRUB_FULL)
|
||||
&& olderthan >= 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You can specify -o, --older-than only with a numeric percentage.\n");
|
||||
log_fatal(EUSER, "You can specify -o, --older-than only with a numeric percentage.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -881,7 +881,7 @@ int state_scrub(struct snapraid_state* state, int plan, int olderthan)
|
|||
|
||||
if (!count) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("The array appears to be empty.\n");
|
||||
log_fatal(EUSER, "The array is empty.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,10 +80,10 @@ int search_file_compare(const void* void_arg, const void* void_data)
|
|||
if (f == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
if (errno == ENOENT) {
|
||||
log_fatal("DANGER! file '%s' disappeared.\n", path);
|
||||
log_fatal("If you moved it, please rerun the same command.\n");
|
||||
log_fatal(EUSER, "DANGER! file '%s' disappeared.\n", path);
|
||||
log_fatal(EUSER, "If you moved it, please rerun the same command.\n");
|
||||
} else {
|
||||
log_fatal("Error opening file '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error opening file '%s'. %s.\n", path, strerror(errno));
|
||||
}
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -92,7 +92,7 @@ int search_file_compare(const void* void_arg, const void* void_data)
|
|||
ret = pread(f, arg->buffer, arg->read_size, arg->offset);
|
||||
if (ret < 0 || (unsigned)ret != arg->read_size) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error reading file '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error reading file '%s'. %s.\n", path, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ int search_file_compare(const void* void_arg, const void* void_data)
|
|||
ret = close(f);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error closing file '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error closing file '%s'. %s.\n", path, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -155,7 +155,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
|
|||
d = opendir(dir);
|
||||
if (!d) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error opening directory '%s'. %s.\n", dir, strerror(errno));
|
||||
log_fatal(errno, "Error opening directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -174,7 +174,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
|
|||
dd = readdir(d);
|
||||
if (dd == 0 && errno != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error reading directory '%s'. %s.\n", dir, strerror(errno));
|
||||
log_fatal(errno, "Error reading directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -214,7 +214,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
|
|||
if (st.st_mode == 0) {
|
||||
if (lstat(path_next, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal(errno, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -223,7 +223,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
|
|||
/* get lstat info about the file */
|
||||
if (lstat(path_next, &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
log_fatal(errno, "Error in stat file/directory '%s'. %s.\n", path_next, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -248,7 +248,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
|
|||
|
||||
if (closedir(d) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error closing directory '%s'. %s.\n", dir, strerror(errno));
|
||||
log_fatal(errno, "Error closing directory '%s'. %s.\n", dir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ static void test_hash(void)
|
|||
digest = tommy_hash_u32(TEST_HASH32[i].seed, buffer_aligned, TEST_HASH32[i].len);
|
||||
if (digest != TEST_HASH32[i].digest) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed hash32 test\n");
|
||||
log_fatal(EINTERNAL, "Failed hash32 test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -204,7 +204,7 @@ static void test_hash(void)
|
|||
digest = tommy_strhash_u32(TEST_STRHASH32[i].seed, buffer_aligned);
|
||||
if (digest != TEST_STRHASH32[i].digest) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed strhash32 test\n");
|
||||
log_fatal(EINTERNAL, "Failed strhash32 test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -216,7 +216,7 @@ static void test_hash(void)
|
|||
digest = tommy_hash_u64(TEST_HASH64[i].seed, buffer_aligned, TEST_HASH64[i].len);
|
||||
if (digest != TEST_HASH64[i].digest) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed hash64 test\n");
|
||||
log_fatal(EINTERNAL, "Failed hash64 test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -230,7 +230,7 @@ static void test_hash(void)
|
|||
memhash(HASH_MURMUR3, seed_aligned, digest, buffer_aligned, TEST_MURMUR3[i].len);
|
||||
if (memcmp(digest, TEST_MURMUR3[i].digest, HASH_MAX) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed Murmur3 test\n");
|
||||
log_fatal(EINTERNAL, "Failed Murmur3 test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -243,7 +243,7 @@ static void test_hash(void)
|
|||
memhash(HASH_SPOOKY2, seed_aligned, digest, buffer_aligned, TEST_SPOOKY2[i].len);
|
||||
if (memcmp(digest, TEST_SPOOKY2[i].digest, HASH_MAX) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed Spooky2 test\n");
|
||||
log_fatal(EINTERNAL, "Failed Spooky2 test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -256,7 +256,7 @@ static void test_hash(void)
|
|||
memhash(HASH_METRO, seed_aligned, digest, buffer_aligned, TEST_METRO[i].len);
|
||||
if (memcmp(digest, TEST_METRO[i].digest, HASH_MAX) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed Metro test\n");
|
||||
log_fatal(EINTERNAL, "Failed Metro test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -269,7 +269,7 @@ static void test_hash(void)
|
|||
memhash(HASH_MUSEAIR, seed_aligned, digest, buffer_aligned, TEST_MUSEAIR[i].len);
|
||||
if (memcmp(digest, TEST_MUSEAIR[i].digest, HASH_MAX) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed MuseAir test\n");
|
||||
log_fatal(EINTERNAL, "Failed MuseAir test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -322,7 +322,7 @@ static void test_crc32c(void)
|
|||
|
||||
if (digest != TEST_CRC32C[i].digest || digest_gen != TEST_CRC32C[i].digest) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed CRC32C test\n");
|
||||
log_fatal(EINTERNAL, "Failed CRC32C test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -585,7 +585,7 @@ static void test_tommy(void)
|
|||
return;
|
||||
bail:
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed tommy test\n");
|
||||
log_fatal(EINTERNAL, "Failed tommy test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -848,7 +848,7 @@ static void test_wnmatch(void)
|
|||
for (int i = 0; WNMATCH_TEST[i].pattern; ++i) {
|
||||
if (wnmatch(WNMATCH_TEST[i].pattern, WNMATCH_TEST[i].text) != WNMATCH_TEST[i].result) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed wnmatch test %s %s, expected %d\n", WNMATCH_TEST[i].pattern, WNMATCH_TEST[i].text, WNMATCH_TEST[i].result);
|
||||
log_fatal(EINTERNAL, "Failed wnmatch test %s %s, expected %d\n", WNMATCH_TEST[i].pattern, WNMATCH_TEST[i].text, WNMATCH_TEST[i].result);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -865,14 +865,14 @@ void selftest(void)
|
|||
/* large file check */
|
||||
if (sizeof(off_t) < sizeof(uint64_t)) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Missing support for large files\n");
|
||||
log_fatal(EINTERNAL, "Missing support for large files\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (util_selftest() != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed UTIL test\n");
|
||||
log_fatal(EINTERNAL, "Failed UTIL test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -882,55 +882,55 @@ void selftest(void)
|
|||
test_wnmatch();
|
||||
if (raid_selftest() != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed SELF test\n");
|
||||
log_fatal(EINTERNAL, "Failed SELF test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (raid_test_sort() != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed SORT test\n");
|
||||
log_fatal(EINTERNAL, "Failed SORT test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (raid_test_insert() != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed INSERT test\n");
|
||||
log_fatal(EINTERNAL, "Failed INSERT test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (raid_test_combo() != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed COMBO test\n");
|
||||
log_fatal(EINTERNAL, "Failed COMBO test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (raid_test_par(RAID_MODE_VANDERMONDE, 32, 256) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed GEN Vandermonde test\n");
|
||||
log_fatal(EINTERNAL, "Failed GEN Vandermonde test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (raid_test_rec(RAID_MODE_VANDERMONDE, 12, 256) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed REC Vandermonde test\n");
|
||||
log_fatal(EINTERNAL, "Failed REC Vandermonde test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (raid_test_par(RAID_MODE_CAUCHY, 32, 256) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed GEN Cauchy test\n");
|
||||
log_fatal(EINTERNAL, "Failed GEN Cauchy test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (raid_test_rec(RAID_MODE_CAUCHY, 12, 256) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed REC Cauchy test\n");
|
||||
log_fatal(EINTERNAL, "Failed REC Cauchy test\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (raid_test_par(RAID_MODE_CAUCHY, 1, 256) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed GEN Cauchy test single data disk\n");
|
||||
log_fatal(EINTERNAL, "Failed GEN Cauchy test single data disk\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -564,7 +564,7 @@ void log_open(const char* file)
|
|||
break;
|
||||
default :
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Invalid type specifier '%c' in the log file.\n", *file);
|
||||
log_fatal(EUSER, "Invalid type specifier '%c' in the log file.\n", *file);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -579,7 +579,7 @@ void log_open(const char* file)
|
|||
stdlog = fopen(path, mode);
|
||||
if (!stdlog) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error opening the log file '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error opening the log file '%s'. %s.\n", path, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -590,7 +590,7 @@ void log_close(const char* file)
|
|||
if (stdlog != stdout && stdlog != stderr && stdlog != 0) {
|
||||
if (fclose(stdlog) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error closing the log file '%s'. %s.\n", file, strerror(errno));
|
||||
log_fatal(errno, "Error closing the log file '%s'. %s.\n", file, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1005,7 +1005,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
struct snapraid_filter* filter = filter_alloc_file(1, "", optarg);
|
||||
if (!filter) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Invalid filter specification '%s'\n", optarg);
|
||||
log_fatal(EUSER, "Invalid filter specification '%s'\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1015,7 +1015,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
struct snapraid_filter* filter = filter_alloc_disk(1, optarg);
|
||||
if (!filter) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Invalid filter specification '%s'\n", optarg);
|
||||
log_fatal(EUSER, "Invalid filter specification '%s'\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1051,7 +1051,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
plan = strtoul(optarg, &e, 10);
|
||||
if (!e || *e || plan > 100) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Invalid plan/percentage '%s'\n", optarg);
|
||||
log_fatal(EUSER, "Invalid plan/percentage '%s'\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1061,7 +1061,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
olderthan = strtoul(optarg, &e, 10);
|
||||
if (!e || *e || olderthan > 1000) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Invalid number of days '%s'\n", optarg);
|
||||
log_fatal(EUSER, "Invalid number of days '%s'\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1069,7 +1069,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
case 'w' : /* --bw-limit */
|
||||
if (optarg == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Missing bandwidth limit\n");
|
||||
log_fatal(EUSER, "Missing bandwidth limit\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1078,7 +1078,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
opt.bwlimit = strtoul(optarg, &e, 10);
|
||||
if (!e || e == optarg) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Invalid bandwidth limit '%s'\n", optarg);
|
||||
log_fatal(EUSER, "Invalid bandwidth limit '%s'\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1092,7 +1092,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
opt.bwlimit *= 1000 * 1000 * 1000;
|
||||
} else if (e[0] != '\0') {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Invalid bandwidth limit suffix '%s'\n", e);
|
||||
log_fatal(EUSER, "Invalid bandwidth limit suffix '%s'\n", e);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1101,7 +1101,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
blockstart = strtoul(optarg, &e, 0);
|
||||
if (!e || *e) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Invalid start position '%s'\n", optarg);
|
||||
log_fatal(EUSER, "Invalid start position '%s'\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1110,7 +1110,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
blockcount = strtoul(optarg, &e, 0);
|
||||
if (!e || *e) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Invalid count number '%s'\n", optarg);
|
||||
log_fatal(EUSER, "Invalid count number '%s'\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1119,7 +1119,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
opt.io_error_limit = strtoul(optarg, &e, 0);
|
||||
if (!e || *e) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Invalid error limit number '%s'\n", optarg);
|
||||
log_fatal(EUSER, "Invalid error limit number '%s'\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1127,7 +1127,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
case 'i' :
|
||||
if (import_timestamp) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Import directory '%s' already specified as '%s'\n", optarg, import_timestamp);
|
||||
log_fatal(EUSER, "Import directory '%s' already specified as '%s'\n", optarg, import_timestamp);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1136,7 +1136,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
case OPT_TEST_IMPORT_CONTENT :
|
||||
if (import_content) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Import directory '%s' already specified as '%s'\n", optarg, import_content);
|
||||
log_fatal(EUSER, "Import directory '%s' already specified as '%s'\n", optarg, import_content);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1145,7 +1145,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
case 'l' :
|
||||
if (log_file) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Log file '%s' already specified as '%s'\n", optarg, log_file);
|
||||
log_fatal(EUSER, "Log file '%s' already specified as '%s'\n", optarg, log_file);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1317,7 +1317,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
opt.io_cache = atoi(optarg);
|
||||
if (opt.io_cache != 1 && (opt.io_cache < IO_MIN || opt.io_cache > IO_MAX)) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("The IO cache should be between %u and %u.\n", IO_MIN, IO_MAX);
|
||||
log_fatal(EUSER, "The IO cache should be between %u and %u.\n", IO_MIN, IO_MAX);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1369,7 +1369,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
FMT_MODE = FMT_PATH;
|
||||
else {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Unknown format '%s'\n", optarg);
|
||||
log_fatal(EUSER, "Unknown format '%s'\n", optarg);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1379,7 +1379,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
break;
|
||||
default :
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Unknown option '%c'\n", (char)c);
|
||||
log_fatal(EUSER, "Unknown option '%c'\n", (char)c);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1450,7 +1450,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
operation = OPERATION_PROBE;
|
||||
} else {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Unknown command '%s'\n", argv[optind]);
|
||||
log_fatal(EUSER, "Unknown command '%s'\n", argv[optind]);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1462,7 +1462,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
default :
|
||||
if (opt.auditonly) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You cannot use -a, --audit-only with the '%s' command\n", command);
|
||||
log_fatal(EUSER, "You cannot use -a, --audit-only with the '%s' command\n", command);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1480,7 +1480,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
default :
|
||||
if (opt.force_device) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You cannot use -D, --force-device with the '%s' command\n", command);
|
||||
log_fatal(EUSER, "You cannot use -D, --force-device with the '%s' command\n", command);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1494,7 +1494,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
default :
|
||||
if (opt.force_nocopy) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You cannot use -N, --force-nocopy with the '%s' command\n", command);
|
||||
log_fatal(EUSER, "You cannot use -N, --force-nocopy with the '%s' command\n", command);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1506,21 +1506,21 @@ int snapraid_main(int argc, char* argv[])
|
|||
default :
|
||||
if (opt.prehash) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You cannot use -h, --pre-hash with the '%s' command\n", command);
|
||||
log_fatal(EUSER, "You cannot use -h, --pre-hash with the '%s' command\n", command);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (opt.force_full) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You cannot use -F, --force-full with the '%s' command\n", command);
|
||||
log_fatal(EUSER, "You cannot use -F, --force-full with the '%s' command\n", command);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (opt.force_realloc) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You cannot use -R, --force-realloc with the '%s' command\n", command);
|
||||
log_fatal(EUSER, "You cannot use -R, --force-realloc with the '%s' command\n", command);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1528,28 +1528,28 @@ int snapraid_main(int argc, char* argv[])
|
|||
|
||||
if (opt.force_full && opt.force_nocopy) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You cannot use the -F, --force-full and -N, --force-nocopy options simultaneously\n");
|
||||
log_fatal(EUSER, "You cannot use the -F, --force-full and -N, --force-nocopy options simultaneously\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (opt.force_realloc && opt.force_nocopy) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You cannot use the -R, --force-realloc and -N, --force-nocopy options simultaneously\n");
|
||||
log_fatal(EUSER, "You cannot use the -R, --force-realloc and -N, --force-nocopy options simultaneously\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (opt.force_realloc && opt.force_full) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You cannot use the -R, --force-realloc and -F, --force-full options simultaneously\n");
|
||||
log_fatal(EUSER, "You cannot use the -R, --force-realloc and -F, --force-full options simultaneously\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (opt.prehash && opt.force_nocopy) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You cannot use the -h, --pre-hash and -N, --force-nocopy options simultaneously\n");
|
||||
log_fatal(EUSER, "You cannot use the -h, --pre-hash and -N, --force-nocopy options simultaneously\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1562,7 +1562,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
default :
|
||||
if (!tommy_list_empty(&filterlist_disk)) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You cannot use -d, --filter-disk with the '%s' command\n", command);
|
||||
log_fatal(EUSER, "You cannot use -d, --filter-disk with the '%s' command\n", command);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1571,19 +1571,19 @@ int snapraid_main(int argc, char* argv[])
|
|||
case OPERATION_SPINDOWN :
|
||||
if (!tommy_list_empty(&filterlist_file)) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You cannot use -f, --filter with the '%s' command\n", command);
|
||||
log_fatal(EUSER, "You cannot use -f, --filter with the '%s' command\n", command);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (filter_missing != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You cannot use -m, --filter-missing with the '%s' command\n", command);
|
||||
log_fatal(EUSER, "You cannot use -m, --filter-missing with the '%s' command\n", command);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (filter_error != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You cannot use -e, --filter-error with the '%s' command\n", command);
|
||||
log_fatal(EUSER, "You cannot use -e, --filter-error with the '%s' command\n", command);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1593,7 +1593,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
/* because we don't keep the information on what disk is the error */
|
||||
if (filter_error != 0 && !tommy_list_empty(&filterlist_disk)) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("You cannot use -e, --filter-error and -d, --filter-disk simultaneously\n");
|
||||
log_fatal(EUSER, "You cannot use -e, --filter-error and -d, --filter-disk simultaneously\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1605,7 +1605,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
default :
|
||||
if (import_timestamp != 0 || import_content != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Import not allowed with the '%s' command\n", command);
|
||||
log_fatal(EUSER, "Import not allowed with the '%s' command\n", command);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1732,10 +1732,10 @@ int snapraid_main(int argc, char* argv[])
|
|||
if (lock == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
if (errno != EWOULDBLOCK) {
|
||||
log_fatal("Failed to create the lock file '%s'. %s.\n", state.lockfile, strerror(errno));
|
||||
log_fatal(errno, "Failed to create the lock file '%s'. %s.\n", state.lockfile, strerror(errno));
|
||||
} else {
|
||||
log_fatal("The lock file '%s' is already in use!\n", state.lockfile);
|
||||
log_fatal("SnapRAID is already in use!\n");
|
||||
log_fatal(errno, "The lock file '%s' is already in use!\n", state.lockfile);
|
||||
log_fatal(errno, "SnapRAID is already in use!\n");
|
||||
}
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -1804,7 +1804,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
ret = system(run); /* ignore error */
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error executing command '%s'.\n", run);
|
||||
log_fatal(errno, "Error executing command '%s'.\n", run);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1951,7 +1951,7 @@ int snapraid_main(int argc, char* argv[])
|
|||
if (!opt.skip_lock && state.lockfile[0]) {
|
||||
if (lock_unlock(lock) == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to close the lock file '%s'. %s.\n", state.lockfile, strerror(errno));
|
||||
log_fatal(errno, "Failed to close the lock file '%s'. %s.\n", state.lockfile, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
534
cmdline/state.c
534
cmdline/state.c
File diff suppressed because it is too large
Load diff
|
|
@ -365,7 +365,7 @@ int state_status(struct snapraid_state* state)
|
|||
log_flush();
|
||||
|
||||
if (!count) {
|
||||
log_fatal("The array is empty.\n");
|
||||
log_fatal(EUSER, "The array is empty.\n");
|
||||
free(timemap);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ STREAM* sopen_read(const char* file, int flags)
|
|||
/* advise sequential access */
|
||||
ret = posix_fadvise(s->handle[0].f, 0, 0, POSIX_FADV_SEQUENTIAL);
|
||||
if (ret == ENOSYS) {
|
||||
log_fatal("WARNING! fadvise() is not supported in this platform. Performance may not be optimal!\n");
|
||||
log_fatal(errno, "WARNING! fadvise() is not supported in this platform. Performance may not be optimal!\n");
|
||||
/* call is not supported, like in armhf, see posix_fadvise manpage */
|
||||
ret = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -204,14 +204,17 @@ static void vmsg(FILE* out, const char* format, va_list ap)
|
|||
free(dup);
|
||||
}
|
||||
|
||||
void log_fatal(const char* format, ...)
|
||||
void log_fatal(int err, const char* format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
lock_msg();
|
||||
|
||||
if (stdlog) {
|
||||
fprintf(stdlog, "msg:fatal: ");
|
||||
if (err == EIO)
|
||||
fprintf(stdlog, "msg:fatal_hardware: ");
|
||||
else
|
||||
fprintf(stdlog, "msg:fatal: ");
|
||||
|
||||
va_start(ap, format);
|
||||
vfprintf(stdlog, format, ap);
|
||||
|
|
@ -229,14 +232,17 @@ void log_fatal(const char* format, ...)
|
|||
unlock_msg();
|
||||
}
|
||||
|
||||
void log_error(const char* format, ...)
|
||||
void log_error(int err, const char* format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
lock_msg();
|
||||
|
||||
if (stdlog) {
|
||||
fprintf(stdlog, "msg:error: ");
|
||||
if (err == EIO)
|
||||
fprintf(stdlog, "msg:error_hardware: ");
|
||||
else
|
||||
fprintf(stdlog, "msg:error: ");
|
||||
|
||||
va_start(ap, format);
|
||||
vfprintf(stdlog, format, ap);
|
||||
|
|
@ -254,14 +260,17 @@ void log_error(const char* format, ...)
|
|||
unlock_msg();
|
||||
}
|
||||
|
||||
void log_expected(const char* format, ...)
|
||||
void log_expected(int err, const char* format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
lock_msg();
|
||||
|
||||
if (stdlog) {
|
||||
fprintf(stdlog, "msg:expected: ");
|
||||
if (err == EIO)
|
||||
fprintf(stdlog, "msg:error_hardware: "); /* we never expect an hardware error */
|
||||
else
|
||||
fprintf(stdlog, "msg:expected: ");
|
||||
|
||||
va_start(ap, format);
|
||||
vfprintf(stdlog, format, ap);
|
||||
|
|
@ -557,7 +566,7 @@ const char* esc_tag(const char* str, char* buffer)
|
|||
|
||||
bail:
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Escape for log is too long\n");
|
||||
log_fatal(EINTERNAL, "Escape for log is too long\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -674,7 +683,7 @@ const char* esc_shell_multi(const char** str_map, unsigned str_max, char* buffer
|
|||
|
||||
bail:
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Escape for shell is too long\n");
|
||||
log_fatal(EINTERNAL, "Escape for shell is too long\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -746,7 +755,7 @@ const char* esc_shell_multi(const char** str_map, unsigned str_max, char* buffer
|
|||
|
||||
bail:
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Escape for shell is too long\n");
|
||||
log_fatal(EINTERNAL, "Escape for shell is too long\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -855,7 +864,7 @@ void pathcpy(char* dst, size_t size, const char* src)
|
|||
|
||||
if (len + 1 > size) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Path too long '%s'\n", src);
|
||||
log_fatal(EINTERNAL, "Path too long '%s'\n", src);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -870,7 +879,7 @@ void pathcat(char* dst, size_t size, const char* src)
|
|||
|
||||
if (dst_len + src_len + 1 > size) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Path too long '%s%s'\n", dst, src);
|
||||
log_fatal(EINTERNAL, "Path too long '%s%s'\n", dst, src);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -884,7 +893,7 @@ void pathcatl(char* dst, size_t dst_len, size_t size, const char* src)
|
|||
|
||||
if (dst_len + src_len + 1 > size) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Path too long '%s%s'\n", dst, src);
|
||||
log_fatal(EINTERNAL, "Path too long '%s%s'\n", dst, src);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -898,7 +907,7 @@ void pathcatc(char* dst, size_t size, char c)
|
|||
|
||||
if (dst_len + 2 > size) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Path too long '%s%c'\n", dst, c);
|
||||
log_fatal(EINTERNAL, "Path too long '%s%c'\n", dst, c);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -961,9 +970,9 @@ void pathprint(char* dst, size_t size, const char* format, ...)
|
|||
/* LCOV_EXCL_START */
|
||||
if (size > 0) {
|
||||
dst[size - 1] = 0;
|
||||
log_fatal("Path too long '%s...'\n", dst);
|
||||
log_fatal(EINTERNAL, "Path too long '%s...'\n", dst);
|
||||
} else {
|
||||
log_fatal("Path too long for empty size'\n");
|
||||
log_fatal(EINTERNAL, "Path too long for empty size'\n");
|
||||
}
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -977,7 +986,7 @@ void pathslash(char* dst, size_t size)
|
|||
if (len > 0 && dst[len - 1] != '/') {
|
||||
if (len + 2 >= size) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Path too long '%s/'\n", dst);
|
||||
log_fatal(EINTERNAL, "Path too long '%s/'\n", dst);
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1097,7 +1106,7 @@ int mkancestor(const char* file)
|
|||
/* create it */
|
||||
if (mkdir(dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error creating directory '%s'. %s.\n", dir, strerror(errno));
|
||||
log_fatal(errno, "Error creating directory '%s'. %s.\n", dir, strerror(errno));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1839,13 +1848,13 @@ int smartctl_attribute(FILE* f, const char* file, const char* name, uint64_t* sm
|
|||
inside = 1;
|
||||
} else if (inside) {
|
||||
if (sscanf(s, "%u %*s %*s %" SCNu64 " %*s %*s %*s %*s %*s %" SCNu64, &id, &normalized, &raw) != 3) {
|
||||
log_fatal("Invalid smartctl line '%s'.\n", s);
|
||||
log_fatal(EEXTERNAL, "Invalid smartctl line '%s'.\n", s);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (id >= 256) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Invalid SMART id '%u'.\n", id);
|
||||
log_fatal(EEXTERNAL, "Invalid SMART id '%u'.\n", id);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1901,7 +1910,7 @@ void thread_mutex_init(thread_mutex_t* mutex)
|
|||
{
|
||||
if (pthread_mutex_init(mutex, 0) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed call to pthread_mutex_init().\n");
|
||||
log_fatal(EINTERNAL, "Failed call to pthread_mutex_init().\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1911,7 +1920,7 @@ void thread_mutex_destroy(thread_mutex_t* mutex)
|
|||
{
|
||||
if (pthread_mutex_destroy(mutex) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed call to pthread_mutex_destroy().\n");
|
||||
log_fatal(EINTERNAL, "Failed call to pthread_mutex_destroy().\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1921,7 +1930,7 @@ void thread_mutex_lock(thread_mutex_t* mutex)
|
|||
{
|
||||
if (pthread_mutex_lock(mutex) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed call to pthread_mutex_lock().\n");
|
||||
log_fatal(EINTERNAL, "Failed call to pthread_mutex_lock().\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1931,7 +1940,7 @@ void thread_mutex_unlock(thread_mutex_t* mutex)
|
|||
{
|
||||
if (pthread_mutex_unlock(mutex) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed call to pthread_mutex_unlock().\n");
|
||||
log_fatal(EINTERNAL, "Failed call to pthread_mutex_unlock().\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1941,7 +1950,7 @@ void thread_cond_init(thread_cond_t* cond)
|
|||
{
|
||||
if (pthread_cond_init(cond, 0) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed call to pthread_cond_init().\n");
|
||||
log_fatal(EINTERNAL, "Failed call to pthread_cond_init().\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1951,7 +1960,7 @@ void thread_cond_destroy(thread_cond_t* cond)
|
|||
{
|
||||
if (pthread_cond_destroy(cond) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed call to pthread_cond_destroy().\n");
|
||||
log_fatal(EINTERNAL, "Failed call to pthread_cond_destroy().\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1961,7 +1970,7 @@ void thread_cond_signal(thread_cond_t* cond)
|
|||
{
|
||||
if (pthread_cond_signal(cond) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed call to pthread_cond_signal().\n");
|
||||
log_fatal(EINTERNAL, "Failed call to pthread_cond_signal().\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1971,7 +1980,7 @@ void thread_cond_broadcast(thread_cond_t* cond)
|
|||
{
|
||||
if (pthread_cond_broadcast(cond) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed call to pthread_cond_broadcast().\n");
|
||||
log_fatal(EINTERNAL, "Failed call to pthread_cond_broadcast().\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1981,7 +1990,7 @@ void thread_cond_wait(thread_cond_t* cond, thread_mutex_t* mutex)
|
|||
{
|
||||
if (pthread_cond_wait(cond, mutex) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed call to pthread_cond_wait().\n");
|
||||
log_fatal(EINTERNAL, "Failed call to pthread_cond_wait().\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -2054,7 +2063,7 @@ void thread_create(thread_id_t* thread, void* (*func)(void*), void *arg)
|
|||
{
|
||||
if (pthread_create(thread, 0, func, arg) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed call to pthread_create().\n");
|
||||
log_fatal(EINTERNAL, "Failed call to pthread_create().\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -2064,7 +2073,7 @@ void thread_join(thread_id_t thread, void** retval)
|
|||
{
|
||||
if (pthread_join(thread, retval) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed call to pthread_join().\n");
|
||||
log_fatal(EINTERNAL, "Failed call to pthread_join().\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,11 @@ uint64_t random_u64(void);
|
|||
/****************************************************************************/
|
||||
/* log */
|
||||
|
||||
/**
|
||||
* Pointer to log function.
|
||||
*/
|
||||
typedef void log_ptr(int err, const char* format, ...) __attribute__((format(attribute_printf, 2, 3)));
|
||||
|
||||
/**
|
||||
* Fatal error messages.
|
||||
*
|
||||
|
|
@ -80,7 +85,7 @@ uint64_t random_u64(void);
|
|||
*
|
||||
* These messages go in the log file and in stderr unconditionally.
|
||||
*/
|
||||
void log_fatal(const char* format, ...) __attribute__((format(attribute_printf, 1, 2)));
|
||||
void log_fatal(int err, const char* format, ...) __attribute__((format(attribute_printf, 2, 3)));
|
||||
|
||||
/**
|
||||
* Unexpected error messages.
|
||||
|
|
@ -93,7 +98,7 @@ void log_fatal(const char* format, ...) __attribute__((format(attribute_printf,
|
|||
*
|
||||
* These messages go in the log file if specified, otherwise they go in stderr.
|
||||
*/
|
||||
void log_error(const char* format, ...) __attribute__((format(attribute_printf, 1, 2)));
|
||||
void log_error(int err, const char* format, ...) __attribute__((format(attribute_printf, 2, 3)));
|
||||
|
||||
/**
|
||||
* Expected error messages, without fallback to stderr.
|
||||
|
|
@ -104,7 +109,7 @@ void log_error(const char* format, ...) __attribute__((format(attribute_printf,
|
|||
*
|
||||
* These messages go in the log file if specified, otherwise they are lost.
|
||||
*/
|
||||
void log_expected(const char* format, ...) __attribute__((format(attribute_printf, 1, 2)));
|
||||
void log_expected(int err, const char* format, ...) __attribute__((format(attribute_printf, 2, 3)));
|
||||
|
||||
/**
|
||||
* Tag messages.
|
||||
|
|
@ -124,14 +129,14 @@ void log_tag(const char* format, ...) __attribute__((format(attribute_printf, 1,
|
|||
*/
|
||||
void log_flush(void);
|
||||
|
||||
/**
|
||||
* Pointer to log function.
|
||||
*/
|
||||
typedef void fptr(const char* format, ...) __attribute__((format(attribute_printf, 1, 2)));
|
||||
|
||||
/****************************************************************************/
|
||||
/* message */
|
||||
|
||||
/**
|
||||
* Pointer to msg function.
|
||||
*/
|
||||
typedef void msg_ptr(const char* format, ...) __attribute__((format(attribute_printf, 1, 2)));
|
||||
|
||||
/**
|
||||
* Message levels.
|
||||
*
|
||||
|
|
|
|||
142
cmdline/sync.c
142
cmdline/sync.c
|
|
@ -39,28 +39,28 @@ static const char* es(int err)
|
|||
static void log_fatal_errno(int err, const char* name)
|
||||
{
|
||||
if (err == EIO) {
|
||||
log_fatal("DANGER! Unexpected input/output error in disk %s. It isn't possible to continue.\n", name);
|
||||
log_fatal(err, "DANGER! Unexpected input/output error in disk %s. It isn't possible to continue.\n", name);
|
||||
} else if (err == EACCES) {
|
||||
log_fatal("WARNING! Grant permission in the disk %s. It isn't possible to continue.\n", name);
|
||||
log_fatal(err, "WARNING! Grant permission in the disk %s. It isn't possible to continue.\n", name);
|
||||
} else if (err == ENOSPC) {
|
||||
log_fatal("WARNING! Ensure there is free space on the disk %s. It isn't possible to continue.\n", name);
|
||||
log_fatal(err, "WARNING! Ensure there is free space on the disk %s. It isn't possible to continue.\n", name);
|
||||
} else {
|
||||
log_fatal("WARNING! Without a working %s disk, it isn't possible to continue.\n", name);
|
||||
log_fatal(err, "WARNING! Without a working %s disk, it isn't possible to continue.\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
static void log_error_errno(int err, const char* name)
|
||||
{
|
||||
if (err == EIO) {
|
||||
log_fatal("DANGER! Unexpected input/output error in disk %s.\n", name);
|
||||
log_fatal(err, "DANGER! Unexpected input/output error in disk %s.\n", name);
|
||||
} else if (err == EACCES) {
|
||||
log_error("WARNING! Grant permission in the disk %s.\n", name);
|
||||
log_error("Rerun the sync command when finished.\n");
|
||||
log_error(err, "WARNING! Grant permission in the disk %s.\n", name);
|
||||
log_error(err, "Rerun the sync command when finished.\n");
|
||||
} else if (err == ENOSPC) {
|
||||
log_error("WARNING! Ensure there is free space on the disk %s.\n", name);
|
||||
log_error(err, "WARNING! Ensure there is free space on the disk %s.\n", name);
|
||||
} else if (err == ENOENT) {
|
||||
log_error("WARNING! You cannot modify files during a sync.\n");
|
||||
log_error("Rerun the sync command when finished.\n");
|
||||
log_error(err, "WARNING! You cannot modify files during a sync.\n");
|
||||
log_error(err, "Rerun the sync command when finished.\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
|
|||
/* and closing a descriptor should never fail */
|
||||
log_tag("%s:%u:%s:%s: Close error. %s.\n", es(errno), i, disk->name, esc_tag(report->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping at block %u\n", i);
|
||||
log_fatal(errno, "Stopping at block %u\n", i);
|
||||
|
||||
if (errno == EIO) {
|
||||
++io_error;
|
||||
|
|
@ -212,10 +212,10 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
|
|||
log_fatal_errno(errno, disk->name);
|
||||
|
||||
if (errno == EIO) {
|
||||
log_fatal("Stopping at block %u\n", i);
|
||||
log_fatal(errno, "Stopping at block %u\n", i);
|
||||
++io_error;
|
||||
} else {
|
||||
log_fatal("Stopping to allow recovery. Try with 'snapraid check -f /%s'\n", fmt_poll(disk, file->sub, esc_buffer));
|
||||
log_fatal(errno, "Stopping to allow recovery. Try with 'snapraid check -f /%s'\n", fmt_poll(disk, file->sub, esc_buffer));
|
||||
++soft_error;
|
||||
}
|
||||
goto bail;
|
||||
|
|
@ -230,14 +230,14 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
|
|||
) {
|
||||
if (handle[j].st.st_size != file->size) {
|
||||
log_tag("error:%u:%s:%s: Unexpected size change\n", i, disk->name, esc_tag(file->sub, esc_buffer));
|
||||
log_error("Unexpected size change at file '%s' from %" PRIu64 " to %" PRIu64 ".\n", handle[j].path, file->size, (uint64_t)handle[j].st.st_size);
|
||||
log_error(ESOFT, "Unexpected size change at file '%s' from %" PRIu64 " to %" PRIu64 ".\n", handle[j].path, file->size, (uint64_t)handle[j].st.st_size);
|
||||
} else if (handle[j].st.st_mtime != file->mtime_sec
|
||||
|| STAT_NSEC(&handle[j].st) != file->mtime_nsec) {
|
||||
log_tag("error:%u:%s:%s: Unexpected time change\n", i, disk->name, esc_tag(file->sub, esc_buffer));
|
||||
log_error("Unexpected time change at file '%s' from %" PRIu64 ".%d to %" PRIu64 ".%d.\n", handle[j].path, file->mtime_sec, file->mtime_nsec, (uint64_t)handle[j].st.st_mtime, STAT_NSEC(&handle[j].st));
|
||||
log_error(ESOFT, "Unexpected time change at file '%s' from %" PRIu64 ".%d to %" PRIu64 ".%d.\n", handle[j].path, file->mtime_sec, file->mtime_nsec, (uint64_t)handle[j].st.st_mtime, STAT_NSEC(&handle[j].st));
|
||||
} else {
|
||||
log_tag("error:%u:%s:%s: Unexpected inode change\n", i, disk->name, esc_tag(file->sub, esc_buffer));
|
||||
log_error("Unexpected inode change from %" PRIu64 " to %" PRIu64 " at file '%s'.\n", file->inode, (uint64_t)handle[j].st.st_ino, handle[j].path);
|
||||
log_error(ESOFT, "Unexpected inode change from %" PRIu64 " to %" PRIu64 " at file '%s'.\n", file->inode, (uint64_t)handle[j].st.st_ino, handle[j].path);
|
||||
}
|
||||
log_error_errno(ENOENT, disk->name); /* same message for ENOENT */
|
||||
|
||||
|
|
@ -255,10 +255,10 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
|
|||
log_fatal_errno(errno, disk->name);
|
||||
|
||||
if (errno == EIO) {
|
||||
log_fatal("Stopping at block %u\n", i);
|
||||
log_fatal(errno, "Stopping at block %u\n", i);
|
||||
++io_error;
|
||||
} else {
|
||||
log_fatal("Stopping to allow recovery. Try with 'snapraid check -f /%s'\n", fmt_poll(disk, file->sub, esc_buffer));
|
||||
log_fatal(errno, "Stopping to allow recovery. Try with 'snapraid check -f /%s'\n", fmt_poll(disk, file->sub, esc_buffer));
|
||||
++soft_error;
|
||||
}
|
||||
goto bail;
|
||||
|
|
@ -286,16 +286,16 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
|
|||
/* compare the hash */
|
||||
if (memcmp(hash, block->hash, BLOCK_HASH_SIZE) != 0) {
|
||||
log_tag("error_data:%u:%s:%s: Unexpected data change\n", i, disk->name, esc_tag(file->sub, esc_buffer));
|
||||
log_error("Data change at file '%s' at position '%u'\n", handle[j].path, file_pos);
|
||||
log_error("WARNING! Unexpected data modification of a file without parity!\n");
|
||||
log_error(EDATA, "Data change at file '%s' at position '%u'\n", handle[j].path, file_pos);
|
||||
log_error(EDATA, "WARNING! Unexpected data modification of a file without parity!\n");
|
||||
|
||||
if (file_flag_has(file, FILE_IS_COPY)) {
|
||||
log_error("This file was detected as a copy of another file with the same name, size,\n");
|
||||
log_error("and timestamp, but the file data isn't matching the assumed copy.\n");
|
||||
log_error("If this is a false positive, and the files are expected to be different,\n");
|
||||
log_error("you can 'sync' anyway using 'snapraid --force-nocopy sync'\n");
|
||||
log_error(EDATA, "This file was detected as a copy of another file with the same name, size,\n");
|
||||
log_error(EDATA, "and timestamp, but the file data isn't matching the assumed copy.\n");
|
||||
log_error(EDATA, "If this is a false positive, and the files are expected to be different,\n");
|
||||
log_error(EDATA, "you can 'sync' anyway using 'snapraid --force-nocopy sync'\n");
|
||||
} else {
|
||||
log_error("Try removing the file from the array and rerun the 'sync' command!\n");
|
||||
log_error(EDATA, "Try removing the file from the array and rerun the 'sync' command!\n");
|
||||
}
|
||||
|
||||
/* block sync to allow a recovery before overwriting */
|
||||
|
|
@ -342,7 +342,7 @@ static int state_hash_process(struct snapraid_state* state, block_off_t blocksta
|
|||
/* and closing a descriptor should never fail */
|
||||
log_tag("%s:%u:%s:%s: Close error. %s.\n", es(errno), blockmax, disk->name, esc_tag(report->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping at block %u\n", blockmax);
|
||||
log_fatal(errno, "Stopping at block %u\n", blockmax);
|
||||
|
||||
if (errno == EIO) {
|
||||
++io_error;
|
||||
|
|
@ -374,7 +374,7 @@ end:
|
|||
}
|
||||
|
||||
if (soft_error)
|
||||
log_fatal("WARNING! Unexpected soft errors!\n");
|
||||
log_fatal(ESOFT, "WARNING! Unexpected soft errors!\n");
|
||||
|
||||
log_tag("hash_summary:error_soft:%u\n", soft_error);
|
||||
|
||||
|
|
@ -540,7 +540,7 @@ static void sync_data_reader(struct snapraid_worker* worker, struct snapraid_tas
|
|||
/* and closing a descriptor should never fail */
|
||||
log_tag("%s:%u:%s:%s: Close error. %s.\n", es(errno), blockcur, disk->name, esc_tag(report->sub, esc_buffer), strerror(errno));
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
|
||||
if (errno == EIO) {
|
||||
task->state = TASK_STATE_IOERROR;
|
||||
|
|
@ -576,10 +576,10 @@ static void sync_data_reader(struct snapraid_worker* worker, struct snapraid_tas
|
|||
log_fatal_errno(errno, disk->name);
|
||||
|
||||
if (errno == EIO) {
|
||||
log_fatal("Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
task->state = TASK_STATE_IOERROR;
|
||||
} else {
|
||||
log_fatal("Stopping to allow recovery. Try with 'snapraid check -f /%s'\n", fmt_poll(disk, task->file->sub, esc_buffer));
|
||||
log_fatal(errno, "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;
|
||||
|
|
@ -594,12 +594,12 @@ static void sync_data_reader(struct snapraid_worker* worker, struct snapraid_tas
|
|||
) {
|
||||
log_tag("error:%u:%s:%s: Unexpected attribute change\n", blockcur, disk->name, esc_tag(task->file->sub, esc_buffer));
|
||||
if (handle->st.st_size != task->file->size) {
|
||||
log_error("Unexpected size change at file '%s' from %" PRIu64 " to %" PRIu64 ".\n", handle->path, task->file->size, (uint64_t)handle->st.st_size);
|
||||
log_error(ESOFT, "Unexpected size change at file '%s' from %" PRIu64 " to %" PRIu64 ".\n", handle->path, task->file->size, (uint64_t)handle->st.st_size);
|
||||
} else if (handle->st.st_mtime != task->file->mtime_sec
|
||||
|| STAT_NSEC(&handle->st) != task->file->mtime_nsec) {
|
||||
log_error("Unexpected time change at file '%s' from %" PRIu64 ".%d to %" PRIu64 ".%d.\n", handle->path, task->file->mtime_sec, task->file->mtime_nsec, (uint64_t)handle->st.st_mtime, STAT_NSEC(&handle->st));
|
||||
log_error(ESOFT, "Unexpected time change at file '%s' from %" PRIu64 ".%d to %" PRIu64 ".%d.\n", handle->path, task->file->mtime_sec, task->file->mtime_nsec, (uint64_t)handle->st.st_mtime, STAT_NSEC(&handle->st));
|
||||
} else {
|
||||
log_error("Unexpected inode change from %" PRIu64 " to %" PRIu64 " at file '%s'.\n", task->file->inode, (uint64_t)handle->st.st_ino, handle->path);
|
||||
log_error(ESOFT, "Unexpected inode change from %" PRIu64 " to %" PRIu64 " at file '%s'.\n", task->file->inode, (uint64_t)handle->st.st_ino, handle->path);
|
||||
}
|
||||
log_error_errno(ENOENT, disk->name); /* same message for ENOENT */
|
||||
|
||||
|
|
@ -620,7 +620,7 @@ static void sync_data_reader(struct snapraid_worker* worker, struct snapraid_tas
|
|||
task->state = TASK_STATE_IOERROR_CONTINUE;
|
||||
} else {
|
||||
log_fatal_errno(errno, disk->name);
|
||||
log_fatal("Stopping to allow recovery. Try with 'snapraid check -f /%s'\n", fmt_poll(disk, task->file->sub, esc_buffer));
|
||||
log_fatal(errno, "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;
|
||||
|
|
@ -655,7 +655,7 @@ static void sync_parity_writer(struct snapraid_worker* worker, struct snapraid_t
|
|||
task->state = TASK_STATE_IOERROR_CONTINUE;
|
||||
} else {
|
||||
log_fatal_errno(errno, lev_config_name(level));
|
||||
log_fatal("Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
task->state = TASK_STATE_ERROR;
|
||||
}
|
||||
return;
|
||||
|
|
@ -919,8 +919,8 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
++io_error;
|
||||
if (io_error >= state->opt.io_error_limit) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("DANGER! Too many input/output errors in the %s disk. It isn't possible to continue.\n", disk->dir);
|
||||
log_fatal("Stopping at block %u\n", blockcur);
|
||||
log_fatal(EIO, "DANGER! Too many input/output errors in the %s disk. It isn't possible to continue.\n", disk->dir);
|
||||
log_fatal(EIO, "Stopping at block %u\n", blockcur);
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -931,7 +931,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
}
|
||||
if (task->state != TASK_STATE_DONE) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency in task state\n");
|
||||
log_fatal(EINTERNAL, "Internal inconsistency in task state\n");
|
||||
os_abort();
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -958,16 +958,16 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
/* if the file has invalid parity, it's a REP changed during the sync */
|
||||
if (block_has_invalid_parity(block)) {
|
||||
log_tag("error:%u:%s:%s: Unexpected data change\n", blockcur, disk->name, esc_tag(file->sub, esc_buffer));
|
||||
log_error("Data change at file '%s' at position '%u'\n", task->path, file_pos);
|
||||
log_error("WARNING! Unexpected data modification of a file without parity!\n");
|
||||
log_error(ESOFT, "Data change at file '%s' at position '%u'\n", task->path, file_pos);
|
||||
log_error(ESOFT, "WARNING! Unexpected data modification of a file without parity!\n");
|
||||
|
||||
if (file_flag_has(file, FILE_IS_COPY)) {
|
||||
log_error("This file was detected as a copy of another file with the same name, size,\n");
|
||||
log_error("and timestamp, but the file data isn't matching the assumed copy.\n");
|
||||
log_error("If this is a false positive, and the files are expected to be different,\n");
|
||||
log_error("you can 'sync' anyway using 'snapraid --force-nocopy sync'\n");
|
||||
log_error(ESOFT, "This file was detected as a copy of another file with the same name, size,\n");
|
||||
log_error(ESOFT, "and timestamp, but the file data isn't matching the assumed copy.\n");
|
||||
log_error(ESOFT, "If this is a false positive, and the files are expected to be different,\n");
|
||||
log_error(ESOFT, "you can 'sync' anyway using 'snapraid --force-nocopy sync'\n");
|
||||
} else {
|
||||
log_error("Try removing the file from the array and rerun the 'sync' command!\n");
|
||||
log_error(ESOFT, "Try removing the file from the array and rerun the 'sync' command!\n");
|
||||
}
|
||||
|
||||
++soft_error;
|
||||
|
|
@ -979,7 +979,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
} else { /* otherwise it's a BLK with silent error */
|
||||
unsigned diff = memdiff(hash, block->hash, BLOCK_HASH_SIZE);
|
||||
log_tag("error_data:%u:%s:%s: Data error at position %u, diff hash bits %u/%u\n", blockcur, disk->name, esc_tag(file->sub, esc_buffer), file_pos, diff, BLOCK_HASH_SIZE * 8);
|
||||
log_error("Data error in file '%s' at position '%u', diff hash bits %u/%u\n", task->path, file_pos, diff, BLOCK_HASH_SIZE * 8);
|
||||
log_error(EDATA, "Data error in file '%s' at position '%u', diff hash bits %u/%u\n", task->path, file_pos, diff, BLOCK_HASH_SIZE * 8);
|
||||
|
||||
/* save the failed block for the fix */
|
||||
failed[failed_count].index = diskcur;
|
||||
|
|
@ -1084,8 +1084,8 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
if (errno == EIO) {
|
||||
log_error_errno(errno, lev_config_name(l));
|
||||
if (io_error >= state->opt.io_error_limit) {
|
||||
log_fatal("DANGER! Too many input/output errors in the %s disk. It isn't possible to continue.\n", lev_config_name(l));
|
||||
log_fatal("Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "DANGER! Too many input/output errors in the %s disk. It isn't possible to continue.\n", lev_config_name(l));
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
++io_error;
|
||||
goto bail;
|
||||
}
|
||||
|
|
@ -1096,7 +1096,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
}
|
||||
|
||||
log_fatal_errno(errno, lev_config_name(l));
|
||||
log_fatal("Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
++soft_error;
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -1263,8 +1263,8 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
++io_error;
|
||||
if (io_error >= state->opt.io_error_limit) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("DANGER! Too many input/output errors in a parity disk. It isn't possible to continue.\n");
|
||||
log_fatal("Stopping at block %u\n", blockcur);
|
||||
log_fatal(EIO, "DANGER! Too many input/output errors in a parity disk. It isn't possible to continue.\n");
|
||||
log_fatal(EIO, "Stopping at block %u\n", blockcur);
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1310,7 +1310,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
ret = state_flush(state, &io, parity_handle, blockcur);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
++io_error;
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -1345,7 +1345,7 @@ static int state_sync_process(struct snapraid_state* state, struct snapraid_pari
|
|||
ret = state_flush(state, &io, parity_handle, blockcur);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Stopping at block %u\n", blockcur);
|
||||
log_fatal(EIO, "Stopping at block %u\n", blockcur);
|
||||
++io_error;
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -1369,7 +1369,7 @@ end:
|
|||
ret = state_flush(state, &io, parity_handle, blockcur);
|
||||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Stopping at block %u\n", blockcur);
|
||||
log_fatal(errno, "Stopping at block %u\n", blockcur);
|
||||
++io_error;
|
||||
goto bail;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -1380,7 +1380,7 @@ end:
|
|||
if ((state->need_write || state->opt.force_content_write))
|
||||
state_write(state);
|
||||
} else {
|
||||
log_fatal("WARNING! Skipped writing state due to --test-kill-after-sync option.\n");
|
||||
log_fatal(EUSER, "WARNING! Skipped writing state due to --test-kill-after-sync option.\n");
|
||||
}
|
||||
|
||||
state_usage_print(state);
|
||||
|
|
@ -1397,14 +1397,14 @@ end:
|
|||
}
|
||||
|
||||
if (soft_error)
|
||||
log_fatal("WARNING! Unexpected soft errors!\n");
|
||||
log_fatal(ESOFT, "WARNING! Unexpected soft errors!\n");
|
||||
if (io_error)
|
||||
log_fatal("DANGER! Unexpected input/output errors! The failing blocks are now marked as bad!\n");
|
||||
log_fatal(EIO, "DANGER! Unexpected input/output errors! The failing blocks are now marked as bad!\n");
|
||||
if (silent_error)
|
||||
log_fatal("DANGER! Unexpected silent data errors! The failing blocks are now marked as bad!\n");
|
||||
log_fatal(EDATA, "DANGER! Unexpected silent data errors! The failing blocks are now marked as bad!\n");
|
||||
if (io_error || silent_error) {
|
||||
log_fatal("Use 'snapraid status' to list the bad blocks.\n");
|
||||
log_fatal("Use 'snapraid -e fix' to recover.\n");
|
||||
log_fatal(ESOFT, "Use 'snapraid status' to list the bad blocks.\n");
|
||||
log_fatal(ESOFT, "Use 'snapraid -e fix' to recover.\n");
|
||||
}
|
||||
|
||||
log_tag("summary:error_soft:%u\n", soft_error);
|
||||
|
|
@ -1487,7 +1487,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
|
||||
if (blockstart > blockmax) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error in the starting block %u. It is larger than the parity size %u.\n", blockstart, blockmax);
|
||||
log_fatal(EUSER, "Error in the starting block %u. It is larger than the parity size %u.\n", blockstart, blockmax);
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1517,7 +1517,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
|
||||
/* if the file is too small */
|
||||
if (parityblocks < used_paritymax) {
|
||||
log_fatal("WARNING! The %s parity has only %u blocks instead of %u.\n", lev_name(l), parityblocks, used_paritymax);
|
||||
log_fatal(ESOFT, "WARNING! The %s parity has only %u blocks instead of %u.\n", lev_name(l), parityblocks, used_paritymax);
|
||||
}
|
||||
|
||||
/* keep the smallest parity number of blocks */
|
||||
|
|
@ -1530,15 +1530,15 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
/* if the parities are too small */
|
||||
if (file_paritymax < used_paritymax) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("DANGER! One or more the parity files are smaller than expected!\n");
|
||||
log_fatal(ESOFT, "DANGER! One or more the parity files are smaller than expected!\n");
|
||||
if (file_paritymax != 0) {
|
||||
log_fatal("If this happens because you are using an old content file,\n");
|
||||
log_fatal("you can 'sync' anyway using 'snapraid --force-full sync'\n");
|
||||
log_fatal("to force a full rebuild of the parity.\n");
|
||||
log_fatal(ESOFT, "If this happens because you are using an old content file,\n");
|
||||
log_fatal(ESOFT, "you can 'sync' anyway using 'snapraid --force-full sync'\n");
|
||||
log_fatal(ESOFT, "to force a full rebuild of the parity.\n");
|
||||
} else {
|
||||
log_fatal("It's possible that the parity disks are not mounted.\n");
|
||||
log_fatal("If instead you are adding a new parity level, you can 'sync' using\n");
|
||||
log_fatal("'snapraid --force-full sync' to force a full rebuild of the parity.\n");
|
||||
log_fatal(ESOFT, "It's possible that the parity disks are not mounted.\n");
|
||||
log_fatal(ESOFT, "If instead you are adding a new parity level, you can 'sync' using\n");
|
||||
log_fatal(ESOFT, "'snapraid --force-full sync' to force a full rebuild of the parity.\n");
|
||||
}
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -1575,7 +1575,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
data_off_t out_size;
|
||||
parity_size(&parity_handle[l], &out_size);
|
||||
parity_overflow(state, out_size);
|
||||
log_fatal("WARNING! Without a usable %s file, it isn't possible to sync.\n", lev_name(l));
|
||||
log_fatal(errno, "WARNING! Without a usable %s file, it isn't possible to sync.\n", lev_name(l));
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1611,7 +1611,7 @@ int state_sync(struct snapraid_state* state, block_off_t blockstart, block_off_t
|
|||
if (state->need_write)
|
||||
state_write(state);
|
||||
} else {
|
||||
log_fatal("WARNING! Skipped state write for --test-skip-content-write option.\n");
|
||||
log_fatal(EUSER, "WARNING! Skipped state write for --test-skip-content-write option.\n");
|
||||
}
|
||||
|
||||
/* skip degenerated cases of empty parity, or skipping all */
|
||||
|
|
|
|||
|
|
@ -376,7 +376,7 @@ int state_thermal_begin(struct snapraid_state* state, time_t now)
|
|||
|
||||
if (state->thermal_temperature_limit != 0 && state->thermal_temperature_limit <= state->thermal_ambient_temperature) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("DANGER! System temperature of %d degrees is higher than the temperature limit of %d degrees. Unable to proceed!\n", state->thermal_ambient_temperature, state->thermal_temperature_limit);
|
||||
log_fatal(EENVIRONMENT, "DANGER! System temperature of %d degrees is higher than the temperature limit of %d degrees. Unable to proceed!\n", state->thermal_ambient_temperature, state->thermal_temperature_limit);
|
||||
log_flush();
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
@ -385,7 +385,7 @@ int state_thermal_begin(struct snapraid_state* state, time_t now)
|
|||
|
||||
if (state_thermal_alarm(state)) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("DANGER! Hard disk temperature of %d degrees is already outside the operating range. Unable to proceed!\n", state->thermal_highest_temperature);
|
||||
log_fatal(EENVIRONMENT, "DANGER! Hard disk temperature of %d degrees is already outside the operating range. Unable to proceed!\n", state->thermal_highest_temperature);
|
||||
log_flush();
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ void state_touch(struct snapraid_state* state)
|
|||
/* get a random nanosecond value */
|
||||
if (randomize(&nano, sizeof(nano)) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to retrieve random values.\n");
|
||||
log_fatal(errno, "Failed to retrieve random values.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ void state_touch(struct snapraid_state* state)
|
|||
f = open(path, flags);
|
||||
if (f == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error opening file '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error opening file '%s'. %s.\n", path, strerror(errno));
|
||||
continue;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -92,7 +92,7 @@ void state_touch(struct snapraid_state* state)
|
|||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
close(f);
|
||||
log_fatal("Error accessing file '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error accessing file '%s'. %s.\n", path, strerror(errno));
|
||||
continue;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ void state_touch(struct snapraid_state* state)
|
|||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
close(f);
|
||||
log_fatal("Error timing file '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error timing file '%s'. %s.\n", path, strerror(errno));
|
||||
continue;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -114,7 +114,7 @@ void state_touch(struct snapraid_state* state)
|
|||
if (ret == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
close(f);
|
||||
log_fatal("Error accessing file '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error accessing file '%s'. %s.\n", path, strerror(errno));
|
||||
continue;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -123,7 +123,7 @@ void state_touch(struct snapraid_state* state)
|
|||
ret = close(f);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Error closing file '%s'. %s.\n", path, strerror(errno));
|
||||
log_fatal(errno, "Error closing file '%s'. %s.\n", path, strerror(errno));
|
||||
continue;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -353,13 +353,13 @@ static int tagread(const char* path, const char* tag, char* value, size_t value_
|
|||
ret = sysread(path, buf, sizeof(buf));
|
||||
if (ret < 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to read '%s'.\n", path);
|
||||
log_fatal(errno, "Failed to read '%s'.\n", path);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if ((size_t)ret + 1 > sizeof(buf)) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Too long read '%s'.\n", path);
|
||||
log_fatal(EEXTERNAL, "Too long read '%s'.\n", path);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -394,7 +394,7 @@ static int tagread(const char* path, const char* tag, char* value, size_t value_
|
|||
}
|
||||
if (!*i) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Missing tag '%s' for '%s'.\n", tag, path);
|
||||
log_fatal(EEXTERNAL, "Missing tag '%s' for '%s'.\n", tag, path);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -407,7 +407,7 @@ static int tagread(const char* path, const char* tag, char* value, size_t value_
|
|||
|
||||
if (!*i) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Empty tag '%s' for '%s'.\n", tag, path);
|
||||
log_fatal(EEXTERNAL, "Empty tag '%s' for '%s'.\n", tag, path);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1253,7 +1253,7 @@ static dev_t devread(const char* path)
|
|||
f = open(path, O_RDONLY);
|
||||
if (f == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to open '%s'.\n", path);
|
||||
log_fatal(errno, "Failed to open '%s'.\n", path);
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1262,14 +1262,14 @@ static dev_t devread(const char* path)
|
|||
if (len < 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
close(f);
|
||||
log_fatal("Failed to read '%s'.\n", path);
|
||||
log_fatal(errno, "Failed to read '%s'.\n", path);
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (len == sizeof(buf)) {
|
||||
/* LCOV_EXCL_START */
|
||||
close(f);
|
||||
log_fatal("Too long read '%s'.\n", path);
|
||||
log_fatal(EEXTERNAL, "Too long read '%s'.\n", path);
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1277,7 +1277,7 @@ static dev_t devread(const char* path)
|
|||
ret = close(f);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to close '%s'.\n", path);
|
||||
log_fatal(errno, "Failed to close '%s'.\n", path);
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1287,7 +1287,7 @@ static dev_t devread(const char* path)
|
|||
ma = strtoul(buf, &e, 10);
|
||||
if (*e != ':') {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Invalid format in '%s' for '%s'.\n", path, buf);
|
||||
log_fatal(EEXTERNAL, "Invalid format in '%s' for '%s'.\n", path, buf);
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1295,7 +1295,7 @@ static dev_t devread(const char* path)
|
|||
mi = strtoul(e + 1, &e, 10);
|
||||
if (*e != 0 && !isspace(*e)) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Invalid format in '%s' for '%s'.\n", path, buf);
|
||||
log_fatal(EEXTERNAL, "Invalid format in '%s' for '%s'.\n", path, buf);
|
||||
return 0;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1372,7 +1372,7 @@ static int devtree(devinfo_t* parent, dev_t device, tommy_list* list)
|
|||
/* get the device file */
|
||||
if (devresolve(device, path, sizeof(path)) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to resolve device '%u:%u'.\n", major(device), minor(device));
|
||||
log_fatal(EEXTERNAL, "Failed to resolve device '%u:%u'.\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1412,7 +1412,7 @@ static int devscan(tommy_list* list)
|
|||
d = opendir(dir);
|
||||
if (d == 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to open dir '%s'.\n", dir);
|
||||
log_fatal(errno, "Failed to open dir '%s'.\n", dir);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1490,14 +1490,14 @@ static int devsmart(dev_t device, const char* name, const char* smartctl, uint64
|
|||
x = find_smartctl();
|
||||
if (!x) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Cannot find smartctl.\n");
|
||||
log_fatal(EEXTERNAL, "Cannot find smartctl.\n");
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (devresolve(device, file, sizeof(file)) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to resolve device '%u:%u'.\n", major(device), minor(device));
|
||||
log_fatal(EEXTERNAL, "Failed to resolve device '%u:%u'.\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1517,7 +1517,7 @@ static int devsmart(dev_t device, const char* name, const char* smartctl, uint64
|
|||
if (!f) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("device:%s:%s:shell\n", file, name);
|
||||
log_fatal("Failed to run '%s' (from popen).\n", cmd);
|
||||
log_fatal(EEXTERNAL, "Failed to run '%s' (from popen).\n", cmd);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1537,14 +1537,14 @@ static int devsmart(dev_t device, const char* name, const char* smartctl, uint64
|
|||
if (!WIFEXITED(ret)) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("device:%s:%s:abort\n", file, name);
|
||||
log_fatal("Failed to run '%s' (not exited).\n", cmd);
|
||||
log_fatal(EEXTERNAL, "Failed to run '%s' (not exited).\n", cmd);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (WEXITSTATUS(ret) == 127) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("device:%s:%s:shell\n", file, name);
|
||||
log_fatal("Failed to run '%s' (from sh).\n", cmd);
|
||||
log_fatal(EEXTERNAL, "Failed to run '%s' (from sh).\n", cmd);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1575,13 +1575,13 @@ static int devstat(dev_t device, uint64_t* count)
|
|||
ret = sysread(path, buf, sizeof(buf));
|
||||
if (ret < 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to read '%s'.\n", path);
|
||||
log_fatal(errno, "Failed to read '%s'.\n", path);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if ((size_t)ret + 1 > sizeof(buf)) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Too long read '%s'.\n", path);
|
||||
log_fatal(EEXTERNAL, "Too long read '%s'.\n", path);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1728,14 +1728,14 @@ static int devprobe(dev_t device, const char* name, const char* smartctl, int* p
|
|||
x = find_smartctl();
|
||||
if (!x) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Cannot find smartctl.\n");
|
||||
log_fatal(EEXTERNAL, "Cannot find smartctl.\n");
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (devresolve(device, file, sizeof(file)) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to resolve device '%u:%u'.\n", major(device), minor(device));
|
||||
log_fatal(EEXTERNAL, "Failed to resolve device '%u:%u'.\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1755,7 +1755,7 @@ static int devprobe(dev_t device, const char* name, const char* smartctl, int* p
|
|||
if (!f) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("device:%s:%s:shell\n", file, name);
|
||||
log_fatal("Failed to run '%s' (from popen).\n", cmd);
|
||||
log_fatal(EEXTERNAL, "Failed to run '%s' (from popen).\n", cmd);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1775,14 +1775,14 @@ static int devprobe(dev_t device, const char* name, const char* smartctl, int* p
|
|||
if (!WIFEXITED(ret)) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("device:%s:%s:abort\n", file, name);
|
||||
log_fatal("Failed to run '%s' (not exited).\n", cmd);
|
||||
log_fatal(EEXTERNAL, "Failed to run '%s' (not exited).\n", cmd);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (WEXITSTATUS(ret) == 127) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("device:%s:%s:shell\n", file, name);
|
||||
log_fatal("Failed to run '%s' (from sh).\n", cmd);
|
||||
log_fatal(EEXTERNAL, "Failed to run '%s' (from sh).\n", cmd);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1817,14 +1817,14 @@ static int devdown(dev_t device, const char* name, const char* smartctl)
|
|||
x = find_smartctl();
|
||||
if (!x) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Cannot find smartctl.\n");
|
||||
log_fatal(EEXTERNAL, "Cannot find smartctl.\n");
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (devresolve(device, file, sizeof(file)) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to resolve device '%u:%u'.\n", major(device), minor(device));
|
||||
log_fatal(EEXTERNAL, "Failed to resolve device '%u:%u'.\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1844,7 +1844,7 @@ static int devdown(dev_t device, const char* name, const char* smartctl)
|
|||
if (!f) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("device:%s:%s:shell\n", file, name);
|
||||
log_fatal("Failed to run '%s' (from popen).\n", cmd);
|
||||
log_fatal(EEXTERNAL, "Failed to run '%s' (from popen).\n", cmd);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1864,21 +1864,21 @@ static int devdown(dev_t device, const char* name, const char* smartctl)
|
|||
if (!WIFEXITED(ret)) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("device:%s:%s:abort\n", file, name);
|
||||
log_fatal("Failed to run '%s' (not exited).\n", cmd);
|
||||
log_fatal(EEXTERNAL, "Failed to run '%s' (not exited).\n", cmd);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (WEXITSTATUS(ret) == 127) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("device:%s:%s:shell\n", file, name);
|
||||
log_fatal("Failed to run '%s' (from sh).\n", cmd);
|
||||
log_fatal(EEXTERNAL, "Failed to run '%s' (from sh).\n", cmd);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
if (WEXITSTATUS(ret) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_tag("device:%s:%s:exit:%d\n", file, name, WEXITSTATUS(ret));
|
||||
log_fatal("Failed to run '%s' with return code %xh.\n", cmd, WEXITSTATUS(ret));
|
||||
log_fatal(EEXTERNAL, "Failed to run '%s' with return code %xh.\n", cmd, WEXITSTATUS(ret));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1922,7 +1922,7 @@ static int devup(dev_t device, const char* name)
|
|||
|
||||
if (devresolve(device, file, sizeof(file)) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to resolve device '%u:%u'.\n", major(device), minor(device));
|
||||
log_fatal(EEXTERNAL, "Failed to resolve device '%u:%u'.\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1930,7 +1930,7 @@ static int devup(dev_t device, const char* name)
|
|||
/* O_DIRECT requires memory aligned to the block size */
|
||||
if (posix_memalign(&buf, 4096, 4096) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to allocate aligned memory for device '%u:%u'.\n", major(device), minor(device));
|
||||
log_fatal(errno, "Failed to allocate aligned memory for device '%u:%u'.\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1940,7 +1940,7 @@ static int devup(dev_t device, const char* name)
|
|||
/* LCOV_EXCL_START */
|
||||
free(buf);
|
||||
log_tag("device:%s:%s:error:%d\n", file, name, errno);
|
||||
log_fatal("Failed to open device '%u:%u'.\n", major(device), minor(device));
|
||||
log_fatal(errno, "Failed to open device '%u:%u'.\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1950,7 +1950,7 @@ static int devup(dev_t device, const char* name)
|
|||
close(f);
|
||||
free(buf);
|
||||
log_tag("device:%s:%s:error:%d\n", file, name, errno);
|
||||
log_fatal("Failed to get device size '%u:%u'.\n", major(device), minor(device));
|
||||
log_fatal(errno, "Failed to get device size '%u:%u'.\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1966,7 +1966,7 @@ static int devup(dev_t device, const char* name)
|
|||
close(f);
|
||||
free(buf);
|
||||
log_tag("device:%s:%s:error:%d\n", file, name, errno);
|
||||
log_fatal("Failed to advise device '%u:%u'.\n", major(device), minor(device));
|
||||
log_fatal(errno, "Failed to advise device '%u:%u'.\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1978,7 +1978,7 @@ static int devup(dev_t device, const char* name)
|
|||
close(f);
|
||||
free(buf);
|
||||
log_tag("device:%s:%s:error:%d\n", file, name, errno);
|
||||
log_fatal("Failed to read device '%u:%u'.\n", major(device), minor(device));
|
||||
log_fatal(errno, "Failed to read device '%u:%u'.\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -1988,7 +1988,7 @@ static int devup(dev_t device, const char* name)
|
|||
/* LCOV_EXCL_START */
|
||||
free(buf);
|
||||
log_tag("device:%s:%s:error:%d\n", file, name, errno);
|
||||
log_fatal("Failed to close device '%u:%u'.\n", major(device), minor(device));
|
||||
log_fatal(errno, "Failed to close device '%u:%u'.\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -2193,7 +2193,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation, int others)
|
|||
/* sysfs interface is required */
|
||||
if (stat("/sys/dev/block", &st) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Missing interface /sys/dev/block.\n");
|
||||
log_fatal(EEXTERNAL, "Missing interface /sys/dev/block.\n");
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -2220,7 +2220,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation, int others)
|
|||
/* obtain the real device */
|
||||
if (devdereference(device, &device) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to dereference device '%u:%u'.\n", major(device), minor(device));
|
||||
log_fatal(EEXTERNAL, "Failed to dereference device '%u:%u'.\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -2238,7 +2238,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation, int others)
|
|||
/* get the device file */
|
||||
if (devresolve(device, devinfo->file, sizeof(devinfo->file)) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to resolve device '%u:%u'.\n", major(device), minor(device));
|
||||
log_fatal(EEXTERNAL, "Failed to resolve device '%u:%u'.\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -2246,7 +2246,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation, int others)
|
|||
/* expand the tree of devices */
|
||||
if (devtree(devinfo, device, low) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to expand device '%u:%u'.\n", major(device), minor(device));
|
||||
log_fatal(EEXTERNAL, "Failed to expand device '%u:%u'.\n", major(device), minor(device));
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -2256,7 +2256,7 @@ int devquery(tommy_list* high, tommy_list* low, int operation, int others)
|
|||
if (others) {
|
||||
if (devscan(low) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Failed to list other devices.\n");
|
||||
log_fatal(EEXTERNAL, "Failed to list other devices.\n");
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -2287,7 +2287,7 @@ void os_init(int opt)
|
|||
ret = blkid_get_cache(&cache, NULL);
|
||||
if (ret != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("WARNING Failed to get blkid cache\n");
|
||||
log_fatal(EEXTERNAL, "WARNING Failed to get blkid cache\n");
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
#endif
|
||||
|
|
@ -2379,7 +2379,7 @@ size_t direct_size(void)
|
|||
|
||||
if (size == -1) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("No page size\n");
|
||||
log_fatal(EEXTERNAL, "No page size\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,8 +134,8 @@ void mtest_vector(int n, size_t size, void** vv)
|
|||
{
|
||||
if (fast_mtest_vector(n, size, vv) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("DANGER! Your RAM memory is broken! DO NOT PROCEED UNTIL FIXED!\n");
|
||||
log_fatal("Try running a memory test like http://www.memtest86.com/\n");
|
||||
log_fatal(EINTERNAL, "DANGER! Your RAM memory is broken! DO NOT PROCEED UNTIL FIXED!\n");
|
||||
log_fatal(EINTERNAL, "Try running a memory test like http://www.memtest86.com/\n");
|
||||
exit(EXIT_FAILURE);
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
|
@ -750,7 +750,7 @@ void memhash(unsigned kind, const unsigned char* seed, void* digest, const void*
|
|||
break;
|
||||
default :
|
||||
/* LCOV_EXCL_START */
|
||||
log_fatal("Internal inconsistency in hash function %u\n", kind);
|
||||
log_fatal(EINTERNAL, "Internal inconsistency in hash function %u\n", kind);
|
||||
exit(EXIT_FAILURE);
|
||||
break;
|
||||
/* LCOV_EXCL_STOP */
|
||||
|
|
|
|||
|
|
@ -537,16 +537,22 @@ Messages printed to the screen.
|
|||
.PD 0
|
||||
.HP 4
|
||||
.I <level>
|
||||
One of \`fatal\`, \`error\`, \`expected\`, \`status\`,
|
||||
\`progress\` or \`verbose\`.
|
||||
One of \`fatal\`, \`fatal_hardware\`, \`error\`, \`error_hardware\`,
|
||||
\`expected\`, \`status\`, \`progress\` or \`verbose\`.
|
||||
.HP 4
|
||||
.I fatal
|
||||
A fatal error occurred. Program will abort after this
|
||||
message.
|
||||
.I fatal, fatal_hardware
|
||||
A fatal error occurred. Program will
|
||||
abort after this message.
|
||||
The \`hardware\` one means that the problem was caused
|
||||
by a hardware failure, like an Input/Output error
|
||||
or a silent data error.
|
||||
.HP 4
|
||||
.I error
|
||||
A generic error condition that doesn\'t prevent the
|
||||
program to continue.
|
||||
.I error, error_hardware
|
||||
A generic error condition that doesn\'t
|
||||
prevent the program to continue.
|
||||
The \`hardware\` one means that the problem was caused
|
||||
by a hardware failure, like an Input/Output error
|
||||
or a silent data error.
|
||||
.HP 4
|
||||
.I expected
|
||||
An expected error condition. At present it
|
||||
|
|
|
|||
|
|
@ -358,12 +358,18 @@ General Progress and Execution Tags
|
|||
=msg:<level>:<msg>
|
||||
Messages printed to the screen.
|
||||
|
||||
<level> - One of `fatal`, `error`, `expected`, `status`,
|
||||
`progress` or `verbose`.
|
||||
fatal - A fatal error occurred. Program will abort after this
|
||||
message.
|
||||
error - A generic error condition that doesn't prevent the
|
||||
program to continue.
|
||||
<level> - One of `fatal`, `fatal_hardware`, `error`, `error_hardware`,
|
||||
`expected`, `status`, `progress` or `verbose`.
|
||||
fatal, fatal_hardware - A fatal error occurred. Program will
|
||||
abort after this message.
|
||||
The `hardware` one means that the problem was caused
|
||||
by a hardware failure, like an Input/Output error
|
||||
or a silent data error.
|
||||
error, error_hardware - A generic error condition that doesn't
|
||||
prevent the program to continue.
|
||||
The `hardware` one means that the problem was caused
|
||||
by a hardware failure, like an Input/Output error
|
||||
or a silent data error.
|
||||
expected - An expected error condition. At present it
|
||||
happens only when using the `-m` option with files
|
||||
expected missing.
|
||||
|
|
|
|||
|
|
@ -377,12 +377,18 @@ Only produced when `--gui` option is used.
|
|||
msg:<level>:<msg>
|
||||
Messages printed to the screen.
|
||||
|
||||
<level> - One of `fatal`, `error`, `expected`, `status`,
|
||||
`progress` or `verbose`.
|
||||
fatal - A fatal error occurred. Program will abort after this
|
||||
message.
|
||||
error - A generic error condition that doesn't prevent the
|
||||
program to continue.
|
||||
<level> - One of `fatal`, `fatal_hardware`, `error`, `error_hardware`,
|
||||
`expected`, `status`, `progress` or `verbose`.
|
||||
fatal, fatal_hardware - A fatal error occurred. Program will
|
||||
abort after this message.
|
||||
The `hardware` one means that the problem was caused
|
||||
by a hardware failure, like an Input/Output error
|
||||
or a silent data error.
|
||||
error, error_hardware - A generic error condition that doesn't
|
||||
prevent the program to continue.
|
||||
The `hardware` one means that the problem was caused
|
||||
by a hardware failure, like an Input/Output error
|
||||
or a silent data error.
|
||||
expected - An expected error condition. At present it
|
||||
happens only when using the `-m` option with files
|
||||
expected missing.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue