OSDN Git Service

GNU/KFreeBSD portability fixes. (Addresses Debian Bug #239934)
authorMatthias Andree <matthias.andree@gmx.de>
Tue, 30 Mar 2004 01:57:41 +0000 (03:57 +0200)
committerMatthias Andree <matthias.andree@gmx.de>
Tue, 30 Mar 2004 01:57:41 +0000 (03:57 +0200)
lib/ext2fs/getsize.c
lib/ext2fs/unix_io.c
misc/util.c

index 4cc4a71..0567a03 100644 (file)
@@ -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 */
 
        /*
index accd71f..b09e3e3 100644 (file)
@@ -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
index 8087135..16ea19f 100644 (file)
@@ -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