]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super-mbr.c
Show all bitmaps while examining bitmap
[thirdparty/mdadm.git] / super-mbr.c
index 5eefdf696819d2be17a493e66ddb246bfcd62e39..62b3f03126cbda2a3a19af14cb123f2646cfff7f 100644 (file)
@@ -81,25 +81,22 @@ static int load_super_mbr(struct supertype *st, int fd, char *devname)
        free_mbr(st);
 
        if (posix_memalign((void**)&super, 512, 512) != 0) {
-               fprintf(stderr, Name ": %s could not allocate superblock\n",
-                       __func__);
+               pr_err("could not allocate superblock\n");
                return 1;
        }
 
-       ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
-
        lseek(fd, 0, 0);
        if (read(fd, super, sizeof(*super)) != sizeof(*super)) {
                if (devname)
-                       fprintf(stderr, Name ": Cannot read partition table on %s\n",
+                       pr_err("Cannot read partition table on %s\n",
                                devname);
                free(super);
                return 1;
        }
+
        if (super->magic != MBR_SIGNATURE_MAGIC) {
                if (devname)
-                       fprintf(stderr, Name ": No partition table found on %s\n",
+                       pr_err("No partition table found on %s\n",
                                devname);
                free(super);
                return 1;
@@ -121,13 +118,10 @@ static int store_mbr(struct supertype *st, int fd)
        struct MBR *old, *super;
 
        if (posix_memalign((void**)&old, 512, 512) != 0) {
-               fprintf(stderr, Name ": %s could not allocate superblock\n",
-                       __func__);
+               pr_err("could not allocate superblock\n");
                return 1;
        }
 
-       ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
-
        lseek(fd, 0, 0);
        if (read(fd, old, sizeof(*old)) != sizeof(*old)) {
                free(old);
@@ -158,7 +152,7 @@ static void getinfo_mbr(struct supertype *st, struct mdinfo *info, char *map)
 
        for (i = 0; i < MBR_PARTITIONS ; i++)
                if (sb->parts[i].blocks_num) {
-                       unsigned long last = 
+                       unsigned long last =
                                (unsigned long)__le32_to_cpu(sb->parts[i].blocks_num)
                                + (unsigned long)__le32_to_cpu(sb->parts[i].first_sect_lba);
                        if (last > info->component_size)
@@ -169,13 +163,12 @@ static void getinfo_mbr(struct supertype *st, struct mdinfo *info, char *map)
 
 static struct supertype *match_metadata_desc(char *arg)
 {
-       struct supertype *st = malloc(sizeof(*st));
+       struct supertype *st;
 
-       if (!st)
-               return st;
        if (strcmp(arg, "mbr") != 0)
                return NULL;
 
+       st = xmalloc(sizeof(*st));
        st->ss = &mbr;
        st->info = NULL;
        st->minor_version = 0;
@@ -188,10 +181,11 @@ static struct supertype *match_metadata_desc(char *arg)
 static int validate_geometry(struct supertype *st, int level,
                             int layout, int raiddisks,
                             int *chunk, unsigned long long size,
+                            unsigned long long data_offset,
                             char *subdev, unsigned long long *freesize,
                             int verbose)
 {
-       fprintf(stderr, Name ": mbr metadata cannot be used this way\n");
+       pr_err("mbr metadata cannot be used this way\n");
        return 0;
 }
 #endif