191 |
return store_nbd_open (name, flags, store); |
return store_nbd_open (name, flags, store); |
192 |
} |
} |
193 |
|
|
194 |
/* Valid name syntax is HOSTNAME:PORT[/BLOCKSIZE]. |
static const char url_prefix[] = "nbd://"; |
195 |
|
|
196 |
|
/* Valid name syntax is [nbd://]HOSTNAME:PORT[/BLOCKSIZE]. |
197 |
If "/BLOCKSIZE" is omitted, the block size is 1. */ |
If "/BLOCKSIZE" is omitted, the block size is 1. */ |
198 |
static error_t |
static error_t |
199 |
nbd_validate_name (const char *name, |
nbd_validate_name (const char *name, |
200 |
const struct store_class *const *classes) |
const struct store_class *const *classes) |
201 |
{ |
{ |
202 |
char *p = strchr (name, ':'), *endp; |
char *p, *endp; |
203 |
|
|
204 |
|
if (!strncmp (name, url_prefix, sizeof url_prefix - 1)) |
205 |
|
name += sizeof url_prefix - 1; |
206 |
|
|
207 |
|
p = strchr (name, ':'); |
208 |
if (p == 0) |
if (p == 0) |
209 |
return EINVAL; |
return EINVAL; |
210 |
endp = 0; |
endp = 0; |
238 |
char **ap; |
char **ap; |
239 |
struct nbd_startup ns; |
struct nbd_startup ns; |
240 |
ssize_t cc; |
ssize_t cc; |
241 |
|
unsigned long int port; |
242 |
|
char *hostname, *p, *endp; |
243 |
|
|
244 |
|
if (!strncmp (name, url_prefix, sizeof url_prefix - 1)) |
245 |
|
name += sizeof url_prefix - 1; |
246 |
|
|
247 |
/* First we have to parse the store name to get the host name and TCP |
/* First we have to parse the store name to get the host name and TCP |
248 |
port number to connect to and the block size to use. */ |
port number to connect to and the block size to use. */ |
249 |
|
|
250 |
unsigned long int port; |
hostname = strdupa (name); |
251 |
char *hostname = strdupa (name); |
p = strchr (hostname, ':'); |
|
char *p = strchr (hostname, ':'), *endp; |
|
252 |
|
|
253 |
if (p == 0) |
if (p == 0) |
254 |
return EINVAL; |
return EINVAL; |
368 |
return err; |
return err; |
369 |
} |
} |
370 |
|
|
371 |
const struct store_class |
const struct store_class store_nbd_class = |
|
store_nbd_class = |
|
372 |
{ |
{ |
373 |
STORAGE_NETWORK, "nbd", |
STORAGE_NETWORK, "nbd", |
374 |
open: nbd_open, |
open: nbd_open, |