diff options
author | Emmanuel Vasilakis <mrzammler@mm.st> | 2023-05-23 16:22:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-23 16:22:56 +0300 |
commit | 89f22f056ca2aae5d143da9a4e94fcab1f7ee1b8 (patch) | |
tree | 20c0c6ff0315af304928f4a842dd61526be703ba /collectors/proc.plugin | |
parent | c0c1e0e85a627d0509a37ea4e7ef00c2cf4aa29f (diff) |
Try to detect bind mounts (#14831)
* try to detect bind mounts
* minor grammar fix
* remove option, skip binds by default
* add check of mount_point length
* add a comment
* use root to compare
---------
Co-authored-by: Chris Akritidis <43294513+cakrit@users.noreply.github.com>
Diffstat (limited to 'collectors/proc.plugin')
-rw-r--r-- | collectors/proc.plugin/proc_self_mountinfo.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/collectors/proc.plugin/proc_self_mountinfo.c b/collectors/proc.plugin/proc_self_mountinfo.c index 0483749c37..1947916039 100644 --- a/collectors/proc.plugin/proc_self_mountinfo.c +++ b/collectors/proc.plugin/proc_self_mountinfo.c @@ -360,6 +360,18 @@ struct mountinfo *mountinfo_read(int do_statvfs) { else { mi->st_dev = 0; } + + //try to detect devices with same minor and major modes. Within these, + //the larger mount point is considered a bind. + struct mountinfo *mt; + for(mt = root; mt; mt = mt->next) { + if(unlikely(mt->major == mi->major && mt->minor == mi->minor && !(mi->flags & MOUNTINFO_IS_BIND))) { + if(strlen(mi->root) < strlen(mt->root)) + mt->flags |= MOUNTINFO_IS_BIND; + else + mi->flags |= MOUNTINFO_IS_BIND; + } + } } else { mi->filesystem = NULL; |