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

Bug#737580: ufsutils-udeb: mkfs.ufs: DIOCGMEDIASIZE: Inappropriate ioctl for device



Control: tag -1 patch pending

Steven Chamberlain <steven@pyro.eu.org> (2014-02-04):
> Package: ufsutils-udeb
> Version: 9.2-3
> Severity: grave
> Tags: jessie sid d-i
> Affects: debian-installer
> User: debian-bsd@lists.debian.org
> Usertags: kfreebsd
> X-Debbugs-Cc: kibi@debian.org
> 
> Image:
> http://d-i.debian.org/daily-images/kfreebsd-amd64/20140203-00:50/netboot-9/mini.iso
> 
> Can reproduce this by trying to format an msdos partition on an IDE disk
> as UFS (with kfreebsd-9 9.2-1-amd64):
> 
> > Feb  4 00:21:34 partman: mkfs.ufs: 
> > Feb  4 00:21:34 partman: DIOCGMEDIASIZE
> > Feb  4 00:21:34 partman: : 
> > Feb  4 00:21:34 partman: Inappropriate ioctl for device
> 
> Running `mkfs.ufs /dev/ada0` at an installer shell curiously tells me
> the size of the partition right before it fails with the above error.

As discussed here:
  https://lists.debian.org/debian-bsd/2014/03/msg00045.html
  https://lists.debian.org/debian-bsd/2014/03/msg00046.html
  https://lists.debian.org/debian-bsd/2014/03/msg00049.html

I've prepared an NMU to backport the fix from 10 to 9, which you'll find
attached. Since ufsutils-udeb is fetched from the archive while d-i is
running, I've tested it the following way: go through partitioning, wait
until the error pops up, drop to a shell, replace mkfs.ufs with the
patched one, and resume installation.

That led me to a successful installation, so I should upload in a few
minutes.


That said, building ufsutils in sid led me to a FTBFS due to missing
<libutil.h>; two solutions: either add a build-dep on libutil-freebsd-dev
which ships it under /usr/include; or adjust 3 files to #include
<bsd/libutil.h> instead. I haven't seen a difference in dependencies for
both cases. Which one do you want?

Mraw,
KiBi.
diff -Nru ufsutils-9.2/debian/changelog ufsutils-9.2/debian/changelog
--- ufsutils-9.2/debian/changelog	2013-11-30 12:56:40.000000000 +0100
+++ ufsutils-9.2/debian/changelog	2014-03-08 12:35:01.000000000 +0100
@@ -1,3 +1,12 @@
+ufsutils (9.2-3.1) unstable; urgency=high
+
+  * Non-maintainer upload.
+  * Steal the following patch from the 10 branch, fixing failures to run
+    mkfs.ufs, notably from d-i (Closes: #737580):
+    05_wipe_otherfs.patch: Handle DIOCGMEDIASIZE failure gracefully.
+
+ -- Cyril Brulebois <kibi@debian.org>  Sat, 08 Mar 2014 12:32:26 +0100
+
 ufsutils (9.2-3) unstable; urgency=low
 
   * Bump kfreebsd-kernel-headers B-D to 9.2~5.
diff -Nru ufsutils-9.2/debian/patches/05_wipe_otherfs.patch ufsutils-9.2/debian/patches/05_wipe_otherfs.patch
--- ufsutils-9.2/debian/patches/05_wipe_otherfs.patch	2013-10-26 16:17:34.000000000 +0200
+++ ufsutils-9.2/debian/patches/05_wipe_otherfs.patch	2014-03-08 12:34:57.000000000 +0100
@@ -8,27 +8,31 @@
  #include <sys/mman.h>
  #include <sys/resource.h>
  #include <sys/stat.h>
-@@ -531,6 +532,24 @@
+@@ -531,6 +532,28 @@
  			}
  		}
  	}
 +	/* Wipe out other file systems. For now we erase first and last 512 kiB
 +	 * (this works for at least UFS1 and ZFS). */
 +	if (!Eflag && !Nflag) {
-+		off_t mediasize;
-+		if (!ioctl(disk.d_fd, DIOCGMEDIASIZE, &mediasize))
-+			err(1, "DIOCGMEDIASIZE");
++		off_t mediasize = 0;
++
 +		printf("Erasing sectors [%jd...%jd]\n",
 +			sblock.fs_sblockloc / disk.d_bsize,
 +			fsbtodb(&sblock, sblock.fs_size) - 1);
 +		berase(&disk, sblock.fs_sblockloc / disk.d_bsize,
 +			1024 * disk.d_bsize - sblock.fs_sblockloc);
 +
-+		printf("Erasing sectors [%jd...%jd]\n",
-+			(mediasize - 1024 * 512) / disk.d_bsize,
-+			(mediasize / disk.d_bsize) - 1);
-+		berase(&disk, (mediasize - 1024 * 512) / disk.d_bsize,
-+			1024 * 512);
++		if (!ioctl(disk.d_fd, DIOCGMEDIASIZE, &mediasize))
++			warn("DIOCGMEDIASIZE");
++
++		if (mediasize) {
++			printf("Erasing sectors [%jd...%jd]\n",
++				(mediasize - 1024 * 512) / disk.d_bsize,
++				(mediasize / disk.d_bsize) - 1);
++			berase(&disk, (mediasize - 1024 * 512) / disk.d_bsize,
++				1024 * 512);
++		}
 +	}
  	if (!Nflag)
  		do_sbwrite(&disk);

Attachment: signature.asc
Description: Digital signature


Reply to: