Skip to content

Commit 44d91f9

Browse files
committed
libcleaner: fix asymmetry in mount table open/close handling
Although nilfs_cleaner_find_fs() uses endmntent() to close the file descriptor for "/proc/mounts", its uses fopen() directly to open it instead of setmntent(). This asymmetry is undesirable because it can cause unintended problems such as lock inconsistencies. Therefore, properly use setmntent(). Signed-off-by: Ryusuke Konishi <[email protected]>
1 parent 8a9a5ab commit 44d91f9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/cleaner_ctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ static int nilfs_cleaner_find_fs(struct nilfs_cleaner *cleaner,
194194
cleaner->mountdir = cdir;
195195
}
196196

197-
fp = fopen(_PATH_MOUNTED, "r");
197+
fp = setmntent(_PATH_MOUNTED, "r");
198198
if (unlikely(fp == NULL)) {
199199
nilfs_cleaner_logger(LOG_ERR, _("Error: cannot open "
200200
_PATH_MOUNTED "."));

0 commit comments

Comments
 (0)