diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | fsset.py | 20 | ||||
-rw-r--r-- | isys/isys.c | 24 |
3 files changed, 42 insertions, 10 deletions
@@ -1,3 +1,11 @@ +2005-05-19 Chris Lumens <clumens@redhat.com> + + * fsset.py (RAIDDevice.mdadmLine): Use the UUID instead of the + super-minor, unless the UUID is somehow not available. + * isys/isys.c: Converted to using kernel MD headers instead of our + own internal copies. Return the RAID's UUID from the superblock as + well. + 2005-05-19 Jeremy Katz <katzj@redhat.com> * loader2/urlinstall.c (loadUrlImages): Use the constant, bumped @@ -1932,8 +1932,26 @@ class RAIDDevice(Device): return [] def mdadmLine (self, devPrefix="/dev"): + levels = ["multipath", "hsm", "translucent", "linear", "raid0", + "raid1", "", "", "raid5", "raid5"] + + (dev, devices, level, numActive) = raid.lookup_raid_device (self.device) + + # First loop over all the devices that make up the RAID trying to read + # the superblock off each. If we read a superblock, return a line that + # can go into the mdadm.conf. If we fail, fall back to the old method + # of using the super-minor. + for d in devices: + try: + (major, minor, uuid, level, nrDisks, totalDisks, mdMinor) = \ + isys.raidsb(d) + return "ARRAY %s/%s level=%s num-devices=%d uuid=%s\n" \ + %(devPrefix, self.device, levels[level+4], nrDisks, uuid) + except ValueError: + pass + return "ARRAY %s/%s super-minor=%s\n" %(devPrefix, self.device, - self.minor) + self.minor) def raidTab (self, devPrefix='/dev'): entry = "" diff --git a/isys/isys.c b/isys/isys.c index ec0d4f818..c90df6636 100644 --- a/isys/isys.c +++ b/isys/isys.c @@ -40,8 +40,10 @@ #include <libintl.h> #include <selinux/selinux.h> #include <libgen.h> +#include <linux/major.h> +#include <linux/raid/md_u.h> +#include <linux/raid/md_p.h> -#include "md-int.h" #include "imount.h" #include "isys.h" #include "net.h" @@ -785,7 +787,7 @@ static PyObject * doFbconProbe (PyObject * s, PyObject * args) { static PyObject * doWipeRaidSuperblock(PyObject * s, PyObject * args) { int fd; unsigned long size; - struct md_superblock_s * sb; + struct mdp_super_t * sb; if (!PyArg_ParseTuple(args, "i", &fd)) return NULL; @@ -802,8 +804,8 @@ static PyObject * doWipeRaidSuperblock(PyObject * s, PyObject * args) { return NULL; } - sb = malloc(sizeof(struct md_superblock_s)); - sb = memset(sb, '\0', sizeof(struct md_superblock_s)); + sb = malloc(sizeof(mdp_super_t)); + sb = memset(sb, '\0', sizeof(mdp_super_t)); if (write(fd, sb, sizeof(sb)) != sizeof(sb)) { PyErr_SetFromErrno(PyExc_SystemError); @@ -816,7 +818,8 @@ static PyObject * doWipeRaidSuperblock(PyObject * s, PyObject * args) { static PyObject * doGetRaidSuperblock(PyObject * s, PyObject * args) { int fd; unsigned long size; - struct md_superblock_s sb; + mdp_super_t sb; + char uuid[36]; if (!PyArg_ParseTuple(args, "i", &fd)) return NULL; @@ -843,15 +846,18 @@ static PyObject * doGetRaidSuperblock(PyObject * s, PyObject * args) { return NULL; } - return Py_BuildValue("(iiiiiii)", sb.major_version, sb.minor_version, - sb.set_magic, sb.level, sb.nr_disks, - sb.raid_disks, sb.md_minor); + sprintf(uuid, "%x:%x:%x:%x", sb.set_uuid0, sb.set_uuid1, sb.set_uuid2, + sb.set_uuid3); + + return Py_BuildValue("(iisiiii)", sb.major_version, sb.minor_version, + uuid, sb.level, sb.nr_disks, sb.raid_disks, + sb.md_minor); } static PyObject * doGetRaidChunkSize(PyObject * s, PyObject * args) { int fd; unsigned long size; - struct md_superblock_s sb; + mdp_super_t sb; if (!PyArg_ParseTuple(args, "i", &fd)) return NULL; |