rename works on the relay
[deliverable/lttng-tools.git] / src / common / consumer / consumer.c
index ba9bece2b5ba5f766e839b30700e2a013a005166..e2f3568b3f3b9e99551ee06f700352444220d026 100644 (file)
@@ -4277,20 +4277,19 @@ end:
        return ret;
 }
 
-int lttng_consumer_rotate_rename(char *current_path, char *new_path,
-               uint32_t create, uid_t uid, gid_t gid)
+static
+int rotate_rename_local(char *current_path, char *new_path,
+               uid_t uid, gid_t gid)
 {
        int ret;
 
-       if (create) {
-               ret = utils_mkdir_recursive(new_path, S_IRWXU | S_IRWXG,
-                               uid, gid);
-               if (ret < 0) {
-                       ERR("Create directory on rotate");
-                       goto end;
-               }
-
+       ret = utils_mkdir_recursive(new_path, S_IRWXU | S_IRWXG,
+                       uid, gid);
+       if (ret < 0) {
+               ERR("Create directory on rotate");
+               goto end;
        }
+
        ret = rename(current_path, new_path);
        /*
         * If a domain has not yet created its channel, the domain-specific
@@ -4306,3 +4305,33 @@ int lttng_consumer_rotate_rename(char *current_path, char *new_path,
 end:
        return ret;
 }
+
+static
+int rotate_rename_relay(char *current_path, char *new_path, uint64_t relayd_id)
+{
+       int ret;
+       struct consumer_relayd_sock_pair *relayd;
+
+       relayd = consumer_find_relayd(relayd_id);
+       if (!relayd) {
+               ERR("Failed to find relayd");
+               ret = -1;
+               goto end;
+       }
+
+       ret = relayd_rotate_rename(&relayd->control_sock, current_path, new_path);
+
+end:
+       return ret;
+
+}
+
+int lttng_consumer_rotate_rename(char *current_path, char *new_path,
+               uid_t uid, gid_t gid, uint64_t relayd_id)
+{
+       if (relayd_id != (uint64_t) -1ULL) {
+               return rotate_rename_relay(current_path, new_path, relayd_id);
+       } else {
+               return rotate_rename_local(current_path, new_path, uid, gid);
+       }
+}
This page took 0.025971 seconds and 5 git commands to generate.