From e69e8640ce523c3ee332bb10a70ea47ef143b04b Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 4 Jan 2016 17:57:51 +0100 Subject: [PATCH] Use pread also in import and search --- cmdline/import.c | 9 +-------- cmdline/search.c | 9 +-------- 2 files changed, 2 insertions(+), 16 deletions(-) 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));