I have an iso image file of 3.5 GB. When I open it with stat I get this
error:
Value too large for defined data type. Is there a woekaround ? I'm
using Linux 2.6.13.
Thanks,
--
Colossus
Xarchiver, a GTK2 only archive manager -
http://xarchiver.sourceforge.net
Cpsed, a Linux OpenGL 3D scene editor - http://cpsed.sourceforge.net
Mizio, a QT proxy hunter scanner tool - http://mizio.sourceforge.net
You can try defining _LARGEFILE64_SOURCE. This should make off_t be 64 bit,
and thus change st_size in stat struct.
Hope this helps.
Cheers
--
Jan Vidar Krey
Unix Software Developer
Recompile with -D_FILE_OFFSET_BITS=64
Igmar
thank you for replying, I did both the things, adding
-D_FILE_OFFSET_BITS=64 in the Makefile and _LARGEFILE64_SOURCE as
following in file iso.h:
#ifndef ISO_H
#define ISO_H
#include <gtk/gtk.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "callbacks.h"
#include "interface.h"
#include "support.h"
#include "main.h"
#define _LARGEFILE_SOURCE 1
#define _LARGEFILE64_SOURCE 1
#define _FILE_OFFSET_BITS 64
struct iso_primary_descriptor
{
CUT
But it still no works, could you please tell me the exact syntax for
the above define ?
Thank you,
Include those *before* including header files.
The compile syntax :
gcc -o x x.c -D_FILE_OFFSET_BITS=64
Igmar
printf ("Size: %lld\n",size)
Robert
Include them in the commandline flags for gcc (via -D in your
Makefile). If you put them in a header file you must make sure that
this header file is included _before_ anything else in _every_ source
file (old and new), otherwise you may end up with different sized
off_t's in different compilation units.
R'
C> Ok, sorry, it works ! But I have problem in displaying the size with
C> the printf, the size is wrong. Is it correct to use
C> printf ("Size: %lld\n",size)
Generally you shall not depend on fact the platform has `size_t'
identical to `long long'. If platform supports C99, print size_t as
%ju (or %jd if it can be signed, e.g. as returned from read()):
printf("Size: %ju\n", size);
Otherwise, use %lld and convert size to `long long'):
printf("Size: %llu\n", (long long) size);
For modern Linux, %ju and size_t is enough. But don't rely on kernel
version (and your story of using kernel 2.6.13 doesn't matter), rely
on [g]libc version.
-netch-
Now the C language standard doesn't know about file offsets. And printf
doesn't have a flag to describe their size.
>
> [snip]
>
> Otherwise, use %lld and convert size to `long long'):
>
> printf("Size: %llu\n", (long long) size);
This is the safe way.
> C>> Ok, sorry, it works ! But I have problem in displaying the size with
> C>> the printf, the size is wrong. Is it correct to use
> C>> printf ("Size: %lld\n",size)
>> Generally you shall not depend on fact the platform has `size_t'
>> identical to `long long'. If platform supports C99, print size_t as
>> %ju (or %jd if it can be signed, e.g. as returned from read()):
RH> The type of a file offset is not size_t (which is the unsigned integer
RH> type returned by sizeof, usually the same size as a pointer, 32 bits on
RH> a 32-bit PC) but off_t. And the C99 printf flag for a size_t is %zu.
RH> (%ju is for a maxint_t, the largest integer type defined on the system).
Correct, I thought for [u]intmax_t but said for size_t.
RH> Now the C language standard doesn't know about file offsets. And printf
RH> doesn't have a flag to describe their size.
So, conversion to [u]intmax_t is the only working way (if system
supports [u]intmax_t and its format conversions).
>> Otherwise, use %lld and convert size to `long long'):
>>
>> printf("Size: %llu\n", (long long) size);
RH> This is the safe way.
In case when `long long' is no narrower than `off_t', yes.
-netch-
whoa - j is intmax_t - z is for size_t.