Beispiel #1
0
void load_conffile(void)
{
	FILE *f;
	char *confdir = NULL;
	char *head;

	if (loaded)
		return;
	if (conffile == NULL) {
		conffile = DefaultConfFile;
		confdir = DefaultConfDir;
	}

	if (strcmp(conffile, "partitions")==0) {
		char *list = dl_strdup("DEV");
		dl_init(list);
		dl_add(list, dl_strdup("partitions"));
		devline(list);
		free_line(list);
	} else if (strcmp(conffile, "none") != 0) {
		f = fopen(conffile, "r");
		/* Debian chose to relocate mdadm.conf into /etc/mdadm/.
		 * To allow Debian users to compile from clean source and still
		 * have a working mdadm, we read /etc/mdadm/mdadm.conf
		 * if /etc/mdadm.conf doesn't exist
		 */
		if (f == NULL &&
		    conffile == DefaultConfFile) {
			f = fopen(DefaultAltConfFile, "r");
			if (f) {
				conffile = DefaultAltConfFile;
				confdir = DefaultAltConfDir;
			}
		}
		if (f) {
			conf_file_or_dir(f);
			fclose(f);
		}
		if (confdir) {
			f = fopen(confdir, "r");
			if (f) {
				conf_file_or_dir(f);
				fclose(f);
			}
		}
	}
	/* If there was no AUTO line, process an empty line
	 * now so that the MDADM_CONF_AUTO env var gets processed.
	 */
	head = dl_strdup("AUTO");
	dl_init(head);
	autoline(head);
	free_line(head);

	loaded = 1;
}
Beispiel #2
0
void conf_file(FILE *f)
{
	char *line;
	while ((line=conf_line(f))) {
		switch(match_keyword(line)) {
		case Devices:
			devline(line);
			break;
		case Array:
			arrayline(line);
			break;
		case Mailaddr:
			mailline(line);
			break;
		case Mailfrom:
			mailfromline(line);
			break;
		case Program:
			programline(line);
			break;
		case CreateDev:
			createline(line);
			break;
		case Homehost:
			homehostline(line);
			break;
		case AutoMode:
			autoline(line);
			break;
		case Policy:
			policyline(line, rule_policy);
			break;
		case PartPolicy:
			policyline(line, rule_part);
			break;
		default:
			pr_err("Unknown keyword %s\n", line);
		}
		free_line(line);
	}
}
Beispiel #3
0
void load_conffile(char *conffile)
{
	FILE *f;
	char *line;

	if (loaded) return;
	if (conffile == NULL)
		conffile = DefaultConfFile;

	if (strcmp(conffile, "none") == 0) {
		loaded = 1;
		return;
	}
	if (strcmp(conffile, "partitions")==0) {
		char *list = dl_strdup("DEV");
		dl_init(list);
		dl_add(list, dl_strdup("partitions"));
		devline(list);
		free_line(list);
		loaded = 1;
		return;
	}
	f = fopen(conffile, "r");
	/* Debian chose to relocate mdadm.conf into /etc/mdadm/.
	 * To allow Debian users to compile from clean source and still
	 * have a working mdadm, we read /etc/mdadm/mdadm.conf
	 * if /etc/mdadm.conf doesn't exist
	 */
	if (f == NULL &&
	    conffile == DefaultConfFile) {
		f = fopen(DefaultAltConfFile, "r");
		if (f)
			conffile = DefaultAltConfFile;
	}
	if (f == NULL)
		return;

	loaded = 1;
	while ((line=conf_line(f))) {
		switch(match_keyword(line)) {
		case 0: /* DEVICE */
			devline(line);
			break;
		case 1: /* ARRAY */
			arrayline(line);
			break;
		case 2: /* MAIL */
			mailline(line);
			break;
		case 3: /* PROGRAM */
			programline(line);
			break;
		default:
			fprintf(stderr, Name ": Unknown keyword %s\n", line);
		}
		free_line(line);
	}
    
	fclose(f);

/*    printf("got file\n"); */
}
Beispiel #4
0
void load_conffile(void)
{
	FILE *f;
	char *line;

	if (loaded) return;
	if (conffile == NULL)
		conffile = DefaultConfFile;

	if (strcmp(conffile, "none") == 0) {
		loaded = 1;
		return;
	}
	if (strcmp(conffile, "partitions")==0) {
		char *list = dl_strdup("DEV");
		dl_init(list);
		dl_add(list, dl_strdup("partitions"));
		devline(list);
		free_line(list);
		loaded = 1;
		return;
	}
	f = fopen(conffile, "r");
	/* Debian chose to relocate mdadm.conf into /etc/mdadm/.
	 * To allow Debian users to compile from clean source and still
	 * have a working mdadm, we read /etc/mdadm/mdadm.conf
	 * if /etc/mdadm.conf doesn't exist
	 */
	if (f == NULL &&
	    conffile == DefaultConfFile) {
		f = fopen(DefaultAltConfFile, "r");
		if (f)
			conffile = DefaultAltConfFile;
	}
	if (f == NULL)
		return;

	loaded = 1;
	while ((line=conf_line(f))) {
		switch(match_keyword(line)) {
		case Devices:
			devline(line);
			break;
		case Array:
			arrayline(line);
			break;
		case Mailaddr:
			mailline(line);
			break;
		case Mailfrom:
			mailfromline(line);
			break;
		case Program:
			programline(line);
			break;
		case CreateDev:
			createline(line);
			break;
		case Homehost:
			homehostline(line);
			break;
		default:
			fprintf(stderr, Name ": Unknown keyword %s\n", line);
		}
		free_line(line);
	}
    
	fclose(f);

/*    printf("got file\n"); */
}