|
Network Block Device @PACKAGE_VERSION@
|
#include "config.h"#include "nbd-debug.h"#include <nbdsrv.h>#include <assert.h>#include <ctype.h>#include <netdb.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#include <syslog.h>#include <unistd.h>#include <sys/stat.h>#include <sys/types.h>#include <sys/socket.h>#include <treefiles.h>#include "backend.h"#include <sys/mount.h>#include <cliserv.h>Go to the source code of this file.
Defines | |
| #define | LINELEN 256 |
| Size of static buffer used to read the authorization file (yuck) | |
Functions | |
| bool | address_matches (const char *mask, const struct sockaddr *addr, GError **err) |
| Check whether a given address matches a given netmask. | |
| uint8_t | getmaskbyte (int masklen) |
| Gets a byte to allow for address masking. | |
| int | authorized_client (CLIENT *opts) |
| Check whether a client is allowed to connect. | |
| SERVER * | dup_serve (const SERVER *const s) |
| duplicate server | |
| uint64_t | size_autodetect (int fhandle) |
| Detect the size of a file. | |
| int | exptrim (struct nbd_request *req, CLIENT *client) |
| Punch a hole in the backend file (if supported by the current system). | |
| void | myseek (int handle, off_t a) |
| seek to a position in a file, with error handling. | |
| #define LINELEN 256 |
Size of static buffer used to read the authorization file (yuck)
Definition at line 24 of file nbdsrv.c.
Referenced by authorized_client().
| 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 |
Definition at line 29 of file nbdsrv.c.
References getmaskbyte(), NBDS_ERR, and NBDS_ERR_GAI.
Referenced by authorized_client().
| 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 113 of file nbdsrv.c.
References address_matches(), SERVER::authname, CLIENT::clientaddr, LINELEN, msg, and CLIENT::server.
Referenced by handle_modern_connection().
duplicate server
| s | the old server we want to duplicate |
Definition at line 157 of file nbdsrv.c.
References SERVER::authname, SERVER::cidrlen, SERVER::cowdir, SERVER::expected_size, SERVER::exportname, SERVER::flags, SERVER::listenaddr, SERVER::max_connections, SERVER::postrun, SERVER::prerun, SERVER::servename, SERVER::transactionlog, and SERVER::virtstyle.
| 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 240 of file nbdsrv.c.
References DEBUG, delete_treefile(), CLIENT::export, CLIENT::exportname, CLIENT::exportsize, F_COPYONWRITE, F_READONLY, F_TREEFILES, FILE_INFO::fhandle, SERVER::flags, nbd_request::from, nbd_request::len, punch_hole(), CLIENT::server, FILE_INFO::startoff, and TREEPAGESIZE.
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 101 of file nbdsrv.c.
Referenced by address_matches(), and 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 292 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 199 of file nbdsrv.c.
References __attribute__, and DEBUG.
Referenced by setupexport().
1.7.3