Пример #1
0
static int write_config(void)
{
	int ret;

	ret = atomic_create_and_write(config_path, (char *)&config,
				sizeof(config));
	if (ret < 0) {
		sd_eprintf("atomic_create_and_write() failed");
		return SD_RES_EIO;
	}

	return SD_RES_SUCCESS;
}
Пример #2
0
static int write_config(void)
{
	int ret;

	if( (!sys->gateway_only)  && (sys->store & STORE_FLAG_KINETIC))
		return kinetic_write_config( (char *)&config, sizeof(config),
			true);
	ret = atomic_create_and_write(config_path, (char *)&config,
				      sizeof(config), true);
	if (ret < 0) {
		sd_err("atomic_create_and_write() failed");
		return SD_RES_EIO;
	}

	return SD_RES_SUCCESS;
}
Пример #3
0
int update_epoch_log(uint32_t epoch, struct sd_node *nodes, size_t nr_nodes)
{
	int ret, len, nodes_len;
	time_t t;
	char path[PATH_MAX], *buf;

	sd_dprintf("update epoch: %d, %zu", epoch, nr_nodes);

	/* Piggyback the epoch creation time for 'collie cluster info' */
	time(&t);
	nodes_len = nr_nodes * sizeof(struct sd_node);
	len = nodes_len + sizeof(time_t);
	buf = xmalloc(len);
	memcpy(buf, nodes, nodes_len);
	memcpy(buf + nodes_len, &t, sizeof(time_t));

	snprintf(path, sizeof(path), "%s%08u", epoch_path, epoch);

	ret = atomic_create_and_write(path, buf, len);

	free(buf);
	return ret;
}