(1) It is a bit unclear where "struct stat" should be used and where the new "zbx_stat_t" should be.
For instance, __zbx_zabbix_log() uses "zbx_stat_t" for a call to stat(), but src/libs/zbxsysinfo/common/file.c uses it the other way round: "struct stat" for a call to zbx_stat().
It seems that the stat()-ing interface should be made more intuitive.
While at it, please see r43975.
Andris Zeila It should be used at least in code that is used also on windows. But I missed the sysinfo/common/ directory.
Andris Zeila RESOLVED in r43980
Aleksandrs Saveljevs These are our current definitions for zbx_stat():
# define zbx_stat(path, buf) __zbx_stat(path, buf)
# define zbx_stat(path, buf) _stat64(path, buf)
# define zbx_stat(path, buf) stat(path, buf)
The first definition accepts "zbx_stat_t", the second "struct __stat64", the third "struct stat".
Here are our current definitions for "zbx_stat_t":
#if defined(_WINDOWS) && defined(_UNICODE)
typedef struct __stat64 zbx_stat_t;
int __zbx_stat(const char *path, zbx_stat_t *buf);
typedef struct stat zbx_stat_t;
#endif /* _WINDOWS && _UNICODE */
It seems that these definitions do not match the second case above, because "zbx_stat_t" will be "struct stat", but _stat64() expects "struct __stat64".
Aleksandrs Saveljevs Also, as pointed above, __zbx_zabbix_log() uses "zbx_stat_t" for a call to stat(). For Windows and Unicode, "zbx_stat_t" will be "struct __stat64". Can stat() really be called on that structure? REOPENED.
Andris Zeila Actually it would call _stat64 because of a define we had in zbxtypes (and now I understood why 'struct stat' worked with _wstat64 before). But it's really confusing, so I removed this defined and replaced all stat() calls used in Windows code with zbx_stat().
Andris Zeila RESOLVED in r44022
Aleksandrs Saveljevs Looks good, but please see 44027.
Andris Zeila Thanks, CLOSED