[Glibc-bsd-commits] r3903 - in trunk/ufsutils/debian: . patches
Robert Millan
rmh at alioth.debian.org
Sun Nov 27 17:09:45 UTC 2011
Author: rmh
Date: 2011-11-27 17:09:45 +0000 (Sun, 27 Nov 2011)
New Revision: 3903
Added:
trunk/ufsutils/debian/patches/04_portable_berase.patch
trunk/ufsutils/debian/patches/05_wipe_otherfs.patch
Modified:
trunk/ufsutils/debian/changelog
trunk/ufsutils/debian/patches/series
Log:
* Remove remnants of ZFS when creating a new file system. (Closes: #635272)
- 04_portable_berase.patch: Fix berase().
- 05_wipe_otherfs.patch: Wipe out other filesystems by erasing first and
last 512 kiB of disk (this works for at least ZFS, in addition to UFS1
which was already taken care of).
Modified: trunk/ufsutils/debian/changelog
===================================================================
--- trunk/ufsutils/debian/changelog 2011-11-27 15:32:20 UTC (rev 3902)
+++ trunk/ufsutils/debian/changelog 2011-11-27 17:09:45 UTC (rev 3903)
@@ -6,8 +6,15 @@
* Fix 02_fsdb.ufs.patch to make ufsutils buildable with --as-needed.
Closes: #632564.
- -- Aurelien Jarno <aurel32 at debian.org> Sat, 23 Jul 2011 19:23:51 +0200
+ [ Robert Millan ]
+ * Remove remnants of ZFS when creating a new file system. (Closes: #635272)
+ - 04_portable_berase.patch: Fix berase().
+ - 05_wipe_otherfs.patch: Wipe out other filesystems by erasing first and
+ last 512 kiB of disk (this works for at least ZFS, in addition to UFS1
+ which was already taken care of).
+ -- Robert Millan <rmh at debian.org> Sun, 27 Nov 2011 18:05:37 +0100
+
ufsutils (8.2-1) unstable; urgency=low
[ Robert Millan ]
Added: trunk/ufsutils/debian/patches/04_portable_berase.patch
===================================================================
--- trunk/ufsutils/debian/patches/04_portable_berase.patch (rev 0)
+++ trunk/ufsutils/debian/patches/04_portable_berase.patch 2011-11-27 17:09:45 UTC (rev 3903)
@@ -0,0 +1,47 @@
+
+Replace DIOCGDELETE call in berase() with a portable implementation instead
+of just disabling it.
+
+Note: DIOCGDELETE needs to be avoided for now, even on GNU/kFreeBSD (see
+PR kern/162905).
+
+--- a/lib/libufs/block.c
++++ b/lib/libufs/block.c
+@@ -144,7 +144,6 @@
+ int
+ berase(struct uufsd *disk, ufs2_daddr_t blockno, ufs2_daddr_t size)
+ {
+- off_t ioarg[2];
+ int rv;
+
+ ERROR(disk, NULL);
+@@ -153,10 +152,28 @@
+ ERROR(disk, "failed to open disk for writing");
+ return(rv);
+ }
+-#ifdef HAVE_BSD_DISKLABEL
++#if 0
++ off_t ioarg[2];
+ ioarg[0] = blockno * disk->d_bsize;
+ ioarg[1] = size;
+ rv = ioctl(disk->d_fd, DIOCGDELETE, ioarg);
++#else
++ off_t offset, chunk;
++
++ offset = blockno * disk->d_bsize;
++
++ while (size > 0) {
++ chunk = size;
++ if (chunk > 65536 * disk->d_bsize)
++ chunk = 65536 * disk->d_bsize;
++ void *zero_chunk = malloc(chunk);
++ rv = pwrite(disk->d_fd, zero_chunk, chunk, offset);
++ free(zero_chunk);
++ size -= chunk;
++ offset += chunk;
++ if (rv == -1)
++ break;
++ }
+ #endif
+ return (rv);
+ }
Added: trunk/ufsutils/debian/patches/05_wipe_otherfs.patch
===================================================================
--- trunk/ufsutils/debian/patches/05_wipe_otherfs.patch (rev 0)
+++ trunk/ufsutils/debian/patches/05_wipe_otherfs.patch 2011-11-27 17:09:45 UTC (rev 3903)
@@ -0,0 +1,39 @@
+--- a/sbin/newfs/mkfs.c
++++ b/sbin/newfs/mkfs.c
+@@ -505,21 +505,23 @@
+ sblock.fs_size * sblock.fs_fsize - sblock.fs_sblockloc);
+ }
+ /*
+- * Wipe out old UFS1 superblock(s) if necessary.
++ * Wipe out other file systems. For now we erase first and last 512 kiB
++ * (this works for at least UFS1 and ZFS).
+ */
+- if (!Nflag && Oflag != 1) {
+- i = bread(&disk, part_ofs + SBLOCK_UFS1 / disk.d_bsize, chdummy, SBLOCKSIZE);
+- if (i == -1)
+- err(1, "can't read old UFS1 superblock: %s", disk.d_error);
++ if (!Eflag && !Nflag) {
++ off_t mediasize = get_block_device_size(disk.d_fd);
+
+- if (fsdummy.fs_magic == FS_UFS1_MAGIC) {
+- fsdummy.fs_magic = 0;
+- bwrite(&disk, part_ofs + SBLOCK_UFS1 / disk.d_bsize,
+- chdummy, SBLOCKSIZE);
+- for (cg = 0; cg < fsdummy.fs_ncg; cg++)
+- bwrite(&disk, part_ofs + fsbtodb(&fsdummy,
+- cgsblock(&fsdummy, cg)), chdummy, SBLOCKSIZE);
+- }
++ 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 (!Nflag)
+ do_sbwrite(&disk);
Modified: trunk/ufsutils/debian/patches/series
===================================================================
--- trunk/ufsutils/debian/patches/series 2011-11-27 15:32:20 UTC (rev 3902)
+++ trunk/ufsutils/debian/patches/series 2011-11-27 17:09:45 UTC (rev 3903)
@@ -14,4 +14,6 @@
02_mkfs.ufs.patch
02_tunefs.ufs.patch
03_ufsmount.patch
+04_portable_berase.patch
+05_wipe_otherfs.patch
99_makefiles.patch
More information about the Glibc-bsd-commits
mailing list