]> git.neil.brown.name Git - susman.git/commitdiff
Convert from /var/run to /run
authorNeilBrown <neilb@suse.de>
Sun, 22 Apr 2012 04:23:21 +0000 (14:23 +1000)
committerNeilBrown <neilb@suse.de>
Sun, 22 Apr 2012 04:23:21 +0000 (14:23 +1000)
New code should be using /run.  So pretend to be new.

Signed-off-by: NeilBrown <neilb@suse.de>
12 files changed:
README
block.sh
lsusd.c
lsused.c
request_suspend.c
susman.c
suspend.py
suspend_block.c
wakealarm.c
wakealarmd.c
wakeevent.c
watcher.c

diff --git a/README b/README
index 89b1c1e731234af3dc58459cf72e24ac09dc2e59..786742f85a625aca20e49b41f23b2134903e5799 100644 (file)
--- a/README
+++ b/README
@@ -10,7 +10,7 @@ It contains:
      required.  It obeys the wakeup_count protocol to get race-free
      suspend and allows clients to register to find out about
      suspend and to block it either briefly or longer term.
-    It uses files in /var/run/suspend for all communication.
+    It uses files in /run/suspend for all communication.
 
     File are:
 
@@ -48,7 +48,7 @@ It contains:
       services to client.
 
       lsused (which needs a better name) listens on the socket
-            /var/run/suspend/registration
+            /run/suspend/registration
       A client may connect and send a list of file descriptors.
       When a suspend is immanent, if any file descriptor is readable,
       lsused will send a 'S' message to the client and await an 'R' reply
@@ -61,7 +61,7 @@ It contains:
 
    wakealarmd:
       This allows clients to register on the socket.
-             /var/run/suspend/wakealarm
+             /run/suspend/wakealarm
       They write a timestamp in seconds since epoch, and will receive
       a 'Now' message when that time arrives.
       Between the time the connection is made and the time a "seconds"
index 50767d01b222509cc25b114aba022617c866f163..18145f4d2ad228284eedf82d8d996a64d9398ac6 100644 (file)
--- a/block.sh
+++ b/block.sh
@@ -18,7 +18,7 @@
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 block_suspend() {
-    exec 9< /var/run/suspend/disabled
+    exec 9< /run/suspend/disabled
     flock --shared 9
 }
 
diff --git a/lsusd.c b/lsusd.c
index c9eab8821ea4236e126ed78bf61a6bc8a8848d58..d16810a7fbeaa8d3d6fd1f649a81f7d68303f782 100644 (file)
--- a/lsusd.c
+++ b/lsusd.c
@@ -34,12 +34,12 @@ static void alert_watchers(void)
        int fd;
        char zero = 0;
 
-       fd = open("/var/run/suspend/watching-next",
+       fd = open("/run/suspend/watching-next",
                  O_RDWR|O_CREAT|O_TRUNC, 0640);
        if (fd < 0)
                return;
        close(fd);
-       fd = open("/var/run/suspend/watching",
+       fd = open("/run/suspend/watching",
                  O_RDWR|O_CREAT|O_TRUNC, 0640);
        if (fd < 0)
                return;
@@ -55,11 +55,11 @@ static void cycle_watchers(void)
        int fd;
        char zero[2];
 
-       fd = open("/var/run/suspend/watching", O_RDWR|O_CREAT, 0640);
+       fd = open("/run/suspend/watching", O_RDWR|O_CREAT, 0640);
        if (fd < 0)
                return;
-       rename("/var/run/suspend/watching-next",
-              "/var/run/suspend/watching");
+       rename("/run/suspend/watching-next",
+              "/run/suspend/watching");
        zero[0] = zero[1] = 0;
        write(fd, zero, 2);
        close(fd);
@@ -148,11 +148,11 @@ static int request_valid()
         * If the 'immediate' file is not locked, we remove
         * and ignore it as the requesting process has died
         */
-       int fd = open("/var/run/suspend/immediate", O_RDWR);
+       int fd = open("/run/suspend/immediate", O_RDWR);
        if (fd >= 0) {
                if (flock(fd, LOCK_EX|LOCK_NB) == 0) {
                        /* we got the lock, so owner must have died */
-                       unlink("/var/run/suspend/immediate");
+                       unlink("/run/suspend/immediate");
                        close(fd);
                } else {
                        /* Still valid */
@@ -160,7 +160,7 @@ static int request_valid()
                        return 1;
                }
        }
-       fd = open("/var/run/suspend/request", O_RDONLY);
+       fd = open("/run/suspend/request", O_RDONLY);
        if (fd < 0)
                return 0;
        close(fd);
@@ -182,10 +182,10 @@ main(int argc, char *argv)
        int dir;
        int disable;
 
-       mkdir("/var/run/suspend", 0770);
+       mkdir("/run/suspend", 0770);
 
-       dir = open("/var/run/suspend", O_RDONLY);
-       disable = open("/var/run/suspend/disabled", O_RDWR|O_CREAT, 0640);
+       dir = open("/run/suspend", O_RDONLY);
+       disable = open("/run/suspend/disabled", O_RDWR|O_CREAT, 0640);
 
        if (dir < 0 || disable < 0)
                exit(1);
@@ -202,12 +202,12 @@ main(int argc, char *argv)
                struct stat stb;
 
                /* Don't accept an old request */
-               unlink("/var/run/suspend/request");
+               unlink("/run/suspend/request");
                wait_request(dir);
                if (flock(disable, LOCK_EX|LOCK_NB) != 0) {
                        flock(disable, LOCK_EX);
                        flock(disable, LOCK_UN);
-                       unlink("/var/run/suspend/request");
+                       unlink("/run/suspend/request");
                        /* blocked - so need to ensure request still valid */
                        continue;
                }
index 8924cd77419f015ac1ed1fd266ed693d47ea4a5e..cef9fe9ffb66db9af0626dcda2eeba127cb75dd3 100644 (file)
--- a/lsused.c
+++ b/lsused.c
@@ -8,7 +8,7 @@
  * shared lock on the suspend/disabled file and then read the event.
  *
  * The client opens connects on a unix domain socket to
- * /var/run/suspend/registration
+ * /run/suspend/registration
  * It sets 'W' with some fds attached to be watched.
  * On notification if any fds are readable we send by 'S' to say
  * Suspend Soon and wait for 'R' to say 'Ready'.
@@ -248,8 +248,8 @@ main(int argc, char *argv[])
 
        s = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK|SOCK_CLOEXEC, 0);
        addr.sun_family = AF_UNIX;
-       strcpy(addr.sun_path, "/var/run/suspend/registration");
-       unlink("/var/run/suspend/registration");
+       strcpy(addr.sun_path, "/run/suspend/registration");
+       unlink("/run/suspend/registration");
        if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0)
                exit(1);
        listen(s, 20);
index c1141ee5a950aebf7d6ca9bb2d1891d224786c20..8b7116c39a40ee87b1311486b78b3c1629c94264 100644 (file)
@@ -31,10 +31,10 @@ static void catch(int sig)
 
 main(int argc, char *argv[])
 {
-       int dirfd = open("/var/run/suspend", O_RDONLY);
-       int fd_request = open("/var/run/suspend/request",
+       int dirfd = open("/run/suspend", O_RDONLY);
+       int fd_request = open("/run/suspend/request",
                              O_RDWR|O_CREAT, 0640);
-       int fd_watching = open("/var/run/suspend/watching", O_RDONLY);
+       int fd_watching = open("/run/suspend/watching", O_RDONLY);
        if (fd_request < 0)
                exit(2);
 
@@ -57,7 +57,7 @@ main(int argc, char *argv[])
                if (fstat(fd_request, &stat) != 0
                    || stat.st_nlink == 0) {
                        struct stat s1, s2;
-                       int fd_watching2 = open("/var/run/suspend/watching",
+                       int fd_watching2 = open("/run/suspend/watching",
                                                O_RDONLY);
                        if (fd_watching < 0 ||
                            fd_watching2 < 0 ||
index a33ee39f2af0800c7e30a2429e2e0f616f57a2e7..2db259af5e97b12bb92506464af68bfca0aa0f68 100644 (file)
--- a/susman.c
+++ b/susman.c
@@ -1,7 +1,7 @@
 /*
  * susman - manage suspend
  * This daemon forks and runs three processes
- * - one which manages suspend based on files in /var/run/suspend
+ * - one which manages suspend based on files in /run/suspend
  * - one which listens on a socket and handles suspend requests that way,
  * - one which provides a wakeup service using the RTC alarm.
  *
index 842b9a566fb6eb336ccc2c98e1115c0a4bac4b54..9f9357cf0ba5bfeb7b4d1e4b22ed53da6266d481 100644 (file)
@@ -32,13 +32,13 @@ class monitor:
         """
         global lock_watcher
         if not lock_watcher:
-            lock_watcher = dnotify.dir('/var/run/suspend')
+            lock_watcher = dnotify.dir('/run/suspend')
 
-        self.f = open('/var/run/suspend/watching', 'r')
+        self.f = open('/run/suspend/watching', 'r')
         self.getlock()
         while os.fstat(self.f.fileno()).st_nlink == 0:
             self.f.close()
-            self.f = open('/var/run/suspend/watching', 'r')
+            self.f = open('/run/suspend/watching', 'r')
             self.getlock()
 
         self.suspended = False
@@ -61,7 +61,7 @@ class monitor:
         if self.suspended:
             # resume has happened if watching-next has been renamed.
             if (os.fstat(self.f.fileno()).st_ino ==
-                os.stat('/var/run/suspend/watching').st_ino):
+                os.stat('/run/suspend/watching').st_ino):
                 global lock_watcher
                 self.suspended = False
                 self.watch.cancel()
@@ -80,7 +80,7 @@ class monitor:
         # ready for suspend
         global lock_watcher
         old = self.f
-        self.f = open('/var/run/suspend/watching-next', 'r')
+        self.f = open('/run/suspend/watching-next', 'r')
         self.getlock()
         self.suspended = True
         self.watch.cancel()
@@ -92,7 +92,7 @@ class monitor:
         if on:
             if self.immediate_fd:
                 return
-            self.immediate_fd = open('/var/run/suspend/immediate','w')
+            self.immediate_fd = open('/run/suspend/immediate','w')
             fcntl.flock(self.immediate_fd, fcntl.LOCK_EX)
             return
         else:
@@ -103,7 +103,7 @@ class monitor:
 
 class blocker:
     def __init__(self, blocked = True):
-        self.blockfd = open('/var/run/suspend/disabled')
+        self.blockfd = open('/run/suspend/disabled')
         if blocked:
             self.block()
     def block(self):
@@ -118,7 +118,7 @@ class blocker:
 
 
 def abort_cycle():
-    fd = open('/var/run/suspend/disabled')
+    fd = open('/run/suspend/disabled')
     fd.read(1)
     fd.close()
 
index 93dd5d91c40c11090fc01f6bfd3c217008845c3f..0c51da797e8c14f71c9d4f51079eff43ef8327ba 100644 (file)
@@ -25,7 +25,7 @@
 
 int suspend_open()
 {
-       return open("/var/run/suspend/disabled", O_RDONLY|O_CLOEXEC);
+       return open("/run/suspend/disabled", O_RDONLY|O_CLOEXEC);
 }
 
 int suspend_block(int handle)
index 65f83f7fd257835655ce0b4bfedb503f845b02b0..9a57c3aedecbab6a3fea9072ee1daba78a447969 100644 (file)
@@ -72,7 +72,7 @@ struct event *wakealarm_set(time_t when, void(*fn)(int, short, void*),
                goto abort;
 
        addr.sun_family = AF_UNIX;
-       strcpy(addr.sun_path, "/var/run/suspend/wakealarm");
+       strcpy(addr.sun_path, "/run/suspend/wakealarm");
        if (connect(h->sock, (struct sockaddr*)&addr, sizeof(addr)) != 0)
                goto abort;
 
index 8640fb372b226065db2db4721a8b4f47d6c579cd..dfd6adb61d587d2d2537da84c9f3fa33cad127bf 100644 (file)
@@ -221,8 +221,8 @@ int main(int argc, char *argv[])
 
        s = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK|SOCK_CLOEXEC, 0);
        addr.sun_family = AF_UNIX;
-       strcpy(addr.sun_path, "/var/run/suspend/wakealarm");
-       unlink("/var/run/suspend/wakealarm");
+       strcpy(addr.sun_path, "/run/suspend/wakealarm");
+       unlink("/run/suspend/wakealarm");
        if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0)
                exit(2);
        listen(s, 20);
index 3640e28e6671366ba018d59df63a56e0fd3a4dc8..0bb62be562a536aff6ad8e2c747314bc09d12d84 100644 (file)
@@ -112,7 +112,7 @@ struct event *wake_set(int fd, void(*fn)(int,short,void*), void *data, int prio)
        if (h->sock < 0 || h->disable < 0)
                goto abort;
        addr.sun_family = AF_UNIX;
-       strcpy(addr.sun_path, "/var/run/suspend/registration");
+       strcpy(addr.sun_path, "/run/suspend/registration");
        if (connect(h->sock, (struct sockaddr*)&addr, sizeof(addr)) != 0)
                goto abort;
 
index 1049e8ce6e3d2d5231c0ce86f2544d6838bc4735..62feff6bdd70ec501ce3c887d83b8552b9c4616c 100644 (file)
--- a/watcher.c
+++ b/watcher.c
@@ -75,7 +75,7 @@ static void checkdir(int efd, short ev, void *vp)
                return;
 
        /* We need to move on now. */
-       fd = open("/var/run/suspend/watching-next", O_RDONLY|O_CLOEXEC);
+       fd = open("/run/suspend/watching-next", O_RDONLY|O_CLOEXEC);
        flock(fd, LOCK_SH);
        han->nextfd = fd;
        rv = han->will_suspend(han->data);
@@ -107,12 +107,12 @@ void *suspend_watch(int (*will_suspend)(void *data),
        han->nextfd = -1;
        signal_set(&han->ev, SIGIO, checkdir, han);
        signal_add(&han->ev, NULL);
-       han->dirfd = open("/var/run/suspend", O_RDONLY|O_CLOEXEC);
+       han->dirfd = open("/run/suspend", O_RDONLY|O_CLOEXEC);
        if (han->dirfd < 0)
                goto abort;
        fcntl(han->dirfd, F_NOTIFY, DN_MODIFY | DN_MULTISHOT);
 again:
-       fd = open("/var/run/suspend/watching", O_RDONLY|O_CLOEXEC);
+       fd = open("/run/suspend/watching", O_RDONLY|O_CLOEXEC);
        flock(fd, LOCK_SH);
        han->fd = fd;
        checkdir(0, 0, han);