From 68296989da35a0d5579a83f465aa751524bbbb4f Mon Sep 17 00:00:00 2001 From: smitsohu Date: Tue, 19 Nov 2019 14:59:02 +0100 Subject: improving remount performance --- src/firejail/fs.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/firejail/fs.c b/src/firejail/fs.c index 1f0ccac1a..7b5200d1c 100644 --- a/src/firejail/fs.c +++ b/src/firejail/fs.c @@ -535,6 +535,14 @@ void fs_remount(const char *dir, OPERATION op, unsigned check_mnt) { void fs_remount_rec(const char *dir, OPERATION op, unsigned check_mnt) { assert(dir); + struct stat s; + if (stat(dir, &s) != 0) + return; + if (!S_ISDIR(s.st_mode)) { + // no need to search in /proc/self/mountinfo for submounts if not a directory + fs_remount(dir, op, check_mnt); + return; + } // get mount point of the directory int mountid = get_mount_id(dir); if (mountid == -1) -- cgit v1.2.3-70-g09d2