glocalfile: Only ignore FS full information for FUSE and ncpfs
Previously, glocalfile.c would not set file system metadata for
the free/used key for file systems which reported 0 free space. This is
because some file systems don’t set that metadata when you call
statfs(), so we can’t reliably report it. However, some do, and they
can legitimately set f_bavail and f_bfree to 0 if the file system is
full.
In order to avoid that, always set the file system metadata unless the
file system is FUSE or ncpfs.
This is a partial revert of commit 0b9f24c1e1: instead of the changes
made in that commit, I think we should maintain a blacklist of file
systems which are known to not correctly report free space.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
https://gitlab.gnome.org/GNOME/glib/issues/328
diff --git a/gio/glocalfile.c b/gio/glocalfile.c
index 2d928cc..30fa228 100644
--- a/gio/glocalfile.c
+++ b/gio/glocalfile.c
@@ -983,15 +983,20 @@
block_size = statfs_buffer.f_bsize;
/* Many backends can't report free size (for instance the gvfs fuse
- backend for backend not supporting this), and set f_bfree to 0,
- but it can be 0 for real too. We treat the available == 0 and
- free == 0 case as "both of these are invalid".
- */
-#ifndef G_OS_WIN32
+ * backend for backend not supporting this), and set f_bfree to 0,
+ * but it can be 0 for real too. We treat the available == 0 and
+ * free == 0 case as "both of these are invalid", but only on file systems
+ * which are known to not support this (otherwise we can omit metadata for
+ * systems which are legitimately full). */
+#if defined(__linux__)
if (statfs_result == 0 &&
- statfs_buffer.f_bavail == 0 && statfs_buffer.f_bfree == 0)
+ statfs_buffer.f_bavail == 0 && statfs_buffer.f_bfree == 0 &&
+ (/* linux/ncp_fs.h: NCP_SUPER_MAGIC == 0x564c */
+ statfs_buffer.f_type == 0x564c ||
+ /* man statfs: FUSE_SUPER_MAGIC == 0x65735546 */
+ statfs_buffer.f_type == 0x65735546))
no_size = TRUE;
-#endif /* G_OS_WIN32 */
+#endif /* __linux__ */
#elif defined(USE_STATVFS)
statfs_result = statvfs (local->filename, &statfs_buffer);