diff --git a/userspace/libscap/scap.c b/userspace/libscap/scap.c index 3c59ef1298..417920671b 100644 --- a/userspace/libscap/scap.c +++ b/userspace/libscap/scap.c @@ -304,7 +304,7 @@ scap_t* scap_open_offline_int(const char* fname, // // Preliminary initializations // - handle->m_mode = SCAP_MODE_FILE; + handle->m_mode = SCAP_MODE_CAPTURE; handle->m_proc_callback = proc_callback; handle->m_proc_callback_context = proc_callback_context; handle->m_devs = NULL; @@ -487,7 +487,7 @@ scap_t* scap_open(scap_open_args args, char *error) { switch(args.mode) { - case SCAP_MODE_FILE: + case SCAP_MODE_CAPTURE: return scap_open_offline_int(args.fname, error, args.proc_callback, args.proc_callback_context, args.import_users, args.start_offset); @@ -859,7 +859,7 @@ int32_t scap_next(scap_t* handle, OUT scap_evt** pevent, OUT uint16_t* pcpuid) switch(handle->m_mode) { - case SCAP_MODE_FILE: + case SCAP_MODE_CAPTURE: res = scap_next_offline(handle, pevent, pcpuid); break; case SCAP_MODE_LIVE: diff --git a/userspace/libscap/scap.h b/userspace/libscap/scap.h index 8585f30f6d..99ec44ecb8 100644 --- a/userspace/libscap/scap.h +++ b/userspace/libscap/scap.h @@ -234,7 +234,7 @@ typedef void (*proc_entry_callback)(void* context, \brief Arguments for scap_open */ typedef enum { - SCAP_MODE_FILE, + SCAP_MODE_CAPTURE, SCAP_MODE_LIVE, SCAP_MODE_NODRIVER } scap_mode_t; diff --git a/userspace/libsinsp/sinsp.cpp b/userspace/libsinsp/sinsp.cpp index 6ac2eafad5..55cd9a4d54 100644 --- a/userspace/libsinsp/sinsp.cpp +++ b/userspace/libsinsp/sinsp.cpp @@ -292,7 +292,7 @@ void sinsp::init() // importing the thread table, so that thread table filtering will work with // container filters // - if(is_offline()) + if(is_capture()) { uint64_t off = scap_ftell(m_h); scap_evt* pevent; @@ -335,7 +335,7 @@ void sinsp::init() } } - if(is_offline() || m_filter_proc_table_when_saving == true) + if(is_capture() || m_filter_proc_table_when_saving == true) { import_thread_table(); } @@ -542,9 +542,9 @@ void sinsp::open(string filename) // // Start the capture // - m_mode = SCAP_MODE_FILE; + m_mode = SCAP_MODE_CAPTURE; scap_open_args oargs; - oargs.mode = SCAP_MODE_FILE; + oargs.mode = SCAP_MODE_CAPTURE; oargs.fname = filename.c_str(); oargs.proc_callback = NULL; oargs.proc_callback_context = NULL; @@ -685,7 +685,7 @@ void sinsp::on_new_entry_from_proc(void* context, { sinsp_threadinfo newti(this); newti.init(tinfo); - if(m_mode == SCAP_MODE_NODRIVER) + if(is_nodriver()) { auto sinsp_tinfo = find_thread(tid, true); if(sinsp_tinfo == nullptr || newti.m_clone_ts > sinsp_tinfo->m_clone_ts) @@ -789,7 +789,7 @@ void sinsp::import_ipv4_interface(const sinsp_ipv4_ifinfo& ifinfo) void sinsp::refresh_ifaddr_list() { #ifdef HAS_CAPTURE - if(!is_offline()) + if(!is_capture()) { ASSERT(m_network_interfaces); scap_refresh_iflist(m_h); @@ -1027,7 +1027,7 @@ int32_t sinsp::next(OUT sinsp_evt **puevt) // // Run the periodic connection and thread table cleanup // - if(!is_offline()) + if(!is_capture()) { m_thread_manager->remove_inactive_threads(); m_container_manager.remove_inactive_containers(); diff --git a/userspace/libsinsp/sinsp.h b/userspace/libsinsp/sinsp.h index 400b04f54c..3ac81183f8 100644 --- a/userspace/libsinsp/sinsp.h +++ b/userspace/libsinsp/sinsp.h @@ -577,9 +577,9 @@ class SINSP_PUBLIC sinsp /*! \brief Returns true if the current capture is offline */ - inline bool is_offline() + inline bool is_capture() { - return m_mode == SCAP_MODE_FILE; + return m_mode == SCAP_MODE_CAPTURE; } /*! @@ -590,6 +590,14 @@ class SINSP_PUBLIC sinsp return m_mode == SCAP_MODE_LIVE; } + /*! + \brief Returns true if the current capture is live + */ + inline bool is_nodriver() + { + return m_mode == SCAP_MODE_NODRIVER; + } + /*! \brief Set the debugging mode of the inspector. diff --git a/userspace/libsinsp/threadinfo.cpp b/userspace/libsinsp/threadinfo.cpp index 2d7ba3ef06..a35f48145a 100644 --- a/userspace/libsinsp/threadinfo.cpp +++ b/userspace/libsinsp/threadinfo.cpp @@ -372,7 +372,7 @@ void sinsp_threadinfo::init(scap_threadinfo* pi) set_cgroups(pi->cgroups, pi->cgroups_len); m_root = pi->root; ASSERT(m_inspector); - m_inspector->m_container_manager.resolve_container(this, !m_inspector->is_offline()); + m_inspector->m_container_manager.resolve_container(this, !m_inspector->is_capture()); // // Prepare for filtering //