src/UserSpaceInstrumentation/InjectLibraryInTraceeTest.cpp
ErrorMessageOr<bool> IsInodeInMapsFile(ino_t inode, pid_t pid) {
  OUTCOME_TRY(auto&& maps_contents,
              orbit_base::ReadFileToString(absl::StrFormat("/proc/%d/maps", pid)));

  std::vector<std::string_view> lines = absl::StrSplit(maps_contents, '\n');

  for (const auto& line : lines) {
    std::vector<std::string_view> fields = absl::StrSplit(line, ' ', absl::SkipEmpty{});
    constexpr int kInodeFieldIndex = 4;
    if (fields.size() <= kInodeFieldIndex) continue;

    ino_t current_inode{};
    if (!absl::SimpleAtoi(fields[kInodeFieldIndex], &current_inode)) continue;
    if (current_inode == inode) return true;
  }

  return false;
}
// This function checks if a certain inode appears in the maps file
// of the process with PID `pid`. It is only comparing the inode and
// not the device id because the latter has proven to be unrealiable
// when using overlayfs. That's the case on the CI because Docker uses
// overlayfs. Fixing that properly is a non-trivial task and isn't
// justified compared to the risk of having an inode clash.
This function checks if a certain inode appears in the maps file
of the process with PID `pid`. It is only comparing the inode and
not the device id because the latter has proven to be unrealiable
when using overlayfs. That's the case on the CI because Docker uses
overlayfs. Fixing that properly is a non-trivial task and isn't
justified compared to the risk of having an inode clash.
This function checks if a certain inode appears in the maps file of the process with PID ` pid ` . It is only comparing the inode and not the device id because the latter has proven to be unrealiable when using overlayfs . That ' s the case on the CI because Docker uses overlayfs . Fixing that properly is a non - trivial task and isn ' t justified compared to the risk of having an inode clash .
ErrorMessageOr<bool> IsInodeInMapsFile(ino_t inode, pid_t pid) {
  OUTCOME_TRY(auto&& maps_contents,
              orbit_base::ReadFileToString(absl::StrFormat("/proc/%d/maps", pid)));
  std::vector<std::string_view> lines = absl::StrSplit(maps_contents, '\n');
  for (const auto& line : lines) {
    std::vector<std::string_view> fields = absl::StrSplit(line, ' ', absl::SkipEmpty{});
    constexpr int kInodeFieldIndex = 4;
    if (fields.size() <= kInodeFieldIndex) continue;
    ino_t current_inode{};
    if (!absl::SimpleAtoi(fields[kInodeFieldIndex], &current_inode)) continue;
    if (current_inode == inode) return true;
  }
  return false;
}
ErrorMessageOr < bool > IsInodeInMapsFile ( ino_t inode , pid_t pid ) { OUTCOME_TRY ( auto && maps_contents , orbit_base :: ReadFileToString ( absl :: StrFormat ( " " , pid ) ) ) ; std :: vector < std :: string_view > lines = absl :: StrSplit ( maps_contents , ' \n ' ) ; for ( const auto & line : lines ) { std :: vector < std :: string_view > fields = absl :: StrSplit ( line , ' ' , absl :: SkipEmpty { } ) ; constexpr int kInodeFieldIndex = 4 ; if ( fields . size ( ) <= kInodeFieldIndex ) continue ; ino_t current_inode { } ; if ( ! absl :: SimpleAtoi ( fields [ kInodeFieldIndex ] , & current_inode ) ) continue ; if ( current_inode == inode ) return true ; } return false ; }
This function checks if a certain inode appears in the maps file
of the process with PID `pid`.
This function checks if a certain inode appears in the maps file of the process with PID ` pid ` .