FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora Development

 
 
LinkBack Thread Tools
 
Old 12-07-2010, 06:58 PM
David Cantrell
 
Default Use wipefs from util-linux-ng instead of dd to wipe old sigs.

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 = '' * 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@redhat.com>
Red Hat / Honolulu, HI

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

Thread Tools




All times are GMT. The time now is 10:26 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org