#include <stdio.h>
#include "lsm_datatypes.hpp"
#include "libstoragemgmt/libstoragemgmt_accessgroups.h"
#include "libstoragemgmt/libstoragemgmt_common.h"
#include "libstoragemgmt/libstoragemgmt_disk.h"
#include "libstoragemgmt/libstoragemgmt_error.h"
#include "libstoragemgmt/libstoragemgmt_fs.h"
#include "libstoragemgmt/libstoragemgmt_nfsexport.h"
#include "libstoragemgmt/libstoragemgmt_plug_interface.h"
#include "libstoragemgmt/libstoragemgmt_pool.h"
#include "libstoragemgmt/libstoragemgmt_snapshot.h"
#include "libstoragemgmt/libstoragemgmt_systems.h"
#include "libstoragemgmt/libstoragemgmt_targetport.h"
#include "libstoragemgmt/libstoragemgmt_types.h"
#include "libstoragemgmt/libstoragemgmt_volumes.h"
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <dlfcn.h>
#include <glib.h>
#include <regex.h>
Go to the source code of this file.
Defines | |
#define | _GNU_SOURCE |
#define | LSM_DEFAULT_PLUGIN_DIR "/var/run/lsm/ipc" |
#define | MEMBER_GET(x, validation, member, error) |
#define | LSM_RETURN_ERR_VAL(type_t, e, x, error) |
#define | CREATE_ALLOC_ARRAY_FUNC(name, rtype) |
#define | CREATE_FREE_ARRAY_FUNC(name, free_func, record_type, error) |
#define | MEMBER_SET_REF(x, validation, member, value, alloc_func, free_func, error) |
#define | MEMBER_SET_VAL(x, validation, member, value, error) |
Functions | |
int | lsm_string_list_append (lsm_string_list *sl, const char *value) |
int | lsm_string_list_delete (lsm_string_list *sl, uint32_t index) |
int | lsm_string_list_elem_set (lsm_string_list *sl, uint32_t index, const char *value) |
const char * | lsm_string_list_elem_get (lsm_string_list *sl, uint32_t index) |
lsm_string_list * | lsm_string_list_alloc (uint32_t size) |
int | lsm_string_list_free (lsm_string_list *sl) |
uint32_t | lsm_string_list_size (lsm_string_list *sl) |
lsm_string_list * | lsm_string_list_copy (lsm_string_list *src) |
lsm_connect * | connection_get () |
void | connection_free (lsm_connect *c) |
const char * | uds_path (void) |
int | driver_load (lsm_connect *c, const char *plugin_name, const char *password, uint32_t timeout, lsm_error_ptr *e, int startup, lsm_flag flags) |
lsm_error_ptr | lsm_error_create (lsm_error_number code, const char *msg, const char *exception, const char *debug, const void *debug_data, uint32_t debug_data_size) |
int | lsm_error_free (lsm_error_ptr e) |
lsm_error_number | lsm_error_number_get (lsm_error_ptr e) |
char * | lsm_error_message_get (lsm_error_ptr e) |
char * | lsm_error_exception_get (lsm_error_ptr e) |
char * | lsm_error_debug_get (lsm_error_ptr e) |
void * | lsm_error_debug_data_get (lsm_error_ptr e, uint32_t *size) |
lsm_pool * | lsm_pool_record_alloc (const char *id, const char *name, uint64_t element_type, uint64_t unsupported_actions, uint64_t totalSpace, uint64_t freeSpace, uint64_t status, const char *status_info, const char *system_id, const char *plugin_data) |
void | lsm_pool_free_space_set (lsm_pool *p, uint64_t free_space) |
lsm_pool * | lsm_pool_record_copy (lsm_pool *toBeCopied) |
int | lsm_pool_record_free (lsm_pool *p) |
CREATE_FREE_ARRAY_FUNC (lsm_pool_record_array_free, lsm_pool_record_free, lsm_pool *, LSM_ERR_INVALID_ARGUMENT) char *lsm_pool_name_get(lsm_pool *p) | |
char * | lsm_pool_id_get (lsm_pool *p) |
uint64_t | lsm_pool_total_space_get (lsm_pool *p) |
uint64_t | lsm_pool_free_space_get (lsm_pool *p) |
uint64_t | lsm_pool_status_get (lsm_pool *p) |
const char * | lsm_pool_status_info_get (lsm_pool *p) |
char * | lsm_pool_system_id_get (lsm_pool *p) |
MEMBER_FUNC_GET (const char *, lsm_pool_plugin_data_get, lsm_pool *p, p, LSM_IS_POOL, plugin_data, NULL) MEMBER_FUNC_GET(uint64_t | |
lsm_pool | MEMBER_FUNC_GET (uint64_t, lsm_pool_unsupported_actions_get, lsm_pool *p, p, LSM_IS_POOL, element_type, 0) lsm_volume *lsm_volume_record_alloc(const char *id |
Variables | |
lsm_pool_element_type_get | |
lsm_pool * | p |
lsm_pool | LSM_IS_POOL |
lsm_pool | element_type |
lsm_pool const char * | name |
lsm_pool const char const char * | vpd83 |
lsm_pool const char const char uint64_t | blockSize |
lsm_pool const char const char uint64_t uint64_t | numberOfBlocks |
lsm_pool const char const char uint64_t uint64_t uint32_t | status |
lsm_pool const char const char uint64_t uint64_t uint32_t const char * | system_id |
lsm_pool const char const char uint64_t uint64_t uint32_t const char const char * | pool_id |
#define _GNU_SOURCE |
Definition at line 20 of file lsm_datatypes.cpp.
#define CREATE_ALLOC_ARRAY_FUNC | ( | name, | |||
rtype | ) |
rtype *name(uint32_t size) \ { \ rtype *rc = NULL; \ if (size > 0) { \ rc = (rtype *) calloc(size, sizeof(rtype)); \ } \ return rc; \ }
When creating arrays of the different types the code is the same. This macro is used to create type safe code.
name | Name of the function | |
rtype | return type |
Definition at line 453 of file lsm_datatypes.cpp.
#define CREATE_FREE_ARRAY_FUNC | ( | name, | |||
free_func, | |||||
record_type, | |||||
error | ) |
int name( record_type pa[], uint32_t size) \ { \ if (pa) { \ uint32_t i = 0; \ for (i = 0; i < size; ++i) { \ free_func(pa[i]); \ } \ free(pa); \ return LSM_ERR_OK; \ } \ return error; \ }
Common macro for freeing the memory associated with one of these data structures.
name | Name of function to create | |
free_func | Function to call to free one of the elements | |
record_type | Type to record | |
error | Value to return on error |
Definition at line 472 of file lsm_datatypes.cpp.
#define LSM_DEFAULT_PLUGIN_DIR "/var/run/lsm/ipc" |
Definition at line 51 of file lsm_datatypes.cpp.
#define LSM_RETURN_ERR_VAL | ( | type_t, | |||
e, | |||||
x, | |||||
error | ) |
if( LSM_IS_ERROR(e) ) { \ return e->x; \ } \ return (type_t)error; \
Definition at line 406 of file lsm_datatypes.cpp.
#define MEMBER_GET | ( | x, | |||
validation, | |||||
member, | |||||
error | ) |
if( validation(x) ) { \ return x->member; \ } else { \ return error; \ }
Definition at line 53 of file lsm_datatypes.cpp.
#define MEMBER_SET_REF | ( | x, | |||
validation, | |||||
member, | |||||
value, | |||||
alloc_func, | |||||
free_func, | |||||
error | ) |
if( validation(x) ) { \ if(x->member) { \ free_func(x->member); \ x->member = NULL; \ } \ if( value ) { \ x->member = alloc_func(value); \ if( !x->member ) { \ return LSM_ERR_NO_MEMORY; \ } \ } \ return LSM_ERR_OK; \ } else { \ return error; \ }
#define MEMBER_SET_VAL | ( | x, | |||
validation, | |||||
member, | |||||
value, | |||||
error | ) |
if( validation(x) ) { \ x->member = value; \ return LSM_ERR_OK; \ } else { \ return error; \ }
void connection_free | ( | lsm_connect * | c | ) |
De-allocates the connection.
c | Connection to free. |
Definition at line 208 of file lsm_datatypes.cpp.
lsm_connect* connection_get | ( | ) |
Returns a pointer to a newly created connection structure.
Definition at line 199 of file lsm_datatypes.cpp.
CREATE_FREE_ARRAY_FUNC | ( | lsm_pool_record_array_free | , | |
lsm_pool_record_free | , | |||
lsm_pool * | , | |||
LSM_ERR_INVALID_ARGUMENT | ||||
) |
Definition at line 578 of file lsm_datatypes.cpp.
int driver_load | ( | lsm_connect * | c, | |
const char * | plugin, | |||
const char * | password, | |||
uint32_t | timeout, | |||
lsm_error_ptr * | e, | |||
int | startup, | |||
lsm_flag | flags | |||
) |
Loads the requester driver specified in the uri.
c | Connection | |
plugin | Short name of plugin | |
password | Password | |
timeout | Initial timeout | |
e | Error data | |
startup | If non zero call rpc start_up, else skip | |
flags | Reserved flag for future use |
Definition at line 289 of file lsm_datatypes.cpp.
lsm_error_ptr lsm_error_create | ( | lsm_error_number | code, | |
const char * | msg, | |||
const char * | exception, | |||
const char * | debug, | |||
const void * | debug_data, | |||
uint32_t | debug_data_size | |||
) |
Creates an error record.
code | ||
msg | ||
exception | ||
debug | ||
debug_data | ||
debug_data_size |
Definition at line 335 of file lsm_datatypes.cpp.
void* lsm_error_debug_data_get | ( | lsm_error_ptr | e, | |
uint32_t * | size | |||
) |
Retrieves the debug data from the error. Note: The returned value is only valid as long as the e is valid, in addition the function will return NULL if e is invalid. To remove the ambiguity call lsm_error_number_get and check return code.
e | The lsm_error_ptr | |
[out] | size | Number of bytes of data returned. |
Definition at line 433 of file lsm_datatypes.cpp.
char* lsm_error_debug_get | ( | lsm_error_ptr | e | ) |
Retrieves the error message from the error. Note: The returned value is only valid as long as the e is valid, in addition the function will return NULL if e is invalid. To remove the ambiguity call lsm_error_number_get and check return code.
e | The lsm_error_ptr |
Definition at line 428 of file lsm_datatypes.cpp.
char* lsm_error_exception_get | ( | lsm_error_ptr | e | ) |
Retrieves the exception message from the error. Note: The returned value is only valid as long as the e is valid, in addition the function will return NULL if e is invalid. To remove the ambiguity call lsm_error_number_get and check return code.
e | The lsm_error_ptr |
Definition at line 423 of file lsm_datatypes.cpp.
int lsm_error_free | ( | lsm_error_ptr | err | ) |
Frees the error record!
err | The error to free! |
Definition at line 373 of file lsm_datatypes.cpp.
char* lsm_error_message_get | ( | lsm_error_ptr | e | ) |
Retrieves the error message from the error. Note: The returned value is only valid as long as the e is valid, in addition the function will return NULL if e is invalid. To remove the ambiguity call lsm_error_number_get and check return code.
e | The lsm_error_ptr |
Definition at line 418 of file lsm_datatypes.cpp.
lsm_error_number lsm_error_number_get | ( | lsm_error_ptr | e | ) |
Retrieves the error number from the error.
e | The lsm_error_ptr |
Definition at line 413 of file lsm_datatypes.cpp.
uint64_t lsm_pool_free_space_get | ( | lsm_pool * | p | ) |
Retrieves the remaining free space in the pool.
p | Pool |
Definition at line 605 of file lsm_datatypes.cpp.
void lsm_pool_free_space_set | ( | lsm_pool * | p, | |
uint64_t | free_space | |||
) |
Used to set the free space on a pool record
p | Pool to modify | |
free_space | New free space value |
Definition at line 522 of file lsm_datatypes.cpp.
char* lsm_pool_id_get | ( | lsm_pool * | p | ) |
Retrieves the system wide unique identifier for the pool. Note: Returned value is only valid as long as p is valid!.
p | Pool |
Definition at line 589 of file lsm_datatypes.cpp.
lsm_pool* lsm_pool_record_alloc | ( | const char * | id, | |
const char * | name, | |||
uint64_t | element_type, | |||
uint64_t | unsupported_actions, | |||
uint64_t | total_space, | |||
uint64_t | free_space, | |||
uint64_t | status, | |||
const char * | status_info, | |||
const char * | system_id, | |||
const char * | plugin_data | |||
) |
Helper function to allocate a pool record.
id | System unique identifier | |
name | Human readable name | |
element_type | A bit field which states what the pool can be used to create | |
unsupported_actions | Things you cannot do with this pool | |
total_space | Total space | |
free_space | Space available | |
status | Pool status, bit field (See LSM_POOL_STATUS_XXXX constants) | |
status_info | Additional textual information on status | |
system_id | System id | |
plugin_data | Reserved for plugin writer use |
Definition at line 489 of file lsm_datatypes.cpp.
Copies a lsm_pool record
to_be_copied | Record to be copied |
Definition at line 529 of file lsm_datatypes.cpp.
int lsm_pool_record_free | ( | lsm_pool * | p | ) |
Frees the memory for an individual pool
p | Valid pool |
Definition at line 545 of file lsm_datatypes.cpp.
uint64_t lsm_pool_status_get | ( | lsm_pool * | s | ) |
Retrieve the status for the Pool.
s | Pool to retrieve status for |
Definition at line 613 of file lsm_datatypes.cpp.
const char* lsm_pool_status_info_get | ( | lsm_pool * | s | ) |
Retrieve the status info for the Pool.
s | Pool to retrieve status for |
Definition at line 621 of file lsm_datatypes.cpp.
char* lsm_pool_system_id_get | ( | lsm_pool * | p | ) |
Retrieve the system id for the specified pool.
p | Pool pointer |
Definition at line 629 of file lsm_datatypes.cpp.
uint64_t lsm_pool_total_space_get | ( | lsm_pool * | p | ) |
Retrieves the total space for the pool.
p | Pool |
Definition at line 597 of file lsm_datatypes.cpp.
lsm_string_list* lsm_string_list_alloc | ( | uint32_t | size | ) |
Allocates storage for string line of specified size.
size | Initial number of strings to allocate |
Definition at line 131 of file lsm_datatypes.cpp.
int lsm_string_list_append | ( | lsm_string_list * | sl, | |
const char * | add | |||
) |
Appends a char * to the string list, will grow container as needed.
sl | String list to append to | |
add | Character string to add |
Definition at line 59 of file lsm_datatypes.cpp.
lsm_string_list* lsm_string_list_copy | ( | lsm_string_list * | src | ) |
Copies a lsm_string_list record.
src | Source to copy |
We had an allocation failure setting an element item
Definition at line 172 of file lsm_datatypes.cpp.
int lsm_string_list_delete | ( | lsm_string_list * | sl, | |
uint32_t | index | |||
) |
Deletes the string at the specified index. NOTE: The elements after this one are moved down, thus if you wanted to iterate over the list deleting each element one by one you need to do so in reverse order.
sl | String list to remove item from | |
index | Specified index |
Definition at line 75 of file lsm_datatypes.cpp.
const char* lsm_string_list_elem_get | ( | lsm_string_list * | sl, | |
uint32_t | index | |||
) |
Returns the value at the specified elem index
sl | Valid string list pointer | |
index | Index to retrieve |
Definition at line 121 of file lsm_datatypes.cpp.
int lsm_string_list_elem_set | ( | lsm_string_list * | sl, | |
uint32_t | index, | |||
const char * | value | |||
) |
Set the specified element with the passed value.
sl | Valid string list pointer | |
index | Element position to set value to | |
value | Value to use for assignment |
Definition at line 89 of file lsm_datatypes.cpp.
int lsm_string_list_free | ( | lsm_string_list * | sl | ) |
Frees the memory allocated with the lsmStringListFree
sl | Record to free |
Definition at line 152 of file lsm_datatypes.cpp.
uint32_t lsm_string_list_size | ( | lsm_string_list * | sl | ) |
Returns the size of the list
sl | Valid string list pointer |
Definition at line 164 of file lsm_datatypes.cpp.
lsm_pool MEMBER_FUNC_GET | ( | uint64_t | , | |
lsm_pool_unsupported_actions_get | , | |||
lsm_pool * | p, | |||
p | , | |||
LSM_IS_POOL | , | |||
element_type | , | |||
0 | ||||
) | const |
MEMBER_FUNC_GET | ( | const char * | , | |
lsm_pool_plugin_data_get | , | |||
lsm_pool * | p, | |||
p | , | |||
LSM_IS_POOL | , | |||
plugin_data | , | |||
NULL | ||||
) |
const char* uds_path | ( | void | ) |
Definition at line 648 of file lsm_datatypes.cpp.
Definition at line 640 of file lsm_datatypes.cpp.
Definition at line 640 of file lsm_datatypes.cpp.
lsm_pool_element_type_get |
Definition at line 640 of file lsm_datatypes.cpp.
Definition at line 648 of file lsm_datatypes.cpp.
lsm_pool const char const char uint64_t uint64_t numberOfBlocks |
Definition at line 648 of file lsm_datatypes.cpp.
Definition at line 640 of file lsm_datatypes.cpp.
Definition at line 648 of file lsm_datatypes.cpp.
Definition at line 648 of file lsm_datatypes.cpp.
Definition at line 648 of file lsm_datatypes.cpp.
Definition at line 648 of file lsm_datatypes.cpp.