return kernctl_disable_syscall(channel->fd, syscall_name);
}
+int kernel_track_pid(struct ltt_kernel_session *session, int pid)
+{
+ DBG("Kernel track PID %d for session id %" PRIu64 ".",
+ pid, session->id);
+ return kernctl_track_pid(session->fd, pid);
+}
+
+int kernel_untrack_pid(struct ltt_kernel_session *session, int pid)
+{
+ DBG("Kernel untrack PID %d for session id %" PRIu64 ".",
+ pid, session->id);
+ return kernctl_untrack_pid(session->fd, pid);
+}
+
+ssize_t kernel_list_tracker_pids(struct ltt_kernel_session *session,
+ int **_pids)
+{
+ int fd, ret;
+ int pid;
+ ssize_t nbmem, count = 0;
+ FILE *fp;
+ int *pids;
+
+ fd = kernctl_list_tracker_pids(session->fd);
+ if (fd < 0) {
+ PERROR("kernel tracker pids list");
+ goto error;
+ }
+
+ fp = fdopen(fd, "r");
+ if (fp == NULL) {
+ PERROR("kernel tracker pids list fdopen");
+ goto error_fp;
+ }
+
+ nbmem = KERNEL_TRACKER_PIDS_INIT_LIST_SIZE;
+ pids = zmalloc(sizeof(*pids) * nbmem);
+ if (pids == NULL) {
+ PERROR("alloc list pids");
+ count = -ENOMEM;
+ goto end;
+ }
+
+ while (fscanf(fp, "process { pid = %u; };\n", &pid) == 1) {
+ if (count >= nbmem) {
+ int *new_pids;
+ size_t new_nbmem;
+
+ new_nbmem = nbmem << 1;
+ DBG("Reallocating pids list from %zu to %zu entries",
+ nbmem, new_nbmem);
+ new_pids = realloc(pids, new_nbmem * sizeof(*new_pids));
+ if (new_pids == NULL) {
+ PERROR("realloc list events");
+ free(pids);
+ count = -ENOMEM;
+ goto end;
+ }
+ /* Zero the new memory */
+ memset(new_pids + nbmem, 0,
+ (new_nbmem - nbmem) * sizeof(*new_pids));
+ nbmem = new_nbmem;
+ pids = new_pids;
+ }
+ pids[count++] = pid;
+ }
+
+ *_pids = pids;
+ DBG("Kernel list tracker pids done (%zd pids)", count);
+end:
+ ret = fclose(fp); /* closes both fp and fd */
+ if (ret) {
+ PERROR("fclose");
+ }
+ return count;
+
+error_fp:
+ ret = close(fd);
+ if (ret) {
+ PERROR("close");
+ }
+error:
+ return -1;
+}
+
/*
* Create kernel metadata, open from the kernel tracer and add it to the
* kernel session.
struct lttng_ht_iter iter;
/* For each consumer socket. */
+ rcu_read_lock();
cds_lfht_for_each_entry(ksess->consumer->socks->ht, &iter.iter,
socket, node.node) {
struct ltt_kernel_channel *chan;
}
}
}
+ rcu_read_unlock();
}
/* Close any relayd session */
* Return 0 on success or else return a LTTNG_ERR code.
*/
int kernel_snapshot_record(struct ltt_kernel_session *ksess,
- struct snapshot_output *output, int wait, uint64_t max_size_per_stream)
+ struct snapshot_output *output, int wait,
+ uint64_t nb_packets_per_stream)
{
int err, ret, saved_metadata_fd;
struct consumer_socket *socket;
ret = consumer_snapshot_channel(socket, chan->fd, output, 0,
ksess->uid, ksess->gid,
DEFAULT_KERNEL_TRACE_DIR, wait,
- max_size_per_stream);
+ nb_packets_per_stream);
pthread_mutex_unlock(socket->lock);
if (ret < 0) {
ret = LTTNG_ERR_KERN_CONSUMER_FAIL;
pthread_mutex_lock(socket->lock);
ret = consumer_snapshot_channel(socket, ksess->metadata->fd, output,
1, ksess->uid, ksess->gid,
- DEFAULT_KERNEL_TRACE_DIR, wait, max_size_per_stream);
+ DEFAULT_KERNEL_TRACE_DIR, wait, 0);
pthread_mutex_unlock(socket->lock);
if (ret < 0) {
ret = LTTNG_ERR_KERN_CONSUMER_FAIL;