]> git.ozlabs.org Git - petitboot/commitdiff
discover/paths: Add stdout callback parameter for load_url_async()
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>
Mon, 19 Dec 2016 00:41:23 +0000 (11:41 +1100)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Tue, 20 Dec 2016 05:40:21 +0000 (16:40 +1100)
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
discover/boot.c
discover/paths.c
discover/paths.h
discover/pxe-parser.c
test/parser/utils.c

index 5347fd7c1d45bbfbe748deaa12b44cdb2c4d930c..da7b946fcbb2dc2628b7df892fa4b752fca81a4c 100644 (file)
@@ -522,7 +522,8 @@ static int start_url_load(struct boot_task *task, const char *name,
        if (!url)
                return 0;
 
        if (!url)
                return 0;
 
-       *result = load_url_async(task, url, boot_process, task);
+       *result = load_url_async(task, url, boot_process, task, NULL,
+                                task->status_arg);
        if (!*result) {
                update_status(task->status_fn, task->status_arg,
                                STATUS_ERROR, _("Error loading %s"), name);
        if (!*result) {
                update_status(task->status_fn, task->status_arg,
                                STATUS_ERROR, _("Error loading %s"), name);
index 8d856192b15a1acb0635bcf1c5db792c8a275898..ad42b5b7760858e7cd3ab6d7217d855e91b72f15 100644 (file)
@@ -370,7 +370,8 @@ static void load_local(struct load_task *task)
  */
 
 struct load_url_result *load_url_async(void *ctx, struct pb_url *url,
  */
 
 struct load_url_result *load_url_async(void *ctx, struct pb_url *url,
-               load_url_complete async_cb, void *async_data)
+               load_url_complete async_cb, void *async_data,
+               waiter_cb stdout_cb, void *stdout_data)
 {
        struct load_url_result *result;
        struct load_task *task;
 {
        struct load_url_result *result;
        struct load_task *task;
@@ -390,6 +391,14 @@ struct load_url_result *load_url_async(void *ctx, struct pb_url *url,
                task->async_data = async_data;
                task->process->exit_cb = load_url_process_exit;
                task->process->data = task;
                task->async_data = async_data;
                task->process->exit_cb = load_url_process_exit;
                task->process->data = task;
+               task->process->stdout_cb = stdout_cb;
+               task->process->stdout_data = stdout_data;
+       }
+
+       /* Make sure we save output for any task that has a custom handler */
+       if (task->process->stdout_cb) {
+               task->process->add_stderr = true;
+               task->process->keep_stdout = true;
        }
 
        switch (url->scheme) {
        }
 
        switch (url->scheme) {
@@ -430,7 +439,7 @@ struct load_url_result *load_url_async(void *ctx, struct pb_url *url,
 
 struct load_url_result *load_url(void *ctx, struct pb_url *url)
 {
 
 struct load_url_result *load_url(void *ctx, struct pb_url *url)
 {
-       return load_url_async(ctx, url, NULL, NULL);
+       return load_url_async(ctx, url, NULL, NULL, NULL, NULL);
 }
 
 void load_url_async_cancel(struct load_url_result *res)
 }
 
 void load_url_async_cancel(struct load_url_result *res)
index 191b8dc84c6a5debcfeb3333362898f1b0d31f5a..35673b7eaef6cc1228d95019fd6ccfe0f5302612 100644 (file)
@@ -2,6 +2,8 @@
 #define PATHS_H
 
 #include <url/url.h>
 #define PATHS_H
 
 #include <url/url.h>
+#include <waiter/waiter.h>
+#include <process/process.h>
 
 /**
  * Utility function for joining two paths. Adds a / between a and b if
 
 /**
  * Utility function for joining two paths. Adds a / between a and b if
@@ -43,7 +45,8 @@ typedef void (*load_url_complete)(struct load_url_result *result, void *data);
 
 /* Load a (potentially remote) file, and return a guaranteed-local name */
 struct load_url_result *load_url_async(void *ctx, struct pb_url *url,
 
 /* Load a (potentially remote) file, and return a guaranteed-local name */
 struct load_url_result *load_url_async(void *ctx, struct pb_url *url,
-               load_url_complete complete, void *data);
+               load_url_complete complete, void *data,
+               waiter_cb stdout_cb, void *stdout_data);
 
 /* Cancel a pending load */
 void load_url_async_cancel(struct load_url_result *res);
 
 /* Cancel a pending load */
 void load_url_async_cancel(struct load_url_result *res);
index 046addbf85959ee25f77de4b36c2e18c7c98fca2..b51511a4b7a8dab7b1ff35a5845840af5ba258b9 100644 (file)
@@ -227,7 +227,8 @@ static void pxe_load_next_filename(struct conf_context *conf)
                if (!url)
                        continue;
 
                if (!url)
                        continue;
 
-               if (load_url_async(conf, url, pxe_conf_parse_cb, conf))
+               if (load_url_async(conf, url, pxe_conf_parse_cb, conf,
+                                  NULL, NULL))
                        break;
        }
 
                        break;
        }
 
@@ -380,7 +381,7 @@ static int pxe_parse(struct discover_context *dc)
 
                /* we have a complete URL; use this and we're done. */
                result = load_url_async(conf->dc, conf->dc->conf_url,
 
                /* we have a complete URL; use this and we're done. */
                result = load_url_async(conf->dc, conf->dc->conf_url,
-                                       pxe_conf_parse_cb, conf);
+                                       pxe_conf_parse_cb, conf, NULL, ctx);
                if (!result) {
                        pb_log("load_url_async fails for %s\n",
                                        dc->conf_url->path);
                if (!result) {
                        pb_log("load_url_async fails for %s\n",
                                        dc->conf_url->path);
index 9d40d2b1e17bf123326e263c0307e60e92206fc6..8900bd72bebdcf37ea04c316520b45f4b0db1a15 100644 (file)
@@ -310,7 +310,8 @@ int parser_replace_file(struct discover_context *ctx,
 }
 
 struct load_url_result *load_url_async(void *ctx, struct pb_url *url,
 }
 
 struct load_url_result *load_url_async(void *ctx, struct pb_url *url,
-               load_url_complete async_cb, void *async_data)
+               load_url_complete async_cb, void *async_data,
+               waiter_cb stdout_cb, void *stdout_data)
 {
        struct conf_context *conf = async_data;
        struct parser_test *test = conf->dc->test_data;
 {
        struct conf_context *conf = async_data;
        struct parser_test *test = conf->dc->test_data;
@@ -320,6 +321,10 @@ struct load_url_result *load_url_async(void *ctx, struct pb_url *url,
        struct test_file *file;
        int fd;
 
        struct test_file *file;
        int fd;
 
+       /* Ignore the stdout callback for tests */
+       (void)stdout_cb;
+       (void)stdout_data;
+
        fd = mkstemp(tmp);
 
        if (fd < 0)
        fd = mkstemp(tmp);
 
        if (fd < 0)