Whamcloud - gitweb
libext2fs: add pseudo bitmap backend type EXT2FS_BMAP64_AUTODIR
[tools/e2fsprogs.git] / lib / ext2fs / getsize.c
index 23c8f12..1e0ed16 100644 (file)
@@ -7,14 +7,15 @@
  * 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>
@@ -159,11 +160,7 @@ errcode_t ext2fs_get_device_size2(const char *file, int blocksize,
        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;
 
@@ -235,13 +232,9 @@ errcode_t ext2fs_get_device_size2(const char *file, int blocksize,
 #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;