* Windows version of ext2fs_get_device_size by Chris Li, VMware.
*
* %Begin-Header%
- * This file may be redistributed under the terms of the GNU Public
- * License.
+ * This file may be redistributed under the terms of the GNU Library
+ * General Public License, version 2.
* %End-Header%
*/
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
+#include "config.h"
#include <stdio.h>
#if HAVE_UNISTD_H
#include <unistd.h>
char ch;
#endif /* HAVE_SYS_DISKLABEL_H */
-#ifdef HAVE_OPEN64
- fd = open64(file, O_RDONLY);
-#else
- fd = open(file, O_RDONLY);
-#endif
+ fd = ext2fs_open_file(file, O_RDONLY, 0);
if (fd < 0)
return errno;
*retblocks = size64 / blocksize;
goto out;
}
-#endif
+#endif /* BLKGETSIZE64 */
#ifdef BLKGETSIZE
if (ioctl(fd, BLKGETSIZE, &size) >= 0) {
#endif /* HAVE_SYS_DISKLABEL_H */
{
-#ifdef HAVE_FSTAT64
- struct stat64 st;
- if (fstat64(fd, &st) == 0)
-#else
- struct stat st;
- if (fstat(fd, &st) == 0)
-#endif
+ ext2fs_struct_stat st;
+
+ if (ext2fs_fstat(fd, &st) == 0)
if (S_ISREG(st.st_mode)) {
*retblocks = st.st_size / blocksize;
goto out;
{
errcode_t retval;
blk64_t blocks;
- retval = ext2fs_get_device_size2(file, blocksize, &blocks);
- if (!retval && blocks < (1ULL << 32)) {
- *retblocks = (blk_t) blocks;
+ retval = ext2fs_get_device_size2(file, blocksize, &blocks);
+ if (retval)
return retval;
- }
- return EFBIG;
+ if (blocks >= (1ULL << 32))
+ return EFBIG;
+ *retblocks = (blk_t) blocks;
+ return 0;
}
#endif /* WIN32 */