Hi,

I recommend this page for info on Large File Support:
<http://www.suse.de/~aj/linux_lfs.html>
-- 
Didi

On Wed, Feb 25, 2004 at 01:05:17PM -0800, David D wrote:
> Hi,
> I'm desperate! 
> I was trying to write a program that uses one of the
> above syscall, but nothing seems to work right for me,
> so please please please take a look and tell me what's
> wrong.
> Summary of the problems:
> 1. without the line "#define stat64 stat" the compiler
> complains that it doesn't know the size of stat64
> structures
> 2. while lstat works fine, fstat and fstat64 give
> absolutely wrong results
> 3. lstat64 completely f#cks up the char pointer that
> it gets as an argument
> 4. open() function return a pretty strange file
> descriptor (3).
> Again, please help me.
> Thanks a lot.
> 
> /*test2.c*/
> #include <fcntl.h>
> #include <sys/stat.h>
> #include <errno.h>
> #include <unistd.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <time.h>
> 
> #define stat64 stat
> 
> int main(int argc, char *argv[])
> {
>     char fileName[50];
>     struct stat statbuf;
>       struct stat64 statbuf64;
>     int a, fstatRet, lstatRet;
>       strcpy(fileName, "/etc/passwd");
>       printf ("fileName: %s\n", fileName);
>       lstatRet=lstat(fileName, &statbuf);
>     if (lstatRet)     return 1;
>     printf("according to lstat: %s was accessed on
> %s\n",fileName, ctime(&(statbuf.st_atime)));
>       a=open (fileName,O_RDONLY );
>       if (a==-1)      printf("could not open %s: %s\n",fileName,
> strerror(errno));
>       else            printf("%s was opened: %d\n",fileName,a);
>       fstatRet=fstat64(a,&statbuf64);
>       printf("according to fstat64: %s was accessed on
> %s",fileName,ctime(&(statbuf64.st_atime)));
>       fstatRet=fstat(a,&statbuf);
>       printf("according to fstat: %s was accessed on
> %s",fileName,ctime(&(statbuf64.st_atime)));
>       lstatRet=lstat64(fileName,&statbuf);
>       printf("after calling lstat64, the fileName is
> %s\n",fileName);
>     return 0;
> }
> $ gcc -o test2 -lm -lc  test2.c  && ./test2
> fileName: /etc/passwd
> according to lstat: /etc/passwd was accessed on Wed
> Feb 25 23:10:00 2004
> /etc/passwd was opened: 3
> according to fstat64: /etc/passwd was accessed on Thu
> Jan  1 02:00:08 1970
> according to fstat: /etc/passwd was accessed on Thu
> Jan  1 02:00:08 1970
> after calling lstat64, the fileName is &#1982;
> 
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail SpamGuard - Read only the mail you want.
> http://antispam.yahoo.com/tools
> 
> =================================================================
> To unsubscribe, send mail to [EMAIL PROTECTED] with
> the word "unsubscribe" in the message body, e.g., run the command
> echo unsubscribe | mail [EMAIL PROTECTED]
> 
>  
>  +++++++++++++++++++++++++++++++++++++++++++
>  This Mail Was Scanned By Mail-seCure System
>  at the Tel-Aviv University CC.

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to