X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=lib%2Fsystem%2Fsystem.c;h=cbf6b9fc5a8b43472dc5c4ea7b823e83b196ee8a;hp=1b506d2edaf6b5e84f9ea4211e0cac1b189f3d31;hb=16ebe978aeced862dd877cfee81ac7604902fd55;hpb=604a1ccf072f9f33326fb6dc919c1b6233d40866 diff --git a/lib/system/system.c b/lib/system/system.c index 1b506d2..cbf6b9f 100644 --- a/lib/system/system.c +++ b/lib/system/system.c @@ -17,15 +17,16 @@ #include "system.h" const struct pb_system_apps pb_system_apps = { - .prefix = PREFIX, - .cp = "/bin/cp", - .kexec = "/sbin/kexec", - .mount = "/bin/mount", - .shutdown = "/sbin/shutdown", - .sftp = "/usr/bin/sftp", - .tftp = "/usr/bin/tftp", - .umount = "/bin/umount", - .wget = "/usr/bin/wget", + .prefix = PREFIX, + .cp = HOST_PROG_CP, + .kexec = HOST_PROG_KEXEC, + .mount = HOST_PROG_MOUNT, + .shutdown = HOST_PROG_SHUTDOWN, + .sftp = HOST_PROG_SFTP, + .tftp = HOST_PROG_TFTP, + .udevadm = HOST_PROG_UDEVADM, + .umount = HOST_PROG_UMOUNT, + .wget = HOST_PROG_WGET, }; int pb_mkdir_recursive(const char *dir) @@ -103,9 +104,11 @@ int pb_rmdir_recursive(const char *base, const char *dir) /** * pb_run_cmd - Run the supplied command. * @cmd_argv: An argument list array for execv. + * @wait: Wait for the child process to complete before returning. + * @dry_run: Don't actually fork and exec. */ -int pb_run_cmd(const char *const *cmd_argv, int wait) +int pb_run_cmd(const char *const *cmd_argv, int wait, int dry_run) { #if defined(DEBUG) enum {do_debug = 1}; @@ -118,14 +121,19 @@ int pb_run_cmd(const char *const *cmd_argv, int wait) if (do_debug) { const char *const *p = cmd_argv; - pb_log("%s: ", __func__); + pb_log("%s: %s", __func__, (dry_run ? "(dry-run) " : "")); + while (*p) { pb_log("%s ", *p); p++; } pb_log("\n"); } else - pb_log("%s: %s\n", __func__, cmd_argv[0]); + pb_log("%s: %s%s\n", __func__, (dry_run ? "(dry-run) " : ""), + cmd_argv[0]); + + if (dry_run) + return 0; pid = fork();