mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Prints more error information in case of some errors.
This commit is contained in:
parent
4adef9dc17
commit
59c7c7380c
2 changed files with 6 additions and 6 deletions
6
handle.c
6
handle.c
|
|
@ -240,18 +240,18 @@ int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, un
|
|||
read_ret = pread(handle->f, block_buffer, read_size, offset);
|
||||
#else
|
||||
if (lseek(handle->f, offset, SEEK_SET) != offset) {
|
||||
fprintf(stderr, "Error seeking file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
fprintf(stderr, "Error seeking file '%s' at offset %"PRIu64". %s.\n", handle->path, offset, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
read_ret = read(handle->f, block_buffer, read_size);
|
||||
#endif
|
||||
if (read_ret < 0) {
|
||||
fprintf(stderr, "Error reading file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
fprintf(stderr, "Error reading file '%s' at offset %"PRIu64". %s.\n", handle->path, offset, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (read_ret != (ssize_t)read_size) { /* signed conversion is safe because block_size is always small */
|
||||
fprintf(stderr, "File '%s' is smaller than expected.\n", handle->path);
|
||||
fprintf(stderr, "File '%s' is smaller than expected. Read %d bytes instead of %d at offset %"PRIu64".\n", handle->path, (int)read_ret, read_size, offset);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
6
parity.c
6
parity.c
|
|
@ -221,18 +221,18 @@ int parity_read(const char* path, int f, block_off_t pos, unsigned char* block_b
|
|||
read_ret = pread(f, block_buffer, block_size, offset);
|
||||
#else
|
||||
if (lseek(f, offset, SEEK_SET) != offset) {
|
||||
fprintf(stderr, "Error seeking file '%s'. %s.\n", path, strerror(errno));
|
||||
fprintf(stderr, "Error seeking file '%s' at offset %"PRIu64". %s.\n", path, offset, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
read_ret = read(f, block_buffer, block_size);
|
||||
#endif
|
||||
if (read_ret < 0) {
|
||||
fprintf(stderr, "Error reading file '%s'. %s.\n", path, strerror(errno));
|
||||
fprintf(stderr, "Error reading file '%s' at offset %"PRIu64". %s.\n", path, offset, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (read_ret != (ssize_t)block_size) { /* signed conversion is safe because block_size is always small */
|
||||
fprintf(stderr, "File '%s' is smaller than expected.\n", path);
|
||||
fprintf(stderr, "File '%s' is smaller than expected. Read %d bytes instead of %d at offset %"PRIu64".\n", path, (int)read_ret, block_size, offset);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue