From 80fb5253810f0132cd6becc37237e08fe6533b5c Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Fri, 12 Feb 2016 09:17:47 +0100 Subject: [PATCH] replaced blacklist NOT_REAL_FILESYSTEMS with whitelist REAL_FILESYSTEMS --- src/file_helpers.py | 10 ++++------ src/test_helpers.py | 10 +++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/file_helpers.py b/src/file_helpers.py index e98937c..b5113b9 100644 --- a/src/file_helpers.py +++ b/src/file_helpers.py @@ -82,11 +82,9 @@ FS_FILL_METHOD_STATVFS = 'statvfs' #: types of mounts found in /proc/mounts to be ignored in get_all_mounts IGNORE_MOUNT_TYPES = 'cgroup', 'pstore' - -#: filesystems that usually do not correspond to something on disc -#: (except maybe swap) -NOT_REAL_FILESYSTEMS = 'none', 'shmfs', 'procfs', 'tmpfs', 'ramfs', 'proc', \ - 'rootfs', 'sysfs', 'devpts', 'sunrpc', 'nfsd' +#: proper filesystems that usually correspond to data on the disc +#: (as opposed to tmpfs, rootfs, sysfs, ...) +REAL_FILESYSTEMS = 'ext2', 'ext3', 'ext4', 'zfs', 'btrs', 'reiserfs', 'nfs4' class FilesystemFillState: @@ -348,7 +346,7 @@ def get_all_mounts(include_duplicates=True): warn('multiple non-rootfs mounts in same file {0}!' .format(new_mount.file)) if new_mount.spec in specs \ - and new_mount.spec not in NOT_REAL_FILESYSTEMS: + and new_mount.spec in REAL_FILESYSTEMS: continue # e.g. bind mounts; ignore this mount # if we reach this, this is no duplicate; remember it diff --git a/src/test_helpers.py b/src/test_helpers.py index 3772375..29e7fff 100644 --- a/src/test_helpers.py +++ b/src/test_helpers.py @@ -21,8 +21,8 @@ Creation motivated by fear of filling disc space during long-running stress tests -.. todo:: Find out why NOT_REAL_FILESYSTEMS generate warnings so quickly even - if they are still empty +.. todo:: Find out why fs not in REAL_FILESYSTEMS generate warnings so quickly + even if they are still empty .. codeauthor:: Intra2net """ @@ -49,7 +49,7 @@ except ImportError: from buffers import LogarithmicBuffer from file_helpers import get_filesystem_fill_states, FilesystemFillState, \ get_mount_info, get_fill_from_statvfs, \ - NOT_REAL_FILESYSTEMS, size_str + REAL_FILESYSTEMS, size_str from iter_helpers import pairwise @@ -116,7 +116,7 @@ class DiscFillChecker: internal helper called from __init__ and run """ - if fs_state.name in NOT_REAL_FILESYSTEMS: + if fs_state.name not in REAL_FILESYSTEMS: return [] if fs_state.size == 0: return [] @@ -389,7 +389,7 @@ def watch_disc_fill(interval=0.1, paths=None): def get_states(): if mounts is None: for state in get_filesystem_fill_states(): - if state.name in NOT_REAL_FILESYSTEMS: + if state.name not in REAL_FILESYSTEMS: continue yield state else: -- 1.7.1