From: Yadnesh Kulkarni Date: Wed, 22 Feb 2023 12:27:55 +0000 (+0530) Subject: Hugepages plugin skips reading write-only file X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fheads%2Fcollectd-5.13;p=thirdparty%2Fcollectd.git Hugepages plugin skips reading write-only file Since 'demote' is a write-only file do not attempt to to read it. This also prevents the plugin from generating incessant logs about the failure to open it. Fixes: #3993 https://docs.kernel.org/admin-guide/mm/hugetlbpage.html --- diff --git a/src/hugepages.c b/src/hugepages.c index e066300be..bd381a926 100644 --- a/src/hugepages.c +++ b/src/hugepages.c @@ -125,6 +125,14 @@ static int read_hugepage_entry(const char *path, const char *entry, struct entry_info *info = e_info; double value; + /** + * Since demote is a write-only file, do not attempt to open it. + * https://docs.kernel.org/admin-guide/mm/hugetlbpage.html + */ + if (strcmp(entry, "demote") == 0) { + return -1; + } + snprintf(path2, sizeof(path2), "%s/%s", path, entry); FILE *fh = fopen(path2, "rt");