From f34de69aeae3b7915ea3866f9af7b8aa7b8853f8 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Sat, 11 Mar 2017 17:19:12 +0100 Subject: [PATCH] bindings: increase reserved buffer size a little So far, only proc_stat_read() is fully using BUF_RESERVE_SIZE so it doesn't actually benefit from the additional memory assigned to it like all the other files in proc do. So double the size and have proc_stat_read() only use half of it. Supposedly fixes #176. Signed-off-by: Christian Brauner --- bindings.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bindings.c b/bindings.c index 0affa79..6387012 100644 --- a/bindings.c +++ b/bindings.c @@ -72,8 +72,8 @@ struct file_info { int cached; }; -/* reserve buffer size, for cpuall in /proc/stat */ -#define BUF_RESERVE_SIZE 256 +/* Reserve buffer size to account for file size changes. */ +#define BUF_RESERVE_SIZE 512 /* * A table caching which pid is init for a pid namespace. @@ -3475,6 +3475,7 @@ static long int getreaperctime(pid_t pid) return sb.st_ctime; } +#define CPUALL_MAX_SIZE (BUF_RESERVE_SIZE / 2) static int proc_stat_read(char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { @@ -3488,7 +3489,6 @@ static int proc_stat_read(char *buf, size_t size, off_t offset, unsigned long user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0, softirq = 0, steal = 0, guest = 0, guest_nice = 0; unsigned long user_sum = 0, nice_sum = 0, system_sum = 0, idle_sum = 0, iowait_sum = 0, irq_sum = 0, softirq_sum = 0, steal_sum = 0, guest_sum = 0, guest_nice_sum = 0; -#define CPUALL_MAX_SIZE BUF_RESERVE_SIZE char cpuall[CPUALL_MAX_SIZE]; /* reserve for cpu all */ char *cache = d->buf + CPUALL_MAX_SIZE; -- 2.39.2