Esempio n. 1
0
void agent_save(const char *username, int iterations, unsigned const char key[KDF_HASH_LEN])
{
	_cleanup_free_ char *iterations_str = xultostr(iterations);
	config_write_string("iterations", iterations_str);
	config_write_string("username", username);
	config_write_encrypted_string("verify", AGENT_VERIFICATION_STRING, key);
	agent_start(key);
}
Esempio n. 2
0
static void upload_queue_run(const struct session *session, unsigned const char key[KDF_HASH_LEN])
{
	_cleanup_free_ char *pid = NULL;
	upload_queue_kill();
	pid_t child = fork();
	if (child < 0)
		die_errno("fork(agent)");
	if (child == 0) {
		int null = open("/dev/null", 0);
		if (null >= 0) {
			dup2(null, 0);
			dup2(null, 1);
			dup2(null, 2);
			close(null);
		}
		setsid();
		IGNORE_RESULT(chdir("/"));
		process_set_name("lpass [upload queue]");
		signal(SIGHUP, upload_queue_cleanup);
		signal(SIGINT, upload_queue_cleanup);
		signal(SIGQUIT, upload_queue_cleanup);
		signal(SIGTERM, upload_queue_cleanup);
		signal(SIGALRM, upload_queue_cleanup);
		upload_queue_upload_all(session, key);
		upload_queue_cleanup(0);
		_exit(EXIT_SUCCESS);
	}
	pid = xultostr(child);
	config_write_string("uploader.pid", pid);
}
Esempio n. 3
0
static void
write_server(GQServerList* list, GqServer* server, gpointer user_data) {
	gpointer* wc_and_cfg = user_data;
	struct writeconfig* wc = wc_and_cfg[0];
	struct gq_config * cfg = wc_and_cfg[1];

/*	  GString *pw = g_string_new(); */
	  config_write(wc, "<ldapserver>\n");
	  wc->indent++;

	  config_write_string(wc, server->name, "name", NULL);
	  config_write_string(wc, server->ldaphost, "ldaphost", NULL);
	  config_write_int(wc, server->ldapport, "ldapport", NULL);
	  config_write_string_ne(wc, server->basedn, "basedn", NULL);
	  config_write_string_ne(wc, server->binddn, "binddn", NULL);

	  if (cfg->config_version == 0) {
	       config_write_string_ne(wc, server->bindpw, "bindpw", NULL);
	  } else if(server->bindpw && *server->bindpw) {
	       gq_keyring_save_server_password(server);
	  }

	  if(server->bindtype != DEFAULT_BINDTYPE)
	       config_write_string_ne(wc, detokenize(token_bindtype, server->bindtype), "bindtype", NULL);
	  config_write_string_ne(wc, server->searchattr,
				 "search-attribute", NULL);
	  if(server->maxentries != DEFAULT_MAXENTRIES)
	       config_write_int(wc, server->maxentries, "maxentries", NULL);
	  if(server->cacheconn != DEFAULT_CACHECONN)
	       config_write_bool(wc, server->cacheconn, 
				 "cache-connection", NULL);
	  if(server->enabletls != DEFAULT_ENABLETLS)
	       config_write_bool(wc, server->enabletls, "enable-tls", NULL);
	  if(server->local_cache_timeout != DEFAULT_LOCAL_CACHE_TIMEOUT)
	       config_write_int(wc, server->local_cache_timeout, 
				"local-cache-timeout", NULL);
	  if(server->ask_pw != DEFAULT_ASK_PW)
	       config_write_bool(wc, server->ask_pw, "ask-pw", NULL);
	  if(server->hide_internal != DEFAULT_HIDE_INTERNAL)
	       config_write_bool(wc, server->hide_internal, 
				 "hide-internal", NULL);
	  if(server->show_ref != DEFAULT_SHOW_REF)
	       config_write_bool(wc, server->show_ref, "show-ref", NULL);

	  wc->indent--;
	  config_write(wc, "</ldapserver>\n\n");
}
Esempio n. 4
0
void config_write_string_ne(struct writeconfig *wc,
			    const char *value,
			    const char *entity, GHashTable *attr)
{
     if(value && strlen(value)) {
	  config_write_string(wc, value, entity, attr);
     }
}
Esempio n. 5
0
void session_save(struct session *session, unsigned const char key[KDF_HASH_LEN])
{
	config_write_encrypted_string("session_uid", session->uid, key);
	config_write_encrypted_string("session_sessionid", session->sessionid, key);
	config_write_encrypted_string("session_token", session->token, key);
	config_write_encrypted_buffer("session_privatekey", (char *)session->private_key.key, session->private_key.len, key);

	/*
	 * existing sessions may not have a server yet; they will fall back
	 * to lastpass.com.
	 */
	if (session->server)
		config_write_string("session_server", session->server);
}
Esempio n. 6
0
static void set_config(void)
{
	char config_key[6];
	int i;

	strcpy(config_key, "ir_");
	for(i=0;i<64;i++) {
		sprintf(&config_key[3], "%02x", i);
		if(key_bindings[i][0] != 0)
			config_write_string(config_key, key_bindings[i]);
		else
			config_delete(config_key);
	}
}
Esempio n. 7
0
static void upload_queue_run(const struct session *session, unsigned const char key[KDF_HASH_LEN])
{
	_cleanup_free_ char *pid = NULL;
	upload_queue_kill();
	pid_t child = fork();
	if (child < 0)
		die_errno("fork(agent)");
	if (child == 0) {
		_cleanup_free_ char *upload_log_path = NULL;

		int null = open("/dev/null", 0);
		int upload_log = null;

		if (lpass_log_level() >= 0) {
			upload_log_path = config_path("lpass.log");
			upload_log = open(upload_log_path,
					  O_WRONLY | O_CREAT | O_APPEND, 0600);
		}
		if (null >= 0) {
			dup2(null, 0);
			dup2(upload_log, 1);
			dup2(null, 2);
			close(null);
			close(upload_log);
		}
		setsid();
		IGNORE_RESULT(chdir("/"));
		process_set_name("lpass [upload queue]");
		signal(SIGHUP, upload_queue_cleanup);
		signal(SIGINT, upload_queue_cleanup);
		signal(SIGQUIT, upload_queue_cleanup);
		signal(SIGTERM, upload_queue_cleanup);
		signal(SIGALRM, upload_queue_cleanup);
		setvbuf(stdout, NULL, _IOLBF, 0);

		if (http_init()) {
			lpass_log(LOG_ERROR, "UQ: unable to restart curl\n");
			_exit(EXIT_FAILURE);
		}

		lpass_log(LOG_DEBUG, "UQ: starting queue run\n");
		upload_queue_upload_all(session, key);
		lpass_log(LOG_DEBUG, "UQ: queue run complete\n");
		upload_queue_cleanup(0);
		_exit(EXIT_SUCCESS);
	}
	pid = xultostr(child);
	config_write_string("uploader.pid", pid);
}
Esempio n. 8
0
static void attrs_dumper(char *key,
			 struct attr_settings *as,
			 struct writeconfig *wc)
{
     GHashTable *attrs = g_hash_table_new(g_str_hash, g_str_equal);
     g_hash_table_insert(attrs, "name", key);

     config_write_start_tag(wc, "ldap-attribute", attrs);
     wc->indent++;

     if (as->defaultDT != -1) {
	  config_write_int(wc, as->defaultDT, "dt-default", NULL);
     }
     if (as->user_friendly != NULL && strlen(as->user_friendly) > 0) {
	  config_write_string(wc, as->user_friendly, "user-friendly", NULL);
     }

     wc->indent--;
     config_write_end_tag(wc, "ldap-attribute");

     g_hash_table_destroy(attrs);
}
Esempio n. 9
0
void evg_mem_config_default(struct config_t *config)
{
	char section[MAX_STRING_SIZE];
	char str[MAX_STRING_SIZE];

	int compute_unit_id;
	int l2_id;
	int mm_id;

	/* Only detailed simulation */
	assert(evg_emu_sim_kind == arch_sim_kind_detailed);

	/* Cache geometry for L1 */
	snprintf(section, sizeof section, "CacheGeometry evg-geo-l1");
	config_write_int(config, section, "Sets", 32);
	config_write_int(config, section, "Assoc", 4);
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 1);
	config_write_string(config, section, "Policy", "LRU");

	/* Cache geometry for L2 */
	snprintf(section, sizeof section, "CacheGeometry evg-geo-l2");
	config_write_int(config, section, "Sets", 256);
	config_write_int(config, section, "Assoc", 8);
	config_write_int(config, section, "BlockSize", 256);
	config_write_int(config, section, "Latency", 10);
	config_write_string(config, section, "Policy", "LRU");

	/* L1 caches and entries */
	EVG_GPU_FOREACH_COMPUTE_UNIT(compute_unit_id)
	{
		/* L1 cache */
		snprintf(section, sizeof section, "Module evg-l1-%d", compute_unit_id);
		config_write_string(config, section, "Type", "Cache");
		config_write_string(config, section, "Geometry", "evg-geo-l1");
		config_write_string(config, section, "LowNetwork", "evg-net-l1-l2");
		config_write_string(config, section, "LowModules", "evg-l2-0 evg-l2-1 evg-l2-2 evg-l2-3");

		/* Entry */
		snprintf(section, sizeof section, "Entry evg-cu-%d", compute_unit_id);
		snprintf(str, sizeof str, "evg-l1-%d", compute_unit_id);
		config_write_string(config, section, "Arch", "Evergreen");
		config_write_int(config, section, "ComputeUnit", compute_unit_id);
		config_write_string(config, section, "Module", str);
	}

	/* L2 caches */
	for (l2_id = 0; l2_id < 4; l2_id++) 
	{
		snprintf(section, sizeof section, "Module evg-l2-%d", l2_id);
		config_write_string(config, section, "Type", "Cache");
		config_write_string(config, section, "Geometry", "evg-geo-l2");
		config_write_string(config, section, "HighNetwork", "evg-net-l1-l2");
		config_write_string(config, section, "LowNetwork", "evg-net-l2-gm");
		config_write_string(config, section, "LowModules", "evg-gm-0 evg-gm-1 evg-gm-2 evg-gm-3");

		snprintf(str, sizeof str, "ADDR DIV 256 MOD 4 EQ %d", l2_id);
		config_write_string(config, section, "AddressRange", str);
	}

	/* Global memory */
	for (mm_id = 0; mm_id < 4; mm_id++) 
	{
		snprintf(section, sizeof section, "Module evg-gm-%d", mm_id);
		config_write_string(config, section, "Type", "MainMemory");
		config_write_string(config, section, "HighNetwork", "evg-net-l2-gm");
		config_write_int(config, section, "BlockSize", 256);
		config_write_int(config, section, "Latency", 100);

		snprintf(str, sizeof str, "ADDR DIV 256 MOD 4 EQ %d", mm_id);
		config_write_string(config, section, "AddressRange", str);
	}

	/* Network connecting L1 caches and L2 */
	snprintf(section, sizeof section, "Network evg-net-l1-l2");
	config_write_int(config, section, "DefaultInputBufferSize", 528);
	config_write_int(config, section, "DefaultOutputBufferSize", 528);
	config_write_int(config, section, "DefaultBandwidth", 264);

	/* Network connecting L2 cache and global memory */
	snprintf(section, sizeof section, "Network evg-net-l2-gm");
	config_write_int(config, section, "DefaultInputBufferSize", 528);
	config_write_int(config, section, "DefaultOutputBufferSize", 528);
	config_write_int(config, section, "DefaultBandwidth", 264);
}
Esempio n. 10
0
void x86_mem_config_default(struct config_t *config)
{
	char section[MAX_STRING_SIZE];
	char str[MAX_STRING_SIZE];

	int core;
	int thread;

	/* Only detailed simulation */
	assert(x86_emu_sim_kind == arch_sim_kind_detailed);

	/* Cache geometry for L1 */
	snprintf(section, sizeof section, "CacheGeometry x86-geo-l1");
	config_write_int(config, section, "Sets", 16);
	config_write_int(config, section, "Assoc", 2);
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 1);
	config_write_string(config, section, "Policy", "LRU");

	/* Cache geometry for L2 */
	snprintf(section, sizeof section, "CacheGeometry x86-geo-l2");
	config_write_int(config, section, "Sets", 64);
	config_write_int(config, section, "Assoc", 4);
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 10);
	config_write_string(config, section, "Policy", "LRU");

	/* L1 caches and entries */
	X86_CORE_FOR_EACH
	{
		/* L1 cache */
		snprintf(section, sizeof section, "Module x86-l1-%d", core);
		config_write_string(config, section, "Type", "Cache");
		config_write_string(config, section, "Geometry", "x86-geo-l1");
		config_write_string(config, section, "LowNetwork", "x86-net-l1-l2");
		config_write_string(config, section, "LowModules", "x86-l2");

		/* Entry */
		snprintf(str, sizeof str, "x86-l1-%d", core);
		X86_THREAD_FOR_EACH
		{
			snprintf(section, sizeof section, "Entry x86-core-%d-thread-%d",
				core, thread);
			config_write_string(config, section, "Arch", "x86");
			config_write_int(config, section, "Core", core);
			config_write_int(config, section, "Thread", thread);
			config_write_string(config, section, "Module", str);
		}
	}

	/* L2 cache */
	snprintf(section, sizeof section, "Module x86-l2");
	config_write_string(config, section, "Type", "Cache");
	config_write_string(config, section, "Geometry", "x86-geo-l2");
	config_write_string(config, section, "HighNetwork", "x86-net-l1-l2");
	config_write_string(config, section, "LowNetwork", "x86-net-l2-mm");
	config_write_string(config, section, "LowModules", "x86-mm");

	/* Main memory */
	snprintf(section, sizeof section, "Module x86-mm");
	config_write_string(config, section, "Type", "MainMemory");
	config_write_string(config, section, "HighNetwork", "x86-net-l2-mm");
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 100);

	/* Network connecting L1 caches and L2 */
	snprintf(section, sizeof section, "Network x86-net-l1-l2");
	config_write_int(config, section, "DefaultInputBufferSize", 144);
	config_write_int(config, section, "DefaultOutputBufferSize", 144);
	config_write_int(config, section, "DefaultBandwidth", 72);

	/* Network connecting L2 cache and global memory */
	snprintf(section, sizeof section, "Network x86-net-l2-mm");
	config_write_int(config, section, "DefaultInputBufferSize", 528);
	config_write_int(config, section, "DefaultOutputBufferSize", 528);
	config_write_int(config, section, "DefaultBandwidth", 264);
}
Esempio n. 11
0
void FrmGpuMemConfigDefault(Timing *self, struct config_t *config)
{
	char section[MAX_STRING_SIZE];
	char str[MAX_STRING_SIZE];

	int sm_id;

	/* Cache geometry for L1 */
	snprintf(section, sizeof section, "CacheGeometry frm-geo-l1");
	config_write_int(config, section, "Sets", 64);
	config_write_int(config, section, "Assoc", 4);
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 1);
	config_write_string(config, section, "Policy", "LRU");

	/* Cache geometry for L2 */
	snprintf(section, sizeof section, "CacheGeometry frm-geo-l2");
	config_write_int(config, section, "Sets", 128);
	config_write_int(config, section, "Assoc", 16);
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 10);
	config_write_string(config, section, "Policy", "LRU");

	/* L1 caches */
	FRM_GPU_FOREACH_SM(sm_id)
	{
		/* L1 cache */
		snprintf(section, sizeof section, "Module frm-l1-%d", sm_id);
		config_write_string(config, section, "Type", "Cache");
		config_write_string(config, section, "Geometry", "frm-geo-l1");
		config_write_string(config, section, "LowNetwork", "frm-net-l1-l2");
		config_write_string(config, section, "LowModules", 
				"frm-l2-0 frm-l2-1 frm-l2-2 frm-l2-3 frm-l2-4 frm-l2-5");

		/* Entry */
		snprintf(section, sizeof section, "Entry frm-sm-%d", sm_id);
		snprintf(str, sizeof str, "frm-l1-%d", sm_id);
		config_write_string(config, section, "Arch", "Fermi");
		config_write_int(config, section, "SM", sm_id);
		config_write_string(config, section, "Module", str);
	}

	/* L2 caches */
	snprintf(section, sizeof section, "Module frm-l2-0");
	config_write_string(config, section, "Type", "Cache");
	config_write_string(config, section, "Geometry", "frm-geo-l2");
	config_write_string(config, section, "HighNetwork", "frm-net-l1-l2");
	config_write_string(config, section, "LowNetwork", "frm-net-l2-0-gm-0");
	config_write_string(config, section, "LowModules", "frm-gm-0");
	config_write_string(config, section, "AddressRange", 
			"ADDR DIV 64 MOD 6 EQ 0");

	snprintf(section, sizeof section, "Module frm-l2-1");
	config_write_string(config, section, "Type", "Cache");
	config_write_string(config, section, "Geometry", "frm-geo-l2");
	config_write_string(config, section, "HighNetwork", "frm-net-l1-l2");
	config_write_string(config, section, "LowNetwork", "frm-net-l2-1-gm-1");
	config_write_string(config, section, "LowModules", "frm-gm-1");
	config_write_string(config, section, "AddressRange", 
			"ADDR DIV 64 MOD 6 EQ 1");

	snprintf(section, sizeof section, "Module frm-l2-2");
	config_write_string(config, section, "Type", "Cache");
	config_write_string(config, section, "Geometry", "frm-geo-l2");
	config_write_string(config, section, "HighNetwork", "frm-net-l1-l2");
	config_write_string(config, section, "LowNetwork", "frm-net-l2-2-gm-2");
	config_write_string(config, section, "LowModules", "frm-gm-2");
	config_write_string(config, section, "AddressRange", 
			"ADDR DIV 64 MOD 6 EQ 2");

	snprintf(section, sizeof section, "Module frm-l2-3");
	config_write_string(config, section, "Type", "Cache");
	config_write_string(config, section, "Geometry", "frm-geo-l2");
	config_write_string(config, section, "HighNetwork", "frm-net-l1-l2");
	config_write_string(config, section, "LowNetwork", "frm-net-l2-3-gm-3");
	config_write_string(config, section, "LowModules", "frm-gm-3");
	config_write_string(config, section, "AddressRange", 
			"ADDR DIV 64 MOD 6 EQ 3");

	snprintf(section, sizeof section, "Module frm-l2-4");
	config_write_string(config, section, "Type", "Cache");
	config_write_string(config, section, "Geometry", "frm-geo-l2");
	config_write_string(config, section, "HighNetwork", "frm-net-l1-l2");
	config_write_string(config, section, "LowNetwork", "frm-net-l2-4-gm-4");
	config_write_string(config, section, "LowModules", "frm-gm-4");
	config_write_string(config, section, "AddressRange", 
			"ADDR DIV 64 MOD 6 EQ 4");

	snprintf(section, sizeof section, "Module frm-l2-5");
	config_write_string(config, section, "Type", "Cache");
	config_write_string(config, section, "Geometry", "frm-geo-l2");
	config_write_string(config, section, "HighNetwork", "frm-net-l1-l2");
	config_write_string(config, section, "LowNetwork", "frm-net-l2-5-gm-5");
	config_write_string(config, section, "LowModules", "frm-gm-5");
	config_write_string(config, section, "AddressRange", 
			"ADDR DIV 64 MOD 6 EQ 5");

	/* Global memory */
	snprintf(section, sizeof section, "Module frm-gm-0");
	config_write_string(config, section, "Type", "MainMemory");
	config_write_string(config, section, "HighNetwork", "frm-net-l2-0-gm-0");
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 100);
	config_write_string(config, section, "AddressRange", 
			"ADDR DIV 64 MOD 6 EQ 0");

	snprintf(section, sizeof section, "Module frm-gm-1");
	config_write_string(config, section, "Type", "MainMemory");
	config_write_string(config, section, "HighNetwork", "frm-net-l2-1-gm-1");
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 100);
	config_write_string(config, section, "AddressRange", 
			"ADDR DIV 64 MOD 6 EQ 1");

	snprintf(section, sizeof section, "Module frm-gm-2");
	config_write_string(config, section, "Type", "MainMemory");
	config_write_string(config, section, "HighNetwork", "frm-net-l2-2-gm-2");
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 100);
	config_write_string(config, section, "AddressRange", 
			"ADDR DIV 64 MOD 6 EQ 2");

	snprintf(section, sizeof section, "Module frm-gm-3");
	config_write_string(config, section, "Type", "MainMemory");
	config_write_string(config, section, "HighNetwork", "frm-net-l2-3-gm-3");
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 100);
	config_write_string(config, section, "AddressRange", 
			"ADDR DIV 64 MOD 6 EQ 3");

	snprintf(section, sizeof section, "Module frm-gm-4");
	config_write_string(config, section, "Type", "MainMemory");
	config_write_string(config, section, "HighNetwork", "frm-net-l2-4-gm-4");
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 100);
	config_write_string(config, section, "AddressRange", 
			"ADDR DIV 64 MOD 6 EQ 4");

	snprintf(section, sizeof section, "Module frm-gm-5");
	config_write_string(config, section, "Type", "MainMemory");
	config_write_string(config, section, "HighNetwork", "frm-net-l2-5-gm-5");
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 100);
	config_write_string(config, section, "AddressRange", 
			"ADDR DIV 64 MOD 6 EQ 5");

	/* Network connecting L1s and L2s */
	snprintf(section, sizeof section, "Network frm-net-l1-l2");
	config_write_int(config, section, "DefaultInputBufferSize", 528);
	config_write_int(config, section, "DefaultOutputBufferSize", 528);
	config_write_int(config, section, "DefaultBandwidth", 264);

	/* Networks connecting memory controllers and global memory banks */
	snprintf(section, sizeof section, "Network frm-net-l2-0-gm-0");
	config_write_int(config, section, "DefaultInputBufferSize", 528);
	config_write_int(config, section, "DefaultOutputBufferSize", 528);
	config_write_int(config, section, "DefaultBandwidth", 264);

	snprintf(section, sizeof section, "Network frm-net-l2-1-gm-1");
	config_write_int(config, section, "DefaultInputBufferSize", 528);
	config_write_int(config, section, "DefaultOutputBufferSize", 528);
	config_write_int(config, section, "DefaultBandwidth", 264);

	snprintf(section, sizeof section, "Network frm-net-l2-2-gm-2");
	config_write_int(config, section, "DefaultInputBufferSize", 528);
	config_write_int(config, section, "DefaultOutputBufferSize", 528);
	config_write_int(config, section, "DefaultBandwidth", 264);

	snprintf(section, sizeof section, "Network frm-net-l2-3-gm-3");
	config_write_int(config, section, "DefaultInputBufferSize", 528);
	config_write_int(config, section, "DefaultOutputBufferSize", 528);
	config_write_int(config, section, "DefaultBandwidth", 264);

	snprintf(section, sizeof section, "Network frm-net-l2-4-gm-4");
	config_write_int(config, section, "DefaultInputBufferSize", 528);
	config_write_int(config, section, "DefaultOutputBufferSize", 528);
	config_write_int(config, section, "DefaultBandwidth", 264);

	snprintf(section, sizeof section, "Network frm-net-l2-5-gm-5");
	config_write_int(config, section, "DefaultInputBufferSize", 528);
	config_write_int(config, section, "DefaultOutputBufferSize", 528);
	config_write_int(config, section, "DefaultBandwidth", 264);
}
Esempio n. 12
0
static gboolean save_config_internal(int write_context,
				     struct gq_config *cfg,
				     const char *rcpath)
{
     GList *templatelist, *oclist, *filterlist;
     GqServer *server;
     struct gq_template *template;
     struct gq_filter *filter;
     struct writeconfig *wc;
     char *tmprcpath;
     struct stat sfile;
     int mode = S_IRUSR|S_IWUSR;
     GList *I;
     gboolean ok = FALSE;
     gpointer wc_and_cfg[2] = {
	     NULL,
	     cfg
     };

     if (cfg->config_version > CURRENT_CONFIG_VERSION) {
	  error_push(write_context,
		     _("Configuration file version too high - saving the configuration is not possible"));
	  return FALSE;
     }

     wc = new_writeconfig();
     wc_and_cfg[0] = wc;

     /* write to temp file... */
     tmprcpath = g_malloc(strlen(rcpath) + 10);
     strcpy(tmprcpath, rcpath);
     strcat(tmprcpath, ".new");

     /* check mode of original file. Do not overwrite without write
        permission. */
     if(stat(rcpath, &sfile) == 0) {
	  mode = sfile.st_mode & (S_IRUSR|S_IWUSR);
     }

     wc->outfile = fopen(tmprcpath, "w");
     if(!wc->outfile) {
	  error_push(write_context,
		     _("Unable to open %1$s for writing:\n%2$s\n"), rcpath,
		     strerror(errno));
	  g_free(tmprcpath);
	  return FALSE;
     }
     fchmod(fileno(wc->outfile), mode);

     config_write(wc, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
     config_write(wc, "<gq-config>\n\n");

     /* global settings */
     wc->indent++;

     if (cfg->config_version > 0) {
	  config_write_int(wc, cfg->config_version, "config-version", NULL);
	  config_write_int(wc, cfg->config_version, "asked-config-version",
			   NULL);
	  config_write_int(wc, cfg->config_version, "last-asked", NULL);
     }

     config_write_bool(wc, cfg->confirm_mod, "confirm-mod", NULL);
     config_write_string(wc, detokenize(token_searchargument, 
					cfg->search_argument),
			 "search-argument", NULL);
     config_write_bool(wc, cfg->showdn, "show-dn", NULL);
     config_write_bool(wc, cfg->showoc, "show-oc", NULL);
     config_write_bool(wc, cfg->show_rdn_only, "show-rdn-only", NULL);
     config_write_bool(wc, cfg->sort_search, "sort-search-mode", NULL);
     config_write_bool(wc, cfg->sort_browse, "sort-browse-mode", NULL);
     config_write_bool(wc, cfg->browse_use_user_friendly, "browse-use-user-friendly", NULL);

     config_write_bool(wc, cfg->restore_window_sizes,
		       "restore-window-sizes", NULL);
     config_write_bool(wc, cfg->restore_window_positions,
		       "restore-window-positions", NULL);
     config_write_bool(wc, cfg->restore_search_history, 
		       "restore-search-history", NULL);
     config_write_bool(wc, cfg->restore_tabs, 
		       "restore-tabs", NULL);
     config_write_bool(wc, cfg->never_leak_credentials, 
		       "never-leak-credentials", NULL);
     config_write_bool(wc, cfg->do_not_use_ldap_conf, 
		       "do-not-use-ldap-conf", NULL);

     config_write_string(wc, detokenize(token_ldifformat, cfg->ldifformat), 
			 "ldif-format", NULL);
     if(strlen(cfg->schemaserver))
	  config_write_string(wc, cfg->schemaserver, "schema-server", NULL);
     config_write(wc, "\n");

     /* ldapservers */
     gq_server_list_foreach(gq_server_list_get(), write_server, wc_and_cfg);

     /* templates */
     templatelist = cfg->templates;
     while(templatelist) {
Esempio n. 13
0
void SIGpuMemConfigDefault(Timing *self, struct config_t *config)
{
	char section[MAX_STRING_SIZE];
	char str[MAX_STRING_SIZE];

	int i;

	/* Cache geometry for vector L1 */
	snprintf(section, sizeof section, "CacheGeometry si-geo-vector-l1");
	config_write_int(config, section, "Sets", 64);
	config_write_int(config, section, "Assoc", 4);
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 1);
	config_write_string(config, section, "Policy", "LRU");

	/* Cache geometry for scalar L1 */
	snprintf(section, sizeof section, "CacheGeometry si-geo-scalar-l1");
	config_write_int(config, section, "Sets", 64);
	config_write_int(config, section, "Assoc", 4);
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 1);
	config_write_string(config, section, "Policy", "LRU");

	/* Cache geometry for L2 */
	snprintf(section, sizeof section, "CacheGeometry si-geo-l2");
	config_write_int(config, section, "Sets", 128);
	config_write_int(config, section, "Assoc", 16);
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 10);
	config_write_string(config, section, "Policy", "LRU");

	/* Create scalar L1 caches */
	for (i = 0; i < (si_gpu_num_compute_units + 3) / 4; i++)
	{
		snprintf(section, sizeof section, "Module si-scalar-l1-%d", i);
		config_write_string(config, section, "Type", "Cache");
		config_write_string(config, section, "Geometry", 
			"si-geo-scalar-l1");
		config_write_string(config, section, "LowNetwork", 
			"si-net-l1-l2");
		config_write_string(config, section, "LowModules", 
			"si-l2-0 si-l2-1 si-l2-2 si-l2-3 si-l2-4 si-l2-5");
	}

	/* Create vector L1 caches */
	for (i = 0; i < si_gpu_num_compute_units; i++)
	{
		snprintf(section, sizeof section, "Module si-vector-l1-%d", i);
		config_write_string(config, section, "Type", "Cache");
		config_write_string(config, section, "Geometry", 
			"si-geo-vector-l1");
		config_write_string(config, section, "LowNetwork", 
			"si-net-l1-l2");
		config_write_string(config, section, "LowModules", 
			"si-l2-0 si-l2-1 si-l2-2 si-l2-3 si-l2-4 si-l2-5");
	}

	/* Create entries from compute units to L1s */
	for (i = 0; i < si_gpu_num_compute_units; i++)
	{
		/* Entry */
		snprintf(section, sizeof section, "Entry si-cu-%d", i);
		config_write_string(config, section, "Arch", "SouthernIslands");
		config_write_int(config, section, "ComputeUnit", i);
		snprintf(str, sizeof str, "si-vector-l1-%d", i);
		config_write_string(config, section, "DataModule", str);
		snprintf(str, sizeof str, "si-scalar-l1-%d", i / 4);
		config_write_string(config, section, "ConstantDataModule", str);
	}

	/* L2 caches */
	snprintf(section, sizeof section, "Module si-l2-0");
	config_write_string(config, section, "Type", "Cache");
	config_write_string(config, section, "Geometry", "si-geo-l2");
	config_write_string(config, section, "HighNetwork", "si-net-l1-l2");
	config_write_string(config, section, "LowNetwork", "si-net-l2-0-gm-0");
	config_write_string(config, section, "LowModules", "si-gm-0");
	config_write_string(config, section, "AddressRange", 
		"ADDR DIV 64 MOD 6 EQ 0");

	snprintf(section, sizeof section, "Module si-l2-1");
	config_write_string(config, section, "Type", "Cache");
	config_write_string(config, section, "Geometry", "si-geo-l2");
	config_write_string(config, section, "HighNetwork", "si-net-l1-l2");
	config_write_string(config, section, "LowNetwork", "si-net-l2-1-gm-1");
	config_write_string(config, section, "LowModules", "si-gm-1");
	config_write_string(config, section, "AddressRange", 
		"ADDR DIV 64 MOD 6 EQ 1");
	
	snprintf(section, sizeof section, "Module si-l2-2");
	config_write_string(config, section, "Type", "Cache");
	config_write_string(config, section, "Geometry", "si-geo-l2");
	config_write_string(config, section, "HighNetwork", "si-net-l1-l2");
	config_write_string(config, section, "LowNetwork", "si-net-l2-2-gm-2");
	config_write_string(config, section, "LowModules", "si-gm-2");
	config_write_string(config, section, "AddressRange", 
		"ADDR DIV 64 MOD 6 EQ 2");

	snprintf(section, sizeof section, "Module si-l2-3");
	config_write_string(config, section, "Type", "Cache");
	config_write_string(config, section, "Geometry", "si-geo-l2");
	config_write_string(config, section, "HighNetwork", "si-net-l1-l2");
	config_write_string(config, section, "LowNetwork", "si-net-l2-3-gm-3");
	config_write_string(config, section, "LowModules", "si-gm-3");
	config_write_string(config, section, "AddressRange", 
		"ADDR DIV 64 MOD 6 EQ 3");

	snprintf(section, sizeof section, "Module si-l2-4");
	config_write_string(config, section, "Type", "Cache");
	config_write_string(config, section, "Geometry", "si-geo-l2");
	config_write_string(config, section, "HighNetwork", "si-net-l1-l2");
	config_write_string(config, section, "LowNetwork", "si-net-l2-4-gm-4");
	config_write_string(config, section, "LowModules", "si-gm-4");
	config_write_string(config, section, "AddressRange", 
		"ADDR DIV 64 MOD 6 EQ 4");

	snprintf(section, sizeof section, "Module si-l2-5");
	config_write_string(config, section, "Type", "Cache");
	config_write_string(config, section, "Geometry", "si-geo-l2");
	config_write_string(config, section, "HighNetwork", "si-net-l1-l2");
	config_write_string(config, section, "LowNetwork", "si-net-l2-5-gm-5");
	config_write_string(config, section, "LowModules", "si-gm-5");
	config_write_string(config, section, "AddressRange", 
		"ADDR DIV 64 MOD 6 EQ 5");

	/* Global memory */
	snprintf(section, sizeof section, "Module si-gm-0");
	config_write_string(config, section, "Type", "MainMemory");
	config_write_string(config, section, "HighNetwork", "si-net-l2-0-gm-0");
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 100);
	config_write_string(config, section, "AddressRange", 
		"ADDR DIV 64 MOD 6 EQ 0");

	snprintf(section, sizeof section, "Module si-gm-1");
	config_write_string(config, section, "Type", "MainMemory");
	config_write_string(config, section, "HighNetwork", "si-net-l2-1-gm-1");
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 100);
	config_write_string(config, section, "AddressRange", 
		"ADDR DIV 64 MOD 6 EQ 1");

	snprintf(section, sizeof section, "Module si-gm-2");
	config_write_string(config, section, "Type", "MainMemory");
	config_write_string(config, section, "HighNetwork", "si-net-l2-2-gm-2");
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 100);
	config_write_string(config, section, "AddressRange", 
		"ADDR DIV 64 MOD 6 EQ 2");

	snprintf(section, sizeof section, "Module si-gm-3");
	config_write_string(config, section, "Type", "MainMemory");
	config_write_string(config, section, "HighNetwork", "si-net-l2-3-gm-3");
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 100);
	config_write_string(config, section, "AddressRange", 
		"ADDR DIV 64 MOD 6 EQ 3");

	snprintf(section, sizeof section, "Module si-gm-4");
	config_write_string(config, section, "Type", "MainMemory");
	config_write_string(config, section, "HighNetwork", "si-net-l2-4-gm-4");
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 100);
	config_write_string(config, section, "AddressRange", 
		"ADDR DIV 64 MOD 6 EQ 4");

	snprintf(section, sizeof section, "Module si-gm-5");
	config_write_string(config, section, "Type", "MainMemory");
	config_write_string(config, section, "HighNetwork", "si-net-l2-5-gm-5");
	config_write_int(config, section, "BlockSize", 64);
	config_write_int(config, section, "Latency", 100);
	config_write_string(config, section, "AddressRange", 
		"ADDR DIV 64 MOD 6 EQ 5");

	/* Network connecting L1s and L2s */
	snprintf(section, sizeof section, "Network si-net-l1-l2");
	config_write_int(config, section, "DefaultInputBufferSize", 528);
	config_write_int(config, section, "DefaultOutputBufferSize", 528);
	config_write_int(config, section, "DefaultBandwidth", 264);

	/* Networks connecting memory controllers and global memory banks */
	snprintf(section, sizeof section, "Network si-net-l2-0-gm-0");
	config_write_int(config, section, "DefaultInputBufferSize", 528);
	config_write_int(config, section, "DefaultOutputBufferSize", 528);
	config_write_int(config, section, "DefaultBandwidth", 264);

	snprintf(section, sizeof section, "Network si-net-l2-1-gm-1");
	config_write_int(config, section, "DefaultInputBufferSize", 528);
	config_write_int(config, section, "DefaultOutputBufferSize", 528);
	config_write_int(config, section, "DefaultBandwidth", 264);

	snprintf(section, sizeof section, "Network si-net-l2-2-gm-2");
	config_write_int(config, section, "DefaultInputBufferSize", 528);
	config_write_int(config, section, "DefaultOutputBufferSize", 528);
	config_write_int(config, section, "DefaultBandwidth", 264);

	snprintf(section, sizeof section, "Network si-net-l2-3-gm-3");
	config_write_int(config, section, "DefaultInputBufferSize", 528);
	config_write_int(config, section, "DefaultOutputBufferSize", 528);
	config_write_int(config, section, "DefaultBandwidth", 264);

	snprintf(section, sizeof section, "Network si-net-l2-4-gm-4");
	config_write_int(config, section, "DefaultInputBufferSize", 528);
	config_write_int(config, section, "DefaultOutputBufferSize", 528);
	config_write_int(config, section, "DefaultBandwidth", 264);

	snprintf(section, sizeof section, "Network si-net-l2-5-gm-5");
	config_write_int(config, section, "DefaultInputBufferSize", 528);
	config_write_int(config, section, "DefaultOutputBufferSize", 528);
	config_write_int(config, section, "DefaultBandwidth", 264);
}