diff options
author | Roland McGrath <roland@gnu.org> | 2001-12-31 08:00:17 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2001-12-31 08:00:17 +0000 |
commit | c3d6922bba033c655008534f29ee92ecfc97f022 (patch) | |
tree | 5672f1f22440e2fe65ba3fadb005b7cc0e765a21 | |
parent | 783fe02433e0f8d5567c417e2dceb63f6c40bf7b (diff) |
restore rev 1.7 change somehow lost in the shuffle
-rw-r--r-- | libstore/nbd.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/libstore/nbd.c b/libstore/nbd.c index 0695410e..ad19af6b 100644 --- a/libstore/nbd.c +++ b/libstore/nbd.c @@ -288,13 +288,20 @@ nbd_open (const char *name, int flags, return store_nbd_open (name, flags, store); } -/* Valid name syntax is HOSTNAME:PORT[/BLOCKSIZE]. +static const char url_prefix[] = "nbd://"; + +/* Valid name syntax is [nbd://]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 = strchr (name, ':'), *endp; + char *p, *endp; + + if (!strncmp (name, url_prefix, sizeof url_prefix - 1)) + name += sizeof url_prefix - 1; + + p = strchr (name, ':'); if (p == 0) return EINVAL; endp = 0; @@ -329,13 +336,17 @@ nbdopen (const char *name, int *mod_flags, struct nbd_startup ns; ssize_t cc; size_t ofs; + 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. */ - unsigned long int port; - char *hostname = strdupa (name); - char *p = strchr (hostname, ':'), *endp; + hostname = strdupa (name); + p = strchr (hostname, ':'); if (p == 0) return EINVAL; @@ -460,8 +471,7 @@ 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, |