From bf557ec53e8df9273b7a579e82a65b3e55d93055 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 752114a5..e3f9d611 100644 --- a/src/bindings.c +++ b/src/bindings.c @@ -46,6 +46,7 @@ #define ROOTDIR "/lxcfs/root" feature_t per_instance_features[63] = { + { .name = "disable_uptime", }, { } }; diff --git a/src/bindings.h b/src/bindings.h index 74b5cfd1..68a25ff4 100644 --- a/src/bindings.h +++ b/src/bindings.h @@ -161,6 +161,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 f48c40b1..f759b756 100644 --- a/src/proc_fuse.c +++ b/src/proc_fuse.c @@ -948,6 +948,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