Network Block Device
@PACKAGE_VERSION@
|
#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 <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 |
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) |
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[]) |
#define MY_NAME "nbd_client" |
Definition at line 45 of file nbd-client.c.
Referenced by main().
#define NBDC_DO_LIST 1 |
Definition at line 52 of file nbd-client.c.
Referenced by main(), and negotiate().
void ask_list | ( | int | sock | ) |
Definition at line 168 of file nbd-client.c.
References err(), htonll, len, magic, NBD_OPT_ABORT, NBD_OPT_LIST, NBD_REP_ACK, NBD_REP_ERR_POLICY, NBD_REP_FLAG_ERROR, NBD_REP_SERVER, ntohll(), opts_magic, and rep_magic.
Referenced by negotiate().
int check_conn | ( | char * | devname, |
int | do_print | ||
) |
void disconnect | ( | char * | device | ) |
Definition at line 436 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 388 of file nbd-client.c.
References err(), and NBD_SET_SOCK.
Referenced by main().
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 450 of file nbd-client.c.
References check_conn(), disconnect(), err(), finish_sock(), G_GNUC_UNUSED, logging(), MY_NAME, NBD_CLEAR_SOCK, NBD_DEFAULT_PORT, NBD_DO_IT, NBD_FLAG_C_FIXED_NEWSTYLE, NBD_FLAG_FIXED_NEWSTYLE, NBDC_DO_LIST, negotiate(), oom_adjust(), opennet(), openunix(), set_timeout(), setsizes(), and usage().
void negotiate | ( | int | sock, |
u64 * | rsize64, | ||
uint16_t * | flags, | ||
char * | name, | ||
uint32_t | needed_flags, | ||
uint32_t | client_flags, | ||
uint32_t | do_opts | ||
) |
Definition at line 264 of file nbd-client.c.
References ask_list(), cliserv_magic, err(), htonll, INIT_PASSWD, magic, NBD_FLAG_C_NO_ZEROES, NBD_FLAG_NO_ZEROES, NBD_OPT_EXPORT_NAME, NBDC_DO_LIST, ntohll(), and opts_magic.
Referenced by main().
|
static |
int opennet | ( | char * | name, |
char * | portstr, | ||
int | sdp | ||
) |
Definition at line 86 of file nbd-client.c.
References AI_NUMERICSERV, err(), err_nonfatal(), and setmysockopt().
Referenced by main().
int openunix | ( | const char * | path | ) |
void set_timeout | ( | int | nbd, |
int | timeout | ||
) |
Definition at line 380 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 354 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, |
... | |||
) |