summaryrefslogtreecommitdiffstats
path: root/libnetdata/procfile/procfile.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2018-11-07 12:19:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2018-11-07 12:20:17 +0000
commita64a253794ac64cb40befee54db53bde17dd0d49 (patch)
treec1024acc5f6e508814b944d99f112259bb28b1be /libnetdata/procfile/procfile.c
parentNew upstream version 1.10.0+dfsg (diff)
downloadnetdata-a64a253794ac64cb40befee54db53bde17dd0d49.tar.xz
netdata-a64a253794ac64cb40befee54db53bde17dd0d49.zip
New upstream version 1.11.0+dfsgupstream/1.11.0+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--libnetdata/procfile/procfile.c (renamed from src/procfile.c)12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/procfile.c b/libnetdata/procfile/procfile.c
index 044f975b5..4a812baab 100644
--- a/src/procfile.c
+++ b/libnetdata/procfile/procfile.c
@@ -1,5 +1,6 @@
-#include "common.h"
-#include "procfile.h"
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#include "../libnetdata.h"
#define PF_PREFIX "PROCFILE"
@@ -7,6 +8,8 @@
#define PFLINES_INCREASE_STEP 10
#define PROCFILE_INCREMENT_BUFFER 512
+int procfile_open_flags = O_RDONLY;
+
int procfile_adaptive_initial_allocation = 0;
// if adaptive allocation is set, these store the
@@ -391,7 +394,7 @@ void procfile_set_open_close(procfile *ff, const char *open, const char *close)
procfile *procfile_open(const char *filename, const char *separators, uint32_t flags) {
debug(D_PROCFILE, PF_PREFIX ": Opening file '%s'", filename);
- int fd = open(filename, O_RDONLY, 0666);
+ int fd = open(filename, procfile_open_flags, 0666);
if(unlikely(fd == -1)) {
if(unlikely(!(flags & PROCFILE_FLAG_NO_ERROR_ON_FILE_IO))) error(PF_PREFIX ": Cannot open file '%s'", filename);
return NULL;
@@ -427,7 +430,7 @@ procfile *procfile_reopen(procfile *ff, const char *filename, const char *separa
close(ff->fd);
}
- ff->fd = open(filename, O_RDONLY, 0666);
+ ff->fd = open(filename, procfile_open_flags, 0666);
if(unlikely(ff->fd == -1)) {
procfile_close(ff);
return NULL;
@@ -451,6 +454,7 @@ procfile *procfile_reopen(procfile *ff, const char *filename, const char *separa
void procfile_print(procfile *ff) {
size_t lines = procfile_lines(ff), l;
char *s;
+ (void)s;
debug(D_PROCFILE, "File '%s' with %zu lines and %zu words", procfile_filename(ff), ff->lines->len, ff->words->len);