X-Git-Url: https://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fpaths.c;h=8d856192b15a1acb0635bcf1c5db792c8a275898;hp=54774cf3b6135cb9ffdac41b0f3f731e7699d1b0;hb=1abc62990a5817de56a55470fb2c62e966134722;hpb=2ad0e66f61e8f8488cff208f8bb7f5127ec9f813 diff --git a/discover/paths.c b/discover/paths.c index 54774cf..8d85619 100644 --- a/discover/paths.c +++ b/discover/paths.c @@ -6,6 +6,8 @@ #include #include #include +#include +#include #include #include @@ -45,13 +47,17 @@ char *join_paths(void *alloc_ctx, const char *a, const char *b) return full_path; } +#ifndef PETITBOOT_TEST static char *local_name(void *ctx) { char *ret, tmp[] = "/tmp/pb-XXXXXX"; + mode_t oldmask; int fd; + oldmask = umask(0644); fd = mkstemp(tmp); + umask(oldmask); if (fd < 0) return NULL; @@ -220,15 +226,16 @@ static enum tftp_type check_tftp_type(void *ctx) const char *argv[] = { pb_system_apps.tftp, "-V", NULL }; struct process *process; enum tftp_type type; + int rc; process = process_create(ctx); process->path = pb_system_apps.tftp; process->argv = argv; process->keep_stdout = true; process->add_stderr = true; - process_run_sync(process); + rc = process_run_sync(process); - if (!process->stdout_buf || process->stdout_len == 0) { + if (rc || !process->stdout_buf || process->stdout_len == 0) { pb_log("Can't check TFTP client type!\n"); type = TFTP_TYPE_BROKEN; @@ -310,8 +317,9 @@ static void load_wget(struct load_task *task, int flags) pb_system_apps.wget, "-O", NULL, /* 2: local file */ - NULL, - NULL, + NULL, /* 3 (optional): --quiet */ + NULL, /* 4 (optional): --no-check-certificate */ + NULL, /* 5: URL */ NULL, }; int i; @@ -375,6 +383,7 @@ struct load_url_result *load_url_async(void *ctx, struct pb_url *url, task->async = async_cb != NULL; task->result = talloc_zero(ctx, struct load_url_result); task->result->task = task; + task->result->url = url; task->process = process_create(task); if (task->async) { task->async_cb = async_cb; @@ -442,3 +451,33 @@ void load_url_async_cancel(struct load_url_result *res) res->status = LOAD_CANCELLED; process_stop_async(task->process); } + +#else + +static void __attribute__((unused)) load_local( + struct load_task *task __attribute__((unused))) +{ +} +static void __attribute__((unused)) load_wget( + struct load_task *task __attribute__((unused)), + int flags __attribute__((unused))) +{ +} +static void __attribute__((unused)) load_tftp( + struct load_task *task __attribute__((unused))) +{ +} +static void __attribute__((unused)) load_sftp( + struct load_task *task __attribute__((unused))) +{ +} +static void __attribute__((unused)) load_nfs( + struct load_task *task __attribute__((unused))) +{ +} +static void __attribute__((unused)) load_url_process_exit( + struct process *process __attribute__((unused))) +{ +} + +#endif