diff options
author | Roland McGrath <roland@gnu.org> | 2001-12-29 23:44:22 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2001-12-29 23:44:22 +0000 |
commit | 526a0826f08550d586ad2964bb71fd67c2bebde1 (patch) | |
tree | 1198861cc377387696a6a504f6192f60b3741944 | |
parent | d07cc9b328799dfe6a1ba16cbb75b1a32258be12 (diff) |
2001-12-29 Roland McGrath <roland@frob.com>
* nbd.c (nbd_validate_name): Skip : before port number.
-rw-r--r-- | libstore/nbd.c | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/libstore/nbd.c b/libstore/nbd.c index c802724e..7e2d2b65 100644 --- a/libstore/nbd.c +++ b/libstore/nbd.c @@ -191,24 +191,17 @@ nbd_open (const char *name, int flags, return store_nbd_open (name, flags, store); } -static const char url_prefix[] = "nbd://"; - -/* Valid name syntax is [nbd://]HOSTNAME:PORT[/BLOCKSIZE]. +/* Valid name syntax is HOSTNAME:PORT[/BLOCKSIZE]. If "/BLOCKSIZE" is omitted, the block size is 1. */ static error_t nbd_validate_name (const char *name, const struct store_class *const *classes) { - char *p, *endp; - - if (!strncmp (name, url_prefix, sizeof url_prefix - 1)) - name += sizeof url_prefix - 1; - - p = strchr (name, ':'); + char *p = strchr (name, ':'), *endp; if (p == 0) return EINVAL; endp = 0; - strtoul (p, &endp, 0); + strtoul (++p, &endp, 0); if (endp == 0 || endp == p) return EINVAL; switch (*endp) @@ -238,17 +231,13 @@ nbdopen (const char *name, int *mod_flags, char **ap; struct nbd_startup ns; 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; /* First we have to parse the store name to get the host name and TCP port number to connect to and the block size to use. */ - hostname = strdupa (name); - p = strchr (hostname, ':'); + unsigned long int port; + char *hostname = strdupa (name); + char *p = strchr (hostname, ':'), *endp; if (p == 0) return EINVAL; @@ -368,7 +357,8 @@ nbd_clear_flags (struct store *store, int flags) return err; } -const struct store_class store_nbd_class = +const struct store_class +store_nbd_class = { STORAGE_NETWORK, "nbd", open: nbd_open, |