Hi,
I'm trying to make GetFreeDiskSpace working with CDROM because a game needs it. However, I'm experiencing problem with statvfs... Indeed, statvfs always returns f_frsize = 0 and f_blocks = 0. If I cd to /mnt/cdrom or edit a file in it, this does not help however if I run a grep or launch Konqueror in that directory, statvfs magically works. I suspect supermount is responsible because statvfs needs the cdrom to be "physically" mounted.
Is it a know issue? (I am on a Mandrake 9.1 base) Or the only solution is to keep a fd opened during the statvfs call so the drive stays mounted...
Thanks in advance, Christian
PS: I used the attached code for testing
#include <sys/types.h> #include <sys/statvfs.h> #include <sys/statfs.h>
int main() { struct statvfs info; struct statfs inf;
if (statfs("/mnt/cdrom", &inf) < 0) { printf("cannot do statfs\n"); return 0; } printf("size = %ld - %ld\n", inf.f_bsize, inf.f_blocks);
if (statvfs("/mnt/cdrom", &info ) < 0) { printf("cannot do statvfs\n"); return 0; } printf("size = %ld - %ld - %ld\n", info.f_bsize, info.f_frsize, info.f_blocks); return 1; }
Christian Costa titan.costa@wanadoo.fr writes:
I'm trying to make GetFreeDiskSpace working with CDROM because a game needs it. However, I'm experiencing problem with statvfs... Indeed, statvfs always returns f_frsize = 0 and f_blocks = 0. If I cd to /mnt/cdrom or edit a file in it, this does not help however if I run a grep or launch Konqueror in that directory, statvfs magically works. I suspect supermount is responsible because statvfs needs the cdrom to be "physically" mounted.
The plan is to reimplement GetFreeDiskSpace on top of NtQueryVolumeInformationFile, which should fix the issue since it will require opening a handle to the directory. The equivalent in your test program would be to open /mnt/cdrom and do a fstatvfs on the resulting file descriptor. Could you verify if this does the right thing for you?
Alexandre Julliard wrote:
Christian Costa titan.costa@wanadoo.fr writes:
I'm trying to make GetFreeDiskSpace working with CDROM because a game needs it. However, I'm experiencing problem with statvfs... Indeed, statvfs always returns f_frsize = 0 and f_blocks = 0. If I cd to /mnt/cdrom or edit a file in it, this does not help however if I run a grep or launch Konqueror in that directory, statvfs magically works. I suspect supermount is responsible because statvfs needs the cdrom to be "physically" mounted.
The plan is to reimplement GetFreeDiskSpace on top of NtQueryVolumeInformationFile, which should fix the issue since it will require opening a handle to the directory. The equivalent in your test program would be to open /mnt/cdrom and do a fstatvfs on the resulting file descriptor. Could you verify if this does the right thing for you?
Yes, this works fine. Thanks. :-) When do you plan to rewrite GetFreeDiskSpace?
Bye, Christian
Christian Costa titan.costa@wanadoo.fr writes:
Yes, this works fine. Thanks. :-) When do you plan to rewrite GetFreeDiskSpace?
In a few days I guess. There are still some missing features in NtCreateFile that need to be done first.