Fixed 'BLKGETSIZE64' incompatibility for Debian-unstable.
authorshort <>
Wed, 5 Nov 2003 06:26:08 +0000 (06:26 +0000)
committershort <>
Wed, 5 Nov 2003 06:26:08 +0000 (06:26 +0000)
 - FIXME: 'BLKGETSIZE64' usually not used at all now.
 - Fix introduces media size limit of 1TB.

src/libcaptive/storage/size.c

index 5348bb9..b70af55 100644 (file)
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
-#include <linux/types.h>       /* for __u64 for u64 for BLKGETSIZE64 */
-#define u64 __u64
-#include <linux/fs.h>  /* for BLKGETSIZE64 */
+/* Do not: #include <linux/fs.h>       * for 'BLKGETSIZE64' *
+ * as including any Linux kernel include files is too much incompatible.
+ */
+#include <sys/mount.h> /* for 'BLKGETSIZE' */
 
 
 static guint64 size_blind(GIOChannel *iochannel)
@@ -94,9 +95,7 @@ static guint64 size_ioctl(GIOChannel *iochannel)
 {
 int fd;
 guint64 r;
-#ifndef BLKGETSIZE64
 long r_long;
-#endif
 
        g_return_val_if_fail(iochannel!=NULL,0);
 
@@ -104,15 +103,14 @@ long r_long;
                return 0;
 
 #ifdef BLKGETSIZE64
-       if (ioctl(fd,BLKGETSIZE64,&r))
-               return 0;
-#else
+       if (!ioctl(fd,BLKGETSIZE64,&r))
+               return r;
+#endif
        if (ioctl(fd,BLKGETSIZE,&r_long))
                return 0;
        if (r_long<0)
                return 0;
        r=((guint64)512)*r_long;
-#endif
 
        return r;
 }