sysvinit-devel
[Top][All Lists]
Advanced

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

[sysvinit] [patch] Gracefully migrate from /etc/powerstatus to /var/run/


From: Petter Reinholdtsen
Subject: [sysvinit] [patch] Gracefully migrate from /etc/powerstatus to /var/run/powerstatus?
Date: Sun, 21 Mar 2010 11:11:35 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Hi, Werner.  I noticed this incompatible change in doc/ChangeLog:

  * Change path "/etc/powerstatus" to "/var/run/powerstatus"

Why was this change implemented, and who are the users of the old
path?

It seem to me like a bad idea to change the path used to communicate
with init without backwards compatibility code and some time to
migrate the programs using the old path.  Because of this, I propose
something like this to make sure the old path is checked too, and a
warning is printed when it is found.

Index: src/init.c
===================================================================
--- src/init.c  (revision 44)
+++ src/init.c  (working copy)
@@ -2393,7 +2396,16 @@
                pwrstat = c;
                close(fd);
                unlink(PWRSTAT);
-       }
+       } else if ((fd = open(PWRSTAT_OLD, O_RDONLY)) >= 0) {
+               /* Path changed 2010-03-20.  Look for the old path for a while. 
*/
+               initlog(L_VB, "warning: found obsolete path %s, use %s instead",
+                       PWRSTAT_OLD, PWRSTAT);
+               c = 0;
+               read(fd, &c, 1);
+               pwrstat = c;
+               close(fd);
+               unlink(PWRSTAT_OLD);
+        }
        do_power_fail(pwrstat);
        DELSET(got_signals, SIGPWR);
   }
Index: src/paths.h
===================================================================
--- src/paths.h (revision 44)
+++ src/paths.h (working copy)
@@ -35,6 +35,7 @@
 #define SHELL          "/bin/sh"               /* Default shell */
 #define SULOGIN                "/sbin/sulogin"         /* Sulogin */
 #define INITSCRIPT     "/etc/initscript"       /* Initscript. */
+#define PWRSTAT_OLD    "/etc/powerstatus"      /* COMPAT: SIGPWR reason 
(OK/BAD) */
 #define PWRSTAT                "/var/run/powerstatus"  /* COMPAT: SIGPWR 
reason (OK/BAD) */

 #if 0

Happy hacking,
-- 
Petter Reinholdtsen




reply via email to

[Prev in Thread] Current Thread [Next in Thread]