| Submitter | Geoff Levand |
|---|---|
| Date | March 25, 2009, 10:35 p.m. |
| Message ID | <20090325223547.363732948@am.sony.com>> |
| Download | mbox | patch |
| Permalink | /patch/25113/ |
| State | Accepted |
| Delegated to: | Jeremy Kerr |
| Headers | show |
Comments
Geoff, > + /* test for urls */ > + > + if (!strncasecmp(path, s_file, sizeof(s_file) - 1)) > + path += sizeof(s_file) - 1; > + else if (strstr(path, "://")) > + return talloc_strdup(alloc_ctx, path); > + > sep = strchr(path, ':'); > if (!sep) { > devpath = mountpoint_for_device(current_dev); We're going to run into problems with this 'sep' test there, we should probably only do that chunk of code when it's not a URL. Cheers, Jeremy
Hi Jeremy, On 03/30/2009 01:34 AM, Jeremy Kerr wrote: >> + /* test for urls */ >> + >> + if (!strncasecmp(path, s_file, sizeof(s_file) - 1)) >> + path += sizeof(s_file) - 1; >> + else if (strstr(path, "://")) >> + return talloc_strdup(alloc_ctx, path); >> + >> sep = strchr(path, ':'); >> if (!sep) { >> devpath = mountpoint_for_device(current_dev); > > We're going to run into problems with this 'sep' test there, we should > probably only do that chunk of code when it's not a URL. I think this should be OK. Here is what I considered: 1 = /boot/vmlinux 2 = /dev/ps3da1:/boot/vmlinux 3 = tftp://192.168.0.5/ps3/vmlinux 4 = file:///boot/vmlinux (1) will be relative to the .conf file. (2) will use the specified device. (3) just returns path (the full URL). (4) is the same as (1), except for the leading 'file://', so just strip that off and process it like (1). Is there something I missed? -Geoff
Patch
--- a/discover/paths.c +++ b/discover/paths.c @@ -116,9 +116,17 @@ const char *mountpoint_for_device(const char *resolve_path(void *alloc_ctx, const char *path, const char *current_dev) { + static const char s_file[] = "file://"; char *ret; const char *devpath, *sep; + /* test for urls */ + + if (!strncasecmp(path, s_file, sizeof(s_file) - 1)) + path += sizeof(s_file) - 1; + else if (strstr(path, "://")) + return talloc_strdup(alloc_ctx, path); + sep = strchr(path, ':'); if (!sep) { devpath = mountpoint_for_device(current_dev);
Add a check to discover's resolve_path() to test if the path is a URL, and if so just return that path. If the path has "file://", treat it as a local path. Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com> --- discover/paths.c | 8 ++++++++ 1 file changed, 8 insertions(+)