summaryrefslogtreecommitdiffstats
path: root/Monitor.c
diff options
context:
space:
mode:
authorAnna Czarnowska <anna.czarnowska@intel.com>2010-11-26 14:29:53 +0100
committerNeilBrown <neilb@suse.de>2010-11-28 23:57:41 +0100
commita1bb206520f3fc58acc4ebde36c51d99c509b94b (patch)
treecf58972b4ef99e44f5f4e9a8ad3dacec8629c049 /Monitor.c
parentMonitor: reset dev when size too small (diff)
downloadmdadm-a1bb206520f3fc58acc4ebde36c51d99c509b94b.tar.xz
mdadm-a1bb206520f3fc58acc4ebde36c51d99c509b94b.zip
Monitor: fix writing autorebuild.pid
If /var/run/mdadm doesn't exist we can never succeed writing so we should try to create it first. When we make sure it is there we write pid file as before. Signed-off-by: Anna Czarnowska <anna.czarnowska@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Monitor.c')
-rw-r--r--Monitor.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/Monitor.c b/Monitor.c
index 8d397bc0..0e916884 100644
--- a/Monitor.c
+++ b/Monitor.c
@@ -296,21 +296,27 @@ static int check_one_sharer(int scan)
} else {
fprintf(stderr, Name ": Warning: One"
" autorebuild process already"
- " running.");
+ " running.\n");
}
}
fclose(fp);
}
if (scan) {
- fp = fopen("/var/run/mdadm/autorebuild.pid", "w");
- if (!fp)
- fprintf(stderr, Name ": Cannot create"
- " autorebuild.pid "
- "file\n");
- else {
- pid = getpid();
- fprintf(fp, "%d\n", pid);
- fclose(fp);
+ if (mkdir("/var/run/mdadm", S_IRWXU) < 0 &&
+ errno != EEXIST) {
+ fprintf(stderr, Name ": Can't create "
+ "autorebuild.pid file\n");
+ } else {
+ fp = fopen("/var/run/mdadm/autorebuild.pid", "w");
+ if (!fp)
+ fprintf(stderr, Name ": Cannot create"
+ " autorebuild.pid"
+ "file\n");
+ else {
+ pid = getpid();
+ fprintf(fp, "%d\n", pid);
+ fclose(fp);
+ }
}
}
return 0;