|
Network Block Device
@PACKAGE_VERSION@
|
#include "lfs.h"#include <glib.h>#include <stdbool.h>#include <stdint.h>#include <sys/socket.h>#include <sys/types.h>#include "nbd.h"Go to the source code of this file.
Data Structures | |
| struct | SERVER |
| Variables associated with a server. More... | |
| struct | CLIENT |
| Variables associated with a client connection. More... | |
| struct | FILE_INFO |
| Variables associated with an open file. More... | |
Macros | |
| #define | NBDS_ERR g_quark_from_static_string("server-error-quark") |
| Error domain common for all NBD server errors. More... | |
| #define | msg(prio,...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, __VA_ARGS__) |
| Logging macros. More... | |
| #define | MY_NAME "nbd_server" |
| #define | F_READONLY 1 |
| Per-export flags: More... | |
| #define | F_MULTIFILE 2 |
| flag to tell us a file is exported using -m More... | |
| #define | F_COPYONWRITE 4 |
| flag to tell us a file is exported using copyonwrite More... | |
| #define | F_AUTOREADONLY 8 |
| flag to tell us a file is set to autoreadonly More... | |
| #define | F_SPARSE 16 |
| flag to tell us copyronwrite should use a sparse file More... | |
| #define | F_SDP 32 |
| flag to tell us the export should be done using the Socket Direct Protocol for RDMA More... | |
| #define | F_SYNC 64 |
| Whether to fsync() after a write. More... | |
| #define | F_FLUSH 128 |
| Whether server wants FLUSH to be sent by the client. More... | |
| #define | F_FUA 256 |
| Whether server wants FUA to be sent by the client. More... | |
| #define | F_ROTATIONAL 512 |
| Whether server wants the client to implement the elevator algorithm. More... | |
| #define | F_TEMPORARY 1024 |
| Whether the backing file is temporary and should be created then unlinked. More... | |
| #define | F_TRIM 2048 |
| Whether server wants TRIM (discard) to be sent by the client. More... | |
| #define | F_FIXED 4096 |
| Client supports fixed new-style protocol (and can thus send us extra options. More... | |
| #define | F_TREEFILES 8192 |
| flag to tell us a file is exported using -t More... | |
Enumerations | |
| enum | VIRT_STYLE { VIRT_NONE =0, VIRT_IPLIT, VIRT_IPHASH, VIRT_CIDR } |
| Types of virtuatlization. More... | |
| enum | NBDS_ERRS { NBDS_ERR_CFILE_NOTFOUND, NBDS_ERR_CFILE_MISSING_GENERIC, NBDS_ERR_CFILE_KEY_MISSING, NBDS_ERR_CFILE_VALUE_INVALID, NBDS_ERR_CFILE_VALUE_UNSUPPORTED, NBDS_ERR_CFILE_NO_EXPORTS, NBDS_ERR_CFILE_INCORRECT_PORT, NBDS_ERR_CFILE_DIR_UNKNOWN, NBDS_ERR_CFILE_READDIR_ERR, NBDS_ERR_SO_LINGER, NBDS_ERR_SO_REUSEADDR, NBDS_ERR_SO_KEEPALIVE, NBDS_ERR_GAI, NBDS_ERR_SOCKET, NBDS_ERR_BIND, NBDS_ERR_LISTEN, NBDS_ERR_SYS } |
| NBD server error codes. More... | |
Functions | |
| bool | address_matches (const char *mask, const struct sockaddr *addr, GError **err) |
| Check whether a given address matches a given netmask. More... | |
| uint8_t | getmaskbyte (int masklen) G_GNUC_PURE |
| Gets a byte to allow for address masking. More... | |
| int | authorized_client (CLIENT *opts) |
| Check whether a client is allowed to connect. More... | |
| SERVER * | dup_serve (const SERVER *const s) |
| duplicate server More... | |
| uint64_t | size_autodetect (int fhandle) |
| Detect the size of a file. More... | |
| int | exptrim (struct nbd_request *req, CLIENT *client) |
| Punch a hole in the backend file (if supported by the current system). More... | |
| void | myseek (int handle, off_t a) |
| seek to a position in a file, with error handling. More... | |
| #define F_AUTOREADONLY 8 |
flag to tell us a file is set to autoreadonly
Definition at line 134 of file nbdsrv.h.
Referenced by handle_write(), mainloop(), and setupexport().
| #define F_COPYONWRITE 4 |
flag to tell us a file is exported using copyonwrite
Definition at line 131 of file nbdsrv.h.
Referenced by cmdline(), dump_section(), expflush(), expread(), expwrite(), mainloop(), parse_cfile(), serveconnection(), and setupexport().
| #define F_FIXED 4096 |
| #define F_FLUSH 128 |
Whether server wants FLUSH to be sent by the client.
Definition at line 138 of file nbdsrv.h.
Referenced by parse_cfile(), and send_export_info().
| #define F_FUA 256 |
Whether server wants FUA to be sent by the client.
Definition at line 139 of file nbdsrv.h.
Referenced by parse_cfile(), and send_export_info().
| #define F_MULTIFILE 2 |
flag to tell us a file is exported using -m
Definition at line 130 of file nbdsrv.h.
Referenced by cmdline(), dump_section(), parse_cfile(), and setupexport().
| #define F_READONLY 1 |
Per-export flags:
flag to tell us a file is readonly
Definition at line 129 of file nbdsrv.h.
Referenced by cmdline(), dump_section(), expflush(), get_filepos(), handle_write(), mainloop(), parse_cfile(), send_export_info(), and setupexport().
| #define F_ROTATIONAL 512 |
Whether server wants the client to implement the elevator algorithm.
Definition at line 140 of file nbdsrv.h.
Referenced by parse_cfile(), and send_export_info().
| #define F_SDP 32 |
flag to tell us the export should be done using the Socket Direct Protocol for RDMA
Definition at line 136 of file nbdsrv.h.
Referenced by parse_cfile().
| #define F_SPARSE 16 |
flag to tell us copyronwrite should use a sparse file
Definition at line 135 of file nbdsrv.h.
Referenced by expwrite(), and parse_cfile().
| #define F_SYNC 64 |
Whether to fsync() after a write.
Definition at line 137 of file nbdsrv.h.
Referenced by expwrite(), parse_cfile(), and rawexpwrite().
| #define F_TEMPORARY 1024 |
Whether the backing file is temporary and should be created then unlinked.
Definition at line 141 of file nbdsrv.h.
Referenced by parse_cfile(), and setupexport().
| #define F_TREEFILES 8192 |
flag to tell us a file is exported using -t
Definition at line 144 of file nbdsrv.h.
Referenced by dump_section(), expflush(), get_filepos(), parse_cfile(), rawexpread(), rawexpwrite(), and setupexport().
| #define F_TRIM 2048 |
Whether server wants TRIM (discard) to be sent by the client.
Definition at line 142 of file nbdsrv.h.
Referenced by parse_cfile(), and send_export_info().
| #define msg | ( | prio, | |
| ... | |||
| ) | g_log(G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, __VA_ARGS__) |
Logging macros.
Definition at line 124 of file nbdsrv.h.
Referenced by authorized_client(), copyonwrite_prepare(), handle_modern_connection(), handle_request(), mainloop(), serveloop(), set_peername(), setup_servers(), setupexport(), and spawn_child().
| #define NBDS_ERR g_quark_from_static_string("server-error-quark") |
Error domain common for all NBD server errors.
Definition at line 88 of file nbdsrv.h.
Referenced by do_cfile_dir(), dosockopts(), main(), open_modern(), open_unix(), and parse_cfile().
| enum NBDS_ERRS |
NBD server error codes.
| enum VIRT_STYLE |
| bool address_matches | ( | const char * | mask, |
| const struct sockaddr * | addr, | ||
| GError ** | err | ||
| ) |
Check whether a given address matches a given netmask.
| mask | the address or netmask to check against, in ASCII representation |
| addr | the address to check |
| int authorized_client | ( | CLIENT * | opts | ) |
Check whether a client is allowed to connect.
Works with an authorization file which contains one line per machine or network, with CIDR-style netmasks.
| opts | The client who's trying to connect. |
Definition at line 110 of file nbdsrv.c.
References msg.
Referenced by handle_modern_connection().
| int exptrim | ( | struct nbd_request * | req, |
| CLIENT * | client | ||
| ) |
Punch a hole in the backend file (if supported by the current system).
| req | the request for which this is being processed |
| client | the client for which we're processing this request |
Definition at line 237 of file nbdsrv.c.
Referenced by handle_trim(), and mainloop().
| uint8_t getmaskbyte | ( | int | masklen | ) |
Gets a byte to allow for address masking.
| masklen | the length of the requested mask. |
Definition at line 98 of file nbdsrv.c.
Referenced by set_peername().
| void myseek | ( | int | handle, |
| off_t | a | ||
| ) |
seek to a position in a file, with error handling.
| handle | a filedescriptor |
| a | position to seek to |
Definition at line 289 of file nbdsrv.c.
References err().
Referenced by expread(), expwrite(), and open_treefile().
| uint64_t size_autodetect | ( | int | fhandle | ) |
Detect the size of a file.
| fhandle | An open filedescriptor |
Definition at line 196 of file nbdsrv.c.
Referenced by setupexport().
1.8.8