diff options
author | Doug Ledford <dledford@redhat.com> | 2010-07-20 18:15:37 +0200 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2010-07-22 16:16:30 +0200 |
commit | 753cf9051223992dc8f18b46d26650fe52e6f2f8 (patch) | |
tree | 9dde7fd290acc5f1af9c87b2e805c55f798e24d9 /mdmon.c | |
parent | Merge branch 'master' of git://github.com/djbw/mdadm (diff) | |
download | mdadm-753cf9051223992dc8f18b46d26650fe52e6f2f8.tar.xz mdadm-753cf9051223992dc8f18b46d26650fe52e6f2f8.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 (compile time define, not changable at run time), mdmonitor
directory which is for the mdadm monitor mode pid file (can only be
passed in via command line at the time mdadm is invoked in monitor mode),
and the directory for the mdadm incremental assembly map file (compile
time define, not changable at run time). 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. Re-use of similar
sounding defines that actually didn't denote their actual usage at
compile time made it more difficult for a person to know what affect
changing the compile time defines would have on the resulting programs.
This patch renames the various defines to clearly identify which item
the define affects. It also reduces the number of various directories
which will be searched for these files as this has lead to confusion
in mdadm and mdmon in terms of which files should take precedence when
files exist in multiple locations, etc. It's best if the person
compiling the program intentionally and with planning selects the
right directories to be used for the various purposes. Which directory
is right depends on which items you are talking about and what boot
loader your system uses and what initramfs generation program your
system uses. Because of the inter-dependency of all these items it
would typically be up to the distribution that mdadm is being integrated
into to select the correct values for these defines.
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
@@ -147,10 +147,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) @@ -204,13 +204,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) @@ -223,7 +220,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) @@ -459,12 +456,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); @@ -488,16 +480,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); |