cygwin-1.5.0-1: Problem stat-ing big file

Ronald Landheer-Cieslak ronald@landheer.com
Thu Jul 10 13:13:00 GMT 2003


I tried pretty much the same thing with the attached files (test.c
generates a very big file, stat.c checks its size, cygcheck.out is
available at http://blytkerchan.chez.tiscali.fr/cygcheck.out (md5 sum:
56aa8e6d575d27bf8a2b740a25e13dd0) because it's rather large and not very
interesting.

Worked like a charm !

Thanx

rlc


On Thu, 10 Jul 2003, Corinna Vinschen wrote:

> On Thu, Jul 10, 2003 at 01:35:37PM +0200, Corinna Vinschen wrote:
> > On Thu, Jul 10, 2003 at 01:26:34PM +0200, Markus Sch?nhaber wrote:
> > > While trying if the new support for files larger than 2GB works, I 
> > > created a file with a size of 4.53 GB (4,869,120,000 Bytes) using a 
> > > simple write in python. No problems here. But when stat-ing the file 
> > > with python's os.stat or by calling stat from C as done in the little 
> > > program below, the size of the file gets reported as 574,152,704 Bytes.
> > 
> > The changes to 64 bit file access are not propagated automatically to
> > existing applications.  E.g. the current `ls' from the fileutils
> > package is compiled with the old (small) stat structure which only
> > has 32 bit off_t for the file size.  If you want to actually use the
> > new struct stat and off_t with 64 bit, you have to recompile the
> > application.
> > 
> > Sorry, but there's no way around that.
> 
> ...and two more hints, just to clarify that a bit:
> 
> - You must compile using the header files and libcygwin.a which has been
>   released together with the DLL to get the correct results.  Mixing
>   old Cygwin headers with the new import lib or vice versa are sure
>   candidates for segmentation fauls.
> 
> - Since off_t is now 64 bit and the st_size member of struct stat is a
>   off_t, your printf isn't correct:
> 
>   printf("Size of file <%s>: %lld", argv[1], s.st_size);
>                              ^^^^
> 
>   %lld is necessary.  %ld matches 32 bit types on Cygwin.
> 
> 
> Corinna
> 
> 
-------------- next part --------------
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>

#define N_GB 5

int main( void )
{
   int i;
   char buffer[1024];
   struct stat stat_info;

   FILE *out = fopen( "out", "web" );

   for ( i = 0; i < N_GB * 1024 * 1024; i++ )
   {
      if ( fwrite( buffer, 1024, 1, out ) != 1 )
      {
	 abort(  );
      }
   }

   fclose( out );

   stat( "out", &stat_info );
   assert( ( stat_info.st_size / ( 1024 * 1024 * 1024 ) ) == N_GB );

   return ( 0 );
}
-------------- next part --------------
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>

int main( int argc, char **argv )
{
   struct stat stat_info;

   argv++;
   while ( argv[0] != NULL )
   {
      if ( stat( argv[0], &stat_info ) == 0 )
	 printf( "%s: %lld\n", argv[0], stat_info.st_size );
      argv++;
   }

   return ( 0 );
}
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list