Re: Silencing ostree-prepare-root



On Tue, Apr 3, 2018 at 2:10 PM, Colin Walters <walters verbum org> wrote:


On Fri, Mar 30, 2018, at 1:56 AM, Alex Kiernan wrote:
I'm trying to completely silence my boot, one of the messages I've got left is:

  Examining ///ostree/boot.1/nano/
c613fde731cc1c6fde4cb55b0f7c57eb2b9b9a493e8302c5e27aeb7575f6aaeb/0
  Resolved OSTree target to:
/ostree/deploy/nano/deploy/
c0970c3d90379b6a869d55d1d2812f306dd591a814d8dae4636bdf16245b63a8.0

Parsing out an additional kernel command line parameter is obviously
easy, but is that a sensible approach? Picking say 'quiet' seems like
an obvious option, but any thoughts?

If this looks good to you I can toss it into a PR:

diff --git a/src/switchroot/ostree-prepare-root.c b/src/switchroot/ostree-prepare-root.c
index a5c3c785..d8fa73c2 100644
--- a/src/switchroot/ostree-prepare-root.c
+++ b/src/switchroot/ostree-prepare-root.c
@@ -60,7 +60,9 @@ resolve_deploy_path (const char * root_mountpoint)
     errx (EXIT_FAILURE, "No OSTree target; expected ostree=/ostree/boot.N/...");

   snprintf (destpath, sizeof(destpath), "%s/%s", root_mountpoint, ostree_target);
-  printf ("Examining %s\n", destpath);
+  /* In systemd case this goes to the journal, but be silent if we're init */
+  if (getpid() != 1)
+    printf ("Examining %s\n", destpath);
   if (lstat (destpath, &stbuf) < 0)
     err (EXIT_FAILURE, "Couldn't find specified OSTree root '%s'", destpath);
   if (!S_ISLNK (stbuf.st_mode))
@@ -68,7 +70,8 @@ resolve_deploy_path (const char * root_mountpoint)
   deploy_path = realpath (destpath, NULL);
   if (deploy_path == NULL)
     err (EXIT_FAILURE, "realpath(%s) failed", destpath);
-  printf ("Resolved OSTree target to: %s\n", deploy_path);
+  if (getpid() != 1)
+    printf ("Resolved OSTree target to: %s\n", deploy_path);
   return deploy_path;
 }


I'm on holiday, so I can't test it out, but from inspection it looks
like it'd do exactly what I need.

-- 
Alex Kiernan


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]