lsm_datatypes.cpp File Reference

#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>
Include dependency graph for lsm_datatypes.cpp:

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_listlsm_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_listlsm_string_list_copy (lsm_string_list *src)
lsm_connectconnection_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_poollsm_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_poollsm_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_poolp
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 Documentation

#define _GNU_SOURCE

Definition at line 20 of file lsm_datatypes.cpp.

#define CREATE_ALLOC_ARRAY_FUNC ( name,
rtype   ) 
Value:
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.

Parameters:
name Name of the function
rtype return type
Returns:
An array of pointers of rtype

Definition at line 453 of file lsm_datatypes.cpp.

#define CREATE_FREE_ARRAY_FUNC ( name,
free_func,
record_type,
error   ) 
Value:
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.

Parameters:
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
Returns:
None

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   ) 
Value:
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   ) 
Value:
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   ) 
Value:
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   ) 
Value:
if( validation(x) ) {                   \
        x->member = value;                  \
        return LSM_ERR_OK;                  \
    } else {                                \
        return error;                       \
    }

Function Documentation

void connection_free ( lsm_connect c  ) 

De-allocates the connection.

Parameters:
c Connection to free.

Definition at line 208 of file lsm_datatypes.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

lsm_connect* connection_get (  ) 

Returns a pointer to a newly created connection structure.

Returns:
NULL on memory exhaustion, else new connection.

Definition at line 199 of file lsm_datatypes.cpp.

Here is the caller graph for this function:

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.

Parameters:
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
Returns:
LSM_ERR_OK on success, else error code.

Definition at line 289 of file lsm_datatypes.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters:
code 
msg 
exception 
debug 
debug_data 
debug_data_size 
Returns:
Null on error, else valid error error record.

Definition at line 335 of file lsm_datatypes.cpp.

Here is the caller graph for this function:

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.

Parameters:
e The lsm_error_ptr
[out] size Number of bytes of data returned.
Returns:
NULL if does not exist, else debug message.

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.

Parameters:
e The lsm_error_ptr
Returns:
NULL if does not exist, else debug message.

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.

Parameters:
e The lsm_error_ptr
Returns:
NULL if exception does not exist, else error exception.

Definition at line 423 of file lsm_datatypes.cpp.

int lsm_error_free ( lsm_error_ptr  err  ) 

Frees the error record!

Parameters:
err The error to free!
Returns:
LSM_ERR_OK on success, else error reason.

Definition at line 373 of file lsm_datatypes.cpp.

Here is the caller graph for this function:

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.

Parameters:
e The lsm_error_ptr
Returns:
NULL if message data does not exist, else error message.

Definition at line 418 of file lsm_datatypes.cpp.

Here is the caller graph for this function:

lsm_error_number lsm_error_number_get ( lsm_error_ptr  e  ) 

Retrieves the error number from the error.

Parameters:
e The lsm_error_ptr
Returns:
-1 if e is not a valid error pointer, else error number.

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.

Parameters:
p Pool
Returns:
The amount of free space.

Definition at line 605 of file lsm_datatypes.cpp.

Here is the caller graph for this function:

void lsm_pool_free_space_set ( lsm_pool p,
uint64_t  free_space 
)

Used to set the free space on a pool record

Parameters:
p Pool to modify
free_space New free space value

Definition at line 522 of file lsm_datatypes.cpp.

Here is the caller graph for this function:

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!.

Parameters:
p Pool
Returns:
The System wide unique identifier.

Definition at line 589 of file lsm_datatypes.cpp.

Here is the caller graph for this function:

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.

Parameters:
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
Returns:
LSM_ERR_OK on success, else error reason.

Definition at line 489 of file lsm_datatypes.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

lsm_pool* lsm_pool_record_copy ( lsm_pool to_be_copied  ) 

Copies a lsm_pool record

Parameters:
to_be_copied Record to be copied
Returns:
NULL on memory exhaustion, else copy.

Definition at line 529 of file lsm_datatypes.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int lsm_pool_record_free ( lsm_pool p  ) 

Frees the memory for an individual pool

Parameters:
p Valid pool
Returns:
LSM_ERR_OK on success, else error reason.

Definition at line 545 of file lsm_datatypes.cpp.

Here is the caller graph for this function:

uint64_t lsm_pool_status_get ( lsm_pool s  ) 

Retrieve the status for the Pool.

Parameters:
s Pool to retrieve status for
Returns:
Pool status which is a bit sensitive field, returns UINT64_MAX on bad pool pointer.

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.

Parameters:
s Pool to retrieve status for
Returns:
Pool status info which is a character string.

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.

Parameters:
p Pool pointer
Returns:
System ID

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.

Parameters:
p Pool
Returns:
Total space of the 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.

Parameters:
size Initial number of strings to allocate
Returns:
NULL on error, else valid lsm_string_list record pointer

Definition at line 131 of file lsm_datatypes.cpp.

Here is the caller graph for this function:

int lsm_string_list_append ( lsm_string_list sl,
const char *  add 
)

Appends a char * to the string list, will grow container as needed.

Parameters:
sl String list to append to
add Character string to add
Returns:
LSM_ERR_OK on success, else error reason

Definition at line 59 of file lsm_datatypes.cpp.

Here is the caller graph for this function:

lsm_string_list* lsm_string_list_copy ( lsm_string_list src  ) 

Copies a lsm_string_list record.

Parameters:
src Source to copy
Returns:
NULL on error, else copy of source.

We had an allocation failure setting an element item

Definition at line 172 of file lsm_datatypes.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters:
sl String list to remove item from
index Specified index
Returns:
LSM_ERR_OK on success, else error reason

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

Parameters:
sl Valid string list pointer
index Index to retrieve
Returns:
Value at that index position.

Definition at line 121 of file lsm_datatypes.cpp.

Here is the caller graph for this function:

int lsm_string_list_elem_set ( lsm_string_list sl,
uint32_t  index,
const char *  value 
)

Set the specified element with the passed value.

Parameters:
sl Valid string list pointer
index Element position to set value to
value Value to use for assignment
Returns:
LSM_ERR_OK on success, else error reason

Definition at line 89 of file lsm_datatypes.cpp.

Here is the caller graph for this function:

int lsm_string_list_free ( lsm_string_list sl  ) 

Frees the memory allocated with the lsmStringListFree

Parameters:
sl Record to free
Returns:
LSM_ERR_OK on success, else error reason.

Definition at line 152 of file lsm_datatypes.cpp.

Here is the caller graph for this function:

uint32_t lsm_string_list_size ( lsm_string_list sl  ) 

Returns the size of the list

Parameters:
sl Valid string list pointer
Returns:
size of list, note you cannot create a zero sized list, so 0 indicates error with structure

Definition at line 164 of file lsm_datatypes.cpp.

Here is the caller graph for this function:

lsm_pool MEMBER_FUNC_GET ( uint64_t  ,
lsm_pool_unsupported_actions_get  ,
lsm_pool p,
p  ,
LSM_IS_POOL  ,
element_type  ,
 
) const
Type Constraints
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 278 of file lsm_datatypes.cpp.

Here is the caller graph for this function:


Variable Documentation

lsm_pool const char const char uint64_t blockSize

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.

lsm_pool const char* name

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.

lsm_pool const char const char uint64_t uint64_t uint32_t const char const char* pool_id

Definition at line 648 of file lsm_datatypes.cpp.

lsm_pool const char const char uint64_t uint64_t uint32_t status

Definition at line 648 of file lsm_datatypes.cpp.

lsm_pool const char const char uint64_t uint64_t uint32_t const char* system_id

Definition at line 648 of file lsm_datatypes.cpp.

lsm_pool const char const char* vpd83

Definition at line 648 of file lsm_datatypes.cpp.


Generated on 9 Jul 2015 for libStorageMgmt by  doxygen 1.6.1