From: Cui Yue Date: Tue, 12 Feb 2019 11:12:30 +0000 (+0800) Subject: src/t_mtab: Add error check for unlock_mtab() X-Git-Tag: v2022.05.01~1266 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0177f3c4588313954ff21ea0017d607a23286e1c;p=xfstests-dev.git src/t_mtab: Add error check for unlock_mtab() 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 Reviewed-by: Eryu Guan Signed-off-by: Eryu Guan --- diff --git a/src/t_mtab.c b/src/t_mtab.c index fd85c6bd..c0640a19 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; + } } }