[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#592292: report correct disk size on kfreebsd



Package: util-linux
Version: 2.17.2-3.1
Severity: important
Tags: patch
User: debian-bsd@lists.debian.org
Usertags: kfreebsd
X-Debbugs-CC: debian-bsd@lists.debian.org

Hi,
This fix makes fdisk report the correct disk size on Debian GNU/kFreeBSD.
diff -ur util-linux-2.17.2/configure.ac util-linux-2.17.2.fix/configure.ac
--- util-linux-2.17.2/configure.ac	2010-08-07 08:33:22.000000000 -0400
+++ util-linux-2.17.2.fix/configure.ac	2010-08-07 07:47:36.752135651 -0400
@@ -94,7 +94,7 @@
 
 AC_SYS_LARGEFILE
 
-AC_CHECK_HEADERS([linux/compiler.h linux/blkpg.h linux/major.h], [], [], [
+AC_CHECK_HEADERS([linux/compiler.h linux/blkpg.h linux/major.h sys/disk.h], [], [], [
 #ifdef HAVE_LINUX_COMPILER_H
 #include <linux/compiler.h>
 #endif
diff -ur util-linux-2.17.2/lib/blkdev.c util-linux-2.17.2.fix/lib/blkdev.c
--- util-linux-2.17.2/lib/blkdev.c	2010-03-22 04:05:42.000000000 -0400
+++ util-linux-2.17.2.fix/lib/blkdev.c	2010-08-07 08:09:42.223428053 -0400
@@ -3,6 +3,10 @@
 #include <sys/ioctl.h>
 #include <unistd.h>
 
+#ifdef HAVE_SYS_DISK_H
+#include <sys/disk.h>
+#endif
+
 #include "blkdev.h"
 #include "linux_version.h"
 
@@ -67,6 +71,17 @@
 	return -1;
 #endif /* BLKGETSIZE */
 
+#ifdef DIOCGMEDIASIZE
+	{
+		off_t size;
+
+		if (ioctl(fd, DIOCGMEDIASIZE, &size) >= 0) {
+			*bytes = size;
+			return 0;
+		}
+	}
+#endif /* DIOCGMEDIASIZE */
+
 	*bytes = blkdev_find_size(fd);
 	return 0;
 }

Reply to: