diff options
-rw-r--r-- | mdadm.h | 1 | ||||
-rw-r--r-- | util.c | 5 |
2 files changed, 6 insertions, 0 deletions
@@ -28,6 +28,7 @@ */ #define _GNU_SOURCE +#define _FILE_OFFSET_BITS 64 #include <unistd.h> #if !defined(__dietlibc__) && !defined(__KLIBC__) extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence)); @@ -830,6 +830,11 @@ struct supertype *guess_super(int fd) int get_dev_size(int fd, char *dname, unsigned long long *sizep) { unsigned long long ldsize; + struct stat st; + + if (fstat(fd, &st) != -1 && S_ISREG(st.st_mode)) + ldsize = (unsigned long long)st.st_size; + else #ifdef BLKGETSIZE64 if (ioctl(fd, BLKGETSIZE64, &ldsize) != 0) #endif |