From: NeilBrown Date: Sun, 22 Apr 2012 04:23:21 +0000 (+1000) Subject: Convert from /var/run to /run X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=a9cd08f797421a400462486801693b6d8705f3f1;p=susman.git Convert from /var/run to /run New code should be using /run. So pretend to be new. Signed-off-by: NeilBrown --- diff --git a/README b/README index 89b1c1e..786742f 100644 --- 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" diff --git a/block.sh b/block.sh index 50767d0..18145f4 100644 --- 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 c9eab88..d16810a 100644 --- 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; } diff --git a/lsused.c b/lsused.c index 8924cd7..cef9fe9 100644 --- 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); diff --git a/request_suspend.c b/request_suspend.c index c1141ee..8b7116c 100644 --- a/request_suspend.c +++ b/request_suspend.c @@ -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 || diff --git a/susman.c b/susman.c index a33ee39..2db259a 100644 --- 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. * diff --git a/suspend.py b/suspend.py index 842b9a5..9f9357c 100644 --- a/suspend.py +++ b/suspend.py @@ -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() diff --git a/suspend_block.c b/suspend_block.c index 93dd5d9..0c51da7 100644 --- a/suspend_block.c +++ b/suspend_block.c @@ -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) diff --git a/wakealarm.c b/wakealarm.c index 65f83f7..9a57c3a 100644 --- a/wakealarm.c +++ b/wakealarm.c @@ -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; diff --git a/wakealarmd.c b/wakealarmd.c index 8640fb3..dfd6adb 100644 --- a/wakealarmd.c +++ b/wakealarmd.c @@ -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); diff --git a/wakeevent.c b/wakeevent.c index 3640e28..0bb62be 100644 --- a/wakeevent.c +++ b/wakeevent.c @@ -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; diff --git a/watcher.c b/watcher.c index 1049e8c..62feff6 100644 --- 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);