[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Standard NBD URL syntax (again)



Hi,

On Wed, May 22, 2019 at 10:37:54AM +0300, Nir Soffer wrote:
> On Wed, May 22, 2019 at 9:42 AM Wouter Verhelst <w@uter.be> wrote:
>     That really depends on how you interpret the / character, but yeah,
>     that's possible. We'll just have to make sure to document that well,
>     then.
> 
> 
> The value of using a URL is user being able to use existing URL parsers.

Sure.

> >>> from urllib.parse import urlparse
> >>> urlparse("nbd://nbd-server.example.com:12345/foo")
> ParseResult(scheme='nbd', netloc='nbd-server.example.com:12345', path='/foo',
> params='', query='', fragment='')
> >>> urlparse("nbd://nbd-server.example.com:12345//foo")
> ParseResult(scheme='nbd', netloc='nbd-server.example.com:12345', path='//foo',
> params='', query='', fragment='')
> 
> So users will mostly likely use //path when accessing the server with the
> second URL.
> 
> Multiple separator are typically normalized to single one, both in web
> applications
> and when accessing the file system:
> 
>     >>> os.path.samefile("/tmp/file", "/tmp///file")
>     True
> 
> Same behavior with:
> 
>     ls /tmp/file
>     ls /tmp//file

The point is that in NBD, the "path" part of the URL, as I proposed it,
isn't a path; it's a free-form name. Where a / is typically a directory
separator in other URLs, it wouldn't be for NBD, since NBD doesn't have
a concept of directories (and I think it would be a bad idea to
introduce one).

So I think it's perfectly fine to state that, after regular URL parsing:

- The first / in the "path" part of the URL (if any) must be dropped
- Duplicate / characters should not be normalized away.

That would allow parsing the URL with python's urllib, because as you've
shown it does not normalize away duplicate / characters.

> I think that the way to think about it is that export names are always
> relative to the server root, so

In NBD, there is no "server root", so this does not compute.

>     nbd://nbd-server.example.com:12345/foo
> 
> maps to the export name "foo" and "/foo".

This would require that a client would add heuristic code to figure out
the right name. It would also fail on servers that have both.

> And both:
> 
>     nbd://nbd-server.example.com:12345/
>     nbd://nbd-server.example.com:12345
> 
> mapped to the empty export name.

That would certainly make sense.

-- 
To the thief who stole my anti-depressants: I hope you're happy

  -- seen somewhere on the Internet on a photo of a billboard


Reply to: