mirror of
https://github.com/troglobit/finit.git
synced 2026-11-08 16:11:10 +00:00
Add timestamps to debug messages to help profiling
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
This commit is contained in:
1 parent
3ce7638dab
commit
804aa3c747
1 file changed
+35
-5
+35
-5
@@ -129,6 +129,31 @@ void chld_handler(int);
|
|||||||
|
|
||||||
static int debug = 0;
|
static int debug = 0;
|
||||||
|
|
||||||
|
#ifdef DEBUG_TIMESTAMP
|
||||||
|
#include <time.h>
|
||||||
|
int _d(char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
struct timeval t;
|
||||||
|
|
||||||
|
if (!debug)
|
||||||
|
return;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
|
||||||
|
gettimeofday(&t);
|
||||||
|
printf("[%d.%03d] ", t.tv_sec, t.tv_usec / 1000);
|
||||||
|
vprintf(fmt, ap);
|
||||||
|
printf("\n");
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define _d(x...) do { if (debug) printf(x); printf("\n"); } while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void build_cmd(char *cmd, char *x, int len)
|
static void build_cmd(char *cmd, char *x, int len)
|
||||||
{
|
{
|
||||||
int l;
|
int l;
|
||||||
@@ -143,8 +168,8 @@ static void build_cmd(char *cmd, char *x, int len)
|
|||||||
for (l = 0; *x && *x != '#' && *x != '\t' && l < len; l++)
|
for (l = 0; *x && *x != '#' && *x != '\t' && l < len; l++)
|
||||||
*c++ = *x++;
|
*c++ = *x++;
|
||||||
*c = 0;
|
*c = 0;
|
||||||
if (debug)
|
|
||||||
printf("cmd = %s\n", cmd);
|
_d("cmd = %s", cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -271,8 +296,7 @@ int main()
|
|||||||
fgets(line, LINE_SIZE, f);
|
fgets(line, LINE_SIZE, f);
|
||||||
chomp(line);
|
chomp(line);
|
||||||
|
|
||||||
if (debug)
|
_d("conf: %s", line);
|
||||||
printf("conf: %s\n", line);
|
|
||||||
|
|
||||||
/* Do this before mounting / read-write */
|
/* Do this before mounting / read-write */
|
||||||
if (MATCH_CMD(line, "check ", x)) {
|
if (MATCH_CMD(line, "check ", x)) {
|
||||||
@@ -331,6 +355,8 @@ int main()
|
|||||||
/*
|
/*
|
||||||
* Mount filesystems
|
* Mount filesystems
|
||||||
*/
|
*/
|
||||||
|
_d("mount filesystems");
|
||||||
|
|
||||||
#ifdef REMOUNT_ROOTFS_RW
|
#ifdef REMOUNT_ROOTFS_RW
|
||||||
system("/bin/mount -n -o remount,rw /");
|
system("/bin/mount -n -o remount,rw /");
|
||||||
#endif
|
#endif
|
||||||
@@ -350,6 +376,7 @@ int main()
|
|||||||
mount("none", "/proc/bus/usb", "usbfs", 0, NULL);
|
mount("none", "/proc/bus/usb", "usbfs", 0, NULL);
|
||||||
mount(SYSROOT, "/", NULL, MS_MOVE, NULL);
|
mount(SYSROOT, "/", NULL, MS_MOVE, NULL);
|
||||||
|
|
||||||
|
_d("make devices");
|
||||||
#ifdef MAKE_DEVICES
|
#ifdef MAKE_DEVICES
|
||||||
mkdir("/dev/input", 0755);
|
mkdir("/dev/input", 0755);
|
||||||
chardev("/dev/urandom", 0666, 1, 9);
|
chardev("/dev/urandom", 0666, 1, 9);
|
||||||
@@ -379,6 +406,7 @@ int main()
|
|||||||
write(fd, "0.0 0 0.0\n", 10);
|
write(fd, "0.0 0 0.0\n", 10);
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
_d("adjust clock");
|
||||||
#ifndef NO_HCTOSYS
|
#ifndef NO_HCTOSYS
|
||||||
system("/sbin/hwclock --hctosys --localtime" HWCLOCK_DIRECTISA);
|
system("/sbin/hwclock --hctosys --localtime" HWCLOCK_DIRECTISA);
|
||||||
#endif
|
#endif
|
||||||
@@ -512,11 +540,13 @@ int main()
|
|||||||
touch("/tmp/nologin");
|
touch("/tmp/nologin");
|
||||||
|
|
||||||
#ifdef USE_MESSAGE_BUS
|
#ifdef USE_MESSAGE_BUS
|
||||||
|
_d("dbus");
|
||||||
mkdir("/var/run/dbus", 0755);
|
mkdir("/var/run/dbus", 0755);
|
||||||
mkdir("/var/lock/subsys/messagebus", 0755);
|
mkdir("/var/lock/subsys/messagebus", 0755);
|
||||||
system(MESSAGE_BUS_START);
|
system(MESSAGE_BUS_START);
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_CONSOLEKIT
|
#ifdef USE_CONSOLEKIT
|
||||||
|
_d("consolekit");
|
||||||
system("/usr/sbin/console-kit-daemon");
|
system("/usr/sbin/console-kit-daemon");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -525,8 +555,8 @@ int main()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
while (access("/tmp/shutdown", F_OK) < 0) {
|
while (access("/tmp/shutdown", F_OK) < 0) {
|
||||||
|
_d("start X as %s\n", username);
|
||||||
if (debug) {
|
if (debug) {
|
||||||
printf("Starting X as %s\n", username);
|
|
||||||
snprintf(line, LINE_SIZE,
|
snprintf(line, LINE_SIZE,
|
||||||
"su -c startx -l %s\n", username);
|
"su -c startx -l %s\n", username);
|
||||||
system(line);
|
system(line);
|
||||||
|
|||||||
Reference in new issue
Block a user