diff options
author | Doug Ledford <dledford@redhat.com> | 2010-04-02 10:53:47 -0400 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2010-04-13 12:55:35 -0400 |
commit | 9f55479619c156538434921cbaac0bafa8bccb86 (patch) | |
tree | 840c5cfbc5fdb92b02b3bc22ca8853a35355cffb /mdmon.c | |
parent | b8d3bda04cbb5c5ff289b16f33401f9cef0a6dff (diff) | |
download | mdadm-9f55479619c156538434921cbaac0bafa8bccb86.tar.gz mdadm-9f55479619c156538434921cbaac0bafa8bccb86.tar.xz mdadm-9f55479619c156538434921cbaac0bafa8bccb86.zip |
Fix all the confusion over directories once and for all. We now have
3 directory definitions: mdmon directory for its pid and sock files,
mdmonitor directory which is for the mdadm monitor mode pid file and
can only be passed in via command line, and the directory for the
mdadm map file. Only the mdadm map file still hunts multiple locations,
and the number of locations has been reduced to /var/run and the
compile time specified location. I could see lowering that to just
1 location, but I didn't do that with this patch.
Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'mdmon.c')
-rw-r--r-- | mdmon.c | 28 |
1 files changed, 6 insertions, 22 deletions
@@ -120,10 +120,10 @@ static int make_pidfile(char *devname) int fd; int n; - if (mkdir(pid_dir, 0700) < 0 && + if (mkdir(MDMON_DIR, 0755) < 0 && errno != EEXIST) return -errno; - sprintf(path, "%s/%s.pid", pid_dir, devname); + sprintf(path, "%s/%s.pid", MDMON_DIR, devname); fd = open(path, O_RDWR|O_CREAT|O_EXCL, 0600); if (fd < 0) @@ -189,13 +189,10 @@ void remove_pidfile(char *devname) { char buf[100]; - sprintf(buf, "%s/%s.pid", pid_dir, devname); + sprintf(buf, "%s/%s.pid", MDMON_DIR, devname); unlink(buf); - sprintf(buf, "%s/%s.sock", pid_dir, devname); + sprintf(buf, "%s/%s.sock", MDMON_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); } static int make_control_sock(char *devname) @@ -208,7 +205,7 @@ static int make_control_sock(char *devname) if (sigterm) return -1; - sprintf(path, "%s/%s.sock", pid_dir, devname); + sprintf(path, "%s/%s.sock", MDMON_DIR, devname); unlink(path); sfd = socket(PF_LOCAL, SOCK_STREAM, 0); if (sfd < 0) @@ -445,12 +442,7 @@ static int mdmon(char *devname, int devnum, int must_fork, int takeover) act.sa_handler = SIG_IGN; sigaction(SIGPIPE, &act, NULL); - pid_dir = VAR_RUN; victim = mdmon_pid(container->devnum); - if (victim < 0) { - pid_dir = ALT_RUN; - victim = mdmon_pid(container->devnum); - } if (victim >= 0) victim_sock = connect_monitor(container->devname); @@ -474,16 +466,8 @@ static int mdmon(char *devname, int devnum, int must_fork, int takeover) */ if (victim > 0) remove_pidfile(devname); - pid_dir = VAR_RUN; if (make_pidfile(devname) < 0) { - /* Try the alternate */ - pid_dir = ALT_RUN; - if (make_pidfile(devname) < 0) { - fprintf(stderr, "mdmon: Neither %s nor %s are writable\n" - " cannot create .pid or .sock files. Aborting\n", - VAR_RUN, ALT_RUN); - exit(3); - } + exit(3); } container->sock = make_control_sock(devname); |