summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2006-05-19 05:50:08 +0000
committerNeil Brown <neilb@suse.de>2006-05-19 05:50:08 +0000
commit997aed5deeabc74eefcf37a0f042ac8707dfe227 (patch)
tree96205aa20830a65b2e88cd5fd863e4bdcb07df4d
parent8fe9db0ffef630b9403206d0c7b8e3a404bd9e8e (diff)
downloadmdadm-997aed5deeabc74eefcf37a0f042ac8707dfe227.tar.gz
mdadm-997aed5deeabc74eefcf37a0f042ac8707dfe227.tar.xz
mdadm-997aed5deeabc74eefcf37a0f042ac8707dfe227.zip
Allow homehost to be set on command line or in config file
Signed-off-by: Neil Brown <neilb@suse.de>
-rw-r--r--ReadMe.c15
-rw-r--r--config.c23
-rw-r--r--mdadm.c32
-rw-r--r--mdadm.h15
4 files changed, 66 insertions, 19 deletions
diff --git a/ReadMe.c b/ReadMe.c
index db06795..ca2bc77 100644
--- a/ReadMe.c
+++ b/ReadMe.c
@@ -130,13 +130,14 @@ struct option long_options[] = {
{"spare-devices",1,0, 'x'},
{"size", 1, 0, 'z'},
{"auto", 1, 0, 'a'}, /* also for --assemble */
- {"assume-clean",0,0, 3 },
+ {"assume-clean",0,0, AssumeClean },
{"metadata", 1, 0, 'e'}, /* superblock format */
{"bitmap", 1, 0, 'b'},
- {"bitmap-chunk", 1, 0, 4},
- {"write-behind", 2, 0, 5},
+ {"bitmap-chunk", 1, 0, BitmapChunk},
+ {"write-behind", 2, 0, WriteBehind},
{"write-mostly",0, 0, 'W'},
- {"re-add", 0, 0, 6},
+ {"re-add", 0, 0, ReAdd},
+ {"homehost", 1, 0, HomeHost},
/* For assemble */
{"uuid", 1, 0, 'u'},
@@ -156,11 +157,11 @@ struct option long_options[] = {
{"stop", 0, 0, 'S'},
{"readonly", 0, 0, 'o'},
{"readwrite", 0, 0, 'w'},
- {"no-degraded",0,0, 4 },
+ {"no-degraded",0,0, NoDegraded },
/* For Detail/Examine */
{"brief", 0, 0, 'b'},
- {"sparc2.2", 0, 0, 22},
+ {"sparc2.2", 0, 0, Sparc22},
{"test", 0, 0, 't'},
/* For Follow/monitor */
@@ -173,7 +174,7 @@ struct option long_options[] = {
{"oneshot", 0, 0, '1'},
{"pid-file", 1, 0, 'i'},
/* For Grow */
- {"backup-file", 1,0, 7},
+ {"backup-file", 1,0, BackupFile},
{0, 0, 0, 0}
};
diff --git a/config.c b/config.c
index ec9e3e1..8382cdf 100644
--- a/config.c
+++ b/config.c
@@ -553,6 +553,20 @@ void programline(char *line)
}
}
+static char *home_host = NULL;
+void homehostline(char *line)
+{
+ char *w;
+
+ for (w=dl_next(line); w != line ; w=dl_next(w)) {
+ if (home_host == NULL)
+ home_host = strdup(w);
+ else
+ fprintf(stderr, Name ": excess host name on HOMEHOST line: %s - ignored\n",
+ w);
+ }
+}
+
int loaded = 0;
@@ -614,6 +628,9 @@ void load_conffile(char *conffile)
case CreateDev:
createline(line);
break;
+ case Homehost:
+ homehostline(line);
+ break;
default:
fprintf(stderr, Name ": Unknown keyword %s\n", line);
}
@@ -643,6 +660,12 @@ char *conf_get_program(char *conffile)
return alert_program;
}
+char *conf_get_homehost(char *conffile)
+{
+ load_conffile(conffile);
+ return home_host;
+}
+
struct createinfo *conf_get_create_info(char *conffile)
{
load_conffile(conffile);
diff --git a/mdadm.c b/mdadm.c
index 902d401..df8d904 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -87,6 +87,7 @@ int main(int argc, char *argv[])
*/
int autof = 0;
+ char *homehost = NULL;
char *mailaddr = NULL;
char *program = NULL;
int delay = 0;
@@ -153,6 +154,10 @@ int main(int argc, char *argv[])
}
continue;
+ case HomeHost:
+ homehost = optarg;
+ continue;
+
case ':':
case '?':
fputs(Usage, stderr);
@@ -441,8 +446,8 @@ int main(int argc, char *argv[])
}
continue;
- case O(CREATE,3):
- case O(BUILD,3): /* assume clean */
+ case O(CREATE,AssumeClean):
+ case O(BUILD,AssumeClean): /* assume clean */
assume_clean = 1;
continue;
@@ -577,7 +582,7 @@ int main(int argc, char *argv[])
fprintf(stderr, Name ": '--update %s' invalid. Only 'sparc2.2', 'super-minor', 'uuid', 'resync' or 'summaries' supported\n",update);
exit(2);
- case O(ASSEMBLE,4): /* --no-degraded */
+ case O(ASSEMBLE,NoDegraded): /* --no-degraded */
runstop = -1; /* --stop isn't allowed for --assemble, so we overload slightly */
continue;
@@ -659,7 +664,7 @@ int main(int argc, char *argv[])
devmode = 'a';
re_add = 0;
continue;
- case O(MANAGE,6):
+ case O(MANAGE,ReAdd):
devmode = 'a';
re_add = 1;
continue;
@@ -723,7 +728,7 @@ int main(int argc, char *argv[])
test = 1;
continue;
- case O(MISC, 22):
+ case O(MISC, Sparc22):
if (devmode != 'E') {
fprintf(stderr, Name ": --sparc2.2 only allowed with --examine\n");
exit(2);
@@ -748,8 +753,8 @@ int main(int argc, char *argv[])
ident.bitmap_fd = bitmap_fd; /* for Assemble */
continue;
- case O(ASSEMBLE, 7):
- case O(GROW, 7):
+ case O(ASSEMBLE, BackupFile):
+ case O(GROW, BackupFile):
/* Specify a file into which grow might place a backup,
* or from which assemble might recover a backup
*/
@@ -773,9 +778,9 @@ int main(int argc, char *argv[])
fprintf(stderr, Name ": bitmap file must contain a '/', or be 'internal', or 'none'\n");
exit(2);
- case O(GROW,4):
- case O(BUILD,4):
- case O(CREATE,4): /* bitmap chunksize */
+ case O(GROW,BitmapChunk):
+ case O(BUILD,BitmapChunk):
+ case O(CREATE,BitmapChunk): /* bitmap chunksize */
bitmap_chunk = strtol(optarg, &c, 10);
if (!optarg[0] || *c || bitmap_chunk < 0 ||
bitmap_chunk & (bitmap_chunk - 1)) {
@@ -787,8 +792,8 @@ int main(int argc, char *argv[])
bitmap_chunk = bitmap_chunk ? bitmap_chunk * 1024 : 512;
continue;
- case O(BUILD, 5):
- case O(CREATE, 5): /* write-behind mode */
+ case O(BUILD, WriteBehind):
+ case O(CREATE, WriteBehind): /* write-behind mode */
write_behind = DEFAULT_MAX_WRITE_BEHIND;
if (optarg) {
write_behind = strtol(optarg, &c, 10);
@@ -893,6 +898,9 @@ int main(int argc, char *argv[])
}
}
+ if (homehost == NULL)
+ homehost = conf_get_homehost(configfile);
+
rv = 0;
switch(mode) {
case MANAGE:
diff --git a/mdadm.h b/mdadm.h
index df43516..991dc8e 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -125,6 +125,20 @@ extern char Version[], Usage[], Help[], OptionHelp[],
Help_create[], Help_build[], Help_assemble[], Help_grow[],
Help_manage[], Help_misc[], Help_monitor[], Help_config[];
+/* for option that don't have short equivilents, we assign arbitrary
+ * small numbers. '1' means an undecorated option, so we start at '2'.
+ */
+enum special_options {
+ AssumeClean = 2,
+ BitmapChunk,
+ WriteBehind,
+ ReAdd,
+ NoDegraded,
+ Sparc22,
+ BackupFile,
+ HomeHost,
+};
+
/* structures read from config file */
/* List of mddevice names and identifiers
* Identifiers can be:
@@ -381,6 +395,7 @@ extern struct createinfo *conf_get_create_info(char *conffile);
extern char *conf_get_mailaddr(char *conffile);
extern char *conf_get_mailfrom(char *conffile);
extern char *conf_get_program(char *conffile);
+extern char *conf_get_homehost(char *conffile);
extern char *conf_line(FILE *file);
extern char *conf_word(FILE *file, int allow_key);
extern void free_line(char *line);