#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)
{
int fd;
guint64 r;
-#ifndef BLKGETSIZE64
long r_long;
-#endif
g_return_val_if_fail(iochannel!=NULL,0);
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;
}