#include "md_p.h"
#include "md_u.h"
-int Detail(char *dev, int brief, int test, char *homehost)
+int Detail(char *dev, int brief, int export, int test, char *homehost)
{
/*
* Print out details for an md array by using
/* Ok, we have some info to print... */
c = map_num(pers, array.level);
- if (brief)
+
+ if (export) {
+ if (c)
+ printf("MD_LEVEL=%s\n", c);
+ printf("MD_DEVICES=%d\n", array.raid_disks);
+ printf("MD_METADATA=%d.%d\n", array.major_version,
+ array.minor_version);
+ st->ss->export_super(super);
+ goto out;
+ }
+
+ if (brief)
printf("ARRAY %s level=%s num-devices=%d", dev, c?c:"-unknown-",array.raid_disks );
else {
mdu_bitmap_file_t bmf;
if (brief > 1 && devices) printf("\n devices=%s", devices);
if (brief) printf("\n");
+out:
if (test && (rv&2)) rv &= ~1;
close(fd);
return rv;
/* For Detail/Examine */
{"brief", 0, 0, 'b'},
+ {"export", 0, 0, 'Y'},
{"sparc2.2", 0, 0, Sparc22},
{"test", 0, 0, 't'},
" --verbose -v : Be more verbose about what is happening\n"
" --quiet -q : Don't print un-necessary messages\n"
" --brief -b : Be less verbose, more brief\n"
+" --export -Y : With --detail, use key=value format for easy\n"
+" import into environment\n"
" --force -f : Override normal checks and be more forceful\n"
"\n"
" --assemble -A : Assemble an array\n"
.BR \-D ", " \-\-detail
Print detail of one or more md devices.
+.TP
+.BR \-Y ", " \-\-export
+When used with
+.BR \-\-detail ,
+output will be formatted as
+.B key=value
+pairs for easy import into the environment.
+
.TP
.BR \-E ", " \-\-examine
Print content of md superblock on device(s).
int brief = 0;
int force = 0;
int test = 0;
+ int export = 0;
int assume_clean = 0;
char *symlinks = NULL;
/* autof indicates whether and how to create device node.
}
continue;
+ case 'Y': export++;
+ continue;
+
case HomeHost:
homehost = optarg;
continue;
e->dev);
continue;
}
- rv |= Detail(name, verbose>1?0:verbose+1, test, homehost);
+ rv |= Detail(name, verbose>1?0:verbose+1,
+ export, test, homehost);
put_md_name(name);
}
} else if (devmode == 'S' && scan) {
for (dv=devlist ; dv; dv=dv->next) {
switch(dv->disposition) {
case 'D':
- rv |= Detail(dv->devname, brief?1+verbose:0, test, homehost); continue;
+ rv |= Detail(dv->devname,
+ brief?1+verbose:0,
+ export, test, homehost);
+ continue;
case 'K': /* Zero superblock */
rv |= Kill(dv->devname, force, quiet); continue;
case 'Q':
void (*examine_super)(void *sbv, char *homehost);
void (*brief_examine_super)(void *sbv);
void (*detail_super)(void *sbv, char *homehost);
+ void (*export_super)(void *sbv);
void (*brief_detail_super)(void *sbv);
void (*uuid_from_super)(int uuid[4], void *sbv);
void (*getinfo_super)(struct mdinfo *info, void *sbv);
int runstop, int verbose, int force, int assume_clean,
char *bitmap_file, int bitmap_chunk, int write_behind, int delay);
-extern int Detail(char *dev, int brief, int test, char *homehost);
+extern int Detail(char *dev, int brief, int export, int test, char *homehost);
extern int Query(char *dev);
extern int Examine(mddev_dev_t devlist, int brief, int scan, int SparcAdjust,
struct supertype *forcest, char *homehost);
else
printf("%08x", sb->set_uuid0);
}
+
+static void export_super0(void *sbv)
+{
+ mdp_super_t *sb = sbv;
+ printf("MD_UUID=");
+ if (sb->minor_version >= 90)
+ printf("%08x:%08x:%08x:%08x", sb->set_uuid0, sb->set_uuid1,
+ sb->set_uuid2, sb->set_uuid3);
+ else
+ printf("%08x", sb->set_uuid0);
+ printf("\n");
+}
#endif
static int match_home0(void *sbv, char *homehost)
.brief_examine_super = brief_examine_super0,
.detail_super = detail_super0,
.brief_detail_super = brief_detail_super0,
+ .export_super = export_super0,
#endif
.match_home = match_home0,
.uuid_from_super = uuid_from_super0,
}
}
+static void export_super1(void *sbv)
+{
+ struct mdp_superblock_1 *sb = sbv;
+ int i;
+ int len = 32;
+
+ for (i=0; i<32; i++)
+ if (sb->set_name[i] == '\n' ||
+ sb->set_name[i] == '\0') {
+ len = i;
+ break;
+ }
+ if (len)
+ printf("MD_NAME=%.*s\n", len, sb->set_name);
+ printf("MD_UUID=");
+ for (i=0; i<16; i++) {
+ if ((i&3)==0 && i != 0) printf(":");
+ printf("%02x", sb->set_uuid[i]);
+ }
+ printf("\n");
+}
+
#endif
static int match_home1(void *sbv, char *homehost)
.brief_examine_super = brief_examine_super1,
.detail_super = detail_super1,
.brief_detail_super = brief_detail_super1,
+ .export_super = export_super1,
#endif
.match_home = match_home1,
.uuid_from_super = uuid_from_super1,