Motr  M0
m0hsm.c File Reference
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <editline/readline.h>
#include "lib/string.h"
#include "m0hsm_api.h"
#include "motr/idx.h"
Include dependency graph for m0hsm.c:

Go to the source code of this file.

Macros

#define IO_SIZE   (1024 * 1024)
 
#define SHORT_OPT   "qv"
 
#define SH_TOK_BUFSIZE   64
 
#define SH_TOK_DELIM   " \t\r\n\a"
 

Functions

static void client_fini (void)
 
static int client_init (void)
 
static int open_entity (struct m0_entity *entity)
 
static int m0hsm_write_file (struct m0_uint128 id, const char *path)
 
static int load_env (char **tgt, const char *env)
 
static int load_client_env ()
 
static void usage ()
 
int64_t read_arg64 (const char *s)
 
int read_fid (const char *s, struct m0_uint128 *fid)
 
static int parse_copy_subopt (char *opts, enum hsm_cp_flags *flags)
 
static int parse_release_subopt (char *opts, enum hsm_rls_flags *flags)
 
static int parse_cmd_options (int argc, char **argv)
 
int m0hsm_test_write (struct m0_uint128 id, off_t offset, size_t len, int seed)
 
int m0hsm_test_read (struct m0_uint128 id, off_t offset, size_t len)
 
static int run_cmd (int argc, char **argv)
 
char ** sh_split_line (char *line, int *argc)
 
static int shell_loop ()
 
int main (int argc, char **argv)
 

Variables

static const char RCFILE [] = ".hsm/config"
 
static char * local_addr
 
static char * ha_addr
 
static char * profile
 
static char * proc_fid
 
static struct m0_clientinstance = NULL
 
static struct m0_container container
 
static struct m0_realm uber_realm
 
static struct m0_config client_conf
 
static struct m0_idx_dix_config dix_conf
 
struct m0hsm_options hsm_options
 
static const struct option option_tab []
 

Macro Definition Documentation

◆ IO_SIZE

#define IO_SIZE   (1024 * 1024)

◆ SH_TOK_BUFSIZE

#define SH_TOK_BUFSIZE   64

Definition at line 608 of file m0hsm.c.

◆ SH_TOK_DELIM

#define SH_TOK_DELIM   " \t\r\n\a"

Definition at line 609 of file m0hsm.c.

◆ SHORT_OPT

#define SHORT_OPT   "qv"

Definition at line 347 of file m0hsm.c.

Function Documentation

◆ client_fini()

static void client_fini ( void  )
static

Definition at line 58 of file m0hsm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ client_init()

static int client_init ( void  )
static

Definition at line 63 of file m0hsm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_client_env()

static int load_client_env ( )
static

Definition at line 203 of file m0hsm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_env()

static int load_env ( char **  tgt,
const char *  env 
)
static

Definition at line 193 of file m0hsm.c.

Here is the caller graph for this function:

◆ m0hsm_test_read()

int m0hsm_test_read ( struct m0_uint128  id,
off_t  offset,
size_t  len 
)

read data from an existing object at the given offset.

Definition at line 2045 of file m0hsm_api.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0hsm_test_write()

int m0hsm_test_write ( struct m0_uint128  id,
off_t  offset,
size_t  len,
int  seed 
)

write data to an existing object at the given offset

Parameters
seedUsed to generate block contents so it can be used to verify we read the right layer.

Definition at line 1875 of file m0hsm_api.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0hsm_write_file()

static int m0hsm_write_file ( struct m0_uint128  id,
const char *  path 
)
static

wraps m0hsm_pwrite

Definition at line 130 of file m0hsm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 680 of file m0hsm.c.

Here is the call graph for this function:

◆ open_entity()

static int open_entity ( struct m0_entity entity)
static

Helper to open an object entity

Definition at line 112 of file m0hsm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_cmd_options()

static int parse_cmd_options ( int  argc,
char **  argv 
)
static

Definition at line 349 of file m0hsm.c.

Here is the caller graph for this function:

◆ parse_copy_subopt()

static int parse_copy_subopt ( char *  opts,
enum hsm_cp_flags flags 
)
static

Definition at line 280 of file m0hsm.c.

Here is the caller graph for this function:

◆ parse_release_subopt()

static int parse_release_subopt ( char *  opts,
enum hsm_rls_flags flags 
)
static

Definition at line 317 of file m0hsm.c.

Here is the caller graph for this function:

◆ read_arg64()

int64_t read_arg64 ( const char *  s)

Definition at line 249 of file m0hsm.c.

Here is the caller graph for this function:

◆ read_fid()

int read_fid ( const char *  s,
struct m0_uint128 fid 
)

Read FID in the format [hi:]lo. Return how many numbers are read.

Definition at line 263 of file m0hsm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_cmd()

static int run_cmd ( int  argc,
char **  argv 
)
static

Definition at line 377 of file m0hsm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sh_split_line()

char** sh_split_line ( char *  line,
int *  argc 
)

Definition at line 610 of file m0hsm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shell_loop()

static int shell_loop ( )
static

Definition at line 652 of file m0hsm.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usage()

static void usage ( void  )
static

Definition at line 216 of file m0hsm.c.

Here is the caller graph for this function:

Variable Documentation

◆ client_conf

struct m0_config client_conf
static

Definition at line 50 of file m0hsm.c.

◆ container

struct m0_container container
static

Definition at line 48 of file m0hsm.c.

◆ dix_conf

struct m0_idx_dix_config dix_conf
static

Definition at line 51 of file m0hsm.c.

◆ ha_addr

char* ha_addr
static

Definition at line 43 of file m0hsm.c.

◆ hsm_options

struct m0hsm_options hsm_options
Initial value:
= {
.trace_level = LOG_INFO,
.op_timeout = 10,
}

Definition at line 53 of file m0hsm.c.

◆ instance

struct m0_client* instance = NULL
static

Definition at line 47 of file m0hsm.c.

◆ local_addr

char* local_addr
static

Definition at line 42 of file m0hsm.c.

◆ option_tab

const struct option option_tab[]
static
Initial value:
= {
{"quiet", no_argument, NULL, 'q'},
{"verbose", required_argument, NULL, 'v'},
}
#define NULL
Definition: misc.h:38

Definition at line 343 of file m0hsm.c.

◆ proc_fid

char* proc_fid
static

Definition at line 45 of file m0hsm.c.

◆ profile

char* profile
static

Definition at line 44 of file m0hsm.c.

◆ RCFILE

const char RCFILE[] = ".hsm/config"
static

Definition at line 39 of file m0hsm.c.

◆ uber_realm

struct m0_realm uber_realm
static

Definition at line 49 of file m0hsm.c.