Bug#632832: ufsutils: growfs.ufs do not work
The same problems exists in ufsutils/8.2-3. Please find attached a patch
for the aforementioned version that addresses this issue.
Regards,
Nikos
Index: ufsutils-8.2/sbin/growfs/growfs.c
===================================================================
--- ufsutils-8.2.orig/sbin/growfs/growfs.c 2013-05-15 13:01:07.000000000 +0300
+++ ufsutils-8.2/sbin/growfs/growfs.c 2013-05-15 13:13:31.000000000 +0300
@@ -1922,20 +1922,22 @@
static void
get_dev_size(int fd, int *size)
{
+#ifdef HAVE_BSD_DISKLABEL
int sectorsize;
off_t mediasize;
-#ifdef HAVE_BSD_DISKLABEL
if (ioctl(fd, DIOCGSECTORSIZE, §orsize) == -1)
err(1,"DIOCGSECTORSIZE");
if (ioctl(fd, DIOCGMEDIASIZE, &mediasize) == -1)
err(1,"DIOCGMEDIASIZE");
-#endif
if (sectorsize <= 0)
errx(1, "bogus sectorsize: %d", sectorsize);
*size = mediasize / sectorsize;
+#else
+ *size = get_block_device_sectors(fd);
+#endif
}
/* ************************************************************** main ***** */
Index: ufsutils-8.2/lib/port/blockdev.h
===================================================================
--- ufsutils-8.2.orig/lib/port/blockdev.h 2013-05-15 13:14:22.000000000 +0300
+++ ufsutils-8.2/lib/port/blockdev.h 2013-05-15 13:15:04.000000000 +0300
@@ -4,5 +4,7 @@
#include <sys/types.h>
int64_t get_block_device_size(int fd);
+int64_t get_block_device_sectors(int fd);
+int get_sector_size(int fd);
#endif
Index: ufsutils-8.2/lib/port/blockdev.c
===================================================================
--- ufsutils-8.2.orig/lib/port/blockdev.c 2013-05-15 13:21:19.000000000 +0300
+++ ufsutils-8.2/lib/port/blockdev.c 2013-05-15 13:31:47.000000000 +0300
@@ -48,6 +48,15 @@
static const int sector_size = 512;
+int
+get_sector_size(int fd)
+{
+ /* In Linux you can ask the OS for the sector size with this syscall:
+ * ioctl(fd, BLKSSZGET, §or_size)
+ */
+ return sector_size;
+}
+
int64_t
get_block_device_size(int fd)
{
@@ -90,3 +99,10 @@
return size;
}
+
+int64_t
+get_block_device_sectors(int fd)
+{
+ return get_block_device_size(fd) / sector_size;
+}
+
Index: ufsutils-8.2/sbin/growfs/Makefile
===================================================================
--- ufsutils-8.2.orig/sbin/growfs/Makefile 2013-05-15 13:36:11.000000000 +0300
+++ ufsutils-8.2/sbin/growfs/Makefile 2013-05-15 13:54:35.000000000 +0300
@@ -15,7 +15,7 @@
ALL_CFLAGS = -DFS_DEBUG
endif
-LDADD += -L../../lib/libufs -lufs
-INCLUDES =
+LDADD += -L../../lib/libufs -lufs -L../../lib/port -lport
+INCLUDES = -I../../lib/libufs -include ../../lib/port/blockdev.h
include ../../Makefile.common
Reply to: