strange runtime problem: struct stat, sys/stat.h

strange runtime problem: struct stat, sys/stat.h

Post by Alexandre Komia » Fri, 03 Mar 2000 04:00:00



I am            : SunOS 5.6 Generic sun4c sparc SUNW,Sun_4_40
C compiler      : /opt/SUNWspro/bin/cc

And now, the problem:

main()
{
        struct  stat    bufstat;
        if(bufstat.st_mtime != (time_t)0 )
                ;

Quote:}

The code above is quite edible for compiler.
But at runtime 'st_mtime' field isn't recognised. Instead, 'st_mtim' play
the role of 'st_mtime'.
'st_mtim' in turn,  isn't passed by the compiler.

Thus, parsing of bufstat (the more, after fstat() calls) cannot be
trusted.

/usr/include/sys/stat.h defines struct stat as follows (fields of interest
are presented):

#if defined(_KERNEL)
struct  stat {
...
        timestruc_t st_atime;
        timestruc_t st_mtime;
        timestruc_t st_ctime;
...

Quote:}

#else /* !defined(_KERNEL) */
struct  stat {
...
        timestruc_t st_atim;
        timestruc_t st_mtim;
        timestruc_t st_ctim;
...
Quote:}

#endif

Any ideas?

Alex,

 
 
 

strange runtime problem: struct stat, sys/stat.h

Post by Casper H.S. Dik - Network Security Engine » Fri, 03 Mar 2000 04:00:00


[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]


>The code above is quite edible for compiler.
>But at runtime 'st_mtime' field isn't recognised. Instead, 'st_mtim' play

At compile time, you mean?

The include file also has:

#define st_mtime        st_mtim.tv_sec

This should make st_mtime work.

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.