summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/ext2fs/getsize.c24
-rw-r--r--lib/ext2fs/unix_io.c4
-rw-r--r--misc/util.c2
3 files changed, 16 insertions, 14 deletions
diff --git a/lib/ext2fs/getsize.c b/lib/ext2fs/getsize.c
index 4cc4a716..0567a031 100644
--- a/lib/ext2fs/getsize.c
+++ b/lib/ext2fs/getsize.c
@@ -28,7 +28,6 @@
#include <linux/fd.h>
#endif
#ifdef HAVE_SYS_DISKLABEL_H
-#include <sys/param.h> /* for __FreeBSD_version */
#include <sys/ioctl.h>
#include <sys/disklabel.h>
#endif /* HAVE_SYS_DISKLABEL_H */
@@ -191,8 +190,18 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize,
return 0;
}
#endif
+
#ifdef HAVE_SYS_DISKLABEL_H
-#if (defined(__FreeBSD__) && __FreeBSD_version < 500040) || defined(APPLE_DARWIN)
+#if defined(DIOCGMEDIASIZE)
+ {
+ off_t ms;
+ u_int bs;
+ if (ioctl(fd, DIOCGMEDIASIZE, &ms) >= 0) {
+ *retblocks = ms / blocksize;
+ return 0;
+ }
+ }
+#elif defined(DIOCGDINFO)
/* old disklabel interface */
part = strlen(file) - 1;
if (part >= 0) {
@@ -212,16 +221,7 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize,
return 0;
}
}
-#else /* __FreeBSD_version < 500040 */
- {
- off_t ms;
- u_int bs;
- if (ioctl(fd, DIOCGMEDIASIZE, &ms) >= 0) {
- *retblocks = ms / blocksize;
- return 0;
- }
- }
-#endif /* __FreeBSD_version < 500040 */
+#endif /* defined(DIOCG*) */
#endif /* HAVE_SYS_DISKLABEL_H */
/*
diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
index accd71f4..b09e3e35 100644
--- a/lib/ext2fs/unix_io.c
+++ b/lib/ext2fs/unix_io.c
@@ -85,7 +85,9 @@ static errcode_t unix_write_byte(io_channel channel, unsigned long offset,
static void reuse_cache(io_channel channel, struct unix_private_data *data,
struct unix_cache *cache, unsigned long block);
-#if defined(__CYGWIN__) || defined(__FreeBSD__)
+/* __FreeBSD_kernel__ is defined by GNU/kFreeBSD - the FreeBSD kernel
+ * does not know buffered block devices - everything is raw. */
+#if defined(__CYGWIN__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#define NEED_BOUNCE_BUFFER
#else
#undef NEED_BOUNCE_BUFFER
diff --git a/misc/util.c b/misc/util.c
index 80871353..16ea19f4 100644
--- a/misc/util.c
+++ b/misc/util.c
@@ -97,7 +97,7 @@ void check_plausibility(const char *device)
"did you specify it correctly?\n"), stderr);
exit(1);
}
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
/* On FreeBSD, all disk devices are character specials */
if (!S_ISBLK(s.st_mode) && !S_ISCHR(s.st_mode))
#else