Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndris Zeila <andris.zeila@zabbix.com>2014-04-08 16:49:23 +0400
committerAndris Zeila <andris.zeila@zabbix.com>2014-04-08 16:49:23 +0400
commit64af8f342eff7c5a01af4cf7b6f6459597e49582 (patch)
tree75ad699cef98a9ddcb34d0da69e1214cb1d7ce54
parent37623b3fd477d28463d76e56e5abd39f502c5c56 (diff)
...G...... [ZBX-7856] added workaround for Windows _wstat64() not working with symlinks
[merge ^/branches/2.2 -c r44213]
-rw-r--r--ChangeLog2
-rw-r--r--include/common.h9
-rw-r--r--include/zbxtypes.h86
-rw-r--r--src/libs/zbxcommon/file.c27
-rw-r--r--src/libs/zbxconf/cfg.c6
-rw-r--r--src/libs/zbxdb/db.c4
-rw-r--r--src/libs/zbxlog/log.c4
-rw-r--r--src/libs/zbxnix/pid.c4
-rw-r--r--src/libs/zbxsysinfo/aix/proc.c8
-rw-r--r--src/libs/zbxsysinfo/common/file.c8
-rw-r--r--src/libs/zbxsysinfo/common/net.c7
-rw-r--r--src/libs/zbxsysinfo/linux/diskio.c4
-rw-r--r--src/libs/zbxsysinfo/linux/proc.c18
-rw-r--r--src/libs/zbxsysinfo/linux/swap.c4
-rw-r--r--src/libs/zbxsysinfo/osf/proc.c8
-rw-r--r--src/libs/zbxsysinfo/solaris/proc.c8
-rw-r--r--src/zabbix_agent/logfiles.c6
-rw-r--r--src/zabbix_server/snmptrapper/snmptrapper.c8
18 files changed, 109 insertions, 112 deletions
diff --git a/ChangeLog b/ChangeLog
index 5c2a0b09d27..bc730e0babf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -80,6 +80,7 @@ New features:
........S. [ZBX-7555] removed "select" statement from the history cache; increased the cache performance (Sasha)
Bug fixes:
+...G...... [ZBX-7856] added workaround for Windows _wstat64() not working with symlinks (wiper)
........S. [ZBX-7534] fixed buffers being too small for long function parameters containing UTF-8 characters (asaveljevs)
...G....S. [ZBX-7046] fixed get_ip_by_socket returning an empty string for IPv4 addresses when Zabbix is compiled with IPv6 support (Juris)
..F....... [ZBX-7630] fixed monitoring event page navigation (Eduard)
@@ -983,6 +984,7 @@ New features:
A.F....... [ZBX-1357] updated Brazilian Portuguese, Italian, Japanese, Slovak and Ukrainian translations; thanks to Zabbix translators (Richlv)
Bug fixes:
+...G...... [ZBX-7856] added workaround for Windows _wstat64() not working with symlinks (wiper)
..F....... [ZBX-8030] fixed {HOSTNAME} macro resolving (Eduard)
...G....S. [ZBX-7046] fixed get_ip_by_socket returning an empty string for IPv4 addresses when Zabbix is compiled with IPv6 support (Juris)
..F....... [ZBX-7966] fixed possibility to copy a templated graph (Ivo)
diff --git a/include/common.h b/include/common.h
index ce8a0bd483d..0b1c3a92250 100644
--- a/include/common.h
+++ b/include/common.h
@@ -1024,10 +1024,13 @@ void dos2unix(char *str);
int str2uint64(const char *str, const char *suffixes, zbx_uint64_t *value);
double str2double(const char *str);
-#if defined(_WINDOWS) && defined(_UNICODE)
-int __zbx_stat(const char *path, struct stat *buf);
+#if defined(_WINDOWS)
+typedef struct __stat64 zbx_stat_t;
+int __zbx_stat(const char *path, zbx_stat_t *buf);
int __zbx_open(const char *pathname, int flags);
-#endif /* _WINDOWS && _UNICODE */
+#else
+typedef struct stat zbx_stat_t;
+#endif /* _WINDOWS */
typedef int (*zbx_process_value_func_t)(const char *, unsigned short, const char *, const char *, const char *,
zbx_uint64_t *, int *, unsigned long *, const char *, unsigned short *, unsigned long *, unsigned char);
diff --git a/include/zbxtypes.h b/include/zbxtypes.h
index fa300cb9508..77f9933aae7 100644
--- a/include/zbxtypes.h
+++ b/include/zbxtypes.h
@@ -27,55 +27,41 @@
#if defined(_WINDOWS)
-#ifdef _UNICODE
# define zbx_stat(path, buf) __zbx_stat(path, buf)
# define zbx_open(pathname, flags) __zbx_open(pathname, flags | O_BINARY)
-#else
-# define zbx_stat(path, buf) _stat64(path, buf)
-# define zbx_open(pathname, flags) open(pathname, flags | O_BINARY)
-#endif
-#ifdef UNICODE
# include <strsafe.h>
-# define zbx_wsnprintf StringCchPrintf
-# define zbx_strlen wcslen
-# define zbx_strchr wcschr
-# define zbx_strstr wcsstr
-# define zbx_fullpath _wfullpath
-#else
-# define zbx_wsnprintf zbx_snprintf
-# define zbx_strlen strlen
-# define zbx_strchr strchr
-# define zbx_strstr strstr
-# define zbx_fullpath _fullpath
-#endif
+# define zbx_wsnprintf StringCchPrintf
+# define zbx_strlen wcslen
+# define zbx_strchr wcschr
+# define zbx_strstr wcsstr
+# define zbx_fullpath _wfullpath
-#ifndef __UINT64_C
-# define __UINT64_C(x) x
-#endif
+# ifndef __UINT64_C
+# define __UINT64_C(x) x
+# endif
-# define zbx_uint64_t unsigned __int64
-# define ZBX_FS_UI64 "%I64u"
-# define ZBX_FS_UO64 "%I64o"
-# define ZBX_FS_UX64 "%I64x"
+# define zbx_uint64_t unsigned __int64
+# define ZBX_FS_UI64 "%I64u"
+# define ZBX_FS_UO64 "%I64o"
+# define ZBX_FS_UX64 "%I64x"
-# define stat _stat64
# define snprintf _snprintf
# define alloca _alloca
-#ifndef uint32_t
-# define uint32_t __int32
-#endif
+# ifndef uint32_t
+# define uint32_t __int32
+# endif
-#ifndef PATH_SEPARATOR
-# define PATH_SEPARATOR '\\'
-#endif
+# ifndef PATH_SEPARATOR
+# define PATH_SEPARATOR '\\'
+# endif
# define strcasecmp lstrcmpiA
typedef __int64 zbx_offset_t;
-#define zbx_lseek(fd, offset, whence) _lseeki64(fd, (zbx_offset_t)(offset), whence)
+# define zbx_lseek(fd, offset, whence) _lseeki64(fd, (zbx_offset_t)(offset), whence)
#else /* _WINDOWS */
@@ -84,37 +70,35 @@ typedef __int64 zbx_offset_t;
# ifndef __UINT64_C
# ifdef UINT64_C
-# define __UINT64_C(c) (UINT64_C(c))
+# define __UINT64_C(c) (UINT64_C(c))
# else
-# define __UINT64_C(c) (c ## ULL)
+# define __UINT64_C(c) (c ## ULL)
# endif
# endif
-# define zbx_uint64_t uint64_t
+# define zbx_uint64_t uint64_t
# if __WORDSIZE == 64
-# define ZBX_FS_UI64 "%lu"
-# define ZBX_FS_UO64 "%lo"
-# define ZBX_FS_UX64 "%lx"
-# define ZBX_OFFSET 10000000000000000UL
+# define ZBX_FS_UI64 "%lu"
+# define ZBX_FS_UO64 "%lo"
+# define ZBX_FS_UX64 "%lx"
# else
# ifdef HAVE_LONG_LONG_QU
-# define ZBX_FS_UI64 "%qu"
-# define ZBX_FS_UO64 "%qo"
-# define ZBX_FS_UX64 "%qx"
+# define ZBX_FS_UI64 "%qu"
+# define ZBX_FS_UO64 "%qo"
+# define ZBX_FS_UX64 "%qx"
# else
-# define ZBX_FS_UI64 "%llu"
-# define ZBX_FS_UO64 "%llo"
-# define ZBX_FS_UX64 "%llx"
+# define ZBX_FS_UI64 "%llu"
+# define ZBX_FS_UO64 "%llo"
+# define ZBX_FS_UX64 "%llx"
# endif
-# define ZBX_OFFSET 10000000000000000ULL
# endif
-#ifndef PATH_SEPARATOR
-# define PATH_SEPARATOR '/'
-#endif
+# ifndef PATH_SEPARATOR
+# define PATH_SEPARATOR '/'
+# endif
typedef off_t zbx_offset_t;
-#define zbx_lseek(fd, offset, whence) lseek(fd, (zbx_offset_t)(offset), whence)
+# define zbx_lseek(fd, offset, whence) lseek(fd, (zbx_offset_t)(offset), whence)
#endif /* _WINDOWS */
diff --git a/src/libs/zbxcommon/file.c b/src/libs/zbxcommon/file.c
index 5f7aee9125d..cef9dc01c3c 100644
--- a/src/libs/zbxcommon/file.c
+++ b/src/libs/zbxcommon/file.c
@@ -19,14 +19,31 @@
#include "common.h"
-#if defined(_WINDOWS) && defined(_UNICODE)
-int __zbx_stat(const char *path, struct stat *buf)
+#if defined(_WINDOWS)
+int __zbx_stat(const char *path, zbx_stat_t *buf)
{
- int ret;
+ int ret, fd;
wchar_t *wpath;
wpath = zbx_utf8_to_unicode(path);
- ret = _wstat64(wpath, buf);
+
+ if (-1 == (ret = _wstat64(wpath, buf)))
+ goto out;
+
+ if (0 != buf->st_size)
+ goto out;
+
+ /* In the case of symlinks _wstat64 returns zero file size. */
+ /* Try to work around it by opening the file and using fstat. */
+
+ ret = -1;
+
+ if (-1 != (fd = _wopen(wpath, O_RDONLY)))
+ {
+ ret = _fstat64(fd, buf);
+ _close(fd);
+ }
+out:
zbx_free(wpath);
return ret;
@@ -158,7 +175,7 @@ int zbx_read(int fd, char *buf, size_t count, const char *encoding)
int zbx_is_regular_file(const char *path)
{
- struct stat st;
+ zbx_stat_t st;
if (0 == zbx_stat(path, &st) && 0 != S_ISREG(st.st_mode))
return SUCCEED;
diff --git a/src/libs/zbxconf/cfg.c b/src/libs/zbxconf/cfg.c
index 880d9dc2833..b5f7788bddc 100644
--- a/src/libs/zbxconf/cfg.c
+++ b/src/libs/zbxconf/cfg.c
@@ -109,12 +109,12 @@ out:
return ret;
#else
DIR *dir;
- struct stat sb;
+ zbx_stat_t sb;
struct dirent *d;
char *incl_file = NULL;
int result = SUCCEED;
- if (-1 == stat(cfg_file, &sb))
+ if (-1 == zbx_stat(cfg_file, &sb))
{
zbx_error("%s: %s\n", cfg_file, zbx_strerror(errno));
return FAIL;
@@ -133,7 +133,7 @@ out:
{
incl_file = zbx_dsprintf(incl_file, "%s/%s", cfg_file, d->d_name);
- if (-1 == stat(incl_file, &sb) || !S_ISREG(sb.st_mode))
+ if (-1 == zbx_stat(incl_file, &sb) || !S_ISREG(sb.st_mode))
continue;
if (FAIL == __parse_cfg_file(incl_file, cfg, level, ZBX_CFG_FILE_REQUIRED, strict))
diff --git a/src/libs/zbxdb/db.c b/src/libs/zbxdb/db.c
index 7de60ed073c..d71e9eb28f7 100644
--- a/src/libs/zbxdb/db.c
+++ b/src/libs/zbxdb/db.c
@@ -508,9 +508,9 @@ void zbx_remove_sqlite3_mutex()
void zbx_db_init(const char *dbname, const char *const db_schema)
{
#if defined(HAVE_SQLITE3)
- struct stat buf;
+ zbx_stat_t buf;
- if (0 != stat(dbname, &buf))
+ if (0 != zbx_stat(dbname, &buf))
{
zabbix_log(LOG_LEVEL_WARNING, "cannot open database file \"%s\": %s", dbname, zbx_strerror(errno));
zabbix_log(LOG_LEVEL_WARNING, "creating database ...");
diff --git a/src/libs/zbxlog/log.c b/src/libs/zbxlog/log.c
index db814d51f92..dff006661fa 100644
--- a/src/libs/zbxlog/log.c
+++ b/src/libs/zbxlog/log.c
@@ -216,7 +216,7 @@ void __zbx_zabbix_log(int level, const char *fmt, ...)
static zbx_uint64_t old_size = 0;
va_list args;
struct tm *tm;
- struct stat buf;
+ zbx_stat_t buf;
#ifdef _WINDOWS
struct _timeb current_time;
WORD wType;
@@ -232,7 +232,7 @@ void __zbx_zabbix_log(int level, const char *fmt, ...)
{
zbx_mutex_lock(&log_file_access);
- if (0 != CONFIG_LOG_FILE_SIZE && 0 == stat(log_filename, &buf))
+ if (0 != CONFIG_LOG_FILE_SIZE && 0 == zbx_stat(log_filename, &buf))
{
if (CONFIG_LOG_FILE_SIZE * ZBX_MEBIBYTE < buf.st_size)
{
diff --git a/src/libs/zbxnix/pid.c b/src/libs/zbxnix/pid.c
index 4376f42ff24..70a100fc39c 100644
--- a/src/libs/zbxnix/pid.c
+++ b/src/libs/zbxnix/pid.c
@@ -27,7 +27,7 @@ static int fdpid = -1;
int create_pid_file(const char *pidfile)
{
int fd;
- struct stat buf;
+ zbx_stat_t buf;
struct flock fl;
fl.l_type = F_WRLCK;
@@ -37,7 +37,7 @@ int create_pid_file(const char *pidfile)
fl.l_pid = getpid();
/* check if pid file already exists */
- if (0 == stat(pidfile, &buf))
+ if (0 == zbx_stat(pidfile, &buf))
{
if (-1 == (fd = open(pidfile, O_WRONLY | O_APPEND)))
{
diff --git a/src/libs/zbxsysinfo/aix/proc.c b/src/libs/zbxsysinfo/aix/proc.c
index 162a1323322..8164b5d0964 100644
--- a/src/libs/zbxsysinfo/aix/proc.c
+++ b/src/libs/zbxsysinfo/aix/proc.c
@@ -74,7 +74,7 @@ int PROC_MEM(AGENT_REQUEST *request, AGENT_RESULT *result)
#ifdef HAVE_SYS_PROCFS_H
DIR *dir;
struct dirent *entries;
- struct stat buf;
+ zbx_stat_t buf;
struct psinfo psinfo;
int fd = -1;
#else
@@ -131,7 +131,7 @@ int PROC_MEM(AGENT_REQUEST *request, AGENT_RESULT *result)
zbx_snprintf(tmp, sizeof(tmp), "/proc/%s/psinfo", entries->d_name);
- if (0 != stat(tmp, &buf))
+ if (0 != zbx_stat(tmp, &buf))
continue;
if (-1 == (fd = open(tmp, O_RDONLY)))
@@ -230,7 +230,7 @@ int PROC_NUM(AGENT_REQUEST *request, AGENT_RESULT *result)
#ifdef HAVE_SYS_PROCFS_H
DIR *dir;
struct dirent *entries;
- struct stat buf;
+ zbx_stat_t buf;
struct psinfo psinfo;
int fd = -1;
#else
@@ -285,7 +285,7 @@ int PROC_NUM(AGENT_REQUEST *request, AGENT_RESULT *result)
zbx_snprintf(tmp, sizeof(tmp), "/proc/%s/psinfo", entries->d_name);
- if (0 != stat(tmp, &buf))
+ if (0 != zbx_stat(tmp, &buf))
continue;
if (-1 == (fd = open(tmp, O_RDONLY)))
diff --git a/src/libs/zbxsysinfo/common/file.c b/src/libs/zbxsysinfo/common/file.c
index fcadf2f3090..a6ac7aa4c23 100644
--- a/src/libs/zbxsysinfo/common/file.c
+++ b/src/libs/zbxsysinfo/common/file.c
@@ -29,7 +29,7 @@ extern int CONFIG_TIMEOUT;
int VFS_FILE_SIZE(AGENT_REQUEST *request, AGENT_RESULT *result)
{
- struct stat buf;
+ zbx_stat_t buf;
char *filename;
int ret = SYSINFO_RET_FAIL;
@@ -50,7 +50,7 @@ err:
int VFS_FILE_TIME(AGENT_REQUEST *request, AGENT_RESULT *result)
{
- struct stat buf;
+ zbx_stat_t buf;
char *filename, *type;
int ret = SYSINFO_RET_FAIL;
@@ -79,7 +79,7 @@ err:
int VFS_FILE_EXISTS(AGENT_REQUEST *request, AGENT_RESULT *result)
{
- struct stat buf;
+ zbx_stat_t buf;
char *filename;
int ret = SYSINFO_RET_FAIL, file_exists = -1;
@@ -111,7 +111,7 @@ int VFS_FILE_CONTENTS(AGENT_REQUEST *request, AGENT_RESULT *result)
char read_buf[MAX_BUFFER_LEN], *utf8, *contents = NULL;
size_t contents_alloc = 0, contents_offset = 0;
int nbytes, flen, f = -1, ret = SYSINFO_RET_FAIL;
- struct stat stat_buf;
+ zbx_stat_t stat_buf;
double ts;
ts = zbx_time();
diff --git a/src/libs/zbxsysinfo/common/net.c b/src/libs/zbxsysinfo/common/net.c
index b6712353313..1b49238f7df 100644
--- a/src/libs/zbxsysinfo/common/net.c
+++ b/src/libs/zbxsysinfo/common/net.c
@@ -174,12 +174,13 @@ static int dns_query(AGENT_REQUEST *request, AGENT_RESULT *result, int short_ans
#if defined(HAVE_RES_QUERY) || defined(_WINDOWS)
size_t offset = 0;
- int res, type, retrans, retry, i, ret = SYSINFO_RET_FAIL,
- saved_nscount, saved_retrans, saved_retry;
+ int res, type, retrans, retry, i, ret = SYSINFO_RET_FAIL;
char *ip, zone[MAX_STRING_LEN], buffer[MAX_STRING_LEN], *zone_str, *param;
struct in_addr inaddr;
+#ifndef _WINDOWS
+ int saved_nscount, saved_retrans, saved_retry;
struct sockaddr_in saved_ns;
-
+#endif
typedef struct
{
char *name;
diff --git a/src/libs/zbxsysinfo/linux/diskio.c b/src/libs/zbxsysinfo/linux/diskio.c
index 58ab6a47c8d..1eaf3b4770b 100644
--- a/src/libs/zbxsysinfo/linux/diskio.c
+++ b/src/libs/zbxsysinfo/linux/diskio.c
@@ -74,7 +74,7 @@ int get_diskstat(const char *devname, zbx_uint64_t *dstat)
char tmp[MAX_STRING_LEN], name[MAX_STRING_LEN], dev_path[MAX_STRING_LEN];
int i, ret = FAIL, dev_exists = FAIL;
zbx_uint64_t ds[ZBX_DSTAT_MAX], rdev_major, rdev_minor;
- struct stat dev_st;
+ zbx_stat_t dev_st;
int found = 0;
for (i = 0; i < ZBX_DSTAT_MAX; i++)
@@ -139,7 +139,7 @@ static int get_kernel_devname(const char *devname, char *kernel_devname, size_t
char tmp[MAX_STRING_LEN], name[MAX_STRING_LEN], dev_path[MAX_STRING_LEN];
int ret = FAIL;
zbx_uint64_t ds[ZBX_DSTAT_MAX], rdev_major, rdev_minor;
- struct stat dev_st;
+ zbx_stat_t dev_st;
if ('\0' == *devname)
return ret;
diff --git a/src/libs/zbxsysinfo/linux/proc.c b/src/libs/zbxsysinfo/linux/proc.c
index 385ab32008d..2556925a940 100644
--- a/src/libs/zbxsysinfo/linux/proc.c
+++ b/src/libs/zbxsysinfo/linux/proc.c
@@ -26,16 +26,6 @@
#define DO_MIN 2
#define DO_AVG 3
-static FILE *open_proc_file(const char *filename)
-{
- struct stat s;
-
- if (0 != stat(filename, &s))
- return NULL;
-
- return fopen(filename, "r");
-}
-
static int get_cmdline(FILE *f_cmd, char **line, size_t *line_offset)
{
size_t line_alloc = ZBX_KIBIBYTE, n;
@@ -265,12 +255,12 @@ int PROC_MEM(AGENT_REQUEST *request, AGENT_RESULT *result)
zbx_snprintf(tmp, sizeof(tmp), "/proc/%s/cmdline", entries->d_name);
- if (NULL == (f_cmd = open_proc_file(tmp)))
+ if (NULL == (f_cmd = fopen(tmp, "r")))
continue;
zbx_snprintf(tmp, sizeof(tmp), "/proc/%s/status", entries->d_name);
- if (NULL == (f_stat = open_proc_file(tmp)))
+ if (NULL == (f_stat = fopen(tmp, "r")))
continue;
if (FAIL == check_procname(f_cmd, f_stat, procname))
@@ -391,12 +381,12 @@ int PROC_NUM(AGENT_REQUEST *request, AGENT_RESULT *result)
zbx_snprintf(tmp, sizeof(tmp), "/proc/%s/cmdline", entries->d_name);
- if (NULL == (f_cmd = open_proc_file(tmp)))
+ if (NULL == (f_cmd = fopen(tmp, "r")))
continue;
zbx_snprintf(tmp, sizeof(tmp), "/proc/%s/status", entries->d_name);
- if (NULL == (f_stat = open_proc_file(tmp)))
+ if (NULL == (f_stat = fopen(tmp, "r")))
continue;
if (FAIL == check_procname(f_cmd, f_stat, procname))
diff --git a/src/libs/zbxsysinfo/linux/swap.c b/src/libs/zbxsysinfo/linux/swap.c
index 0b570a131e0..60014635915 100644
--- a/src/libs/zbxsysinfo/linux/swap.c
+++ b/src/libs/zbxsysinfo/linux/swap.c
@@ -109,12 +109,12 @@ static int get_swap_dev_stat(const char *swapdev, swap_stat_t *result)
int ret = SYSINFO_RET_FAIL;
char line[MAX_STRING_LEN];
int rdev_major, rdev_minor;
- struct stat dev_st;
+ zbx_stat_t dev_st;
FILE *f;
assert(result);
- if (-1 == stat(swapdev, &dev_st))
+ if (-1 == zbx_stat(swapdev, &dev_st))
return ret;
if (NULL == (f = fopen(INFO_FILE_NAME, "r")))
diff --git a/src/libs/zbxsysinfo/osf/proc.c b/src/libs/zbxsysinfo/osf/proc.c
index 6750defd8de..712a2a17752 100644
--- a/src/libs/zbxsysinfo/osf/proc.c
+++ b/src/libs/zbxsysinfo/osf/proc.c
@@ -32,7 +32,7 @@ int PROC_MEM(AGENT_REQUEST *request, AGENT_RESULT *result)
int proc;
struct dirent *entries;
- struct stat buf;
+ zbx_stat_t buf;
struct passwd *usrinfo;
struct prpsinfo psinfo;
@@ -82,7 +82,7 @@ int PROC_MEM(AGENT_REQUEST *request, AGENT_RESULT *result)
strscpy(filename, "/proc/");
zbx_strlcat(filename, entries->d_name, MAX_STRING_LEN);
- if (0 == stat(filename, &buf))
+ if (0 == zbx_stat(filename, &buf))
{
proc = open(filename, O_RDONLY);
if (-1 == proc)
@@ -154,7 +154,7 @@ int PROC_NUM(AGENT_REQUEST *request, AGENT_RESULT *result)
int proc;
struct dirent *entries;
- struct stat buf;
+ zbx_stat_t buf;
struct passwd *usrinfo;
struct prpsinfo psinfo;
@@ -200,7 +200,7 @@ int PROC_NUM(AGENT_REQUEST *request, AGENT_RESULT *result)
strscpy(filename, "/proc/");
zbx_strlcat(filename, entries->d_name,MAX_STRING_LEN);
- if (0 == stat(filename,&buf))
+ if (0 == zbx_stat(filename, &buf))
{
proc = open(filename, O_RDONLY);
if (-1 == proc)
diff --git a/src/libs/zbxsysinfo/solaris/proc.c b/src/libs/zbxsysinfo/solaris/proc.c
index 9f401808cca..30854ca9432 100644
--- a/src/libs/zbxsysinfo/solaris/proc.c
+++ b/src/libs/zbxsysinfo/solaris/proc.c
@@ -49,7 +49,7 @@ int PROC_MEM(AGENT_REQUEST *request, AGENT_RESULT *result)
char tmp[MAX_STRING_LEN], *procname, *proccomm, *param;
DIR *dir;
struct dirent *entries;
- struct stat buf;
+ zbx_stat_t buf;
struct passwd *usrinfo;
psinfo_t psinfo; /* In the correct procfs.h, the structure name is psinfo_t */
int fd = -1;
@@ -100,7 +100,7 @@ int PROC_MEM(AGENT_REQUEST *request, AGENT_RESULT *result)
zbx_snprintf(tmp, sizeof(tmp), "/proc/%s/psinfo", entries->d_name);
- if (0 != stat(tmp, &buf))
+ if (0 != zbx_stat(tmp, &buf))
continue;
if (-1 == (fd = open(tmp, O_RDONLY)))
@@ -155,7 +155,7 @@ int PROC_NUM(AGENT_REQUEST *request, AGENT_RESULT *result)
char tmp[MAX_STRING_LEN], *procname, *proccomm, *param;
DIR *dir;
struct dirent *entries;
- struct stat buf;
+ zbx_stat_t buf;
struct passwd *usrinfo;
psinfo_t psinfo; /* In the correct procfs.h, the structure name is psinfo_t */
int fd = -1;
@@ -204,7 +204,7 @@ int PROC_NUM(AGENT_REQUEST *request, AGENT_RESULT *result)
zbx_snprintf(tmp, sizeof(tmp), "/proc/%s/psinfo", entries->d_name);
- if (0 != stat(tmp, &buf))
+ if (0 != zbx_stat(tmp, &buf))
continue;
if (-1 == (fd = open(tmp, O_RDONLY)))
diff --git a/src/zabbix_agent/logfiles.c b/src/zabbix_agent/logfiles.c
index 30da8928d9e..69f0d4b2921 100644
--- a/src/zabbix_agent/logfiles.c
+++ b/src/zabbix_agent/logfiles.c
@@ -106,7 +106,7 @@ static int split_filename(const char *filename, char **directory, char **format)
{
const char *__function_name = "split_filename";
const char *separator = NULL;
- struct stat buf;
+ zbx_stat_t buf;
int ret = FAIL;
#ifdef _WINDOWS
size_t sz;
@@ -401,7 +401,7 @@ int process_logrt(char *filename, zbx_uint64_t *lastlogsize, int *mtime, unsigne
const char *__function_name = "process_logrt";
int i = 0, ret = FAIL, logfiles_num = 0, logfiles_alloc = 0, j = 0, reg_error;
char err_buf[MAX_STRING_LEN], *directory = NULL, *format = NULL, *logfile_candidate = NULL;
- struct stat file_buf;
+ zbx_stat_t file_buf;
struct st_logfile *logfiles = NULL;
#ifdef _WINDOWS
char *find_path = NULL, *file_name_utf8;
@@ -918,7 +918,7 @@ int process_log(char *filename, zbx_uint64_t *lastlogsize, int *mtime, unsigned
const char *__function_name = "process_log";
int f, ret = FAIL;
- struct stat buf;
+ zbx_stat_t buf;
zbx_uint64_t l_size;
zabbix_log(LOG_LEVEL_DEBUG, "In %s() filename:'%s' lastlogsize:" ZBX_FS_UI64 " mtime: %d",
diff --git a/src/zabbix_server/snmptrapper/snmptrapper.c b/src/zabbix_server/snmptrapper/snmptrapper.c
index 116ec25fd54..625e5d8d8e5 100644
--- a/src/zabbix_server/snmptrapper/snmptrapper.c
+++ b/src/zabbix_server/snmptrapper/snmptrapper.c
@@ -386,14 +386,14 @@ static void close_trap_file()
******************************************************************************/
static int open_trap_file()
{
- struct stat file_buf;
+ zbx_stat_t file_buf;
if (-1 == (trap_fd = open(CONFIG_SNMPTRAP_FILE, O_RDONLY)))
{
if (ENOENT != errno) /* file exists but cannot be opened */
zabbix_log(LOG_LEVEL_CRIT, "cannot open [%s]: %s", CONFIG_SNMPTRAP_FILE, zbx_strerror(errno));
}
- else if (FAIL == stat(CONFIG_SNMPTRAP_FILE, &file_buf))
+ else if (0 != zbx_stat(CONFIG_SNMPTRAP_FILE, &file_buf))
{
zabbix_log(LOG_LEVEL_CRIT, "cannot stat [%s]: %s", CONFIG_SNMPTRAP_FILE, zbx_strerror(errno));
close_trap_file();
@@ -419,11 +419,11 @@ static int open_trap_file()
******************************************************************************/
static int get_latest_data()
{
- struct stat file_buf;
+ zbx_stat_t file_buf;
if (-1 != trap_fd) /* a trap file is already open */
{
- if (0 != stat(CONFIG_SNMPTRAP_FILE, &file_buf))
+ if (0 != zbx_stat(CONFIG_SNMPTRAP_FILE, &file_buf))
{
/* file might have been renamed or deleted, process the current file */