vol: Make ntops functions 64-bit capable

Add 64-bit offset and length support to ntops functions.

Change-Id: I1804d49df344839598c39084b7763cec4100c8c7
Reviewed-on: http://gerrit.openafs.org/3708
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
Jeffrey Altman 2011-01-20 02:09:44 -05:00 committed by Derrick Brashear
parent 48508a2021
commit 3c25ae062a
2 changed files with 30 additions and 18 deletions

View File

@ -172,7 +172,7 @@ nt_close(FD_t fd)
}
int
nt_write(FD_t fd, char *buf, size_t size)
nt_write(FD_t fd, char *buf, afs_sfsize_t size)
{
BOOL code;
DWORD nbytes;
@ -187,7 +187,7 @@ nt_write(FD_t fd, char *buf, size_t size)
}
int
nt_pwrite(FD_t fd, const void * buf, size_t count, afs_foff_t offset)
nt_pwrite(FD_t fd, const void * buf, afs_sfsize_t count, afs_foff_t offset)
{
/*
* same comment as read
@ -212,7 +212,7 @@ nt_pwrite(FD_t fd, const void * buf, size_t count, afs_foff_t offset)
}
int
nt_read(FD_t fd, char *buf, size_t size)
nt_read(FD_t fd, char *buf, afs_sfsize_t size)
{
BOOL code;
DWORD nbytes;
@ -230,7 +230,7 @@ nt_read(FD_t fd, char *buf, size_t size)
}
int
nt_pread(FD_t fd, void * buf, size_t count, afs_foff_t offset)
nt_pread(FD_t fd, void * buf, afs_sfsize_t count, afs_foff_t offset)
{
/*
* This really ought to call NtReadFile
@ -259,15 +259,18 @@ nt_pread(FD_t fd, void * buf, size_t count, afs_foff_t offset)
return (ssize_t)nbytes;
}
int
afs_sfsize_t
nt_size(FD_t fd)
{
BY_HANDLE_FILE_INFORMATION finfo;
LARGE_INTEGER FileSize;
if (!GetFileInformationByHandle(fd, &finfo))
return -1;
return finfo.nFileSizeLow;
FileSize.HighPart = finfo.nFileSizeHigh;
FileSize.LowPart = finfo.nFileSizeLow;
return FileSize.QuadPart;
}
@ -322,10 +325,14 @@ nt_sync(int cdrive)
/* Currently nt_ftruncate only tested to shrink a file. */
int
nt_ftruncate(FD_t fd, int len)
nt_ftruncate(FD_t fd, afs_foff_t len)
{
if (SetFilePointer(fd, (LONG) len, NULL, FILE_BEGIN)
== 0xffffffff) {
LARGE_INTEGER length;
length.QuadPart = len;
if (SetFilePointerEx(fd, length, NULL, FILE_BEGIN)
== 0xffffffff) {
errno = nterr_nt2unix(GetLastError(), EBADF);
return -1;
}
@ -346,9 +353,14 @@ nt_fsync(FD_t fd)
int
nt_seek(FD_t fd, int off, int where)
nt_seek(FD_t fd, afs_foff_t off, int where)
{
int code = SetFilePointer(fd, off, NULL, where);
int code;
LARGE_INTEGER offset;
offset.QuadPart = off;
code = SetFilePointerEx(fd, offset, NULL, where);
return code;
}

View File

@ -24,17 +24,17 @@ extern char *PrintInode(char *, Inode);
/* Basic file operations */
extern FD_t nt_open(char *name, int flags, int mode);
extern int nt_close(FD_t fd);
extern int nt_write(FD_t fd, char *buf, size_t size);
extern int nt_read(FD_t fd, char *buf, size_t size);
extern int nt_pread(FD_t fd, void * buf, size_t count, afs_foff_t offset);
extern int nt_pwrite(FD_t fd, const void * buf, size_t count, afs_foff_t offset);
extern int nt_size(FD_t fd);
extern int nt_write(FD_t fd, char *buf, afs_sfsize_t size);
extern int nt_read(FD_t fd, char *buf, afs_sfsize_t size);
extern int nt_pread(FD_t fd, void * buf, afs_sfsize_t count, afs_foff_t offset);
extern int nt_pwrite(FD_t fd, const void * buf, afs_sfsize_t count, afs_foff_t offset);
extern afs_sfsize_t nt_size(FD_t fd);
extern int nt_getFileCreationTime(FD_t fd, FILETIME * ftime);
extern int nt_setFileCreationTime(FD_t fd, FILETIME * ftime);
extern int nt_sync(int cdrive);
extern int nt_ftruncate(FD_t fd, int len);
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, int off, int where);
extern int nt_seek(FD_t fd, afs_foff_t off, int where);
extern FILE *nt_fdopen(IHandle_t * h, char *fdperms);
extern int nt_unlink(char *name);