delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/03/02/16:39:48

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
Date: Sat, 02 Mar 2002 21:28:35 +0000
From: "Richard Dawe" <rich AT phekda DOT freeserve DOT co DOT uk>
Sender: rich AT phekda DOT freeserve DOT co DOT uk
To: djgpp-workers AT delorie DOT com
X-Mailer: Emacs 21.0.98 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.6
CC: Waldemar Schultz <schultz AT ma DOT tum DOT de>
Subject: Fix statvfs.txh example for FAT32
Message-Id: <E16hH0f-0001Ey-00@phekda.freeserve.co.uk>
Reply-To: djgpp-workers AT delorie DOT com

Hello.

Waldemar Schultz posted a suggested to comp.os.msdos.djgpp fixing
the example in statvfs.txh "work out of the box on large FAT32 drives".
(Thanks, Waldemar!) Presumably the example did not work before, because
the size would overflow 2GB and appear as a negative number.

Anyway, below is a patch against DJGPP CVS. I made a couple of changes:

* Use names that don't clash with reserve C symbols ("free").
* Change format string for unsigned long long from long long.

I tested the new example program, and it works. If there are no objections,
I'll commit this patch in a week.

Thanks, bye, Rich =]

--- /develop/djgpp/src/libc/compat/sys/vfs/statfs.txh	Thu Jan 31 23:00:12 2002
+++ c:/develop/djgpp.rw/src/libc/compat/sys/vfs/statfs.txh	Sat Mar  2 21:27:06 2002
@@ -46,7 +46,11 @@ Zero on success, nonzero on failure.
 
 @example
 struct statfs fs;
+unsigned long long bfree, bsize;
+
 statfs("anything", &fs);
-printf("%d bytes left\n", fs.f_bfree * fs.f_bsize);
+bfree = fs.f_bfree;
+bsize = fs.f_bsize;
+printf("%llu bytes left\n", bfree * bsize);
 @end example
 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019