Test API to control the storage server

Overview

Generic server functions for storage server. More…

// typedefs

typedef struct tapi_storage_server tapi_storage_server;
typedef te_errno (*tapi_storage_server_method_enable)(tapi_storage_server *server);
typedef te_errno (*tapi_storage_server_method_disable)(tapi_storage_server *server);
typedef bool (*tapi_storage_server_method_is_enabled)(tapi_storage_server *server);

typedef te_errno (*tapi_storage_server_method_add_storage)(
    tapi_storage_server *server,
    const char *storage_name
    );

typedef te_errno (*tapi_storage_server_method_add_share)(
    tapi_storage_server *server,
    const char *storage,
    const char *path
    );

typedef te_errno (*tapi_storage_server_method_del_share)(
    tapi_storage_server *server,
    const char *storage,
    const char *path
    );

typedef te_errno (*tapi_storage_server_method_get_share)(
    tapi_storage_server *server,
    tapi_storage_share_list *share
    );

typedef struct tapi_storage_server_methods tapi_storage_server_methods;

// structs

struct tapi_storage_server;
struct tapi_storage_server_methods;

// global functions

static te_errno tapi_storage_server_enable(tapi_storage_server* server);
static te_errno tapi_storage_server_disable(tapi_storage_server* server);
static bool tapi_storage_server_is_enabled(tapi_storage_server* server);
static te_errno tapi_storage_server_add_storage(tapi_storage_server* server, const char* storage_name);
static te_errno tapi_storage_server_add_share(tapi_storage_server* server, const char* storage, const char* path);
static te_errno tapi_storage_server_del_share(tapi_storage_server* server, const char* storage, const char* path);
static te_errno tapi_storage_server_get_share(tapi_storage_server* server, tapi_storage_share_list* share);
te_errno tapi_storage_server_init(tapi_storage_service_type type, rcf_rpc_server* rpcs, const tapi_storage_server_methods* methods, tapi_storage_auth_params* auth, void* context, tapi_storage_server* server);
void tapi_storage_server_fini(tapi_storage_server* server);

// macros

#define TAPI_STORAGE_SERVER_INIT

Detailed Documentation

Generic server functions for storage server.

Copyright (C) 2004-2022 OKTET Labs Ltd. All rights reserved.

Typedefs

typedef te_errno (*tapi_storage_server_method_enable)(tapi_storage_server *server)

Enable a storage server.

Parameters:

server

Server handle.

Returns:

Status code.

typedef te_errno (*tapi_storage_server_method_disable)(tapi_storage_server *server)

Disable a storage server.

Parameters:

server

Server handle.

Returns:

Status code.

typedef bool (*tapi_storage_server_method_is_enabled)(tapi_storage_server *server)

Check if server enabled or not.

Parameters:

server

Server handle.

Returns:

true if server is enabled.

typedef te_errno (*tapi_storage_server_method_add_storage)(
    tapi_storage_server *server,
    const char *storage_name
    )

Add a storage to the share, i.e. it looks for storage with specified name, gets appropriate mount point and adds the last one to the share list.

Parameters:

server

Server handle.

storage_name

Name of the storage.

Returns:

Status code.

typedef te_errno (*tapi_storage_server_method_add_share)(
    tapi_storage_server *server,
    const char *storage,
    const char *path
    )

Add a directory to storage share.

Parameters:

server

Server handle.

storage

Storage device can be represented by name, mount point, etc. depends on server implementation. May be NULL.

path

Directory pathname on the storage to be shared if storage is not NULL, or full path if storage is NULL. May be NULL if it is required to add all storage data to share.

Returns:

Status code.

typedef te_errno (*tapi_storage_server_method_del_share)(
    tapi_storage_server *server,
    const char *storage,
    const char *path
    )

Delete directory from storage sharing.

Parameters:

server

Server handle.

storage

Storage device can be represented by name, mount point, etc. depends on server implementation. May be NULL.

path

Directory pathname on the storage to be removed from the sharing list if storage is not NULL, or full path if storage is NULL. May be NULL if trere are all storage data is shared.

Returns:

Status code.

typedef te_errno (*tapi_storage_server_method_get_share)(
    tapi_storage_server *server,
    tapi_storage_share_list *share
    )

Get shared directories list. share should be freed by user with tapi_storage_share_list_free when it is no longer needed.

Parameters:

server

Server handle.

share

List of shared directories.

Returns:

Status code.

See also:

tapi_storage_share_list_free

typedef struct tapi_storage_server_methods tapi_storage_server_methods

Methods to operate the server.

Global Functions

static te_errno tapi_storage_server_enable(tapi_storage_server* server)

Enable a storage server. Server should be disabled with tapi_storage_server_disable when it is no longer needed.

Parameters:

server

Server handle.

Returns:

Status code.

See also:

tapi_storage_server_disable

static te_errno tapi_storage_server_disable(tapi_storage_server* server)

Disable a storage server that was enabled with tapi_storage_server_enable.

Parameters:

server

Server handle.

Returns:

Status code.

See also:

tapi_storage_server_enable

static bool tapi_storage_server_is_enabled(tapi_storage_server* server)

Check if server enabled or not.

Parameters:

server

Server handle.

Returns:

true if server is enabled.

static te_errno tapi_storage_server_add_storage(tapi_storage_server* server, const char* storage_name)

Add a storage to the share, i.e. it looks for storage with specified name, gets appropriate mount point and adds the last one to the share list.

Parameters:

server

Server handle.

storage_name

Name of the storage.

Returns:

Status code.

static te_errno tapi_storage_server_add_share(tapi_storage_server* server, const char* storage, const char* path)

Add a directory to storage share.

Parameters:

server

Server handle.

storage

Storage device can be represented by name, mount point, etc. depends on server implementation. May be NULL.

path

Directory pathname on the storage to be shared if storage is not NULL, or full path if storage is NULL. May be NULL if it is required to add all storage data to share.

Returns:

Status code.

static te_errno tapi_storage_server_del_share(tapi_storage_server* server, const char* storage, const char* path)

Delete directory from storage sharing.

Parameters:

server

Server handle.

storage

Storage device can be represented by name, mount point, etc. depends on server implementation. May be NULL.

path

Directory pathname on the storage to be removed from the sharing list if storage is not NULL, or full path if storage is NULL. May be NULL if trere are all storage data is shared.

Returns:

Status code.

static te_errno tapi_storage_server_get_share(tapi_storage_server* server, tapi_storage_share_list* share)

Get shared directories list. share should be freed by user with tapi_storage_share_list_free when it is no longer needed.

Parameters:

server

Server handle.

share

List of shared directories.

Returns:

Status code.

See also:

tapi_storage_share_list_free

te_errno tapi_storage_server_init(tapi_storage_service_type type, rcf_rpc_server* rpcs, const tapi_storage_server_methods* methods, tapi_storage_auth_params* auth, void* context, tapi_storage_server* server)

Initialize server handle. Server should be released with tapi_storage_server_fini when it is no longer needed.

Parameters:

type

Back-end server type.

rpcs

RPC server handle.

methods

Back-end server specific methods.

auth

Back-end server specific authorization parameters. May be NULL.

context

Back-end server specific context. Don’t free the context before finishing work with server.

server

Server handle.

Returns:

Status code.

See also:

tapi_storage_server_fini

void tapi_storage_server_fini(tapi_storage_server* server)

Release server that was initialized with tapi_storage_server_init.

Parameters:

server

Server handle.

See also:

tapi_storage_server_init

Macros

#define TAPI_STORAGE_SERVER_INIT

On-stack tapi_storage_server structure initializer.