]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super-ddf.c
Create.c: fix uclibc build
[thirdparty/mdadm.git] / super-ddf.c
index 949e7d15547466701ffc39d507002fb2fb4f87b1..21426c753c6dff4d9dfdba152bb2fb8ac503f107 100644 (file)
@@ -1592,15 +1592,20 @@ static unsigned int get_vd_num_of_subarray(struct supertype *st)
        sra = sysfs_read(-1, st->devnm, GET_VERSION);
        if (!sra || sra->array.major_version != -1 ||
            sra->array.minor_version != -2 ||
-           !is_subarray(sra->text_version))
+           !is_subarray(sra->text_version)) {
+               if (sra)
+                       sysfs_free(sra);
                return DDF_NOTFOUND;
+       }
 
        sub = strchr(sra->text_version + 1, '/');
        if (sub != NULL)
                vcnum = strtoul(sub + 1, &end, 10);
        if (sub == NULL || *sub == '\0' || *end != '\0' ||
-           vcnum >= be16_to_cpu(ddf->active->max_vd_entries))
+           vcnum >= be16_to_cpu(ddf->active->max_vd_entries)) {
+               sysfs_free(sra);
                return DDF_NOTFOUND;
+       }
 
        return vcnum;
 }
@@ -1612,7 +1617,7 @@ static void brief_examine_super_ddf(struct supertype *st, int verbose)
        struct mdinfo info;
        char nbuf[64];
        getinfo_super_ddf(st, &info, NULL);
-       fname_from_uuid(st, &info, nbuf, ':');
+       fname_from_uuid(&info, nbuf);
 
        printf("ARRAY metadata=ddf UUID=%s\n", nbuf + 5);
 }
@@ -1627,7 +1632,7 @@ static void brief_examine_subarrays_ddf(struct supertype *st, int verbose)
        unsigned int i;
        char nbuf[64];
        getinfo_super_ddf(st, &info, NULL);
-       fname_from_uuid(st, &info, nbuf, ':');
+       fname_from_uuid(&info, nbuf);
 
        for (i = 0; i < be16_to_cpu(ddf->virt->max_vdes); i++) {
                struct virtual_entry *ve = &ddf->virt->entries[i];
@@ -1640,10 +1645,10 @@ static void brief_examine_subarrays_ddf(struct supertype *st, int verbose)
                ddf->currentconf =&vcl;
                vcl.vcnum = i;
                uuid_from_super_ddf(st, info.uuid);
-               fname_from_uuid(st, &info, nbuf1, ':');
+               fname_from_uuid(&info, nbuf1);
                _ddf_array_name(namebuf, ddf, i);
                printf("ARRAY%s%s container=%s member=%d UUID=%s\n",
-                      namebuf[0] == '\0' ? "" : " /dev/md/", namebuf,
+                      namebuf[0] == '\0' ? "" : " " DEV_MD_DIR, namebuf,
                       nbuf+5, i, nbuf1+5);
        }
 }
@@ -1653,7 +1658,7 @@ static void export_examine_super_ddf(struct supertype *st)
        struct mdinfo info;
        char nbuf[64];
        getinfo_super_ddf(st, &info, NULL);
-       fname_from_uuid(st, &info, nbuf, ':');
+       fname_from_uuid(&info, nbuf);
        printf("MD_METADATA=ddf\n");
        printf("MD_LEVEL=container\n");
        printf("MD_UUID=%s\n", nbuf+5);
@@ -1793,7 +1798,7 @@ static void brief_detail_super_ddf(struct supertype *st, char *subarray)
                return;
        else
                uuid_of_ddf_subarray(ddf, vcnum, info.uuid);
-       fname_from_uuid(st, &info, nbuf,':');
+       fname_from_uuid(&info, nbuf);
        printf(" UUID=%s", nbuf + 5);
 }
 
@@ -1979,12 +1984,14 @@ static void getinfo_super_ddf(struct supertype *st, struct mdinfo *info, char *m
                info->disk.number = be32_to_cpu(ddf->dlist->disk.refnum);
                info->disk.raid_disk = find_phys(ddf, ddf->dlist->disk.refnum);
 
+               if (info->disk.raid_disk < 0)
+                       return;
+
                info->data_offset = be64_to_cpu(ddf->phys->
                                                  entries[info->disk.raid_disk].
                                                  config_size);
                info->component_size = ddf->dlist->size - info->data_offset;
-               if (info->disk.raid_disk >= 0)
-                       pde = ddf->phys->entries + info->disk.raid_disk;
+               pde = ddf->phys->entries + info->disk.raid_disk;
                if (pde &&
                    !(be16_to_cpu(pde->state) & DDF_Failed) &&
                    !(be16_to_cpu(pde->state) & DDF_Missing))
@@ -2139,75 +2146,6 @@ static void getinfo_super_ddf_bvd(struct supertype *st, struct mdinfo *info, cha
                }
 }
 
-static int update_super_ddf(struct supertype *st, struct mdinfo *info,
-                           char *update,
-                           char *devname, int verbose,
-                           int uuid_set, char *homehost)
-{
-       /* For 'assemble' and 'force' we need to return non-zero if any
-        * change was made.  For others, the return value is ignored.
-        * Update options are:
-        *  force-one : This device looks a bit old but needs to be included,
-        *        update age info appropriately.
-        *  assemble: clear any 'faulty' flag to allow this device to
-        *              be assembled.
-        *  force-array: Array is degraded but being forced, mark it clean
-        *         if that will be needed to assemble it.
-        *
-        *  newdev:  not used ????
-        *  grow:  Array has gained a new device - this is currently for
-        *              linear only
-        *  resync: mark as dirty so a resync will happen.
-        *  uuid:  Change the uuid of the array to match what is given
-        *  homehost:  update the recorded homehost
-        *  name:  update the name - preserving the homehost
-        *  _reshape_progress: record new reshape_progress position.
-        *
-        * Following are not relevant for this version:
-        *  sparc2.2 : update from old dodgey metadata
-        *  super-minor: change the preferred_minor number
-        *  summaries:  update redundant counters.
-        */
-       int rv = 0;
-//     struct ddf_super *ddf = st->sb;
-//     struct vd_config *vd = find_vdcr(ddf, info->container_member);
-//     struct virtual_entry *ve = find_ve(ddf);
-
-       /* we don't need to handle "force-*" or "assemble" as
-        * there is no need to 'trick' the kernel.  When the metadata is
-        * first updated to activate the array, all the implied modifications
-        * will just happen.
-        */
-
-       if (strcmp(update, "grow") == 0) {
-               /* FIXME */
-       } else if (strcmp(update, "resync") == 0) {
-//             info->resync_checkpoint = 0;
-       } else if (strcmp(update, "homehost") == 0) {
-               /* homehost is stored in controller->vendor_data,
-                * or it is when we are the vendor
-                */
-//             if (info->vendor_is_local)
-//                     strcpy(ddf->controller.vendor_data, homehost);
-               rv = -1;
-       } else if (strcmp(update, "name") == 0) {
-               /* name is stored in virtual_entry->name */
-//             memset(ve->name, ' ', 16);
-//             strncpy(ve->name, info->name, 16);
-               rv = -1;
-       } else if (strcmp(update, "_reshape_progress") == 0) {
-               /* We don't support reshape yet */
-       } else if (strcmp(update, "assemble") == 0 ) {
-               /* Do nothing, just succeed */
-               rv = 0;
-       } else
-               rv = -1;
-
-//     update_all_csum(ddf);
-
-       return rv;
-}
-
 static void make_header_guid(char *guid)
 {
        be32 stamp;
@@ -2428,8 +2366,7 @@ static int init_super_ddf(struct supertype *st,
         * Remaining 16 are serial number.... maybe a hostname would do?
         */
        memcpy(ddf->controller.guid, T10, sizeof(T10));
-       gethostname(hostname, sizeof(hostname));
-       hostname[sizeof(hostname) - 1] = 0;
+       s_gethostname(hostname, sizeof(hostname));
        hostlen = strlen(hostname);
        memcpy(ddf->controller.guid + 24 - hostlen, hostname, hostlen);
        for (i = strlen(T10) ; i+hostlen < 24; i++)
@@ -3325,7 +3262,7 @@ validate_geometry_ddf_container(struct supertype *st,
        int fd;
        unsigned long long ldsize;
 
-       if (level != LEVEL_CONTAINER)
+       if (!is_container(level))
                return 0;
        if (!dev)
                return 1;
@@ -3371,7 +3308,7 @@ static int validate_geometry_ddf(struct supertype *st,
 
        if (level == LEVEL_NONE)
                level = LEVEL_CONTAINER;
-       if (level == LEVEL_CONTAINER) {
+       if (is_container(level)) {
                /* Must be a fresh device to add to a container */
                return validate_geometry_ddf_container(st, level, raiddisks,
                                                       data_offset, dev,
@@ -3488,7 +3425,7 @@ static int validate_geometry_ddf_bvd(struct supertype *st,
        struct dl *dl;
        unsigned long long maxsize;
        /* ddf/bvd supports lots of things, but not containers */
-       if (level == LEVEL_CONTAINER) {
+       if (is_container(level)) {
                if (verbose)
                        pr_err("DDF cannot create a container within an container\n");
                return 0;
@@ -5211,7 +5148,6 @@ struct superswitch super_ddf = {
        .match_home     = match_home_ddf,
        .uuid_from_super= uuid_from_super_ddf,
        .getinfo_super  = getinfo_super_ddf,
-       .update_super   = update_super_ddf,
 
        .avail_size     = avail_size_ddf,
 
@@ -5226,6 +5162,7 @@ struct superswitch super_ddf = {
        .default_geometry = default_geometry_ddf,
 
        .external       = 1,
+       .swapuuid       = 0,
 
 /* for mdmon */
        .open_new       = ddf_open_new,