[uClibc] Re: fstat and fstat64

Simon Posnjak sposnjak at gmail.com
Fri Jun 3 10:41:25 UTC 2005


Hi all,

I did a bit more investigating and found that the problem is some have
connected to sys/stat.h. In there you have:

# ifdef __REDIRECT
extern int __REDIRECT (stat,
                       (__const char *__restrict __file,
                        struct stat *__restrict __buf) __THROW,
                       stat64);
extern int __REDIRECT (fstat, (int __fd, struct stat *__buf) __THROW, fstat64);
# else

This code translates to:

extern int fstat (int __fd, struct stat *__buf) __asm__ ("" "fstat64");

(If I am reading this correctly) This means that when I call fstat I
relay call fstat64. But the problem is that sizeof (struct stat) !=
sizeof (struct stat64). The difference is that first one uses unsigned
short to do the padding and the second one unsigned int:

struct stat
{
  __dev_t st_dev;
  unsigned short int __pad1; 

  __ino_t __st_ino; 
 
  __mode_t st_mode; 
  __nlink_t st_nlink;
  __uid_t st_uid; 
  __gid_t st_gid;
  __dev_t st_rdev; 
  unsigned short int __pad2;
                              
  __off64_t st_size;
                            
  __blksize_t st_blksize; 
                                
  __blkcnt64_t st_blocks;
                               
  __time_t st_atime; 
  unsigned long int __unused1;  
  __time_t st_mtime;           
  unsigned long int __unused2; 
  __time_t st_ctime;           
  unsigned long int __unused3;  
                               
  __ino64_t st_ino;             
};

struct stat64{
  __dev_t st_dev;  
  unsigned int __pad1; 

  __ino_t __st_ino;

  __mode_t st_mode;
  __nlink_t st_nlink;

  __uid_t st_uid;
  __gid_t st_gid;

  __dev_t st_rdev;
  unsigned int __pad2;

  __off64_t st_size;
  __blksize_t st_blksize;

  __blkcnt64_t st_blocks;


  __time_t st_atime;
  unsigned long int __unused1;

  __time_t st_mtime;
  unsigned long int __unused2;


  __time_t st_ctime;
  unsigned long int __unused3;

  __ino64_t st_ino;
};

Any idea how do I fix this?

Regards Simon

On 6/2/05, Simon Posnjak <sposnjak at gmail.com> wrote:
> Hi all,
> 
> Yesterday I reported that I am having problems with sqlite3 (3.2.1)
> and uclibc (0.9.27). Today I did a bit of investigating and found that
> the problem is connected to fstat function.



More information about the uClibc mailing list