Sindbad~EG File Manager
/**
@file
@brief Process (aka task) info storage
@details Copyright (c) 2017-2021 Acronis International GmbH
@author Ivan Matveev (ivan.matveev@acronis.com)
@since $Id: $
*/
#pragma once
#include "transport_protocol.h" // task_status_t
#include <linux/path.h>
#include <linux/rbtree.h>
#include <linux/spinlock.h>
#include <linux/types.h> // bool
typedef struct {
struct rb_node rb_node;
pid_t pid;
atomic_t ref_cnt;
spinlock_t spinlock;
task_status_t status;
struct path exe_path;
struct list_head exited_list_item;
struct list_head clear_list_item;
bool is_exe_path_changed;
} task_info_t;
typedef struct task_info_map_s {
bool is_acquired;
spinlock_t spinlock;
struct rb_root root;
spinlock_t exited_list_spinlock;
struct list_head exited_list;
} task_info_map_t;
#define MAX_TASK_INFO_MAP_SIZE 4
const char *task_status_to_string(task_status_t status);
// on success return 0
int task_info_map_del_by_map_id(unsigned char map_id, pid_t pid);
// ========================= useful wrappers ========================= //
// create task_info struct if needed
// errors:
// 1. ENOMEM - alloc failed
// 2. ENOENT - no such pid or task_struct without executable file
// 3. EINVAL - task_info with sutch pid already exist - synchronisation broken
int task_info_status_set_by_map_id(unsigned char map_id, pid_t pid, task_status_t status);
void task_info_map_clear_exited_list_by_map_id(unsigned char map_id);
void task_info_map_on_exit_event(pid_t tgid, pid_t pid);
typedef void (*for_each_task_info_with_pid)(task_info_t *task_info, void *arg);
unsigned char acquire_task_info_map(void);
void release_task_info_map(unsigned char id);
int check_exec_with_task_info(pid_t tgid, struct path exe_path);
void task_info_maps_init(void);
void task_info_maps_clear(void);
bool sys_call_fs_events_should_skip(pid_t pid, uint64_t events_mask);
void get_should_send_task_info_map_ids(bool *should_send_map_ids, msg_type_img_t msg_type);
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists