From 9d164ac31265c8438968d613dc89a97b8a4eafb7 Mon Sep 17 00:00:00 2001 From: Claudio Matsuoka Date: Fri, 2 May 2008 15:34:13 -0300 Subject: [PATCH] Enable runtime debug in finit-alt if DEBUG parameter is specified Signed-off-by: Claudio Matsuoka --- Changelog | 2 +- Makefile | 3 --- finit-alt.c | 31 ++++++++++--------------------- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/Changelog b/Changelog index 2c65acd5..c93bf903 100644 --- a/Changelog +++ b/Changelog @@ -7,7 +7,7 @@ O.4 () - add services.sh example and nash-hotplug patch for Mandriva - mount /proc/bus/usb in Mandriva - finit-mdv checks filesystem if CHECKFS= parameter is specified - + - add runtime debug to finit-alt if DEBUG parameter is specified 0.3 (20080223) - Change poweroff method to reboot(RB_POWER_OFF) (Metalshark) diff --git a/Makefile b/Makefile index 1518126d..acd6a5ec 100644 --- a/Makefile +++ b/Makefile @@ -16,9 +16,6 @@ BINS = finit finit-mod finit-mdv # Default user for finit-alt if not "user" #DEFUSER = fred -# Add -DDEBUG to build with debug messages, also drops to terminal after X -#CFLAGS += -DDEBUG - # Use -march=pentium-m to build for Eeepc CFLAGS += -march=pentium-m diff --git a/finit-alt.c b/finit-alt.c index b2eda033..201f9a6e 100644 --- a/finit-alt.c +++ b/finit-alt.c @@ -40,14 +40,6 @@ THE SOFTWARE. #include "helpers.h" -#ifdef DEBUG -#define debug(x...) do { \ - printf("finit: %d: ", __LINE__); printf(x); printf("\n"); \ - } while (0) -#else -#define debug(x...) -#endif - #ifndef DEFUSER #define DEFUSER "user" #endif @@ -110,6 +102,7 @@ int main() struct sigaction sa, act; char *x; sigset_t nmask, nmask2; + int debug = 0; puts("finit-alt " VERSION " (built " __DATE__ " by " WHOAMI ")"); @@ -164,6 +157,9 @@ int main() reboot(RB_AUTOBOOT); } #endif + if ((strstr(line, "DEBUG"))) { + debug = 1; + } fclose(f); } @@ -172,8 +168,6 @@ int main() /* * Mount filesystems */ - debug("mount filesystems"); - #ifdef REMOUNT_ROOTFS_RW system("/bin/mount -n -o remount,rw /"); #endif @@ -194,7 +188,6 @@ int main() mount(SYSROOT, "/", NULL, MS_MOVE, NULL); #ifdef MAKE_DEVICES - debug("make devices"); mkdir("/dev/input", 0755); chardev("/dev/urandom", 0666, 1, 9); chardev("/dev/ptmx", 0666, 5, 2); @@ -300,8 +293,6 @@ int main() mkdir("/tmp/.ICE-unix", 01777); umask(022); - debug("forking"); - if (!fork()) { /* child process */ @@ -336,13 +327,12 @@ int main() #endif while (access("/tmp/shutdown", F_OK) < 0) { - debug("start X as " DEFUSER); -#ifdef DEBUG - system("su -c startx -l " DEFUSER); - system("/bin/sh"); -#else - system("su -c startx -l " DEFUSER " &> /dev/null"); -#endif + if (debug) { + system("su -c startx -l " DEFUSER); + system("/bin/sh"); + } else { + system("su -c startx -l " DEFUSER " &> /dev/null"); + } } exit(0); @@ -366,7 +356,6 @@ int main() */ void shutdown(int sig) { - debug("shutdown"); touch("/tmp/shutdown"); kill(-1, SIGTERM);