]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Windows: fix parameters and return value from nt_seek
authorRod Widdowson <rdw@steadingsoftware.com>
Sun, 23 Jan 2011 14:29:51 +0000 (14:29 +0000)
committerJeffrey Altman <jaltman@openafs.org>
Tue, 25 Jan 2011 09:56:10 +0000 (01:56 -0800)
SetFilePointerEx takes specific values
(FILE_BEGIN/FILE_CURRENT/FILE_END) whilse fseek requires SEEK_SET,
SEK_END, SEEK_CUR.  It turns out that these overlap, but we should
not let that pass unchallenged.

SetFilePointerEx returns nonzero for success zero for failure. fseek
returns the other way around.

Neither of these changes currently matter, but we should fix them.

Change-Id: Ib31cf6265fa1e714232ff0d2e099c657e41f17e9
Reviewed-on: http://gerrit.openafs.org/3746
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
src/vol/ntops.c
src/vol/ntops.h

index 715480d5eed6399a869390466fa9c2aeabd64bf7..645be227ea0c88b7424502474bcf740ca9d4773b 100644 (file)
@@ -322,15 +322,30 @@ nt_fsync(FD_t fd)
 
 
 int
-nt_seek(FD_t fd, afs_foff_t off, int where)
+nt_seek(FD_t fd, afs_foff_t off, int whence)
 {
     int code;
     LARGE_INTEGER offset;
-
+    int where;
+
+    if (SEEK_SET == whence) {
+       where = FILE_BEGIN;
+    } else if (SEEK_END == whence) {
+       where = FILE_END;
+    } else if (SEEK_CUR == whence) {
+       where = FILE_CURRENT;
+    } else {
+       errno = EINVAL;
+       return -1;
+    }
     offset.QuadPart = off;
 
     code = SetFilePointerEx(fd, offset, NULL, where);
-    return code;
+    if (0 == code) {
+       errno = nterr_nt2unix(GetLastError(), EBADF);
+       return -1;
+    }
+    return 0;
 }
 
 /* nt_DevToDrive
index 66619791066270170d78ff5d46c76725c8ba1929..e50b2e0fdc31d356442f57c14f7f6f31aa0e96a5 100644 (file)
@@ -34,7 +34,7 @@ extern int nt_setFileCreationTime(FD_t fd, FILETIME * ftime);
 extern int nt_sync(int cdrive);
 extern int nt_ftruncate(FD_t fd, afs_foff_t len);
 extern int nt_fsync(FD_t fd);
-extern int nt_seek(FD_t fd, afs_foff_t off, int where);
+extern int nt_seek(FD_t fd, afs_foff_t off, int whence);
 extern FILE *nt_fdopen(IHandle_t * h, char *fdperms);
 extern int nt_unlink(char *name);