diff --git a/cmdline/import.c b/cmdline/import.c index 0741dd63..c878fb84 100644 --- a/cmdline/import.c +++ b/cmdline/import.c @@ -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)); diff --git a/cmdline/search.c b/cmdline/search.c index 09a26283..357e0498 100644 --- a/cmdline/search.c +++ b/cmdline/search.c @@ -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));