Exemplo n.º 1
0
char *conf_get_homehost(int *require_homehostp)
{
	load_conffile();
	if (require_homehostp)
		*require_homehostp = require_homehost;
	return home_host;
}
Exemplo n.º 2
0
int conf_test_metadata(const char *version, struct dev_policy *pol, int is_homehost)
{
	/* If anyone said 'yes', that sticks.
	 * else if homehost applies, use that
	 * else if there is a 'no', say 'no'.
	 * else 'yes'.
	 */
	struct dev_policy *p;
	int no=0, found_homehost=0;
	load_conffile();

	pol = pol_find(pol, pol_auto);
	pol_for_each(p, pol, version) {
		if (strcmp(p->value, "yes") == 0)
			return 1;
		if (strcmp(p->value, "homehost") == 0)
			found_homehost = 1;
		if (strcmp(p->value, "no") == 0)
			no = 1;
	}
	if (is_homehost && found_homehost)
		return 1;
	if (no)
		return 0;
	return 1;
}
Exemplo n.º 3
0
mddev_ident_t conf_get_ident(char *conffile, char *dev)
{
	mddev_ident_t rv;
	load_conffile(conffile);
	rv = mddevlist;
	while (dev && rv && strcmp(dev, rv->devname)!=0)
		rv = rv->next;
	return rv;
}
Exemplo n.º 4
0
struct mddev_ident *conf_get_ident(char *dev)
{
	struct mddev_ident *rv;
	load_conffile();
	rv = mddevlist;
	while (dev && rv && (rv->devname == NULL
			     || !devname_matches(dev, rv->devname)))
		rv = rv->next;
	return rv;
}
Exemplo n.º 5
0
struct mddev_dev *conf_get_devs()
{
	glob_t globbuf;
	struct conf_dev *cd;
	int flags = 0;
	static struct mddev_dev *dlist = NULL;
	unsigned int i;

	while (dlist) {
		struct mddev_dev *t = dlist;
		dlist = dlist->next;
		free(t->devname);
		free(t);
	}

	load_conffile();

	if (cdevlist == NULL) {
		/* default to 'partitions' and 'containers' */
		dlist = load_partitions();
		append_dlist(&dlist, load_containers());
	}

	for (cd=cdevlist; cd; cd=cd->next) {
		if (strcasecmp(cd->name, "partitions")==0)
			append_dlist(&dlist, load_partitions());
		else if (strcasecmp(cd->name, "containers")==0)
			append_dlist(&dlist, load_containers());
		else {
			glob(cd->name, flags, NULL, &globbuf);
			flags |= GLOB_APPEND;
		}
	}
	if (flags & GLOB_APPEND) {
		for (i=0; i<globbuf.gl_pathc; i++) {
			struct mddev_dev *t = xmalloc(sizeof(*t));
			memset(t, 0, sizeof(*t));
			t->devname = xstrdup(globbuf.gl_pathv[i]);
			t->next = dlist;
			dlist = t;
/*	printf("one dev is %s\n", t->devname);*/
		}
		globfree(&globbuf);
	}

	return dlist;
}
Exemplo n.º 6
0
mddev_dev_t conf_get_devs()
{
	glob_t globbuf;
	struct conf_dev *cd;
	int flags = 0;
	static mddev_dev_t dlist = NULL;
	unsigned int i;

	while (dlist) {
		mddev_dev_t t = dlist;
		dlist = dlist->next;
		free(t->devname);
		free(t);
	}
    
	load_conffile();

	if (cdevlist == NULL)
		/* default to 'partitions */
		dlist = load_partitions();

	for (cd=cdevlist; cd; cd=cd->next) {
		if (strcasecmp(cd->name, "partitions")==0 && dlist == NULL)
			dlist = load_partitions();
		else {
			glob(cd->name, flags, NULL, &globbuf);
			flags |= GLOB_APPEND;
		}
	}
	if (flags & GLOB_APPEND) {
		for (i=0; i<globbuf.gl_pathc; i++) {
			mddev_dev_t t = malloc(sizeof(*t));
			t->devname = strdup(globbuf.gl_pathv[i]);
			t->next = dlist;
			t->used = 0;
			dlist = t;
/*	printf("one dev is %s\n", t->devname);*/
		}
		globfree(&globbuf);
	}

	return dlist;
}
Exemplo n.º 7
0
int conf_name_is_free(char *name)
{
	/* Check if this name is already taken by an ARRAY entry in
	 * the config file.
	 * It can be taken either by a match on devname, name, or
	 * even super-minor.
	 */
	struct mddev_ident *dev;

	load_conffile();
	for (dev = mddevlist; dev; dev = dev->next) {
		char nbuf[100];
		if (dev->devname && devname_matches(name, dev->devname))
			return 0;
		if (dev->name[0] && devname_matches(name, dev->name))
			return 0;
		sprintf(nbuf, "%d", dev->super_minor);
		if (dev->super_minor != UnSet &&
		    devname_matches(name, nbuf))
			return 0;
	}
	return 1;
}
Exemplo n.º 8
0
char *conf_get_program(char *conffile)
{
	load_conffile(conffile);
	return alert_program;
}
Exemplo n.º 9
0
char *conf_get_mailaddr(char *conffile)
{
	load_conffile(conffile);
	return alert_email;
}
Exemplo n.º 10
0
struct createinfo *conf_get_create_info(void)
{
	load_conffile();
	return &createinfo;
}
Exemplo n.º 11
0
char *conf_get_program(void)
{
	load_conffile();
	return alert_program;
}
Exemplo n.º 12
0
char *conf_get_mailfrom(void)
{
	load_conffile();
	return alert_mail_from;
}
Exemplo n.º 13
0
char *conf_get_mailaddr(void)
{
	load_conffile();
	return alert_email;
}
Exemplo n.º 14
0
char *conf_get_homehost(void)
{
	load_conffile();
	return home_host;
}