コード例 #1
0
int main(void)
{
	struct libiscsi_node *found_nodes;
	struct libiscsi_context *context;
	int i, found, rc = 0;

	context = libiscsi_init();
	if (!context) {
		fprintf(stderr, "Error initializing libiscsi\n");
		return 1;
	}

	rc = libiscsi_discover_firmware(context, &found, &found_nodes);
	if (rc)
		fprintf(stderr, "Error discovering: %s\n",
			libiscsi_get_error_string(context));

	for (i = 0; i < found; i++) {
		fprintf(stdout, "Found node: %s, tpgt: %d, portal: %s:%d\n",
			found_nodes[i].name, found_nodes[i].tpgt,
			found_nodes[i].address,	found_nodes[i].port);
	}

	libiscsi_cleanup(context);
	free (found_nodes);

	return rc;
}
コード例 #2
0
ファイル: test_logout.c プロジェクト: phatina/open-iscsi
int main(void)
{
	struct libiscsi_node node;
	struct libiscsi_context *context;
	int rc = 0;

	snprintf(node.name, LIBISCSI_VALUE_MAXLEN, "%s",
		 "iqn.2009-01.com.example:testdisk");
	node.tpgt = 1;
	snprintf(node.address, NI_MAXHOST, "%s", "127.0.0.1");
	node.port = 3260;
	
	context = libiscsi_init();
	if (!context) {
		fprintf(stderr, "Error initializing libiscsi\n");
		return 1;
	}

	rc = libiscsi_node_logout(context, &node);
	if (rc)
		fprintf(stderr, "Error logging out: %s\n",
			libiscsi_get_error_string(context));

	libiscsi_cleanup(context);

	return rc;
}
コード例 #3
0
void
storaged_iscsi_state_free (StoragedISCSIState *state)
{
  g_return_if_fail (state);

  /* Free/Unref members. */
  if (state->iscsi_ctx)
    libiscsi_cleanup (state->iscsi_ctx);

  g_free (state);
}
コード例 #4
0
ファイル: test_params.c プロジェクト: phatina/open-iscsi
int main(void)
{
	struct libiscsi_node node;
	struct libiscsi_context *context;
	char orig_value[LIBISCSI_VALUE_MAXLEN], value[LIBISCSI_VALUE_MAXLEN];
	int rc = 0;

	snprintf(node.name, LIBISCSI_VALUE_MAXLEN, "%s",
		 "iqn.2009-01.com.example:testdisk");
	node.tpgt = 1;
	snprintf(node.address, NI_MAXHOST, "%s", "127.0.0.1");
	node.port = 3260;

	context = libiscsi_init();
	if (!context) {
		fprintf(stderr, "Error initializing libiscsi\n");
		return 1;
	}

	rc = libiscsi_node_get_parameter(context, &node, "node.startup",
		orig_value);
	if (rc) {
		fprintf(stderr, "Error getting original value: %s\n",
			libiscsi_get_error_string(context));
		goto leave;
	}

	rc = libiscsi_node_set_parameter(context, &node, "node.startup",
		"automatic");
	if (rc) {
		fprintf(stderr, "Error setting node startup param: %s\n",
			libiscsi_get_error_string(context));
		goto leave;
	}

	rc = libiscsi_node_get_parameter(context, &node, "node.startup",
		value);
	if (rc) {
		fprintf(stderr, "Error getting node startup param: %s\n",
			libiscsi_get_error_string(context));
		goto leave;
	}
	
	if (strcmp(value, "automatic")) {
		fprintf(stderr, "Error set and get values do not match!\n");
		rc = EIO;
		goto leave;
	}

	rc = libiscsi_node_set_parameter(context, &node, "node.startup",
		orig_value);
	if (rc) {
		fprintf(stderr, "Error setting original value: %s\n",
			libiscsi_get_error_string(context));
		goto leave;
	}

	rc = libiscsi_node_get_parameter(context, &node, "node.startup",
		value);
	if (rc) {
		fprintf(stderr, "Error re-getting original value: %s\n",
			libiscsi_get_error_string(context));
		goto leave;
	}

	if (strcmp(value, orig_value)) {
		fprintf(stderr,
			"Error set and get original values do not match!\n");
		rc = EIO;
		goto leave;
	}

leave:
	libiscsi_cleanup(context);

	return rc;
}