+ end:
+ return retval;
+}
+
+static int do_cmd_put_subbuffer(const char *recvbuf, struct ustcomm_source *src)
+{
+ int retval = 0;
+ struct ust_trace *trace;
+ char trace_name[] = "auto";
+ int i;
+ char *channel_and_cpu;
+ int found = 0;
+ int result;
+ char *ch_name;
+ int ch_cpu;
+ long consumed_old;
+ char *consumed_old_str;
+ char *endptr;
+ char *reply = NULL;
+
+ DBG("put_subbuf");
+
+ channel_and_cpu = strdup(nth_token(recvbuf, 1));
+ if(channel_and_cpu == NULL) {
+ ERR("cannot parse channel");
+ retval = -1;
+ goto end;
+ }
+
+ consumed_old_str = strdup(nth_token(recvbuf, 2));
+ if(consumed_old_str == NULL) {
+ ERR("cannot parse consumed_old");
+ retval = -1;
+ goto free_channel_and_cpu;
+ }
+ consumed_old = strtol(consumed_old_str, &endptr, 10);
+ if(*endptr != '\0') {
+ ERR("invalid value for consumed_old");
+ retval = -1;
+ goto free_consumed_old_str;
+ }
+
+ seperate_channel_cpu(channel_and_cpu, &ch_name, &ch_cpu);
+ if(ch_cpu == -1) {
+ ERR("problem parsing channel name");
+ retval = -1;
+ goto free_short_chan_name;
+ }
+
+ ltt_lock_traces();
+ trace = _ltt_trace_find(trace_name);
+
+ if(trace == NULL) {
+ DBG("Cannot find trace. It was likely destroyed by the user.");
+ result = ustcomm_send_reply(&ustcomm_app.server, "NOTFOUND", src);
+ if(result) {
+ ERR("ustcomm_send_reply failed");
+ retval = -1;
+ goto unlock_traces;