mirror of https://github.com/vitalif/e2fsprogs
getsize.c (ext2fs_get_device_size): Add support for Windows
9x/NT under Cygwin. Thanks to Sam Robb (samrobb@users.sourceforge.net) for pointing this and the suggested code patch.bitmap-optimize
parent
029de63277
commit
1a9c8c35ba
|
@ -1,3 +1,10 @@
|
||||||
|
2004-10-08 Theodore Ts'o <tytso@mit.edu>
|
||||||
|
|
||||||
|
* getsize.c (ext2fs_get_device_size): Add support for Windows
|
||||||
|
9x/NT under Cygwin. Thanks to Sam Robb
|
||||||
|
(samrobb@users.sourceforge.net) for pointing this and the
|
||||||
|
suggested code patch.
|
||||||
|
|
||||||
2004-09-17 Theodore Ts'o <tytso@mit.edu>
|
2004-09-17 Theodore Ts'o <tytso@mit.edu>
|
||||||
|
|
||||||
* getsize.c: Clean up header #include's.
|
* getsize.c: Clean up header #include's.
|
||||||
|
|
|
@ -61,6 +61,10 @@
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
#include "winioctl.h"
|
#include "winioctl.h"
|
||||||
|
|
||||||
|
#if (_WIN32_WINNT >= 0x0500)
|
||||||
|
#define HAVE_GET_FILE_SIZE_EX 1
|
||||||
|
#endif
|
||||||
|
|
||||||
errcode_t ext2fs_get_device_size(const char *file, int blocksize,
|
errcode_t ext2fs_get_device_size(const char *file, int blocksize,
|
||||||
blk_t *retblocks)
|
blk_t *retblocks)
|
||||||
{
|
{
|
||||||
|
@ -68,7 +72,11 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize,
|
||||||
PARTITION_INFORMATION pi;
|
PARTITION_INFORMATION pi;
|
||||||
DISK_GEOMETRY gi;
|
DISK_GEOMETRY gi;
|
||||||
DWORD retbytes;
|
DWORD retbytes;
|
||||||
|
#ifdef HAVE_GET_FILE_SIZE_EX
|
||||||
LARGE_INTEGER filesize;
|
LARGE_INTEGER filesize;
|
||||||
|
#else
|
||||||
|
DWORD filesize;
|
||||||
|
#endif /* HAVE_GET_FILE_SIZE_EX */
|
||||||
|
|
||||||
dev = CreateFile(file, GENERIC_READ,
|
dev = CreateFile(file, GENERIC_READ,
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE ,
|
FILE_SHARE_READ | FILE_SHARE_WRITE ,
|
||||||
|
@ -93,9 +101,18 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize,
|
||||||
gi.TracksPerCylinder *
|
gi.TracksPerCylinder *
|
||||||
gi.Cylinders.QuadPart / blocksize;
|
gi.Cylinders.QuadPart / blocksize;
|
||||||
|
|
||||||
|
#ifdef HAVE_GET_FILE_SIZE_EX
|
||||||
} else if (GetFileSizeEx(dev, &filesize)) {
|
} else if (GetFileSizeEx(dev, &filesize)) {
|
||||||
*retblocks = filesize.QuadPart / blocksize;
|
*retblocks = filesize.QuadPart / blocksize;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
} else {
|
||||||
|
filesize = GetFileSize(dev, NULL);
|
||||||
|
if (INVALID_FILE_SIZE != filesize) {
|
||||||
|
*retblocks = filesize / blocksize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* HAVE_GET_FILE_SIZE_EX */
|
||||||
|
|
||||||
CloseHandle(dev);
|
CloseHandle(dev);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue