Some error messages changes.

This commit is contained in:
Andrea Mazzoleni 2011-09-03 11:01:12 +02:00
parent 23a26390ce
commit 1ed3d59c02
2 changed files with 11 additions and 7 deletions

View file

@ -226,14 +226,18 @@ int parity_read(const char* path, int f, block_off_t pos, unsigned char* block_b
}
read_ret = read(f, block_buffer, block_size);
#endif
if (read_ret != (ssize_t)block_size) { /* conversion is safe because block_size is always small */
#endif
if (read_ret < 0) {
fprintf(stderr, "Error reading file '%s'. %s.\n", path, 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);
return -1;
}
/* Here isn't needed to call posix_fadvise(..., POSIX_FADV_DONTNEED) because */
/* we already advised sequential access with POSIX_FADV_SEQUENTIAL. */
/* Here isn't needed to call posix_fadvise(..., POSIX_FADV_DONTNEED) */
/* because we already advised sequential access with POSIX_FADV_SEQUENTIAL. */
/* In Linux 2.6.33 it's enough to ensure that data is not kept in the cache. */
/* Better to do nothing and save a syscall for each block. */