Network Block Device  @PACKAGE_VERSION@
Macros | Functions
nbd-client.c File Reference
#include "config.h"
#include "lfs.h"
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/types.h>
#include <unistd.h>
#include <netinet/tcp.h>
#include <netinet/in.h>
#include <netdb.h>
#include "netdb-compat.h"
#include <stdio.h>
#include <fcntl.h>
#include <syslog.h>
#include <stdlib.h>
#include <sys/mount.h>
#include <sys/mman.h>
#include <signal.h>
#include <errno.h>
#include <getopt.h>
#include <stdarg.h>
#include <stdbool.h>
#include <time.h>
#include <linux/ioctl.h>
#include "cliserv.h"

Go to the source code of this file.

Macros

#define MY_NAME   "nbd_client"
 
#define NBDC_DO_LIST   1
 
#define CHECK_LEN   field_len = strcspn(loc, fsep); ws_len = strspn(loc+field_len, fsep); if(field_len > line_len || line_len <= 0) { goto out; }
 
#define MOVE_NEXT   line_len -= field_len + ws_len; loc += field_len + ws_len
 

Functions

int check_conn (char *devname, int do_print)
 
int opennet (char *name, char *portstr, int sdp)
 
int openunix (const char *path)
 
void ask_list (int sock)
 
void negotiate (int sock, u64 *rsize64, uint16_t *flags, char *name, uint32_t needed_flags, uint32_t client_flags, uint32_t do_opts)
 
bool get_from_config (char *cfgname, char **name_ptr, char **dev_ptr, char **hostn_ptr, int *bs, int *timeout, int *persist, int *swap, int *sdp, int *b_unix, char **port)
 
void setsizes (int nbd, u64 size64, int blocksize, u32 flags)
 
void set_timeout (int nbd, int timeout)
 
void finish_sock (int sock, int nbd, int swap)
 
static int oom_adjust (const char *file, const char *value)
 
void usage (char *errmsg,...)
 
void disconnect (char *device)
 
int main (int argc, char *argv[])
 

Macro Definition Documentation

#define CHECK_LEN   field_len = strcspn(loc, fsep); ws_len = strspn(loc+field_len, fsep); if(field_len > line_len || line_len <= 0) { goto out; }

Referenced by get_from_config().

#define MOVE_NEXT   line_len -= field_len + ws_len; loc += field_len + ws_len

Referenced by get_from_config().

#define MY_NAME   "nbd_client"

Definition at line 47 of file nbd-client.c.

Referenced by main().

#define NBDC_DO_LIST   1

Definition at line 54 of file nbd-client.c.

Referenced by main(), and negotiate().

Function Documentation

void ask_list ( int  sock)
int check_conn ( char *  devname,
int  do_print 
)

Definition at line 56 of file nbd-client.c.

References len.

Referenced by main().

void disconnect ( char *  device)

Definition at line 540 of file nbd-client.c.

References err(), NBD_CLEAR_SOCK, and NBD_DISCONNECT.

Referenced by main().

void finish_sock ( int  sock,
int  nbd,
int  swap 
)

Definition at line 490 of file nbd-client.c.

References err(), and NBD_SET_SOCK.

Referenced by main().

bool get_from_config ( char *  cfgname,
char **  name_ptr,
char **  dev_ptr,
char **  hostn_ptr,
int *  bs,
int *  timeout,
int *  persist,
int *  swap,
int *  sdp,
int *  b_unix,
char **  port 
)

Definition at line 346 of file nbd-client.c.

References CHECK_LEN, MOVE_NEXT, and SYSCONFDIR.

Referenced by main().

int main ( int  argc,
char *  argv[] 
)
void negotiate ( int  sock,
u64 *  rsize64,
uint16_t *  flags,
char *  name,
uint32_t  needed_flags,
uint32_t  client_flags,
uint32_t  do_opts 
)
static int oom_adjust ( const char *  file,
const char *  value 
)
static

Definition at line 501 of file nbd-client.c.

References len.

Referenced by main().

int opennet ( char *  name,
char *  portstr,
int  sdp 
)

Definition at line 88 of file nbd-client.c.

References AI_NUMERICSERV, err(), err_nonfatal(), and setmysockopt().

Referenced by main().

int openunix ( const char *  path)

Definition at line 144 of file nbd-client.c.

References err_nonfatal().

Referenced by main().

void set_timeout ( int  nbd,
int  timeout 
)

Definition at line 482 of file nbd-client.c.

References err(), and NBD_SET_TIMEOUT.

Referenced by main().

void setsizes ( int  nbd,
u64  size64,
int  blocksize,
u32  flags 
)

Definition at line 456 of file nbd-client.c.

References err(), NBD_CLEAR_SOCK, NBD_FLAG_READ_ONLY, NBD_SET_BLKSIZE, NBD_SET_FLAGS, and NBD_SET_SIZE_BLOCKS.

Referenced by main().

void usage ( char *  errmsg,
  ... 
)

Definition at line 515 of file nbd-client.c.

References PACKAGE_VERSION.

Referenced by main().