/** @file task_tools.h @brief Tools for manipulating task struct @details Copyright (c) 2024 Acronis International GmbH @author Denis Kopyrin ([email protected]) @since $Id: $ */ #pragma once #include "message.h" #include "task_info_map.h" #include "transport.h" #include "si_common.h" static inline void refresh_task(task_info_t* task_info, const transport_ids_t* ids) { send_msg_async_unref(heur_exec_msg_new(task_info, ids)); } static inline SiTimeMicroseconds make_process_start_time(struct task_struct* tsk) { SiTimeMicroseconds start_time; if (tsk->group_leader) tsk = tsk->group_leader; #ifdef HAVE_TIMESPEC_REAL_START_TIME // From ancient times to 3.16 start_time.microseconds = tsk->real_start_time.tv_sec * 1000000 + tsk->real_start_time.tv_nsec / 1000; #else #ifdef HAVE_REAL_START_TIME // From 3.17 to 5.5 start_time.microseconds = tsk->real_start_time / 1000; #else // From 5.6 to 5.10; from 5.11 to now is using time namespace (timens_add_boottime_ns) // but I do not care about it so I use the same code as in 5.6+. // Even if 'current' is in a namespace, client service should be // still outside of the time ns so it matches the requirement of // unique pid being generated the same way from fileprotector and userspace. start_time.microseconds = tsk->start_boottime / 1000; #endif #endif return start_time; }