Exemplo n.º 1
0
static void _write_array(struct pfilter *pf, FILE *fp, const char *path,
			 void *data)
{
	void *d;
	int first = 1;
	struct dm_hash_node *n;

	for (n = dm_hash_get_first(pf->devices); n;
	     n = dm_hash_get_next(pf->devices, n)) {
		d = dm_hash_get_data(pf->devices, n);

		if (d != data)
			continue;

		if (!first)
			fprintf(fp, ",\n");
		else {
			fprintf(fp, "\t%s=[\n", path);
			first = 0;
		}

		fprintf(fp, "\t\t\"%s\"", dm_hash_get_key(pf->devices, n));
	}

	if (!first)
		fprintf(fp, "\n\t]\n");

	return;
}
Exemplo n.º 2
0
static void remove_info(const char *resource)
{
	int num_open;

	pthread_mutex_lock(&lv_hash_lock);
	dm_hash_remove(lv_hash, resource);

	/* When last lock is remove, validate there are not left opened devices */
	if (!dm_hash_get_first(lv_hash)) {
		if (critical_section())
			log_error(INTERNAL_ERROR "No volumes are locked however clvmd is in activation mode critical section.");
		if ((num_open = dev_cache_check_for_open_devices()))
			log_error(INTERNAL_ERROR "No volumes are locked however %d devices are still open.", num_open);
	}

	pthread_mutex_unlock(&lv_hash_lock);
}