Skip to content

Commit

Permalink
remove usage of realpath
Browse files Browse the repository at this point in the history
  • Loading branch information
hariharan-devarajan committed Oct 6, 2023
1 parent f7f51d9 commit 2ed7ef9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 26 deletions.
10 changes: 2 additions & 8 deletions src/dlio_profiler/brahma/posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,10 @@ class POSIXDLIOProfiler : public POSIX {
logger = DLIO_LOGGER_INIT();
}
inline void trace(const char* filename) {
char resolved_path[PATH_MAX];
char* data = realpath(filename, resolved_path);
(void) data;
track_filename.push_back(resolved_path);
track_filename.push_back(filename);
}
inline void untrace(const char* filename) {
char resolved_path[PATH_MAX];
char* data = realpath(filename, resolved_path);
(void) data;
ignore_filename.push_back(resolved_path);
ignore_filename.push_back(filename);
}
~POSIXDLIOProfiler() override = default;
static std::shared_ptr<POSIXDLIOProfiler> get_instance() {
Expand Down
10 changes: 2 additions & 8 deletions src/dlio_profiler/brahma/stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,10 @@ class STDIODLIOProfiler : public STDIO {
}

inline void trace(const char* filename) {
char resolved_path[PATH_MAX];
char* data = realpath(filename, resolved_path);
(void) data;
track_filename.push_back(resolved_path);
track_filename.push_back(filename);
}
inline void untrace(const char* filename) {
char resolved_path[PATH_MAX];
char* data = realpath(filename, resolved_path);
(void) data;
ignore_filename.push_back(resolved_path);
ignore_filename.push_back(filename);
}

~STDIODLIOProfiler() = default;
Expand Down
17 changes: 7 additions & 10 deletions src/dlio_profiler/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,27 @@ inline std::pair<bool, std::string> is_traced_common(const char* filename, const
const std::vector<std::string>& track_filename) {
bool found = false;
bool ignore = false;
char resolved_path[PATH_MAX];
char* data = realpath(filename, resolved_path);
(void) data;
if (ignore_files(resolved_path) || ignore_files(filename)) {
DLIO_PROFILER_LOGINFO("Profiler ignoring file %s for func %s", resolved_path, func);
if (ignore_files(filename)) {
DLIO_PROFILER_LOGINFO("Profiler ignoring file %s for func %s", filename, func);
return std::pair<bool, std::string>(false, filename);
}
for (const auto file : ignore_filename) {
if (strstr(resolved_path, file.c_str()) != NULL) {
DLIO_PROFILER_LOGINFO("Profiler Intercepted POSIX not file %s for func %s", resolved_path, func);
if (strstr(filename, file.c_str()) != NULL) {
DLIO_PROFILER_LOGINFO("Profiler Intercepted POSIX not file %s for func %s", filename, func);
ignore = true;
break;
}
}
if (!ignore) {
for (const auto file : track_filename) {
if (strstr(resolved_path, file.c_str()) != NULL) {
DLIO_PROFILER_LOGINFO("Profiler Intercepted POSIX tracing file %s for func %s", resolved_path, func);
if (strstr(filename, file.c_str()) != NULL) {
DLIO_PROFILER_LOGINFO("Profiler Intercepted POSIX tracing file %s for func %s", filename, func);
found = true;
break;
}
}
}
if (!found and !ignore) DLIO_PROFILER_LOGINFO("Profiler Intercepted POSIX not tracing file %s for func %s", resolved_path, func);
if (!found and !ignore) DLIO_PROFILER_LOGINFO("Profiler Intercepted POSIX not tracing file %s for func %s", filename, func);
return std::pair<bool, std::string>(found, filename);
}
#endif // DLIO_PROFILER_UTILS_H

0 comments on commit 2ed7ef9

Please sign in to comment.