summaryrefslogtreecommitdiffstats
path: root/src/ewf.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2010-11-05 09:00:22 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2010-11-05 09:00:22 +0100
commit377144c3a7062b44cdd607c91e86c24cd7fc0f61 (patch)
treef7d7db52476407e8592e046f49763bde31bc2b34 /src/ewf.c
parent173e66e1bc9e04d171097eb57d42692fd4440126 (diff)
Introduce pread_fast(), a function that can return a pointer to the data in cache
instead of using memcpy to fill the buffer with a copy of the data
Diffstat (limited to 'src/ewf.c')
-rw-r--r--src/ewf.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ewf.c b/src/ewf.c
index 2424f9f..cdf7136 100644
--- a/src/ewf.c
+++ b/src/ewf.c
@@ -58,6 +58,7 @@
static const char *fewf_description(disk_t *disk);
static const char *fewf_description_short(disk_t *disk);
static int fewf_clean(disk_t *disk);
+static void *fewf_pread_fast(disk_t *disk, void *buffer, const unsigned int count, const uint64_t offset);
static int fewf_pread(disk_t *disk, void *buffer, const unsigned int count, const uint64_t offset);
static int fewf_nopwrite(disk_t *disk, const void *buffer, const unsigned int count, const uint64_t offset);
static int fewf_sync(disk_t *disk);
@@ -129,6 +130,7 @@ disk_t *fewf_init(const char *device, const arch_fnct_t *arch, const int mode)
disk->data=data;
disk->description=fewf_description;
disk->description_short=fewf_description_short;
+ disk->pread_fast=fewf_pread_fast;
disk->pread=fewf_pread;
disk->pwrite=fewf_nopwrite;
disk->sync=fewf_sync;
@@ -237,6 +239,13 @@ static int fewf_pread(disk_t *disk, void *buffer, const unsigned int count, cons
return taille;
}
+static void *fewf_pread_fast(disk_t *disk, void *buf, const unsigned int count, const uint64_t offset)
+{
+ if(fewf_pread(disk, buf, count, offset)==offset)
+ return buf;
+ return NULL;
+}
+
static int fewf_nopwrite(disk_t *disk, const void *buffer, const unsigned int count, const uint64_t offset)
{
log_error("fewf_nopwrite(xx,%u,buffer,%lu(%u/%u/%u)) write refused\n",