shm-path: remove directory hierarchy on destroy
[lttng-tools.git] / src / bin / lttng-sessiond / ust-registry.c
index 26f306d52d516ac6091e74a1cb26ef73821dbbbd..f9ddd25a5928e197d15834446fa9710ec665a44b 100644 (file)
@@ -547,6 +547,7 @@ int ust_registry_session_init(struct ust_registry_session **sessionp,
                int byte_order,
                uint32_t major,
                uint32_t minor,
                int byte_order,
                uint32_t major,
                uint32_t minor,
+               const char *root_shm_path,
                const char *shm_path,
                uid_t euid,
                gid_t egid)
                const char *shm_path,
                uid_t euid,
                gid_t egid)
@@ -571,6 +572,9 @@ int ust_registry_session_init(struct ust_registry_session **sessionp,
        session->long_alignment = long_alignment;
        session->byte_order = byte_order;
        session->metadata_fd = -1;
        session->long_alignment = long_alignment;
        session->byte_order = byte_order;
        session->metadata_fd = -1;
+       strncpy(session->root_shm_path, root_shm_path,
+               sizeof(session->root_shm_path));
+       session->root_shm_path[sizeof(session->root_shm_path) - 1] = '\0';
        if (shm_path[0]) {
                strncpy(session->shm_path, shm_path,
                        sizeof(session->shm_path));
        if (shm_path[0]) {
                strncpy(session->shm_path, shm_path,
                        sizeof(session->shm_path));
@@ -676,4 +680,10 @@ void ust_registry_session_destroy(struct ust_registry_session *reg)
                        PERROR("unlink");
                }
        }
                        PERROR("unlink");
                }
        }
+       if (reg->root_shm_path[0]) {
+               /*
+                * Try deleting the directory hierarchy.
+                */
+               (void) utils_recursive_rmdir(reg->root_shm_path);
+       }
 }
 }
This page took 0.023667 seconds and 4 git commands to generate.