Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion libnvme/src/accessors-fabrics.ld
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,23 @@
LIBNVMF_ACCESSORS_3 {
global:
libnvmf_discovery_args_get_lsp;
libnvmf_discovery_args_set_lsp;
libnvmf_discovery_args_get_max_retries;
libnvmf_discovery_args_set_lsp;
libnvmf_discovery_args_set_max_retries;
libnvmf_uri_get_fragment;
libnvmf_uri_get_host;
libnvmf_uri_get_path_segments;
libnvmf_uri_get_port;
libnvmf_uri_get_protocol;
libnvmf_uri_get_query;
libnvmf_uri_get_scheme;
libnvmf_uri_get_userinfo;
libnvmf_uri_set_fragment;
libnvmf_uri_set_host;
libnvmf_uri_set_path_segments;
libnvmf_uri_set_port;
libnvmf_uri_set_protocol;
libnvmf_uri_set_query;
libnvmf_uri_set_scheme;
libnvmf_uri_set_userinfo;
};
1 change: 0 additions & 1 deletion libnvme/src/libnvme.ld
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ LIBNVME_3 {
libnvme_ns_write_uncorrectable;
libnvme_ns_write_zeros;
libnvme_open;
Comment thread
igaw marked this conversation as resolved.
libnvme_parse_uri;
libnvme_path_get_ctrl;
libnvme_path_get_ns;
libnvme_path_get_queue_depth;
Expand Down
3 changes: 2 additions & 1 deletion libnvme/src/libnvmf.ld
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ LIBNVMF_3 {
libnvmf_discovery_nbft;
libnvmf_eflags_str;
libnvmf_exat_ptr_next;
libnvmf_free_uri;
libnvmf_get_default_trsvcid;
libnvmf_get_discovery_log;
libnvmf_is_registration_supported;
Expand All @@ -44,6 +43,8 @@ LIBNVMF_3 {
libnvmf_subtype_str;
libnvmf_treq_str;
libnvmf_trtype_str;
Comment thread
igaw marked this conversation as resolved.
libnvmf_uri_free;
libnvmf_uri_parse;
local:
*;
};
124 changes: 124 additions & 0 deletions libnvme/src/nvme/accessors-fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,127 @@ __public __u8 libnvmf_discovery_args_get_lsp(
return p->lsp;
}

/****************************************************************************
* Accessors for: struct libnvmf_uri
****************************************************************************/

__public void libnvmf_uri_set_scheme(struct libnvmf_uri *p, const char *scheme)
{
free(p->scheme);
p->scheme = scheme ? strdup(scheme) : NULL;
}

__public const char *libnvmf_uri_get_scheme(const struct libnvmf_uri *p)
{
return p->scheme;
}

__public void libnvmf_uri_set_protocol(
struct libnvmf_uri *p,
const char *protocol)
{
free(p->protocol);
p->protocol = protocol ? strdup(protocol) : NULL;
}

__public const char *libnvmf_uri_get_protocol(const struct libnvmf_uri *p)
{
return p->protocol;
}

__public void libnvmf_uri_set_userinfo(
struct libnvmf_uri *p,
const char *userinfo)
{
free(p->userinfo);
p->userinfo = userinfo ? strdup(userinfo) : NULL;
}

__public const char *libnvmf_uri_get_userinfo(const struct libnvmf_uri *p)
{
return p->userinfo;
}

__public void libnvmf_uri_set_host(struct libnvmf_uri *p, const char *host)
{
free(p->host);
p->host = host ? strdup(host) : NULL;
}

__public const char *libnvmf_uri_get_host(const struct libnvmf_uri *p)
{
return p->host;
}

__public void libnvmf_uri_set_port(struct libnvmf_uri *p, int port)
{
p->port = port;
}

__public int libnvmf_uri_get_port(const struct libnvmf_uri *p)
{
return p->port;
}

__public void libnvmf_uri_set_path_segments(
struct libnvmf_uri *p,
const char *const *path_segments)
{
char **new_array = NULL;
size_t i;

if (path_segments) {
for (i = 0; path_segments[i]; i++)
;

new_array = calloc(i + 1, sizeof(char *));
if (new_array != NULL) {
for (i = 0; path_segments[i]; i++) {
new_array[i] = strdup(path_segments[i]);
if (!new_array[i]) {
while (i > 0)
free(new_array[--i]);
free(new_array);
new_array = NULL;
break;
}
}
}
}

for (i = 0; p->path_segments && p->path_segments[i]; i++)
free(p->path_segments[i]);
free(p->path_segments);
p->path_segments = new_array;
}

__public const char *const *libnvmf_uri_get_path_segments(
const struct libnvmf_uri *p)
{
return (const char *const *)p->path_segments;
}

__public void libnvmf_uri_set_query(struct libnvmf_uri *p, const char *query)
{
free(p->query);
p->query = query ? strdup(query) : NULL;
}

__public const char *libnvmf_uri_get_query(const struct libnvmf_uri *p)
{
return p->query;
}

__public void libnvmf_uri_set_fragment(
struct libnvmf_uri *p,
const char *fragment)
{
free(p->fragment);
p->fragment = fragment ? strdup(fragment) : NULL;
}

__public const char *libnvmf_uri_get_fragment(const struct libnvmf_uri *p)
{
return p->fragment;
}

127 changes: 127 additions & 0 deletions libnvme/src/nvme/accessors-fabrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

/* Forward declarations. These are internal (opaque) structs. */
struct libnvmf_discovery_args;
struct libnvmf_uri;

/****************************************************************************
* Accessors for: struct libnvmf_discovery_args
Expand Down Expand Up @@ -67,4 +68,130 @@ void libnvmf_discovery_args_set_lsp(struct libnvmf_discovery_args *p, __u8 lsp);
*/
__u8 libnvmf_discovery_args_get_lsp(const struct libnvmf_discovery_args *p);

/****************************************************************************
* Accessors for: struct libnvmf_uri
****************************************************************************/

/**
* libnvmf_uri_set_scheme() - Set scheme.
* @p: The &struct libnvmf_uri instance to update.
* @scheme: New string; a copy is stored. Pass NULL to clear.
*/
void libnvmf_uri_set_scheme(struct libnvmf_uri *p, const char *scheme);

/**
* libnvmf_uri_get_scheme() - Get scheme.
* @p: The &struct libnvmf_uri instance to query.
*
* Return: The value of the scheme field, or NULL if not set.
*/
const char *libnvmf_uri_get_scheme(const struct libnvmf_uri *p);

/**
* libnvmf_uri_set_protocol() - Set protocol.
* @p: The &struct libnvmf_uri instance to update.
* @protocol: New string; a copy is stored. Pass NULL to clear.
*/
void libnvmf_uri_set_protocol(struct libnvmf_uri *p, const char *protocol);

/**
* libnvmf_uri_get_protocol() - Get protocol.
* @p: The &struct libnvmf_uri instance to query.
*
* Return: The value of the protocol field, or NULL if not set.
*/
const char *libnvmf_uri_get_protocol(const struct libnvmf_uri *p);

/**
* libnvmf_uri_set_userinfo() - Set userinfo.
* @p: The &struct libnvmf_uri instance to update.
* @userinfo: New string; a copy is stored. Pass NULL to clear.
*/
void libnvmf_uri_set_userinfo(struct libnvmf_uri *p, const char *userinfo);

/**
* libnvmf_uri_get_userinfo() - Get userinfo.
* @p: The &struct libnvmf_uri instance to query.
*
* Return: The value of the userinfo field, or NULL if not set.
*/
const char *libnvmf_uri_get_userinfo(const struct libnvmf_uri *p);

/**
* libnvmf_uri_set_host() - Set host.
* @p: The &struct libnvmf_uri instance to update.
* @host: New string; a copy is stored. Pass NULL to clear.
*/
void libnvmf_uri_set_host(struct libnvmf_uri *p, const char *host);

/**
* libnvmf_uri_get_host() - Get host.
* @p: The &struct libnvmf_uri instance to query.
*
* Return: The value of the host field, or NULL if not set.
*/
const char *libnvmf_uri_get_host(const struct libnvmf_uri *p);

/**
* libnvmf_uri_set_port() - Set port.
* @p: The &struct libnvmf_uri instance to update.
* @port: Value to assign to the port field.
*/
void libnvmf_uri_set_port(struct libnvmf_uri *p, int port);

/**
* libnvmf_uri_get_port() - Get port.
* @p: The &struct libnvmf_uri instance to query.
*
* Return: The value of the port field.
*/
int libnvmf_uri_get_port(const struct libnvmf_uri *p);

/**
* libnvmf_uri_set_path_segments() - Set path_segments.
* @p: The &struct libnvmf_uri instance to update.
* @path_segments: New NULL-terminated string array; deep-copied.
*/
void libnvmf_uri_set_path_segments(
struct libnvmf_uri *p,
const char *const *path_segments);

/**
* libnvmf_uri_get_path_segments() - Get path_segments.
* @p: The &struct libnvmf_uri instance to query.
*
* Return: The value of the path_segments field.
*/
const char *const *libnvmf_uri_get_path_segments(const struct libnvmf_uri *p);

/**
* libnvmf_uri_set_query() - Set query.
* @p: The &struct libnvmf_uri instance to update.
* @query: New string; a copy is stored. Pass NULL to clear.
*/
void libnvmf_uri_set_query(struct libnvmf_uri *p, const char *query);

/**
* libnvmf_uri_get_query() - Get query.
* @p: The &struct libnvmf_uri instance to query.
*
* Return: The value of the query field, or NULL if not set.
*/
const char *libnvmf_uri_get_query(const struct libnvmf_uri *p);

/**
* libnvmf_uri_set_fragment() - Set fragment.
* @p: The &struct libnvmf_uri instance to update.
* @fragment: New string; a copy is stored. Pass NULL to clear.
*/
void libnvmf_uri_set_fragment(struct libnvmf_uri *p, const char *fragment);

/**
* libnvmf_uri_get_fragment() - Get fragment.
* @p: The &struct libnvmf_uri instance to query.
*
* Return: The value of the fragment field, or NULL if not set.
*/
const char *libnvmf_uri_get_fragment(const struct libnvmf_uri *p);

#endif /* _ACCESSORS_FABRICS_H_ */
Loading
Loading