[Pkg-sysvinit-commits] r1432 - in sysvinit-upstream/trunk: doc man src

Petter Reinholdtsen pere at alioth.debian.org
Sat Jul 11 06:45:24 UTC 2009


Author: pere
Date: 2009-07-11 06:45:23 +0000 (Sat, 11 Jul 2009)
New Revision: 1432

Modified:
   sysvinit-upstream/trunk/doc/Changelog
   sysvinit-upstream/trunk/man/bootlogd.8
   sysvinit-upstream/trunk/src/bootlogd.c
Log:
Add bootlogd option -c to tell it to create the log file if it does
not exist.  Patch from Thomas Hood.


Modified: sysvinit-upstream/trunk/doc/Changelog
===================================================================
--- sysvinit-upstream/trunk/doc/Changelog	2009-07-11 06:42:26 UTC (rev 1431)
+++ sysvinit-upstream/trunk/doc/Changelog	2009-07-11 06:45:23 UTC (rev 1432)
@@ -45,6 +45,8 @@
     the child successfully.
   * Add bootlogd option -s to make it possible to control the use of
     fdatasync().  Patch from Thomas Hood.
+  * Add bootlogd option -c to tell it to create the log file if it does
+    not exist.  Patch from Thomas Hood.
 
  -- Petter Reinholdtsen <pere at debian.org>  Fri, 30 Jul 2004 14:14:58 +0200
 

Modified: sysvinit-upstream/trunk/man/bootlogd.8
===================================================================
--- sysvinit-upstream/trunk/man/bootlogd.8	2009-07-11 06:42:26 UTC (rev 1431)
+++ sysvinit-upstream/trunk/man/bootlogd.8	2009-07-11 06:45:23 UTC (rev 1432)
@@ -3,6 +3,7 @@
 bootlogd \- record boot messages
 .SH SYNOPSIS
 .B /sbin/bootlogd
+.RB [ \-c ]
 .RB [ \-d ]
 .RB [ \-r ]
 .RB [ \-s ]
@@ -16,6 +17,12 @@
 .SH OPTIONS
 .IP \fB\-d\fP
 Do not fork and run in the background.
+.IP \fB\-c\fP
+Attempt to write to the logfile even if it does not yet exist.
+Without this option,
+.B bootlogd
+will wait for the logfile to appear before attempting to write to it.
+This behavior prevents bootlogd from creating logfiles under mount points.
 .IP \fB\-r\fP
 If there is an existing logfile called \fIlogfile\fP rename it to
 \fIlogfile~\fP unless \fIlogfile~\fP already exists.

Modified: sysvinit-upstream/trunk/src/bootlogd.c
===================================================================
--- sysvinit-upstream/trunk/src/bootlogd.c	2009-07-11 06:42:26 UTC (rev 1431)
+++ sysvinit-upstream/trunk/src/bootlogd.c	2009-07-11 06:45:23 UTC (rev 1432)
@@ -56,6 +56,7 @@
 
 int got_signal = 0;
 int didnl = 1;
+int createlogfile = 0;
 int syncalot = 0;
 
 struct line {
@@ -385,7 +386,7 @@
  */
 void usage(void)
 {
-	fprintf(stderr, "Usage: bootlogd [-v] [-r] [-d] [-p pidfile] [-l logfile]\n");
+	fprintf(stderr, "Usage: bootlogd [-v] [-r] [-d] [-s] [-c] [-p pidfile] [-l logfile]\n");
 	exit(1);
 }
 
@@ -447,7 +448,7 @@
 	rotate = 0;
 	dontfork = 0;
 
-	while ((i = getopt(argc, argv, "dsl:p:rv")) != EOF) switch(i) {
+	while ((i = getopt(argc, argv, "cdsl:p:rv")) != EOF) switch(i) {
 		case 'l':
 			logfile = optarg;
 			break;
@@ -461,6 +462,9 @@
 		case 'p':
 			pidfile = optarg;
 			break;
+		case 'c':
+			createlogfile = 1;
+			break;
 		case 'd':
 			dontfork = 1;
 			break;
@@ -613,12 +617,16 @@
 		/*
 		 *	Perhaps we need to open the logfile.
 		 */
-		if (fp == NULL && rotate && access(logfile, F_OK) == 0) {
-			snprintf(buf, sizeof(buf), "%s~", logfile);
-			rename(logfile, buf);
+		if (fp == NULL && access(logfile, F_OK) == 0) {
+			if (rotate) {
+				snprintf(buf, sizeof(buf), "%s~", logfile);
+				rename(logfile, buf);
+			}
+			fp = fopen(logfile, "a");
 		}
-		if (fp == NULL)
+		if (fp == NULL && createlogfile)
 			fp = fopen(logfile, "a");
+
 		if (inptr >= outptr)
 			todo = inptr - outptr;
 		else




More information about the Pkg-sysvinit-commits mailing list