288 |
return store_nbd_open (name, flags, store); |
return store_nbd_open (name, flags, store); |
289 |
} |
} |
290 |
|
|
291 |
/* Valid name syntax is HOSTNAME:PORT[/BLOCKSIZE]. |
static const char url_prefix[] = "nbd://"; |
292 |
|
|
293 |
|
/* Valid name syntax is [nbd://]HOSTNAME:PORT[/BLOCKSIZE]. |
294 |
If "/BLOCKSIZE" is omitted, the block size is 1. */ |
If "/BLOCKSIZE" is omitted, the block size is 1. */ |
295 |
static error_t |
static error_t |
296 |
nbd_validate_name (const char *name, |
nbd_validate_name (const char *name, |
297 |
const struct store_class *const *classes) |
const struct store_class *const *classes) |
298 |
{ |
{ |
299 |
char *p = strchr (name, ':'), *endp; |
char *p, *endp; |
300 |
|
|
301 |
|
if (!strncmp (name, url_prefix, sizeof url_prefix - 1)) |
302 |
|
name += sizeof url_prefix - 1; |
303 |
|
|
304 |
|
p = strchr (name, ':'); |
305 |
if (p == 0) |
if (p == 0) |
306 |
return EINVAL; |
return EINVAL; |
307 |
endp = 0; |
endp = 0; |
336 |
struct nbd_startup ns; |
struct nbd_startup ns; |
337 |
ssize_t cc; |
ssize_t cc; |
338 |
size_t ofs; |
size_t ofs; |
339 |
|
unsigned long int port; |
340 |
|
char *hostname, *p, *endp; |
341 |
|
|
342 |
|
if (!strncmp (name, url_prefix, sizeof url_prefix - 1)) |
343 |
|
name += sizeof url_prefix - 1; |
344 |
|
|
345 |
/* 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 |
346 |
port number to connect to and the block size to use. */ |
port number to connect to and the block size to use. */ |
347 |
|
|
348 |
unsigned long int port; |
hostname = strdupa (name); |
349 |
char *hostname = strdupa (name); |
p = strchr (hostname, ':'); |
|
char *p = strchr (hostname, ':'), *endp; |
|
350 |
|
|
351 |
if (p == 0) |
if (p == 0) |
352 |
return EINVAL; |
return EINVAL; |
471 |
return err; |
return err; |
472 |
} |
} |
473 |
|
|
474 |
const struct store_class |
const struct store_class store_nbd_class = |
|
store_nbd_class = |
|
475 |
{ |
{ |
476 |
STORAGE_NETWORK, "nbd", |
STORAGE_NETWORK, "nbd", |
477 |
open: nbd_open, |
open: nbd_open, |