summaryrefslogtreecommitdiffstats
path: root/daemons/cmirrord/functions.c
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2011-09-21 10:42:53 +0000
committerZdenek Kabelac <zkabelac@redhat.com>2011-09-21 10:42:53 +0000
commitd9bba4f16f7c6f6f4496e831bfb3137defc459fe (patch)
treec1202f2717da5f9d56eeb35bb2fa6293075fb470 /daemons/cmirrord/functions.c
parentda1350d420c1a9ef4b58a3fb8de23eeffc235224 (diff)
downloadlvm2-d9bba4f16f7c6f6f4496e831bfb3137defc459fe.tar.gz
lvm2-d9bba4f16f7c6f6f4496e831bfb3137defc459fe.tar.xz
lvm2-d9bba4f16f7c6f6f4496e831bfb3137defc459fe.zip
Check for failing 'stat' and skip this loop iteration
(since data in statbuf are invalid). Check whether sysconf managed to find _SC_PAGESIZE. Report at least debug warning about failing unlink (logging scheme here seems to be a different then in lvm). Duplicate terminal FDs and use similar code as is made in clvmd and cleanup warns about missing open/close tests. FIXME: Looks like we already have 3 instancies of the same code in lvm repo.
Diffstat (limited to 'daemons/cmirrord/functions.c')
-rw-r--r--daemons/cmirrord/functions.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/daemons/cmirrord/functions.c b/daemons/cmirrord/functions.c
index 16112105..192ab40e 100644
--- a/daemons/cmirrord/functions.c
+++ b/daemons/cmirrord/functions.c
@@ -329,7 +329,10 @@ static int find_disk_path(char *major_minor_str, char *path_rtn, int *unlink_pat
*/
sprintf(path_rtn, "/dev/mapper/%s", dep->d_name);
- stat(path_rtn, &statbuf);
+ if (stat(path_rtn, &statbuf) < 0) {
+ LOG_DBG("Unable to stat %s", path_rtn);
+ continue;
+ }
if (S_ISBLK(statbuf.st_mode) &&
(major(statbuf.st_rdev) == major) &&
(minor(statbuf.st_rdev) == minor)) {
@@ -476,7 +479,12 @@ static int _clog_ctr(char *uuid, uint64_t luid,
lc->sync_count = (log_sync == NOSYNC) ? region_count : 0;
if (disk_log) {
- page_size = sysconf(_SC_PAGESIZE);
+ if ((page_size = sysconf(_SC_PAGESIZE)) < 0) {
+ LOG_ERROR("Unable to read pagesize: %s",
+ strerror(errno));
+ r = errno;
+ goto fail;
+ }
pages = *(lc->clean_bits) / page_size;
pages += *(lc->clean_bits) % page_size ? 1 : 0;
pages += 1; /* for header */
@@ -489,7 +497,10 @@ static int _clog_ctr(char *uuid, uint64_t luid,
goto fail;
}
if (unlink_path)
- unlink(disk_path);
+ if (unlink(disk_path) < 0) {
+ LOG_DBG("Warning: Unable to unlink log device, %s: %s",
+ disk_path, strerror(errno));
+ }
lc->disk_fd = r;
lc->disk_size = pages * page_size;