diff options
Diffstat (limited to 'Incremental.c')
-rw-r--r-- | Incremental.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Incremental.c b/Incremental.c index ed29488..1fcc4f0 100644 --- a/Incremental.c +++ b/Incremental.c @@ -882,3 +882,60 @@ int IncrementalRemove(char *devname, int verbose) devlist.disposition = 'r'; return Manage_subdevs(ent->dev, mdfd, &devlist, verbose); } + +/* + * IncrementalNewDisk - Check to see if the passed in device belongs to any + * DOMAIN entries from the config file, and if so, perform the required + * action. + * + * @devname - The device we are supposed to examine. This is a currently + * non-raid device, decide if we should claim it and if so, perform the + * required actions. + * + * Special note: Due to limitations of the whole hotplug model, any time we + * have a partitioned device, the bare drive will get called into this + * function because only the partitions will register as already being raid + * members, the bare drive itself won't. We need to be smart enough here + * so that even if we have a DOMAIN line that says partition, that we don't + * actually do the partitioning if the right partition table is already there. + */ +int IncrementalNewDisk(char *devname, int verbose, int export) +{ + struct mdstat_ent *mdstat, *md; + struct domain_ent *domain; + + domain = conf_get_domain(devname); + if (!domain) + return 0; + if ((domain->action & action_mask) <= incremental) + /* Nothing to do. We only get called in the case that there + * is no current superblock on the device in question, and + * since our matching domain says we should either ignore or + * use devices incrementally, they have to already have a + * superblock. Since we don't, we're done. + */ + return 0; + if (domain->action == partition) { + /* Special case. Basically, we can only put this action on + * whole disk devices, and since we are partitioning them, + * the whole device necessarily won't ever be part of an + * array, so we will never have any arrays in our domain, ever. + * As such, we have to figure out what to do from other + * hints. + */ + /* We haven't filled this out yet */ + return 0; + } + mdstat = arrays_in_domain(devname, domain); + if (!mdstat) { + /* As a technical design decision, we *must* have at least one + * array in our domain that we can add this device to or else + * we simply can't do anything with this device. + */ + printf("No arrays found in domain!\n"); + return 1; + } + for (md = mdstat; md; md = md->next) + printf(Name ": %s\n", md->dev); + return 0; +} |