File: evdi_debug.c

package info (click to toggle)
evdi 1.14.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 576 kB
  • sloc: ansic: 5,575; cpp: 474; python: 163; sh: 147; makefile: 143
file content (35 lines) | stat: -rw-r--r-- 888 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2015 - 2019 DisplayLink (UK) Ltd.
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License v2. See the file COPYING in the main directory of this archive for
 * more details.
 */

#include <linux/sched.h>
#include <linux/proc_fs.h>

#include "evdi_debug.h"

void evdi_log_process(char *buf, size_t size)
{
	int task_pid = (int)task_pid_nr(current);
	char task_comm[TASK_COMM_LEN] = { 0 };

	get_task_comm(task_comm, current);

	if (current->group_leader) {
		char process_comm[TASK_COMM_LEN] = { 0 };

		get_task_comm(process_comm, current->group_leader);
		snprintf(buf, size, "Task %d (%s) of process %d (%s)",
			  task_pid,
			  task_comm,
			  (int)task_pid_nr(current->group_leader),
			  process_comm);
	} else {
		snprintf(buf, size, "Task %d (%s)",
			  task_pid,
			  task_comm);
	}
}