diff options
author | Anna Czarnowska <anna.czarnowska@intel.com> | 2010-11-26 14:29:53 +0100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-11-28 23:57:41 +0100 |
commit | a1bb206520f3fc58acc4ebde36c51d99c509b94b (patch) | |
tree | cf58972b4ef99e44f5f4e9a8ad3dacec8629c049 /Monitor.c | |
parent | Monitor: reset dev when size too small (diff) | |
download | mdadm-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.c | 26 |
1 files changed, 16 insertions, 10 deletions
@@ -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; |