/* SPDX-License-Identifier: LGPL-2.1+ */
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
#include "config.h"
-#ifdef HAVE_FUSE3
-#ifndef FUSE_USE_VERSION
-#define FUSE_USE_VERSION 30
-#endif
-#else
-#ifndef FUSE_USE_VERSION
-#define FUSE_USE_VERSION 26
-#endif
-#endif
-
-#define _FILE_OFFSET_BITS 64
-
-#define __STDC_FORMAT_MACROS
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
-#include <fuse.h>
#include <inttypes.h>
#include <libgen.h>
#include <pthread.h>
#include <sys/sysinfo.h>
#include <sys/vfs.h>
+#include "proc_cpuview.h"
+
#include "bindings.h"
#include "cgroup_fuse.h"
#include "cpuset_parse.h"
for (struct cg_proc_stat *prev = NULL; node; ) {
if (!cgroup_supports("cpu", node->cg, "cpu.shares")) {
- call_cleaner(free_proc_stat_node) struct cg_proc_stat *cur = node;
+ struct cg_proc_stat *cur = node;
if (prev)
prev->next = node->next;
first = node->next;
node = node->next;
- lxcfs_debug("Removing stat node for %s\n", cur->cg);
+ lxcfs_debug("Removing stat node for %s\n", cur);
+
+ free_proc_stat_node(cur);
} else {
if (!first)
first = node;
if (all_used >= cg_used) {
cg_cpu_usage[curcpu].idle = idle + (all_used - cg_used);
-
} else {
- lxcfs_error("cpu%d from %s has unexpected cpu time: %" PRIu64 " in /proc/stat, %" PRIu64 " in cpuacct.usage_all; unable to determine idle time",
- curcpu, cg, all_used, cg_used);
+ lxcfs_v("cpu%d from %s has unexpected cpu time: %" PRIu64 " in /proc/stat, %" PRIu64 " in cpuacct.usage_all; unable to determine idle time",
+ curcpu, cg, all_used, cg_used);
cg_cpu_usage[curcpu].idle = idle;
}
}
total_len = 0;
goto out_pthread_mutex_unlock;
}
- if (l >= buf_size) {
+ if ((size_t)l >= buf_size) {
lxcfs_error("Write to cache was truncated");
total_len = 0;
goto out_pthread_mutex_unlock;
total_len = 0;
goto out_pthread_mutex_unlock;
}
- if (l >= buf_size) {
+ if ((size_t)l >= buf_size) {
lxcfs_error("Write to cache was truncated");
total_len = 0;
goto out_pthread_mutex_unlock;
total_len = 0;
goto out_pthread_mutex_unlock;
}
- if (l >= buf_size) {
+ if ((size_t)l >= buf_size) {
lxcfs_error("Write to cache was truncated");
total_len = 0;
goto out_pthread_mutex_unlock;
total_len = 0;
goto out_pthread_mutex_unlock;
}
- if (l >= buf_size) {
+ if ((size_t)l >= buf_size) {
lxcfs_error("Write to cache was truncated");
total_len = 0;
goto out_pthread_mutex_unlock;
size_t cache_size = d->buflen;
if (offset) {
- int left;
+ size_t left;
if (offset > d->size)
return -EINVAL;
l = snprintf(cache, cache_size, "processor : %d\n", curcpu);
if (l < 0)
return log_error(0, "Failed to write cache");
- if (l >= cache_size)
+ if ((size_t)l >= cache_size)
return log_error(0, "Write to cache was truncated");
cache += l;
cache_size -= l;
l = snprintf(cache, cache_size, "processor %d:%s", curcpu, p);
if (l < 0)
return log_error(0, "Failed to write cache");
- if (l >= cache_size)
+ if ((size_t)l >= cache_size)
return log_error(0, "Write to cache was truncated");
cache += l;
l = snprintf(cache, cache_size, "%s", line);
if (l < 0)
return log_error(0, "Failed to write cache");
- if (l >= cache_size)
+ if ((size_t)l >= cache_size)
return log_error(0, "Write to cache was truncated");
cache += l;
cache_size = d->buflen;
total_len = 0;
l = snprintf(cache, cache_size, "vendor_id : IBM/S390\n");
- if (l < 0 || l >= cache_size)
+ if (l < 0 || (size_t)l >= cache_size)
return 0;
cache_size -= l;
cache += l;
total_len += l;
l = snprintf(cache, cache_size, "# processors : %d\n", curcpu + 1);
- if (l < 0 || l >= cache_size)
+ if (l < 0 || (size_t)l >= cache_size)
return 0;
cache_size -= l;
cache += l;
total_len += l;
l = snprintf(cache, cache_size, "%s", origcache);
- if (l < 0 || l >= cache_size)
+ if (l < 0 || (size_t)l >= cache_size)
return 0;
total_len += l;
}