X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fzone.c;h=188fbe3db3dc89108eb9ef45431d7aabb9108d58;hb=edb3002086ef96755804b2d155728cb9a0428935;hp=385e5116af87b67b1bc67761dad82718d2859e1b;hpb=4ecc24f84bc88eca1f358e604fceea3ef71683ff;p=collectd.git diff --git a/src/zone.c b/src/zone.c index 385e5116..188fbe3d 100644 --- a/src/zone.c +++ b/src/zone.c @@ -17,9 +17,18 @@ * * Authors: * Mathijs Mohlmann + * Dagobert Michelsen (forward-porting) **/ -#define _BSD_SOURCE +#if HAVE_CONFIG_H +# include "config.h" +# undef HAVE_CONFIG_H +#endif +/* avoid procfs.h error "Cannot use procfs in the large file compilation environment" */ +#if !defined(_LP64) && _FILE_OFFSET_BITS == 64 +# undef _FILE_OFFSET_BITS +# undef _LARGEFILE64_SOURCE +#endif #include "collectd.h" #include "common.h" @@ -65,10 +74,8 @@ zone_read_procfile(char *pidstr, char *file, void *buf, size_t bufsize) char procfile[MAX_PROCFS_PATH]; (void)snprintf(procfile, sizeof(procfile), "/proc/%s/%s", pidstr, file); - while ((fd = open(procfile, O_RDONLY)) == -1) { - if ((errno != EMFILE) || (errno != ENFILE)) { - return(1); - } + if ((fd = open(procfile, O_RDONLY)) == -1) { + return (1); } if (pread(fd, buf, bufsize, 0) != bufsize) { @@ -156,7 +163,8 @@ zone_scandir(DIR *procdir) return(NULL); } - for (rewinddir(procdir); (direntp = readdir(procdir)); ) { + rewinddir(procdir); + while ((direntp = readdir(procdir))) { pidstr = direntp->d_name; if (pidstr[0] == '.') /* skip "." and ".." */ continue;