191 |
return store_nbd_open (name, flags, store); |
return store_nbd_open (name, flags, store); |
192 |
} |
} |
193 |
|
|
194 |
static const char url_prefix[] = "nbd://"; |
/* Valid name syntax is HOSTNAME:PORT[/BLOCKSIZE]. |
|
|
|
|
/* Valid name syntax is [nbd://]HOSTNAME:PORT[/BLOCKSIZE]. |
|
195 |
If "/BLOCKSIZE" is omitted, the block size is 1. */ |
If "/BLOCKSIZE" is omitted, the block size is 1. */ |
196 |
static error_t |
static error_t |
197 |
nbd_validate_name (const char *name, |
nbd_validate_name (const char *name, |
198 |
const struct store_class *const *classes) |
const struct store_class *const *classes) |
199 |
{ |
{ |
200 |
char *p, *endp; |
char *p = strchr (name, ':'), *endp; |
|
|
|
|
if (!strncmp (name, url_prefix, sizeof url_prefix - 1)) |
|
|
name += sizeof url_prefix - 1; |
|
|
|
|
|
p = strchr (name, ':'); |
|
201 |
if (p == 0) |
if (p == 0) |
202 |
return EINVAL; |
return EINVAL; |
203 |
endp = 0; |
endp = 0; |
204 |
strtoul (p, &endp, 0); |
strtoul (++p, &endp, 0); |
205 |
if (endp == 0 || endp == p) |
if (endp == 0 || endp == p) |
206 |
return EINVAL; |
return EINVAL; |
207 |
switch (*endp) |
switch (*endp) |
231 |
char **ap; |
char **ap; |
232 |
struct nbd_startup ns; |
struct nbd_startup ns; |
233 |
ssize_t cc; |
ssize_t cc; |
|
unsigned long int port; |
|
|
char *hostname, *p, *endp; |
|
|
|
|
|
if (!strncmp (name, url_prefix, sizeof url_prefix - 1)) |
|
|
name += sizeof url_prefix - 1; |
|
234 |
|
|
235 |
/* 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 |
236 |
port number to connect to and the block size to use. */ |
port number to connect to and the block size to use. */ |
237 |
|
|
238 |
hostname = strdupa (name); |
unsigned long int port; |
239 |
p = strchr (hostname, ':'); |
char *hostname = strdupa (name); |
240 |
|
char *p = strchr (hostname, ':'), *endp; |
241 |
|
|
242 |
if (p == 0) |
if (p == 0) |
243 |
return EINVAL; |
return EINVAL; |
357 |
return err; |
return err; |
358 |
} |
} |
359 |
|
|
360 |
const struct store_class store_nbd_class = |
const struct store_class |
361 |
|
store_nbd_class = |
362 |
{ |
{ |
363 |
STORAGE_NETWORK, "nbd", |
STORAGE_NETWORK, "nbd", |
364 |
open: nbd_open, |
open: nbd_open, |