Use older 2TB-limited 'BLKGETSIZE' if 'BLKGETSIZE64' is not available.
authorshort <>
Fri, 22 Aug 2003 00:45:01 +0000 (00:45 +0000)
committershort <>
Fri, 22 Aug 2003 00:45:01 +0000 (00:45 +0000)
src/libcaptive/storage/size.c

index 594c624..5348bb9 100644 (file)
@@ -92,16 +92,27 @@ int fd;
 
 static guint64 size_ioctl(GIOChannel *iochannel)
 {
-int fd,err;
+int fd;
 guint64 r;
+#ifndef BLKGETSIZE64
+long r_long;
+#endif
 
        g_return_val_if_fail(iochannel!=NULL,0);
 
        if (-1==(fd=iounixchannel_get_fd(iochannel)))
                return 0;
 
-       if ((err=ioctl(fd,BLKGETSIZE64,&r)))
+#ifdef BLKGETSIZE64
+       if (ioctl(fd,BLKGETSIZE64,&r))
+               return 0;
+#else
+       if (ioctl(fd,BLKGETSIZE,&r_long))
+               return 0;
+       if (r_long<0)
                return 0;
+       r=((guint64)512)*r_long;
+#endif
 
        return r;
 }