unsigned long long size64;
blkid_loff_t high, low;
-#ifdef DKIOCGETBLOCKCOUNT /* For Apple Darwin */
- if (ioctl(fd, DKIOCGETBLOCKCOUNT, &size64) >= 0) {
+#if defined DKIOCGETBLOCKCOUNT && defined DKIOCGETBLOCKSIZE /* For Apple Darwin */
+ unsigned int size;
+
+ if (ioctl(fd, DKIOCGETBLOCKCOUNT, &size64) >= 0 &&
+ ioctl(fd, DKIOCGETBLOCKSIZE, &size) >= 0) {
if (sizeof(blkid_loff_t) < sizeof(unsigned long long) &&
- (size64 << 9) > 0xFFFFFFFF)
+ (size64 * size) > 0xFFFFFFFF)
return 0; /* EFBIG */
- return (blkid_loff_t)size64 << 9;
+ return (blkid_loff_t)size64 * size;
}
#endif
if (fd < 0)
return errno;
-#ifdef DKIOCGETBLOCKCOUNT /* For Apple Darwin */
- if (ioctl(fd, DKIOCGETBLOCKCOUNT, &size64) >= 0) {
- *retblocks = size64 / (blocksize / 512);
+#if defined DKIOCGETBLOCKCOUNT && defined DKIOCGETBLOCKSIZE /* For Apple Darwin */
+ unsigned int size;
+
+ if (ioctl(fd, DKIOCGETBLOCKCOUNT, &size64) >= 0 &&
+ ioctl(fd, DKIOCGETBLOCKSIZE, &size) >= 0) {
+ *retblocks = size64 * size / blocksize;
goto out;
}
#endif