re-introduce blacklist since fstype not always known
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Fri, 12 Feb 2016 08:45:14 +0000 (09:45 +0100)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Fri, 12 Feb 2016 08:45:14 +0000 (09:45 +0100)
src/file_helpers.py
src/test_helpers.py

index b5113b9..fe89e05 100644 (file)
@@ -41,6 +41,9 @@ What I found out on the way about filesystems:
   complicated!
 * forking for df takes time!
 
+.. note:: if decide to deprecate df_wrapper, can change FilesystemFillState to
+          have full mount point info -> remove NOT_REAL_FILESYSTEMS_SPEC
+
 .. codeauthor:: Intra2net
 """
 
@@ -83,9 +86,17 @@ FS_FILL_METHOD_STATVFS = 'statvfs'
 IGNORE_MOUNT_TYPES = 'cgroup', 'pstore'
 
 #: 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'
-
+#: (value for field MountPoint.vfstype)
+REAL_FILESYSTEMS_TYPE = 'ext2', 'ext3', 'ext4', 'zfs', 'btrs', 'reiserfs', \
+                        'nfs4'
+
+#: filesystem name (MountPoint.spec / FilesystemFillState.name) that usually
+#: does not correspond to something on disc (except, maybe, swap)
+#: (only still here because df does not give fs type result, so class
+#:  FilesystemFillState does not have full mount info)
+NOT_REAL_FILESYSTEMS_SPEC = 'none', 'shmfs', 'procfs', 'tmpfs', 'ramfs', \
+                            'proc', 'rootfs', 'sysfs', 'devpts', 'sunrpc', \
+                            'nfsd'
 
 class FilesystemFillState:
     """ representation of 1 line of the 'df' command
@@ -346,7 +357,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 in REAL_FILESYSTEMS:
+                        and new_mount.vfstype in REAL_FILESYSTEMS_TYPE:
                     continue        # e.g. bind mounts; ignore this mount
 
                 # if we reach this, this is no duplicate; remember it
index 29e7fff..b2e6c83 100644 (file)
@@ -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, \
-                         REAL_FILESYSTEMS, size_str
+                         NOT_REAL_FILESYSTEMS_SPEC, size_str
 from iter_helpers import pairwise
 
 
@@ -116,7 +116,7 @@ class DiscFillChecker:
 
         internal helper called from __init__ and run
         """
-        if fs_state.name not in REAL_FILESYSTEMS:
+        if fs_state.name in NOT_REAL_FILESYSTEMS_SPEC:
             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 not in REAL_FILESYSTEMS:
+                if state.name in NOT_REAL_FILESYSTEMS_SPEC:
                     continue
                 yield state
         else: