Message-ID: <3B47A9FE.106D49A9@alpha.delta.edu> Date: Sat, 07 Jul 2001 20:31:58 -0400 From: "David Witbrodt" X-Mailer: Mozilla 4.75 [en] (Win98; U) X-Accept-Language: en,ja MIME-Version: 1.0 To: DJGPP mailing list Subject: statfs() mystery deepens -- DJGPP workers exonerated, though! Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com DJGPPers, As the subject line indicates, I have been able to determine that the discrepancy is somehow my fault. I am more baffled than before. I just finished a little routine of gathering information, so let me share with you what I have discovered. First, some updated system info, which I now believe to be irrelevant: Swap file (C:\WIN386.SWP) size: 335 544 320 bytes Recycle bin: 204 Mb reserved My program (calling statfs() and multiplying the f_bsize and f_bfree fields) gives: 4 026 531 840 bytes free statfs () "TEST" program gives: f_bfree = 1 002 886 available blocks f_bsize = 4096 bytes f_bfree * f_bsize = 4 107 821 056 bytes free Windows (c:->properties) reports: 4 107 821 056 bytes free DJGPP workers are vindicated! What I am calling the "TEST" program is the output of the program resulting from "gcc -DTEST -o statfstest.exe statfs.c". I manually calculated the bytes free from this output. The program I wrote calculates the same expression and saves it in a variable before writing it to the screen. So I started a GDB session (having previously compiled the program using gstabs+). Here is a partial record of what I found, beginning with a short listing of the 3 most relevant lines in my program: 310: statfs (fspec, &fs); 311: bt = (unsigned long long) fs.f_bsize * fs.f_blocks; // total bytes 312: bf = (unsigned long long) fs.f_bsize * fs.f_fbfree; // bytes free (gdb) p bf $1 = 4026531840 (gdb) p fspec $2 = "c:/djgpp/programs/files/prog07/*.*", '\000' (gdb) p fs $3 = {f_type = 0, f_bsize = 4096, f_blocks = 2044282, f_bfree = 983040, f_bavail = 983040, f_files = 2044282, f_ffree = 983040, f_fsid = {2, 0}, f_magic = 72020} The discrepancy is here -- the statfs() "TEST" program reports 1 002 886 available blocks, while the call of statfs() in my program only yields 983040 available blocks. (Immediately exiting gdb and running the "TEST" program still yields 1 002 886 available blocks.) Both programs (mine, and the "TEST" program) were recompiled immediately before I started gathering all of these figures. Apparently the fault is mine somehow, but I don't understand how I could call statfs() differently to make it work the same way as the "TEST" program! I should point out that I am compiling statfs() as a C++ function, while the "TEST" program compiles it as a C function. I hardly think that could cause this differential behavior, though. Hope you wizards can show me the light, here! Thanks, Dave W. "... for if leisure and security were enjoyed by all alike, the great mass of human beings ... would learn to think for themselves; and when once they had done this, they would sooner or later realize that the privileged minority had no function, and they would sweep it away." - Emmanuel Goldstein