replaced blacklist NOT_REAL_FILESYSTEMS with whitelist REAL_FILESYSTEMS
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Fri, 12 Feb 2016 08:17:47 +0000 (09:17 +0100)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Fri, 12 Feb 2016 08:17:47 +0000 (09:17 +0100)
src/file_helpers.py
src/test_helpers.py

index e98937c..b5113b9 100644 (file)
@@ -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
index 3772375..29e7fff 100644 (file)
@@ -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: