mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-19 14:36:38 -05:00
More consistent in error reporting for files with garbage at the end.
This commit is contained in:
parent
46fb4a311a
commit
8b3075a023
3 changed files with 21 additions and 13 deletions
9
handle.c
9
handle.c
|
|
@ -177,9 +177,8 @@ int handle_create(struct snapraid_handle* handle, struct snapraid_file* file)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* return the warning condition of a larger file */
|
||||
/* return if the file size was truncated */
|
||||
if (handle->st.st_size > file->size) {
|
||||
fprintf(stderr, "File '%s' truncated to size %"PRIu64".\n", handle->path, file->size);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -272,10 +271,14 @@ int handle_read(struct snapraid_handle* handle, struct snapraid_block* block, un
|
|||
|
||||
read_ret = read(handle->f, block_buffer, read_size);
|
||||
#endif
|
||||
if (read_ret != (ssize_t)read_size) { /* conversion is safe because block_size is always small */
|
||||
if (read_ret < 0) {
|
||||
fprintf(stderr, "Error reading file '%s'. %s.\n", handle->path, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (read_ret != (ssize_t)read_size) {
|
||||
fprintf(stderr, "File '%s' is smaller than expected.\n", handle->path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* pad with 0 */
|
||||
if (read_size < block_size) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue