Message ID | 1549969950-4886-1-git-send-email-cuiyue-fnst@cn.fujitsu.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | generic/089: Add error check for unlock_mtab() | expand |
diff --git a/src/t_mtab.c b/src/t_mtab.c index fd85c6b..6a17fbd 100644 --- a/src/t_mtab.c +++ b/src/t_mtab.c @@ -184,9 +184,15 @@ lock_mtab (void) { /* Remove lock file. */ void unlock_mtab (void) { + int ret; if (we_created_lockfile) { - unlink (mounted_lock); - we_created_lockfile = 0; + ret = unlink (mounted_lock); + if (ret) { + fprintf(stderr, "Cannot remove lock file: %s\n", strerror(errno)); + exit(1); + } else { + we_created_lockfile = 0; + } } }
When unlink() fails, that is, when the lock file is not deleted successfully, variable we_created_lockfile is still set to 0. On the next iteration, the 3 processes will not be able to successfully create the lock file. Signed-off-by: Cui Yue <cuiyue-fnst@cn.fujitsu.com> --- src/t_mtab.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)