From 8918bf243090820eef99e7ff6f92205681163c51 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 27 Feb 2012 11:28:47 +0000 Subject: [PATCH] Add some log_sys_errors to close() call --- daemons/clvmd/clvmd.c | 3 ++- lib/misc/lvm-file.c | 3 ++- tools/dmsetup.c | 8 +++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c index ea5380b1d..d6d33cedc 100644 --- a/daemons/clvmd/clvmd.c +++ b/daemons/clvmd/clvmd.c @@ -198,7 +198,8 @@ static void safe_close(int *fd) if (*fd >= 0) { int to_close = *fd; *fd = -1; - close(to_close); + if (close(to_close)) + log_sys_error("close", ""); /* path */ } } diff --git a/lib/misc/lvm-file.c b/lib/misc/lvm-file.c index 6e50cf814..d71737b7f 100644 --- a/lib/misc/lvm-file.c +++ b/lib/misc/lvm-file.c @@ -253,7 +253,8 @@ int fcntl_lock_file(const char *file, short lock_type, int warn_if_read_only) if (fcntl(lockfd, F_SETLKW, &lock)) { log_sys_error("fcntl", file); - close(lockfd); + if (close(lockfd)) + log_sys_error("close", file); return -1; } diff --git a/tools/dmsetup.c b/tools/dmsetup.c index d6d9dcfed..0ae49c784 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -3240,7 +3240,8 @@ static int _loop_table(char *table, size_t tlen, char *file, blksize = fsbuf.f_frsize; #endif - close(fd); + if (close(fd)) + log_sys_error("close", file); if (dm_snprintf(table, tlen, "%llu %llu loop %s %llu\n", 0ULL, (long long unsigned)sectors, file, (long long unsigned)off) < 0) @@ -3252,8 +3253,9 @@ static int _loop_table(char *table, size_t tlen, char *file, return 1; error: - if (fd > -1) - close(fd); + if (fd > -1 && close(fd)) + log_sys_error("close", file); + return 0; }