Re: [PATCH] Use wipefs from util-linux-ng instead of dd to wipe old sigs.

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

 



Big ack.

On 12/07/2010 09:53 AM, David Lehman wrote:
This should cover all the formats recognized by blkid. Finally.
---
  pyanaconda/storage/formats/__init__.py |   39 ++++++++++++-------------------
  scripts/upd-instroot                   |    1 +
  2 files changed, 16 insertions(+), 24 deletions(-)

diff --git a/pyanaconda/storage/formats/__init__.py b/pyanaconda/storage/formats/__init__.py
index f84b160..5edada4 100644
--- a/pyanaconda/storage/formats/__init__.py
+++ b/pyanaconda/storage/formats/__init__.py
@@ -22,7 +22,9 @@

  import os

-from pyanaconda.iutil import notify_kernel, get_sysfs_path_by_name
+from pyanaconda.iutil import notify_kernel
+from pyanaconda.iutil import get_sysfs_path_by_name
+from pyanaconda.iutil import execWithRedirect
  from ..storage_log import log_method_call
  from ..errors import *
  from ..devicelibs.dm import dm_node_from_name
@@ -268,31 +270,20 @@ class DeviceFormat(object):
      def destroy(self, *args, **kwargs):
          log_method_call(self, device=self.device,
                          type=self.type, status=self.status)
-        # zero out the 1MB at the beginning and end of the device in the
-        # hope that it will wipe any metadata from filesystems that
-        # previously occupied this device
-        log.debug("zeroing out beginning and end of %s..." % self.device)
-        fd = None
-
          try:
-            fd = os.open(self.device, os.O_RDWR)
-            buf = '\0' * 1024 * 1024
-            os.write(fd, buf)
-            os.lseek(fd, -1024 * 1024, 2)
-            os.write(fd, buf)
-            os.close(fd)
-        except OSError as e:
-            if getattr(e, "errno", None) == 28: # No space left in device
-                pass
-            else:
-                log.error("error zeroing out %s: %s" % (self.device, e))
-
-            if fd:
-                os.close(fd)
+            rc = execWithRedirect("wipefs", ["-a", self.device],
+                                  stderr="/dev/tty5",
+                                  stdout="/dev/tty5")
          except Exception as e:
-            log.error("error zeroing out %s: %s" % (self.device, e))
-            if fd:
-                os.close(fd)
+            err = str(e)
+        else:
+            err = ""
+            if rc:
+                err = str(rc)
+
+        if err:
+            msg = "error wiping old signatures from %s: %s" % (self.device, err)
+            raise FormatDestroyError(msg)

          self.exists = False

diff --git a/scripts/upd-instroot b/scripts/upd-instroot
index f3bd76b..4255ad0 100755
--- a/scripts/upd-instroot
+++ b/scripts/upd-instroot
@@ -572,6 +572,7 @@ sbin/tune2fs
  sbin/udev*
  sbin/umount*
  sbin/vconfig
+sbin/wipefs
  sbin/xfs_repair
  sbin/xfsrestore
  sbin/ybin


--
David Cantrell <dcantrell@xxxxxxxxxx>
Red Hat / Honolulu, HI

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux