]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephfs_proxy: copy config files into a subdirectory and keep the name
authorXavi Hernandez <xhernandez@gmail.com>
Tue, 13 Jan 2026 12:30:16 +0000 (13:30 +0100)
committerXavi Hernandez <xhernandez@gmail.com>
Tue, 10 Feb 2026 07:20:27 +0000 (08:20 +0100)
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 <xhernandez@gmail.com>
src/libcephfs_proxy/proxy_mount.c

index 1c404f64e26b2e529d871ab65d962176f107486a..67f8c5882885392f306a6fe2b28d4174df2ea388 100644 (file)
@@ -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) {