summaryrefslogtreecommitdiffstats
path: root/discover
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-09-26 15:15:29 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-09-26 15:20:59 +0800
commit384d406380d8bf164ed2ca3879488cc4974239be (patch)
treede69ec7911a7fc8abb4390f5436c3f842fd53180 /discover
parent2e97d0eea0d8a480877a1aabb4c67ad1aad59ed1 (diff)
downloadtalos-petitboot-384d406380d8bf164ed2ca3879488cc4974239be.tar.gz
talos-petitboot-384d406380d8bf164ed2ca3879488cc4974239be.zip
discover/paths: Check local file URLs in load_url
Make the error case for local files the same as for remotes. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover')
-rw-r--r--discover/paths.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/discover/paths.c b/discover/paths.c
index b163e45..c352ca0 100644
--- a/discover/paths.c
+++ b/discover/paths.c
@@ -313,6 +313,25 @@ static void load_wget(struct load_task *task, int flags)
load_process_to_local_file(task, argv, 2);
}
+/* Although we don't need to load anything for a local path (we just return
+ * the path from the file:// URL), the other load helpers will error-out on
+ * non-existant files. So, do the same here with an access() check on the local
+ * filename.
+ */
+static void load_local(struct load_task *task)
+{
+ int rc;
+
+ rc = access(task->url->path, F_OK);
+ if (rc) {
+ task->result->status = LOAD_ERROR;
+ } else {
+ task->result->local = talloc_strdup(task->result,
+ task->url->path);
+ task->result->status = LOAD_OK;
+ }
+}
+
/**
* load_url - Loads a (possibly) remote URL and returns the local file
* path.
@@ -366,9 +385,7 @@ struct load_url_result *load_url_async(void *ctx, struct pb_url *url,
load_tftp(task);
break;
default:
- task->result->local = talloc_strdup(task->result,
- url->path);
- task->result->status = LOAD_OK;
+ load_local(task);
break;
}
OpenPOWER on IntegriCloud