After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 528848 - [PATCH] statfs lies
[PATCH] statfs lies
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: fuse
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gvfs-maint
gvfs-maint
: 536606 (view as bug list)
Depends on:
Blocks: 521976 544531
 
 
Reported: 2008-04-19 02:17 UTC by Bill Nottingham
Modified: 2009-01-12 21:24 UTC
See Also:
GNOME target: ---
GNOME version: 2.21/2.22


Attachments
don't inherit statfs() fields from the root filesystem (511 bytes, patch)
2008-04-28 16:38 UTC, Bill Nottingham
committed Details | Review

Description Bill Nottingham 2008-04-19 02:17:47 UTC
gvfs-fuse-daemon does, in its statfs function:

...
  memset (stbuf, 0, sizeof (*stbuf));

  stbuf->f_bsize = 4096;
  stbuf->f_frsize = 4096;  /* Ignored by FUSE */
  stbuf->f_blocks = 0;
  stbuf->f_bfree = 0;
  stbuf->f_bavail = 0;
  stbuf->f_files = 0;
  stbuf->f_ffree = 0;
  stbuf->f_favail = 0;  /* Ignored by FUSE */
  stbuf->f_fsid = 1;  /* Ignored by FUSE */
  stbuf->f_flag = 0;  /* Ignored by FUSE */
  stbuf->f_namemax = 1024;

  if (statvfs ("/", stbuf) != 0)
    result = -errno;
...

meaning that all the fields about available space, used space, etc. are inherited from the root filesystem. This seems wrong because:

1) ~/.gvfs isn't a normal writable filesystem with space concerns, certainly not until you mount something with it
2) it's not even guaranteed to be on the same filesystem as '/', so using that seems odd in any case

Eliding this call leaves the space fields as zero, with the following advantages:
- it no longer confuses baobab (yeah, I know)
- it doesn't show up in 'df' to confuse users
Comment 1 Bill Nottingham 2008-04-28 16:38:31 UTC
Created attachment 110050 [details] [review]
don't inherit statfs() fields from the root filesystem

This removes the statvfs calls, so that statfs() on ~/.gvfs doesn't return the values for the root filesystem.
Comment 2 Benoît Dejean 2008-05-01 16:10:12 UTC
Is that statfs call mandatory ? I can several python/FUSE fs which don't implement it and are totally OK.
Comment 3 David Zeuthen (not reading bugmail) 2008-05-01 17:26:34 UTC
FWIW, this patch looks good to me. I'll ask gicmp for permission to commit it.
Comment 4 Christian Kellner 2008-05-01 20:01:28 UTC
Looks good. Thanks for looking David. Please commit.
Comment 5 Benoît Dejean 2008-05-01 21:48:42 UTC
Why not just drop the statfs impl at all ?

stbuf->f_bsize = 4096;
stbuf->f_frsize = 4096;  /* Ignored by FUSE */

are still lies ...
Comment 6 Benoît Dejean 2008-06-04 19:05:38 UTC
*** Bug 536606 has been marked as a duplicate of this bug. ***
Comment 7 André Klapper 2008-07-18 15:09:22 UTC
*ping* can we get this committed please?
Comment 8 Matthias Clasen 2008-07-29 03:40:30 UTC
2008-07-28  Matthias Clasen  <mclasen@redhat.com>

        Bug 528848 – [PATCH] statfs lies

        * client/gvfsfusedaemon.c (vfs_statfs): Don't call
        statvfs on /. Patch by Bill Nottingham.
Comment 9 Benoît Dejean 2008-07-30 11:54:51 UTC
I suggest that we also don't fake

          stbuf->f_bsize = 4096;
          stbuf->f_frsize = 4096;  /* Ignored by FUSE */


but rather set them to 0 so that we follow the GNU-df semantic where filesystem with 0 block size are ignored.