]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super-mbr.c
Create: support --readonly flag.
[thirdparty/mdadm.git] / super-mbr.c
index 0751e17cec965fd9182e8a53613070157bf3f07e..bbbc65bf3173f66c06f2ced55bba0900a12b1f15 100644 (file)
@@ -80,11 +80,8 @@ static int load_super_mbr(struct supertype *st, int fd, char *devname)
 
        free_mbr(st);
 
-       if (st->subarray[0])
-               return 1;
-
        if (posix_memalign((void**)&super, 512, 512) != 0) {
-               fprintf(stderr, Name ": %s could not allocate superblock\n",
+               pr_err("%s could not allocate superblock\n",
                        __func__);
                return 1;
        }
@@ -94,7 +91,7 @@ static int load_super_mbr(struct supertype *st, int fd, char *devname)
        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;
@@ -102,7 +99,7 @@ static int load_super_mbr(struct supertype *st, int fd, char *devname)
  
        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;
@@ -124,7 +121,7 @@ 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",
+               pr_err("%s could not allocate superblock\n",
                        __func__);
                return 1;
        }
@@ -172,13 +169,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;
@@ -190,11 +186,11 @@ static struct supertype *match_metadata_desc(char *arg)
 #ifndef MDASSEMBLE
 static int validate_geometry(struct supertype *st, int level,
                             int layout, int raiddisks,
-                            int chunk, unsigned long long size,
+                            int *chunk, unsigned long long size,
                             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
@@ -202,8 +198,8 @@ static int validate_geometry(struct supertype *st, int level,
 struct superswitch mbr = {
 #ifndef MDASSEMBLE
        .examine_super = examine_mbr,
-#endif
        .validate_geometry = validate_geometry,
+#endif
        .match_metadata_desc = match_metadata_desc,
        .load_super = load_super_mbr,
        .store_super = store_mbr,