Use pread also in import and search

This commit is contained in:
Andrea Mazzoleni 2016-01-04 17:57:51 +01:00
parent 18cc80bd7e
commit e69e8640ce
2 changed files with 2 additions and 16 deletions

View file

@ -185,14 +185,7 @@ int state_import_fetch(struct snapraid_state* state, int rehash, struct snapraid
/* LCOV_EXCL_STOP */
}
if (lseek(f, block->offset, SEEK_SET) != block->offset) {
/* LCOV_EXCL_START */
log_fatal("Error seeking file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
ret = read(f, buffer, read_size);
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));

View file

@ -89,14 +89,7 @@ int search_file_compare(const void* void_arg, const void* void_data)
/* LCOV_EXCL_STOP */
}
if (lseek(f, arg->offset, SEEK_SET) != arg->offset) {
/* LCOV_EXCL_START */
log_fatal("Error seeking file '%s'. %s.\n", path, strerror(errno));
exit(EXIT_FAILURE);
/* LCOV_EXCL_STOP */
}
ret = read(f, arg->buffer, arg->read_size);
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));