1 #include <linux/debugfs.h>
2 #include <linux/module.h>
4 #include <driver/swap_debugfs.h>
5 #include <us_manager/sspt/sspt_proc.h>
7 #include "debugfs_us_manager.h"
9 #define MAX_APPS_COUNT 8 /* According to daemon defenitions */
10 #define PID_STRING 21 /* Maximum pid string = 20 (max digits count in
11 * unsigned int on 64-bit arch) + 1 (for \n) */
13 /* ============================================================================
15 * ============================================================================
24 static void on_each_proc_callback(struct sspt_proc *proc, void *data)
26 struct read_buf *rbuf = (struct read_buf *)data;
27 char pid_str[PID_STRING];
30 sprintf(pid_str, "%d", proc->tgid);
32 len = strlen(pid_str);
34 if (rbuf->end - rbuf->ptr < len + 2)
37 if (rbuf->ptr != rbuf->begin) {
42 memcpy(rbuf->ptr, pid_str, len);
46 static ssize_t read_tasks(struct file *file, char __user *user_buf,
47 size_t count, loff_t *ppos)
49 char buf[PID_STRING * MAX_APPS_COUNT];
50 struct read_buf rbuf = {
53 .end = buf + sizeof(buf)
56 on_each_proc_no_lock(on_each_proc_callback, (void *)&rbuf);
58 if (rbuf.ptr < rbuf.end)
62 return simple_read_from_buffer(user_buf, count, ppos, rbuf.begin,
63 rbuf.ptr - rbuf.begin);
66 static const struct file_operations fops_tasks = {
71 /* ============================================================================
73 * ============================================================================
76 static struct dentry *us_manager_dir = NULL;
78 void exit_debugfs_us_manager(void)
81 debugfs_remove_recursive(us_manager_dir);
83 us_manager_dir = NULL;
86 int init_debugfs_us_manager(void)
88 struct dentry *swap_dir, *dentry;
90 swap_dir = get_swap_debugfs_dir();
94 us_manager_dir = debugfs_create_dir(US_MANAGER_DFS_DIR, swap_dir);
95 if (us_manager_dir == NULL)
98 dentry = debugfs_create_file(US_MANAGER_TASKS, 0600, us_manager_dir, NULL,
106 exit_debugfs_us_manager();