|
Network Block Device
@PACKAGE_VERSION@
|
#include <errno.h>#include <string.h>#include <netdb.h>#include <netinet/tcp.h>#include <netinet/in.h>#include <stdlib.h>#include "nbd.h"Go to the source code of this file.
Macros | |
| #define | __be32 u32 |
| #define | __be64 u64 |
| #define | fdatasync(arg) fsync(arg) |
| #define | G_GNUC_NORETURN |
| #define | G_GNUC_UNUSED |
| #define | INIT_PASSWD "NBDMAGIC" |
| #define | INFO(a) do { } while(0) |
| #define | htonll ntohll |
| #define | NBD_DEFAULT_PORT |
| #define | NBD_OPT_EXPORT_NAME (1) /** Client wants to select a named export (is followed by name of export) */ |
| #define | NBD_OPT_ABORT (2) /** Client wishes to abort negotiation */ |
| #define | NBD_OPT_LIST (3) /** Client request list of supported exports (not followed by data) */ |
| #define | NBD_REP_ACK (1) /** ACK a request. Data: option number to be acked */ |
| #define | NBD_REP_SERVER (2) /** Reply to NBD_OPT_LIST (one of these per server; must be followed by NBD_REP_ACK to signal the end of the list */ |
| #define | NBD_REP_FLAG_ERROR (1 << 31) /** If the high bit is set, the reply is an error */ |
| #define | NBD_REP_ERR_UNSUP (1 | NBD_REP_FLAG_ERROR) /** Client requested an option not understood by this version of the server */ |
| #define | NBD_REP_ERR_POLICY (2 | NBD_REP_FLAG_ERROR) /** Client requested an option not allowed by server configuration. (e.g., the option was disabled) */ |
| #define | NBD_REP_ERR_INVALID (3 | NBD_REP_FLAG_ERROR) /** Client issued an invalid request */ |
| #define | NBD_REP_ERR_PLATFORM (4 | NBD_REP_FLAG_ERROR) /** Option not supported on this platform */ |
| #define | NBD_FLAG_FIXED_NEWSTYLE (1 << 0) /* new-style export that actually supports extending */ |
| #define | NBD_FLAG_NO_ZEROES (1 << 1) /* we won't send the 128 bits of zeroes if the client sends NBD_FLAG_C_NO_ZEROES */ |
| #define | NBD_FLAG_C_FIXED_NEWSTYLE NBD_FLAG_FIXED_NEWSTYLE |
| #define | NBD_FLAG_C_NO_ZEROES NBD_FLAG_NO_ZEROES |
Functions | |
| void | setmysockopt (int sock) |
| void | err_nonfatal (const char *s) |
| void | err (const char *s) G_GNUC_NORETURN |
| void | logging (const char *name) |
| uint64_t | ntohll (uint64_t a) |
Variables | |
| const u64 | cliserv_magic |
| const u64 | opts_magic |
| const u64 | rep_magic |
| #define fdatasync | ( | arg | ) | fsync(arg) |
Definition at line 44 of file cliserv.h.
Referenced by expwrite(), and rawexpwrite().
| #define G_GNUC_NORETURN |
Definition at line 62 of file cliserv.h.
Referenced by serveloop().
| #define htonll ntohll |
Definition at line 83 of file cliserv.h.
Referenced by ask_list(), main(), negotiate(), send_export_info(), and send_reply().
| #define INFO | ( | a | ) | do { } while(0) |
Definition at line 73 of file cliserv.h.
Referenced by setmysockopt().
| #define INIT_PASSWD "NBDMAGIC" |
Definition at line 71 of file cliserv.h.
Referenced by negotiate().
| #define NBD_DEFAULT_PORT |
Definition at line 85 of file cliserv.h.
Referenced by main(), and open_modern().
| #define NBD_FLAG_C_FIXED_NEWSTYLE NBD_FLAG_FIXED_NEWSTYLE |
| #define NBD_FLAG_C_NO_ZEROES NBD_FLAG_NO_ZEROES |
Definition at line 107 of file cliserv.h.
Referenced by negotiate().
| #define NBD_FLAG_FIXED_NEWSTYLE (1 << 0) /* new-style export that actually supports extending */ |
Definition at line 103 of file cliserv.h.
Referenced by main(), and negotiate().
| #define NBD_FLAG_NO_ZEROES (1 << 1) /* we won't send the 128 bits of zeroes if the client sends NBD_FLAG_C_NO_ZEROES */ |
Definition at line 104 of file cliserv.h.
Referenced by negotiate().
| #define NBD_OPT_ABORT (2) /** Client wishes to abort negotiation */ |
Definition at line 90 of file cliserv.h.
Referenced by ask_list(), and negotiate().
| #define NBD_OPT_EXPORT_NAME (1) /** Client wants to select a named export (is followed by name of export) */ |
Definition at line 89 of file cliserv.h.
Referenced by negotiate().
| #define NBD_OPT_LIST (3) /** Client request list of supported exports (not followed by data) */ |
Definition at line 91 of file cliserv.h.
Referenced by ask_list(), and negotiate().
| #define NBD_REP_ACK (1) /** ACK a request. Data: option number to be acked */ |
Definition at line 94 of file cliserv.h.
Referenced by ask_list(), and handle_list().
| #define NBD_REP_ERR_INVALID (3 | NBD_REP_FLAG_ERROR) /** Client issued an invalid request */ |
Definition at line 99 of file cliserv.h.
Referenced by handle_list().
| #define NBD_REP_ERR_PLATFORM (4 | NBD_REP_FLAG_ERROR) /** Option not supported on this platform */ |
| #define NBD_REP_ERR_POLICY (2 | NBD_REP_FLAG_ERROR) /** Client requested an option not allowed by server configuration. (e.g., the option was disabled) */ |
Definition at line 98 of file cliserv.h.
Referenced by ask_list(), and handle_list().
| #define NBD_REP_ERR_UNSUP (1 | NBD_REP_FLAG_ERROR) /** Client requested an option not understood by this version of the server */ |
Definition at line 97 of file cliserv.h.
Referenced by negotiate().
| #define NBD_REP_FLAG_ERROR (1 << 31) /** If the high bit is set, the reply is an error */ |
Definition at line 96 of file cliserv.h.
Referenced by ask_list().
| #define NBD_REP_SERVER (2) /** Reply to NBD_OPT_LIST (one of these per server; must be followed by NBD_REP_ACK to signal the end of the list */ |
Definition at line 95 of file cliserv.h.
Referenced by ask_list(), and handle_list().
| void err | ( | const char * | s | ) |
Definition at line 56 of file cliserv.c.
References err_nonfatal().
Referenced by ask_list(), construct_path(), copyonwrite_prepare(), daemonize(), disconnect(), dousers(), finish_sock(), handle_export_name(), handle_list(), handle_oldstyle_connection(), main(), mainloop(), mkdir_path(), myseek(), negotiate(), open_treefile(), opennet(), parse_cfile(), readit(), send_export_info(), serveloop(), set_timeout(), setsizes(), setup_servers(), setupexport(), and writeit().
| void err_nonfatal | ( | const char * | s | ) |
Definition at line 30 of file cliserv.c.
Referenced by err(), handle_list(), negotiate(), opennet(), openunix(), and socket_accept().
| void logging | ( | const char * | name | ) |
| uint64_t ntohll | ( | uint64_t | a | ) |
| void setmysockopt | ( | int | sock | ) |
Definition at line 12 of file cliserv.c.
References INFO.
Referenced by opennet(), and serveconnection().
| const u64 cliserv_magic |
Definition at line 8 of file cliserv.c.
Referenced by negotiate().
| const u64 opts_magic |
Definition at line 9 of file cliserv.c.
Referenced by ask_list(), and negotiate().
| const u64 rep_magic |
Definition at line 10 of file cliserv.c.
Referenced by ask_list().
1.8.11