Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPROVEMENT] No longer checks hash when searching files #132

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 11 additions & 18 deletions src/tracer.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,11 @@ find_pinfo(pid_t pid)
}

FILE_INFO *
find_finfo(char *abspath, char *hash)
find_finfo(char *abspath)
{
int i = numfinfo;

while (i >= 0 && !(!strcmp(abspath, finfo[i].abspath)
&& (!(finfo[i].was_hash_printed)
|| (hash == NULL && finfo[i].hash == NULL)
|| !strcmp(hash, finfo[i].hash)))) {
while (i >= 0 && strcmp(abspath, finfo[i].abspath)) {
--i;
}

Expand Down Expand Up @@ -247,29 +244,27 @@ handle_open(PROCESS_INFO *pi, int fd, int dirfd, void *path, int purpose)
if (abspath == NULL)
error(EXIT_FAILURE, errno, "on handle_open absolutepath");

char *hash = NULL;

FILE_INFO *f = NULL;

if ((purpose & O_ACCMODE) == O_RDONLY) {
hash = get_file_hash(abspath);
f = find_finfo(abspath, hash);
f = find_finfo(abspath);
}

if (!f) {
f = next_finfo();
char *hash = get_file_hash(abspath);

finfo_new(f, path, abspath, hash);
} else {
free(path);
free(abspath);
free(hash);
}
*finfo_at(pi, fd) = f - finfo;

record_fileuse(pi->outname, f->outname, purpose);
if (!f->was_hash_printed && (purpose & O_ACCMODE) == O_RDONLY) {
f->was_hash_printed = 1;
record_hash(f->outname, hash);
record_hash(f->outname, f->hash);
}
}

Expand All @@ -292,19 +287,17 @@ handle_execve(PROCESS_INFO *pi, int dirfd, char *path)
}
}

char *hash = get_file_hash(abspath);

FILE_INFO *f;

if (!(f = find_finfo(abspath, hash))) {
if (!(f = find_finfo(abspath))) {
f = next_finfo();
char *hash = get_file_hash(abspath);

finfo_new(f, path, abspath, hash);
record_hash(f->outname, f->hash);
f->was_hash_printed = 1;
} else {
free(abspath);
free(hash);
free(path);
}

Expand All @@ -315,17 +308,17 @@ static void
handle_rename_entry(PROCESS_INFO *pi, int olddirfd, char *oldpath)
{
char *abspath = absolutepath(pi->pid, olddirfd, oldpath);
char *hash = get_file_hash(abspath);

FILE_INFO *f = find_finfo(abspath, hash);
FILE_INFO *f = find_finfo(abspath);

if (!f) {
f = next_finfo();
char *hash = get_file_hash(abspath);

finfo_new(f, oldpath, abspath, hash);
} else {
free(oldpath);
free(abspath);
free(hash);
}

pi->entry_info = (void *) (f - finfo);
Expand Down