mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-27 17:52:58 +02:00
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
This commit is contained in:
@@ -983,15 +983,20 @@ g_local_file_query_filesystem_info (GFile *file,
|
|||||||
block_size = statfs_buffer.f_bsize;
|
block_size = statfs_buffer.f_bsize;
|
||||||
|
|
||||||
/* Many backends can't report free size (for instance the gvfs fuse
|
/* Many backends can't report free size (for instance the gvfs fuse
|
||||||
backend for backend not supporting this), and set f_bfree to 0,
|
* 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
|
* but it can be 0 for real too. We treat the available == 0 and
|
||||||
free == 0 case as "both of these are invalid".
|
* 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
|
||||||
#ifndef G_OS_WIN32
|
* systems which are legitimately full). */
|
||||||
|
#if defined(__linux__)
|
||||||
if (statfs_result == 0 &&
|
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;
|
no_size = TRUE;
|
||||||
#endif /* G_OS_WIN32 */
|
#endif /* __linux__ */
|
||||||
|
|
||||||
#elif defined(USE_STATVFS)
|
#elif defined(USE_STATVFS)
|
||||||
statfs_result = statvfs (local->filename, &statfs_buffer);
|
statfs_result = statvfs (local->filename, &statfs_buffer);
|
||||||
|
Reference in New Issue
Block a user