From: Xavi Hernandez Date: Tue, 13 Jan 2026 12:30:16 +0000 (+0100) Subject: libcephfs_proxy: copy config files into a subdirectory and keep the name X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=235fd846ca2292e7183f963f0b351b4514317fc1;p=ceph.git libcephfs_proxy: copy config files into a subdirectory and keep the name Instead of creating a copy of the config file whose name contains the hash of the file, we create a directory using the hash and size as its name, and the file is copied inside using the same exact name. This is necessary because libcephfs, in some cases, may deduce the cluster name from the name of the config file. Signed-off-by: Xavi Hernandez --- diff --git a/src/libcephfs_proxy/proxy_mount.c b/src/libcephfs_proxy/proxy_mount.c index 1c404f64e26..67f8c588288 100644 --- a/src/libcephfs_proxy/proxy_mount.c +++ b/src/libcephfs_proxy/proxy_mount.c @@ -654,6 +654,7 @@ static int32_t proxy_config_prepare(proxy_settings_t *settings, char hash[65]; proxy_config_t cfg; struct stat before; + const char *name; int32_t err; cfg.size = 4096; @@ -685,8 +686,28 @@ static int32_t proxy_config_prepare(proxy_settings_t *settings, goto done_dst; } - err = proxy_snprintf(path, size, "%s/ceph-%s.conf", settings->work_dir, - hash); + err = proxy_snprintf(path, size, "%s/%s_%d", settings->work_dir, + hash, cfg.total); + if (err < 0) { + goto done_dst; + } + + if (mkdir(path, 0700) < 0) { + if (errno != EEXIST) { + err = proxy_log(LOG_ERR, errno, + "Failed to create a directory"); + goto done_dst; + } + } + + name = strrchr(config, '/'); + if (name == NULL) { + name = config; + } else { + name++; + } + + err = proxy_snprintf(path + err, size - err, "/%s", name); if (err < 0) { goto done_dst; } @@ -829,7 +850,8 @@ static int32_t proxy_instance_release(proxy_instance_t *instance) static int32_t proxy_instance_config(proxy_instance_t *instance, const char *config) { - char path[strlen(instance->settings->work_dir) + 128], *ppath; + char path[strlen(instance->settings->work_dir) + strlen(config) + 80]; + char *ppath; int32_t err; if (instance->mounted) {