From 4e41528ba52c42cada71b09b65dd978e126ed1a8 Mon Sep 17 00:00:00 2001 From: Alexander Mikhalitsyn Date: Sun, 28 Apr 2024 22:05:51 +0200 Subject: [PATCH] proc_fuse: add disable_uptime feature Signed-off-by: Alexander Mikhalitsyn --- src/bindings.c | 1 + src/bindings.h | 1 + src/proc_fuse.c | 3 +++ 3 files changed, 5 insertions(+) diff --git a/src/bindings.c b/src/bindings.c index 01690169..62ecbbbe 100644 --- a/src/bindings.c +++ b/src/bindings.c @@ -41,6 +41,7 @@ #include "utils.h" feature_t per_instance_features[63] = { + { .name = "disable_uptime", }, { } }; diff --git a/src/bindings.h b/src/bindings.h index df3a8aa9..6218795c 100644 --- a/src/bindings.h +++ b/src/bindings.h @@ -165,6 +165,7 @@ struct pidns_store { /* Do not free on liblxcfs reload (contains useful persistent data) */ bool keep_on_reload; +#define LXCFS_FEATURES_DISABLE_UPTIME (1 << 0) /* bit mask for per-instance configuration options (on/off) */ __u64 features; }; diff --git a/src/proc_fuse.c b/src/proc_fuse.c index 1049e72d..c991d236 100644 --- a/src/proc_fuse.c +++ b/src/proc_fuse.c @@ -942,6 +942,9 @@ static int proc_uptime_read(char *buf, size_t size, off_t offset, return total_len; } + if (check_set_lxcfs_feature(fc->pid, LXCFS_FEATURE_CHECK, LXCFS_FEATURES_DISABLE_UPTIME)) + return read_file_fuse("/proc/uptime", buf, size, d); + reaperage = get_reaper_age(fc->pid); /* * To understand why this is done, please read the comment to the