diff --git a/mdadm.h b/mdadm.h index 1a7db81..2a5e1c8 100644 --- a/mdadm.h +++ b/mdadm.h @@ -28,6 +28,7 @@ */ #define _GNU_SOURCE +#define _FILE_OFFSET_BITS 64 #include #if !defined(__dietlibc__) && !defined(__KLIBC__) extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence)); diff --git a/util.c b/util.c index 1ba236b..bd46999 100644 --- a/util.c +++ b/util.c @@ -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