mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Adds a new -l, --log option.
This commit is contained in:
parent
7f8551fccb
commit
0200a2b7fa
19 changed files with 280 additions and 193 deletions
14
parity.c
14
parity.c
|
|
@ -76,8 +76,8 @@ void parity_overflow(struct snapraid_state* state, data_off_t size)
|
|||
if (file->blockmax > 0) {
|
||||
if (file->blockvec[0].parity_pos > blockalloc) {
|
||||
if (state->gui) {
|
||||
fprintf(stderr, "outofparity:%s:%s\n", disk->name, file->sub);
|
||||
fflush(stderr);
|
||||
fprintf(stdlog, "outofparity:%s:%s\n", disk->name, file->sub);
|
||||
fflush(stdlog);
|
||||
}
|
||||
if (first) {
|
||||
first = 0;
|
||||
|
|
@ -363,7 +363,7 @@ int parity_write(struct snapraid_parity* parity, block_off_t pos, unsigned char*
|
|||
return 0;
|
||||
}
|
||||
|
||||
int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char* block_buffer, unsigned block_size)
|
||||
int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char* block_buffer, unsigned block_size, FILE* stdout)
|
||||
{
|
||||
ssize_t read_ret;
|
||||
data_off_t offset;
|
||||
|
|
@ -373,13 +373,13 @@ int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char*
|
|||
|
||||
/* check if we are going to read only not initialized data */
|
||||
if (offset >= parity->valid_size) {
|
||||
fprintf(stderr, "Reading missing data from file '%s' at offset %"PRIu64".\n", parity->path, offset);
|
||||
fprintf(stdout, "Reading missing data from file '%s' at offset %"PRIu64".\n", parity->path, offset);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if !HAVE_PREAD
|
||||
if (lseek(parity->f, offset, SEEK_SET) != offset) {
|
||||
fprintf(stderr, "Error seeking file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno));
|
||||
fprintf(stdout, "Error seeking file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -393,11 +393,11 @@ int parity_read(struct snapraid_parity* parity, block_off_t pos, unsigned char*
|
|||
read_ret = read(parity->f, block_buffer + count, block_size - count);
|
||||
#endif
|
||||
if (read_ret < 0) {
|
||||
fprintf(stderr, "Error reading file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno));
|
||||
fprintf(stdout, "Error reading file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (read_ret == 0) {
|
||||
fprintf(stderr, "Unexpected end of file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno));
|
||||
fprintf(stdout, "Unexpected end of file '%s' at offset %"PRIu64". %s.\n", parity->path, offset, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue