Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.7.0, 5.7.1
-
None
-
FreeBSD-Current with Qt-5.7.1
-
fa3940cc4b5580070f465d1f64a23a69bc925367
Description
QStorageInfo uses getmntinfo(*mntbufp,*flags) [1] on FreeBSD to query the information on the filesystems. The flags are those supported by getfsstat(buf,bufsize,*flags).
According to [2]:
Normally flags should be specified as MNT_WAIT. If flags is set to
MNT_NOWAIT, getfsstat() will return the information it has available
without requesting an update from each file system. Thus, some of the
information will be out of date, but getfsstat() will not block waiting
for information from a file system that is unable to respond.
And from sys/mount.h [3] we have:
/* Flags for various system call interfaces. waitfor flags to vfs_sync() and getfsstat() */
#define MNT_WAIT 1 /* synchronously wait for I/O to complete */
#define MNT_NOWAIT 2 /* start all I/O, but do not wait for it */
#define MNT_LAZY 3 /* push data not written by filesystem syncer */
#define MNT_SUSPEND 4 /* Suspend file system after sync */
With the code as is, QStorageInfo alway returns unitialized data:
name: ""
fileSystemType: "0"
size: 0 MB
availableSize: 0 MB
The attached patch switches to the flag MNT_NOWAIT (I think it is enough to get the available data), which in return gives
name: ""
fileSystemType: "tmpfs"
size: 26346 MB
availableSize: 25990 MB
[1] getmntinfo(3)
[2] getfsstat(2)
[3] sys/mount.h