Skip to content

Commit

Permalink
init: If "quiet" is found on the command line, suppress debug output.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwmjones committed Mar 18, 2016
1 parent e434bb8 commit 43559d6
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions init/init.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ static const char *moderror(int err)
} }
} }


/* Leave this enabled for now. When we get more confident in the boot /* If "quiet" is found on the command line, set this which suppresses
* process we can turn this off or make it configurable. * ordinary debug messages.
*/ */
#define verbose 1 static int quiet = 0;


static void mount_proc (void); static void mount_proc (void);
static void print_uptime (void); static void print_uptime (void);
Expand All @@ -90,7 +90,6 @@ main ()
{ {
mount_proc (); mount_proc ();


print_uptime ();
fprintf (stderr, "supermin: ext2 mini initrd starting up: " fprintf (stderr, "supermin: ext2 mini initrd starting up: "
PACKAGE_VERSION PACKAGE_VERSION
#if defined(__dietlibc__) #if defined(__dietlibc__)
Expand All @@ -105,14 +104,20 @@ main ()
"\n"); "\n");


read_cmdline (); read_cmdline ();
quiet = strstr (cmdline, "quiet") != NULL;

if (!quiet) {
fprintf (stderr, "supermin: cmdline: %s\n", cmdline);
print_uptime ();
}


/* Create some fixed directories. */ /* Create some fixed directories. */
mkdir ("/dev", 0755); mkdir ("/dev", 0755);
mkdir ("/root", 0755); mkdir ("/root", 0755);
mkdir ("/sys", 0755); mkdir ("/sys", 0755);


/* Mount /sys. */ /* Mount /sys. */
if (verbose) if (!quiet)
fprintf (stderr, "supermin: mounting /sys\n"); fprintf (stderr, "supermin: mounting /sys\n");
if (mount ("sysfs", "/sys", "sysfs", 0, "") == -1) { if (mount ("sysfs", "/sys", "sysfs", 0, "") == -1) {
perror ("mount: /sys"); perror ("mount: /sys");
Expand Down Expand Up @@ -208,7 +213,7 @@ main ()
exit (EXIT_FAILURE); exit (EXIT_FAILURE);


found: found:
if (verbose) if (!quiet)
fprintf (stderr, "supermin: picked %s as root device\n", path); fprintf (stderr, "supermin: picked %s as root device\n", path);


fgets (line, sizeof line, fp); fgets (line, sizeof line, fp);
Expand All @@ -229,7 +234,7 @@ main ()
perror ("ioctl: TIOCSCTTY"); perror ("ioctl: TIOCSCTTY");
#endif #endif


if (verbose) if (!quiet)
fprintf (stderr, "supermin: creating /dev/root as block special %d:%d\n", fprintf (stderr, "supermin: creating /dev/root as block special %d:%d\n",
major, minor); major, minor);


Expand All @@ -239,7 +244,7 @@ main ()
} }


/* Mount new root and chroot to it. */ /* Mount new root and chroot to it. */
if (verbose) if (!quiet)
fprintf (stderr, "supermin: mounting new root on /root\n"); fprintf (stderr, "supermin: mounting new root on /root\n");
if (mount ("/dev/root", "/root", "ext2", MS_NOATIME, "") == -1) { if (mount ("/dev/root", "/root", "ext2", MS_NOATIME, "") == -1) {
perror ("mount: /root"); perror ("mount: /root");
Expand All @@ -250,7 +255,7 @@ main ()
* Documentation/filesystems/ramfs-rootfs-initramfs.txt * Documentation/filesystems/ramfs-rootfs-initramfs.txt
* We could remove the old initramfs files, but let's not bother. * We could remove the old initramfs files, but let's not bother.
*/ */
if (verbose) if (!quiet)
fprintf (stderr, "supermin: chroot\n"); fprintf (stderr, "supermin: chroot\n");


if (chroot ("/root") == -1) { if (chroot ("/root") == -1) {
Expand Down Expand Up @@ -282,7 +287,7 @@ insmod (const char *filename)
{ {
size_t size; size_t size;


if (verbose) if (!quiet)
fprintf (stderr, "supermin: internal insmod %s\n", filename); fprintf (stderr, "supermin: internal insmod %s\n", filename);


int fd = open (filename, O_RDONLY); int fd = open (filename, O_RDONLY);
Expand Down Expand Up @@ -323,7 +328,7 @@ mount_proc (void)
if (access ("/proc/uptime", R_OK) == -1) { if (access ("/proc/uptime", R_OK) == -1) {
mkdir ("/proc", 0755); mkdir ("/proc", 0755);


if (verbose) if (!quiet)
fprintf (stderr, "supermin: mounting /proc\n"); fprintf (stderr, "supermin: mounting /proc\n");


if (mount ("proc", "/proc", "proc", 0, "") == -1) { if (mount ("proc", "/proc", "proc", 0, "") == -1) {
Expand Down Expand Up @@ -370,8 +375,6 @@ read_cmdline (void)
len = strlen (cmdline); len = strlen (cmdline);
if (len >= 1 && cmdline[len-1] == '\n') if (len >= 1 && cmdline[len-1] == '\n')
cmdline[len-1] = '\0'; cmdline[len-1] = '\0';

fprintf (stderr, "supermin: cmdline: %s\n", cmdline);
} }


/* Display a directory on stderr. This is used for debugging only. */ /* Display a directory on stderr. This is used for debugging only. */
Expand Down

0 comments on commit 43559d6

Please sign in to comment.