summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2006-05-23 06:46:40 +0000
committerNeil Brown <neilb@suse.de>2006-05-23 06:46:40 +0000
commit8a46fe8487986f96e5313156336c02cc551282c8 (patch)
treee9c53c4285bf45486948fc555c8df487c4220268
parent83b6208e890f29115c56a252de82dfd7c50488d0 (diff)
downloadmdadm-8a46fe8487986f96e5313156336c02cc551282c8.tar.gz
mdadm-8a46fe8487986f96e5313156336c02cc551282c8.tar.xz
mdadm-8a46fe8487986f96e5313156336c02cc551282c8.zip
Allow autoassembly to choose it's own name for the array.
This cannot be used yet, but it is working towards auto-assembly. When auto-assembling an array, we make a name in /dev/md/ giving a number (from the peferred minor) or name (from set-name). Signed-off-by: Neil Brown <neilb@suse.de>
-rw-r--r--Assemble.c51
-rw-r--r--super0.c2
2 files changed, 33 insertions, 20 deletions
diff --git a/Assemble.c b/Assemble.c
index 4516b62..46ec9bc 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -139,27 +139,29 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
struct mdinfo info;
char *avail;
int nextspare = 0;
-
- vers = md_get_version(mdfd);
- if (vers <= 0) {
- fprintf(stderr, Name ": %s appears not to be an md device.\n", mddev);
- return 1;
- }
- if (vers < 9000) {
- fprintf(stderr, Name ": Assemble requires driver version 0.90.0 or later.\n"
- " Upgrade your kernel or try --build\n");
- return 1;
- }
+
if (get_linux_version() < 2004000)
old_linux = 1;
- if (ioctl(mdfd, GET_ARRAY_INFO, &info.array)>=0) {
- fprintf(stderr, Name ": device %s already active - cannot assemble it\n",
- mddev);
- return 1;
- }
- ioctl(mdfd, STOP_ARRAY, NULL); /* just incase it was started but has no content */
+ if (mdfd >= 0) {
+ vers = md_get_version(mdfd);
+ if (vers <= 0) {
+ fprintf(stderr, Name ": %s appears not to be an md device.\n", mddev);
+ return 1;
+ }
+ if (vers < 9000) {
+ fprintf(stderr, Name ": Assemble requires driver version 0.90.0 or later.\n"
+ " Upgrade your kernel or try --build\n");
+ return 1;
+ }
+ if (ioctl(mdfd, GET_ARRAY_INFO, &info.array)>=0) {
+ fprintf(stderr, Name ": device %s already active - cannot assemble it\n",
+ mddev);
+ return 1;
+ }
+ ioctl(mdfd, STOP_ARRAY, NULL); /* just incase it was started but has no content */
+ }
/*
* If any subdevs are listed, then any that don't
* match ident are discarded. Remainder must all match and
@@ -173,7 +175,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
ident->super_minor < 0 &&
ident->devices == NULL) {
fprintf(stderr, Name ": No identity information available for %s - cannot assemble.\n",
- mddev);
+ mddev ? mddev : "further assembly");
return 1;
}
if (devlist == NULL)
@@ -191,7 +193,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
if (verbose>0)
fprintf(stderr, Name ": looking for devices for %s\n",
- mddev);
+ mddev ? mddev : "further assembly");
/* first walk the list of devices to find a consistent set
* that match the criterea, if that is possible.
@@ -332,6 +334,17 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
tmpdev->used = 1;
}
+ if (mdfd < 0) {
+ /* So... it is up to me to open the device.
+ * We create a name '/dev/md/XXX' based on the info in the
+ * superblock, and call open_mddev on that
+ */
+ asprintf(&mddev, "/dev/md/%s", info.name);
+ mdfd = open_mddev(mddev, 0);
+ if (mdfd < 0)
+ return mdfd;
+ }
+
/* Ok, no bad inconsistancy, we can try updating etc */
for (tmpdev = devlist; tmpdev; tmpdev=tmpdev->next) if (tmpdev->used) {
char *devname = tmpdev->devname;
diff --git a/super0.c b/super0.c
index cc2f7a9..7025445 100644
--- a/super0.c
+++ b/super0.c
@@ -334,7 +334,7 @@ static void getinfo_super0(struct mdinfo *info, void *sbv)
} else
info->reshape_active = 0;
- info->name[0] = 0;
+ sprintf(info->name, "%d", sb->md_minor);
/* work_disks is calculated rather than read directly */
for (i=0; i < MD_SB_DISKS; i++)
if ((sb->disks[i].state & (1<<MD_DISK_SYNC)) &&