Command to make a directory on the consumer or relay
[lttng-tools.git] / src / common / consumer / consumer.c
index 2d66048087727d6ae8fe063aeb871a36dbea8536..b449c1637875ec3d9fd480e49982975ca17ab193 100644 (file)
@@ -3783,3 +3783,51 @@ unsigned long consumer_get_consume_start_pos(unsigned long consumed_pos,
        }
        return start_pos;
 }
+
+static
+int mkdir_local(const char *path, uid_t uid, gid_t gid)
+{
+       int ret;
+
+       ret = utils_mkdir_recursive(path, S_IRWXU | S_IRWXG, uid, gid);
+       if (ret < 0) {
+               /* utils_mkdir_recursive logs an error. */
+               goto end;
+       }
+
+       ret = 0;
+end:
+       return ret;
+}
+
+static
+int mkdir_relay(const char *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;
+       }
+
+       pthread_mutex_lock(&relayd->ctrl_sock_mutex);
+       ret = relayd_mkdir(&relayd->control_sock, path);
+       pthread_mutex_unlock(&relayd->ctrl_sock_mutex);
+
+end:
+       return ret;
+
+}
+
+int lttng_consumer_mkdir(const char *path, uid_t uid, gid_t gid,
+               uint64_t relayd_id)
+{
+       if (relayd_id != -1ULL) {
+               return mkdir_relay(path, relayd_id);
+       } else {
+               return mkdir_local(path, uid, gid);
+       }
+}
This page took 0.024218 seconds and 5 git commands to generate.