Skip to content

Commit

Permalink
cleanup unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
bmiddha committed Dec 12, 2024
1 parent 01807d3 commit fcd1118
Showing 1 changed file with 0 additions and 64 deletions.
64 changes: 0 additions & 64 deletions src/trace_exec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -315,70 +315,6 @@ void read_maybe_relative_pathname_from_tracee(pid_t pid, char *cwd, __u64 addr,
}
}

void join_path(const char *path1, const char *path2, char *fullpath, size_t fullpath_size)
{
char *path1_segments[PATH_MAX];
char *path2_segments[PATH_MAX];
char *fullpath_segments[PATH_MAX];
int path1_segment_count = 0;
int path2_segment_count = 0;
int fullpath_segment_count = 0;

char *token = strtok((char *)path1, "/");
while (token != NULL)
{
path1_segments[path1_segment_count++] = token;
token = strtok(NULL, "/");
}

token = strtok((char *)path2, "/");
while (token != NULL)
{
path2_segments[path2_segment_count++] = token;
token = strtok(NULL, "/");
}

for (int i = 0; i < path1_segment_count; i++)
{
if (strcmp(path1_segments[i], "..") == 0)
{
if (fullpath_segment_count > 0)
{
fullpath_segment_count--;
}
}
else if (strcmp(path1_segments[i], ".") != 0)
{
fullpath_segments[fullpath_segment_count++] = path1_segments[i];
}
}

for (int i = 0; i < path2_segment_count; i++)
{
if (strcmp(path2_segments[i], "..") == 0)
{
if (fullpath_segment_count > 0)
{
fullpath_segment_count--;
}
}
else if (strcmp(path2_segments[i], ".") != 0)
{
fullpath_segments[fullpath_segment_count++] = path2_segments[i];
}
}

fullpath[0] = '\0';
for (int i = 0; i < fullpath_segment_count; i++)
{
if (i > 0)
{
strncat(fullpath, "/", fullpath_size);
}
strncat(fullpath, fullpath_segments[i], fullpath_size);
}
}

void parse_dirfd_pathname_from_tracee(pid_t pid, __u64 dirfd, __u64 pathname, char *fullpath, size_t fullpath_size)
{
char path[PATH_MAX];
Expand Down

0 comments on commit fcd1118

Please sign in to comment.