Skip to content

Commit

Permalink
update(userspace/libsinsp): add also proc.fd.*.name fields
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo Susini <[email protected]>
  • Loading branch information
loresuso committed Jun 11, 2024
1 parent b1316a2 commit d8015d2
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
48 changes: 48 additions & 0 deletions userspace/libsinsp/sinsp_filtercheck_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ static const filtercheck_field_info sinsp_filter_check_thread_fields[] =
{PT_CHARBUF, EPF_NONE, PF_NA, "proc.fd.stdin.type", "Standard Input fd type", "The type of file descriptor 0, corresponding to stdin, of the process generating the event."},
{PT_CHARBUF, EPF_NONE, PF_NA, "proc.fd.stdout.type", "Standard Output fd type", "The type of file descriptor 1, corresponding to stdout, of the process generating the event."},
{PT_CHARBUF, EPF_NONE, PF_NA, "proc.fd.stderr.type", "Standard Error fd type", "The type of file descriptor 2, corresponding to stderr, of the process generating the event."},
{PT_CHARBUF, EPF_NONE, PF_NA, "proc.fd.stdin.name", "Standard Input fd name", "The name of the file descriptor 0, corresponding to stdin, of the process generating the event."},
{PT_CHARBUF, EPF_NONE, PF_NA, "proc.fd.stdout.name", "Standard Output fd name", "The name of the file descriptor 1, corresponding to stdout, of the process generating the event."},
{PT_CHARBUF, EPF_NONE, PF_NA, "proc.fd.stderr.name", "Standard Error fd name", "The name of the file descriptor 2, corresponding to stderr, of the process generating the event."},
};

sinsp_filter_check_thread::sinsp_filter_check_thread()
Expand Down Expand Up @@ -1660,6 +1663,51 @@ uint8_t* sinsp_filter_check_thread::extract_single(sinsp_evt *evt, uint32_t* len
m_tstr = fdinfo->get_typestring();
RETURN_EXTRACT_STRING(m_tstr);
}
case TYPE_FD_STDIN_NAME:
{
auto fdtable_ptr = tinfo->get_fd_table();
if (fdtable_ptr == nullptr)
{
return NULL;
}
auto fdinfo = fdtable_ptr->find(0);
if (fdinfo == nullptr)
{
return NULL;
}
m_tstr = fdinfo->m_name.c_str();
RETURN_EXTRACT_STRING(m_tstr);
}
case TYPE_FD_STDOUT_NAME:
{
auto fdtable_ptr = tinfo->get_fd_table();
if (fdtable_ptr == nullptr)
{
return NULL;
}
auto fdinfo = fdtable_ptr->find(1);
if (fdinfo == nullptr)
{
return NULL;
}
m_tstr = fdinfo->m_name.c_str();
RETURN_EXTRACT_STRING(m_tstr);
}
case TYPE_FD_STDERR_NAME:
{
auto fdtable_ptr = tinfo->get_fd_table();
if (fdtable_ptr == nullptr)
{
return NULL;
}
auto fdinfo = fdtable_ptr->find(2);
if (fdinfo == nullptr)
{
return NULL;
}
m_tstr = fdinfo->m_name.c_str();
RETURN_EXTRACT_STRING(m_tstr);
}
default:
ASSERT(false);
return NULL;
Expand Down
3 changes: 3 additions & 0 deletions userspace/libsinsp/sinsp_filtercheck_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ class sinsp_filter_check_thread : public sinsp_filter_check
TYPE_FD_STDIN_TYPE,
TYPE_FD_STDOUT_TYPE,
TYPE_FD_STDERR_TYPE,
TYPE_FD_STDIN_NAME,
TYPE_FD_STDOUT_NAME,
TYPE_FD_STDERR_NAME,
};

sinsp_filter_check_thread();
Expand Down

0 comments on commit d8015d2

Please sign in to comment.