Skip to content

Commit

Permalink
hook faccessat
Browse files Browse the repository at this point in the history
  • Loading branch information
KoyamaSohei committed Oct 3, 2024
1 parent 5cc7602 commit fa1b1d6
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion client/libfinchrun.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,28 @@ hook_renameat(long a1, long a2, long a3, long a4, long a5, long a6, long a7)
return next_sys_call(a1, a2, a3, a4, a5, a6, a7);
}

static long
hook_faccessat(long a1, long a2, long a3, long a4, long a5, long a6, long a7)
{
int dirfd = (int)a2;
char *path = (char *)a3;
if (strncmp(path, prefix, prefix_len) == 0) {
struct stat st;
int ret;
path += prefix_len;
ret = finchfs_stat(path, &st);
return ret < 0 ? -errno : ret;
}
if ((dirfd >> FINCH_FD_SHIFT) == 1) {
struct stat st;
int ret;
ret = finchfs_fstatat(dirfd ^ (1 << FINCH_FD_SHIFT), path, &st,
0);
return ret < 0 ? -errno : ret;
}
return next_sys_call(a1, a2, a3, a4, a5, a6, a7);
}

static long
hook_statx(long a1, long a2, long a3, long a4, long a5, long a6, long a7)
{
Expand Down Expand Up @@ -687,13 +709,18 @@ hook_function(long a1, long a2, long a3, long a4, long a5, long a6, long a7)
case SYS_newfstatat:
ret = hook_newfstatat(a1, a2, a3, a4, a5, a6, a7);
break;
break;
case SYS_unlinkat:
ret = hook_unlinkat(a1, a2, a3, a4, a5, a6, a7);
break;
case SYS_renameat:
ret = hook_renameat(a1, a2, a3, a4, a5, a6, a7);
break;
case SYS_faccessat:
ret = hook_faccessat(a1, a2, a3, a4, a5, a6, a7);
break;
case SYS_faccessat2:
ret = hook_faccessat(a1, a2, a3, a4, a5, a6, a7);
break;
case SYS_statx:
ret = hook_statx(a1, a2, a3, a4, a5, a6, a7);
break;
Expand Down

0 comments on commit fa1b1d6

Please sign in to comment.