Index: /zzuf/trunk/src/preload.c
===================================================================
--- /zzuf/trunk/src/preload.c	(revision 1481)
+++ /zzuf/trunk/src/preload.c	(revision 1482)
@@ -34,5 +34,4 @@
 #include <stdlib.h>
 #include <fcntl.h>
-#include <errno.h>
 #include <regex.h>
 
@@ -56,4 +55,5 @@
 static int     (*open64_orig)  (const char *file, int oflag, ...);
 static ssize_t (*read_orig)    (int fd, void *buf, size_t count);
+static off_t   (*lseek_orig)   (int fd, off_t offset, int whence);
 static off64_t (*lseek64_orig) (int fd, off64_t offset, int whence);
 static int     (*close_orig)   (int fd);
@@ -80,4 +80,5 @@
     LOADSYM(open64);
     LOADSYM(read);
+    LOADSYM(lseek);
     LOADSYM(lseek64);
     LOADSYM(close);
@@ -89,5 +90,5 @@
 
 /* Our function wrappers */
-#define FOPEN(fn, path, mode) \
+#define FOPEN(fn) \
     do \
     { \
@@ -117,10 +118,10 @@
 FILE *fopen(const char *path, const char *mode)
 {
-    FILE *ret; FOPEN(fopen, path, mode); return ret;
+    FILE *ret; FOPEN(fopen); return ret;
 }
 
 FILE *fopen64(const char *path, const char *mode)
 {
-    FILE *ret; FOPEN(fopen64, path, mode); return ret;
+    FILE *ret; FOPEN(fopen64); return ret;
 }
 
@@ -197,5 +198,5 @@
 }
 
-#define OPEN(fn, file, oflag) \
+#define OPEN(fn) \
     do \
     { \
@@ -241,10 +242,10 @@
 int open(const char *file, int oflag, ...)
 {
-    int ret; OPEN(open, file, oflag); return ret;
+    int ret; OPEN(open); return ret;
 }
 
 int open64(const char *file, int oflag, ...)
 {
-    int ret; OPEN(open64, file, oflag); return ret;
+    int ret; OPEN(open64); return ret;
 }
 
@@ -268,4 +269,31 @@
         files[fd].pos += ret;
     }
+
+    /* Sanity check */
+    if((uint64_t)lseek64_orig(fd, 0, SEEK_CUR) != files[fd].pos)
+        fprintf(stderr, "ZZUF ERROR: OFFSET INCONSISTENCY\n");
+
+    return ret;
+}
+
+#define LSEEK(fn, off_t) \
+    do { \
+        if(!_zzuf_ready) \
+            LOADSYM(fn); \
+        ret = ORIG(fn)(fd, offset, whence); \
+        if(!_zzuf_ready) \
+            return ret; \
+        if(!files[fd].managed) \
+            return ret; \
+        debug(STR(fn)"(%i, %lli, %i) = %lli", \
+              fd, (long long int)offset, whence, (long long int)ret); \
+        if(ret != (off_t)-1) \
+            files[fd].pos = (int64_t)ret; \
+    } while(0)
+
+off_t lseek(int fd, off_t offset, int whence)
+{
+    off_t ret;
+    LSEEK(lseek, off_t);
     return ret;
 }
@@ -273,19 +301,6 @@
 off64_t lseek64(int fd, off64_t offset, int whence)
 {
-    int ret;
-
-    if(!_zzuf_ready)
-        LOADSYM(lseek64);
-    ret = lseek64_orig(fd, offset, whence);
-    if(!_zzuf_ready)
-        return ret;
-
-    if(!files[fd].managed)
-        return ret;
-
-    debug("lseek64(%i, %lli, %i) = %i", fd, (long long int)offset, whence, ret);
-    if(ret != (off64_t)-1)
-        files[fd].pos = (int64_t)ret;
-
+    off64_t ret;
+    LSEEK(lseek64, off64_t);
     return ret;
 }
