diff options
author | NeilBrown <neilb@suse.de> | 2010-02-04 06:31:49 +0100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-02-04 06:47:28 +0100 |
commit | 5d4d1b26d3da8b489ed7e2f5a38f7d90b7f4008f (patch) | |
tree | 86261d4f1521d7953bdbde959fd96bd0fb744d9c /mdmon.c | |
parent | Having single function to read mdmon pid file. (diff) | |
download | mdadm-5d4d1b26d3da8b489ed7e2f5a38f7d90b7f4008f.tar.xz mdadm-5d4d1b26d3da8b489ed7e2f5a38f7d90b7f4008f.zip |
mdmon: allow pid to be stored in different directory.
/var/run probably doesn't persist from early boot.
So if necessary, store in in /lib/init/rw or somewhere else
that does persist.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mdmon.c')
-rw-r--r-- | mdmon.c | 21 |
1 files changed, 9 insertions, 12 deletions
@@ -113,19 +113,16 @@ static struct superswitch *find_metadata_methods(char *vers) return NULL; } -int make_pidfile(char *devname, int o_excl) +int make_pidfile(char *devname) { char path[100]; char pid[10]; int fd; int n; - if (sigterm) - return -1; - - sprintf(path, "/var/run/mdadm/%s.pid", devname); + sprintf(path, "%s/%s.pid", pid_dir, devname); - fd = open(path, O_RDWR|O_CREAT|o_excl, 0600); + fd = open(path, O_RDWR|O_CREAT|O_EXCL, 0600); if (fd < 0) return -errno; sprintf(pid, "%d\n", getpid()); @@ -186,13 +183,13 @@ void remove_pidfile(char *devname) { char buf[100]; - if (sigterm) - return; - - sprintf(buf, "/var/run/mdadm/%s.pid", devname); + sprintf(buf, "%s/%s.pid", pid_dir, devname); unlink(buf); - sprintf(buf, "/var/run/mdadm/%s.sock", devname); + sprintf(buf, "%s/%s.sock", pid_dir, devname); unlink(buf); + if (strcmp(pid_dir, ALT_RUN) == 0) + /* try to clean up when we are finished with this dir */ + rmdir(pid_dir); } int make_control_sock(char *devname) @@ -205,7 +202,7 @@ int make_control_sock(char *devname) if (sigterm) return -1; - sprintf(path, "/var/run/mdadm/%s.sock", devname); + sprintf(path, "%s/%s.sock", pid_dir, devname); unlink(path); sfd = socket(PF_LOCAL, SOCK_STREAM, 0); if (sfd < 0) |