From 4fcc0f58700d3d4229f477998fb572774fcd0867 Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Mon, 23 Aug 2004 21:25:52 +0000 Subject: some hacks to work around the lvm tools being stupid * wipe md superblocks if we successfully create a pv (#130713) * disable filtering for all of our creates. I know better than the tools (#130706) --- isys/isys.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'isys/isys.c') diff --git a/isys/isys.c b/isys/isys.c index 164e5ea2e..c7aa46ebd 100644 --- a/isys/isys.c +++ b/isys/isys.c @@ -75,6 +75,7 @@ static PyObject * doLoSetup(PyObject * s, PyObject * args); static PyObject * doUnLoSetup(PyObject * s, PyObject * args); static PyObject * doLoChangeFd(PyObject * s, PyObject * args); static PyObject * doDdFile(PyObject * s, PyObject * args); +static PyObject * doWipeRaidSuperblock(PyObject * s, PyObject * args); static PyObject * doGetRaidSuperblock(PyObject * s, PyObject * args); static PyObject * doGetRaidChunkSize(PyObject * s, PyObject * args); static PyObject * doDevSpaceFree(PyObject * s, PyObject * args); @@ -124,6 +125,7 @@ static PyMethodDef isysModuleMethods[] = { { "raidstop", (PyCFunction) doRaidStop, METH_VARARGS, NULL }, { "raidstart", (PyCFunction) doRaidStart, METH_VARARGS, NULL }, { "getraidsb", (PyCFunction) doGetRaidSuperblock, METH_VARARGS, NULL }, + { "wiperaidsb", (PyCFunction) doWipeRaidSuperblock, METH_VARARGS, NULL }, { "getraidchunk", (PyCFunction) doGetRaidChunkSize, METH_VARARGS, NULL }, { "lochangefd", (PyCFunction) doLoChangeFd, METH_VARARGS, NULL }, { "losetup", (PyCFunction) doLoSetup, METH_VARARGS, NULL }, @@ -782,6 +784,37 @@ static PyObject * doFbconProbe (PyObject * s, PyObject * args) { return Py_BuildValue("(iiss)", size, 0, "", ""); } +static PyObject * doWipeRaidSuperblock(PyObject * s, PyObject * args) { + int fd; + unsigned long size; + struct md_superblock_s * sb; + + if (!PyArg_ParseTuple(args, "i", &fd)) return NULL; + + if (ioctl(fd, BLKGETSIZE, &size)) { + PyErr_SetFromErrno(PyExc_SystemError); + return NULL; + } + + /* put the size in 1k blocks */ + size >>= 1; + + if (lseek64(fd, ((off64_t) 1024) * (off64_t) MD_NEW_SIZE_BLOCKS(size), SEEK_SET) < 0) { + PyErr_SetFromErrno(PyExc_SystemError); + return NULL; + } + + sb = malloc(sizeof(struct md_superblock_s)); + sb = memset(sb, '\0', sizeof(struct md_superblock_s)); + + if (write(fd, sb, sizeof(sb)) != sizeof(sb)) { + PyErr_SetFromErrno(PyExc_SystemError); + return NULL; + } + + return Py_None; +} + static PyObject * doGetRaidSuperblock(PyObject * s, PyObject * args) { int fd; unsigned long size; -- cgit