#define _LARGEFILE64_SOURCE
/* include this before sys/queues.h! */
+#include "config.h"
#include "blkidP.h"
#include <stdio.h>
{
int valid_blkgetsize64 = 1;
#ifdef __linux__
- struct utsname ut;
+ struct utsname ut;
#endif
unsigned long long size64;
unsigned long size;
return 0; /* EFBIG */
return size64;
}
-#endif
+#endif /* BLKGETSIZE64 */
#ifdef BLKGETSIZE
if (ioctl(fd, BLKGETSIZE, &size) >= 0)
* Note that FreeBSD >= 4.0 has disk devices as unbuffered (raw,
* character) devices, so we need to check for S_ISCHR, too.
*/
- if ((fstat(fd, &st) >= 0) && (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)))
+ if (fstat(fd, &st) >= 0 && (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)))
part = st.st_rdev & 7;
+
if (part >= 0 && (ioctl(fd, DIOCGDINFO, (char *)&lab) >= 0)) {
pp = &lab.d_partitions[part];
if (pp->p_size)
}
#endif /* HAVE_SYS_DISKLABEL_H */
{
-#ifdef HAVE_FSTAT64
+#if defined(HAVE_FSTAT64) && !defined(__OSX_AVAILABLE_BUT_DEPRECATED)
struct stat64 st;
if (fstat64(fd, &st) == 0)
#else
return st.st_size;
}
-
/*
* OK, we couldn't figure it out by using a specialized ioctl,
* which is generally the best way. So do binary search to
low = 0;
for (high = 1024; valid_offset(fd, high); high *= 2)
low = high;
- while (low < high - 1)
- {
+ while (low < high - 1) {
const blkid_loff_t mid = (low + high) / 2;
if (valid_offset(fd, mid))
perror(argv[0]);
bytes = blkid_get_dev_size(fd);
- printf("Device %s has %Ld 1k blocks.\n", argv[1],
+ printf("Device %s has %Ld 1k blocks.\n", argv[1],
(unsigned long long) bytes >> 10);
return 0;