# Buggy code
def update(self):
    """Update the FS stats using the input method."""
    # Init new stats
    stats = self.get_init_value()

    if self.input_method == "local":
        # Update stats using the standard system lib

        # Grab the stats using the psutil disk_partitions
        # If 'all'=False return physical devices only (e.g. hard disks, cd-rom drives, USB keys)
        # and ignore all others (e.g. memory partitions such as /dev/shm)
        try:
            fs_stat = psutil.disk_partitions(all=False)
        except UnicodeDecodeError:
            return self.stats

        # Optionnal hack to allow logicals mounts points (issue #448)
        # Ex: Had to put 'allow=zfs' in the [fs] section of the conf file
        #     to allow zfs monitoring
        for fstype in self.get_conf_value("allow"):
            try:
                fs_stat += [
                    f
                    for f in psutil.disk_partitions(all=True)
                    if f.fstype.find(fstype) >= 0
                ]
            except UnicodeDecodeError:
                return self.stats

        # Loop over fs
        for fs in fs_stat:
            # Do not take hidden file system into account
            if self.is_hide(fs.mountpoint):
                continue
            # Grab the disk usage
            try:
                fs_usage = psutil.disk_usage(fs.mountpoint)
            except OSError:
                # Correct issue #346
                # Disk is ejected during the command
                continue
            fs_current = {
                "device_name": fs.device,
                "fs_type": fs.fstype,
                # Manage non breaking space (see issue #1065)
                "mnt_point": u(fs.mountpoint).replace("\u00a0", " "),
                "size": fs_usage.total,
                "used": fs_usage.used,
                "free": fs_usage.free,
                "percent": fs_usage.percent,
                "key": self.get_key(),
            }
            stats.append(fs_current)

    elif self.input_method == "snmp":
        # Update stats using SNMP

        # SNMP bulk command to get all file system in one shot
        try:
            fs_stat = self.get_stats_snmp(
                snmp_oid=snmp_oid[self.short_system_name], bulk=True
            )
        except KeyError:
            fs_stat = self.get_stats_snmp(snmp_oid=snmp_oid["default"], bulk=True)

        # Loop over fs
        if self.short_system_name in ("windows", "esxi"):
            # Windows or ESXi tips
            for fs in fs_stat:
                # Memory stats are grabbed in the same OID table (ignore it)
                if (
                    fs == "Virtual Memory"
                    or fs == "Physical Memory"
                    or fs == "Real Memory"
                ):
                    continue
                size = int(fs_stat[fs]["size"]) * int(fs_stat[fs]["alloc_unit"])
                used = int(fs_stat[fs]["used"]) * int(fs_stat[fs]["alloc_unit"])
                percent = float(used * 100 / size)
                fs_current = {
                    "device_name": "",
                    "mnt_point": fs.partition(" ")[0],
                    "size": size,
                    "used": used,
                    "percent": percent,
                    "key": self.get_key(),
                }
                stats.append(fs_current)
        else:
            # Default behavior
            for fs in fs_stat:
                fs_current = {
                    "device_name": fs_stat[fs]["device_name"],
                    "mnt_point": fs,
                    "size": int(fs_stat[fs]["size"]) * 1024,
                    "used": int(fs_stat[fs]["used"]) * 1024,
                    "percent": float(fs_stat[fs]["percent"]),
                    "key": self.get_key(),
                }
                stats.append(fs_current)

    # Update the stats
    self.stats = stats

    return self.stats


# Traceback (PermissionError)
/$ glances
Traceback (most recent call last):
File "/snap/glances/410/bin/glances", line 11, in <module>
load_entry_point('Glances==3.1.1', 'console_scripts', 'glances')()
File "/snap/glances/410/lib/python3.5/site-packages/glances/__init__.py", line 140, in main
start(config=config, args=args)
File "/snap/glances/410/lib/python3.5/site-packages/glances/__init__.py", line 106, in start
mode = GlancesMode(config=config, args=args)
File "/snap/glances/410/lib/python3.5/site-packages/glances/standalone.py", line 74, in __init__
self.stats.update()
File "/snap/glances/410/lib/python3.5/site-packages/glances/stats.py", line 228, in update
self._plugins[p].update()
File "/snap/glances/410/lib/python3.5/site-packages/glances/plugins/glances_plugin.py", line 915, in wrapper
ret = fct(self, *args, **kw)
File "/snap/glances/410/lib/python3.5/site-packages/glances/plugins/glances_plugin.py", line 924, in wrapper
ret = fct(*args, **kw)
File "/snap/glances/410/lib/python3.5/site-packages/glances/plugins/glances_fs.py", line 100, in update
fs_stat = psutil.disk_partitions(all=False)
File "/snap/glances/410/lib/python3.5/site-packages/psutil/__init__.py", line 2133, in disk_partitions
return _psplatform.disk_partitions(all)
File "/snap/glances/410/lib/python3.5/site-packages/psutil/_pslinux.py", line 1167, in disk_partitions
partitions = cext.disk_partitions(mounts_path)
PermissionError: [Errno 13] Permission denied: '/proc/4287/mounts'

# Fixed code
def update(self):
    """Update the FS stats using the input method."""
    # Init new stats
    stats = self.get_init_value()

    if self.input_method == "local":
        # Update stats using the standard system lib

        # Grab the stats using the psutil disk_partitions
        # If 'all'=False return physical devices only (e.g. hard disks, cd-rom drives, USB keys)
        # and ignore all others (e.g. memory partitions such as /dev/shm)
        try:
            fs_stat = psutil.disk_partitions(all=False)
        except (UnicodeDecodeError, PermissionError):
            return self.stats

        # Optionnal hack to allow logicals mounts points (issue #448)
        # Ex: Had to put 'allow=zfs' in the [fs] section of the conf file
        #     to allow zfs monitoring
        for fstype in self.get_conf_value("allow"):
            try:
                fs_stat += [
                    f
                    for f in psutil.disk_partitions(all=True)
                    if f.fstype.find(fstype) >= 0
                ]
            except UnicodeDecodeError:
                return self.stats

        # Loop over fs
        for fs in fs_stat:
            # Do not take hidden file system into account
            if self.is_hide(fs.mountpoint):
                continue
            # Grab the disk usage
            try:
                fs_usage = psutil.disk_usage(fs.mountpoint)
            except OSError:
                # Correct issue #346
                # Disk is ejected during the command
                continue
            fs_current = {
                "device_name": fs.device,
                "fs_type": fs.fstype,
                # Manage non breaking space (see issue #1065)
                "mnt_point": u(fs.mountpoint).replace("\u00a0", " "),
                "size": fs_usage.total,
                "used": fs_usage.used,
                "free": fs_usage.free,
                "percent": fs_usage.percent,
                "key": self.get_key(),
            }
            stats.append(fs_current)

    elif self.input_method == "snmp":
        # Update stats using SNMP

        # SNMP bulk command to get all file system in one shot
        try:
            fs_stat = self.get_stats_snmp(
                snmp_oid=snmp_oid[self.short_system_name], bulk=True
            )
        except KeyError:
            fs_stat = self.get_stats_snmp(snmp_oid=snmp_oid["default"], bulk=True)

        # Loop over fs
        if self.short_system_name in ("windows", "esxi"):
            # Windows or ESXi tips
            for fs in fs_stat:
                # Memory stats are grabbed in the same OID table (ignore it)
                if (
                    fs == "Virtual Memory"
                    or fs == "Physical Memory"
                    or fs == "Real Memory"
                ):
                    continue
                size = int(fs_stat[fs]["size"]) * int(fs_stat[fs]["alloc_unit"])
                used = int(fs_stat[fs]["used"]) * int(fs_stat[fs]["alloc_unit"])
                percent = float(used * 100 / size)
                fs_current = {
                    "device_name": "",
                    "mnt_point": fs.partition(" ")[0],
                    "size": size,
                    "used": used,
                    "percent": percent,
                    "key": self.get_key(),
                }
                stats.append(fs_current)
        else:
            # Default behavior
            for fs in fs_stat:
                fs_current = {
                    "device_name": fs_stat[fs]["device_name"],
                    "mnt_point": fs,
                    "size": int(fs_stat[fs]["size"]) * 1024,
                    "used": int(fs_stat[fs]["used"]) * 1024,
                    "percent": float(fs_stat[fs]["percent"]),
                    "key": self.get_key(),
                }
                stats.append(fs_current)

    # Update the stats
    self.stats = stats

    return self.stats