diff options
author | Chris Lumens <clumens@redhat.com> | 2005-06-27 21:17:43 +0000 |
---|---|---|
committer | Chris Lumens <clumens@redhat.com> | 2005-06-27 21:17:43 +0000 |
commit | 66e26cbfe6b118a8536bb1b72874865e75ebbcbf (patch) | |
tree | 98d2f661762518ff37535dc2f74e1e4256a2bf5d | |
parent | fb4043fed810b52570db5c698e3e260ff20e5ab8 (diff) | |
download | anaconda-66e26cbfe6b118a8536bb1b72874865e75ebbcbf.tar.gz anaconda-66e26cbfe6b118a8536bb1b72874865e75ebbcbf.tar.xz anaconda-66e26cbfe6b118a8536bb1b72874865e75ebbcbf.zip |
Added a clobberDevice method that is used before formatting a device to
get rid of any identifying information (such as labels).
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | fsset.py | 19 | ||||
-rw-r--r-- | isys/isys.c | 30 | ||||
-rw-r--r-- | isys/isys.py | 3 |
4 files changed, 60 insertions, 0 deletions
@@ -1,3 +1,11 @@ +2005-06-27 Chris Lumens <clumens@redhat.com> + + * fsset.py: Add a clobberDevice method used for obliterating + identifying information and call it before formatting. + * isys/isys.c (doClobberExt2): Add function to clobber ext2 + filesystems. + * isys/isys.py (ext2Clobber): Glue. + 2005-06-24 Chris Lumens <clumens@redhat.com> * scripts/upd-instroot (KEEPFILEGR): libpixman is required for cairo @@ -285,6 +285,9 @@ class FileSystemType: def labelDevice(self, entry, chroot): pass + + def clobberDevice(self, entry, chroot): + pass def isFormattable(self): return self.formattable @@ -557,6 +560,10 @@ class extFileSystem(FileSystemType): if rc: raise SystemError + def clobberDevice(self, entry, chroot): + device = entry.device.setupDevice(chroot) + isys.ext2Clobber(device) + # this is only for ext3 filesystems, but migration is a method # of the ext2 fstype, so it needs to be here. FIXME should be moved def setExt3Options(self, entry, message, chroot='/'): @@ -766,6 +773,17 @@ class swapFileSystem(FileSystemType): raise SystemError entry.setLabel(label) + def clobberDevice(self, entry, chroot): + pagesize = isys.getpagesize() + dev = entry.device.setupDevice(chroot) + try: + fd = os.open(dev, os.O_RDWR) + buf = "\0x00" * pagesize + os.write(fd, buf) + os.close(fd) + except: + pass + fileSystemTypeRegister(swapFileSystem()) class FATFileSystem(FileSystemType): @@ -1439,6 +1457,7 @@ MAILADDR root def formatEntry(self, entry, chroot): log("formatting %s as %s" %(entry.mountpoint, entry.fsystem.name)) + entry.fsystem.clobberDevice(entry, chroot) entry.fsystem.formatDevice(entry, self.progressWindow, chroot) def badblocksEntry(self, entry, chroot): diff --git a/isys/isys.c b/isys/isys.c index 6a08f7cb1..66fce0e78 100644 --- a/isys/isys.c +++ b/isys/isys.c @@ -89,6 +89,7 @@ static PyObject * doResetResolv(PyObject * s, PyObject * args); static PyObject * doSetResolvRetry(PyObject * s, PyObject * args); static PyObject * doLoadFont(PyObject * s, PyObject * args); static PyObject * doLoadKeymap(PyObject * s, PyObject * args); +static PyObject * doClobberExt2 (PyObject * s, PyObject * args); static PyObject * doReadE2fsLabel(PyObject * s, PyObject * args); static PyObject * doExt2Dirty(PyObject * s, PyObject * args); static PyObject * doExt2HasJournal(PyObject * s, PyObject * args); @@ -122,6 +123,7 @@ static PyMethodDef isysModuleMethods[] = { { "e2dirty", (PyCFunction) doExt2Dirty, METH_VARARGS, NULL }, { "e2hasjournal", (PyCFunction) doExt2HasJournal, METH_VARARGS, NULL }, { "e2fslabel", (PyCFunction) doReadE2fsLabel, METH_VARARGS, NULL }, + { "e2fsclobber", (PyCFunction) doClobberExt2, METH_VARARGS, NULL }, { "devSpaceFree", (PyCFunction) doDevSpaceFree, METH_VARARGS, NULL }, { "raidstop", (PyCFunction) doRaidStop, METH_VARARGS, NULL }, { "raidstart", (PyCFunction) doRaidStart, METH_VARARGS, NULL }, @@ -1009,6 +1011,34 @@ static PyObject * doSetResolvRetry(PyObject * s, PyObject * args) { return Py_None; } +static PyObject * doClobberExt2 (PyObject * s, PyObject * args) { + char * device; + ext2_filsys fsys; + struct ext2_super_block sb; + int rc; + + if (!PyArg_ParseTuple(args, "s", &device)) return NULL; + + rc = ext2fs_open(device, EXT2_FLAG_FORCE, 0, 0, unix_io_manager, &fsys); + + if (rc) { + Py_INCREF(Py_None); + return Py_None; + } + + memset(&sb, 0, sizeof(struct ext2_super_block)); + rc = ext2fs_initialize (device, 0, &sb, unix_io_manager, &fsys); + if (rc) { + Py_INCREF(Py_None); + return Py_None; + } + + ext2fs_close(fsys); + + Py_INCREF(Py_None); + return Py_None; +} + static PyObject * doReadE2fsLabel(PyObject * s, PyObject * args) { char * device; ext2_filsys fsys; diff --git a/isys/isys.py b/isys/isys.py index 250ec9837..3d3446443 100644 --- a/isys/isys.py +++ b/isys/isys.py @@ -691,6 +691,9 @@ def readFSLabel(device, makeDevNode = 1): label = readJFSLabel(device, makeDevNode) return label +def ext2Clobber(device, makeDevNode = 1): + _isys.e2fsclobber(device) + def ext2IsDirty(device): makeDevInode(device, "/tmp/disk") label = _isys.e2dirty("/tmp/disk"); |