|
Network Block Device
@PACKAGE_VERSION@
|
#include "config.h"#include "lfs.h"#include <sys/ioctl.h>#include <sys/socket.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) |
| void | ask_list (int sock) |
| void | negotiate (int sock, u64 *rsize64, u32 *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 44 of file nbd-client.c.
Referenced by logging().
| #define NBDC_DO_LIST 1 |
Definition at line 51 of file nbd-client.c.
Referenced by main(), and negotiate().
| void ask_list | ( | int | sock | ) |
Definition at line 134 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 405 of file nbd-client.c.
References err(), NBD_CLEAR_QUE, NBD_CLEAR_SOCK, and NBD_DISCONNECT.
Referenced by main().
| void finish_sock | ( | int | sock, |
| int | nbd, | ||
| int | swap | ||
| ) |
Definition at line 358 of file nbd-client.c.
References err(), and NBD_SET_SOCK.
Referenced by main().
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 422 of file nbd-client.c.
References check_conn(), disconnect(), err(), finish_sock(), G_GNUC_UNUSED, logging(), NBD_CLEAR_QUE, 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(), set_timeout(), setsizes(), and usage().
| void negotiate | ( | int | sock, |
| u64 * | rsize64, | ||
| u32 * | flags, | ||
| char * | name, | ||
| uint32_t | needed_flags, | ||
| uint32_t | client_flags, | ||
| uint32_t | do_opts | ||
| ) |
Definition at line 223 of file nbd-client.c.
References ask_list(), cliserv_magic, err(), htonll, INIT_PASSWD, magic, 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 81 of file nbd-client.c.
References AI_NUMERICSERV, err(), err_nonfatal(), and setmysockopt().
Referenced by main().
| void set_timeout | ( | int | nbd, |
| int | timeout | ||
| ) |
Definition at line 350 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 324 of file nbd-client.c.
References err(), NBD_CLEAR_SOCK, NBD_FLAG_READ_ONLY, NBD_SET_BLKSIZE, NBD_SET_FLAGS, NBD_SET_SIZE_BLOCKS, and size.
Referenced by main().
| void usage | ( | char * | errmsg, |
| ... | |||
| ) |
1.8.8