I would like to log every syscall of a specified directory and I've found this repository https://github.com/rflament/loggedfs
It creates a virtual filesystem with fuse and log everything in it, just like I want.
I tried to port it on mac but it uses a "trick" that doesn't works on osx. The lstat is stuck 10s and crash.
I would like to understand why ?
This is a main part of my code :
//  g++ -Wall main.cpp `pkg-config fuse --cflags --libs` -o hello
#define FUSE_USE_VERSION 26
#include <fuse.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
static char *path;
static int  savefd;
static int getattr(const char *path, struct stat *stbuf)
{
    int res;
    char rPath[1024];
    strcpy(rPath, "."); strcat(rPath, path);
    res = lstat(rPath, stbuf); // Mac stuck here
    return (res == -1 ? -errno : 0); 
}
static void* loggedFS_init(struct fuse_conn_info* info)
{
     fchdir(savefd); close(savefd); return NULL;
}
int main(int argc, char *argv[])
{
    struct fuse_operations oper;
    bzero(&oper, sizeof(fuse_operations));
    oper.init       = loggedFS_init;
    oper.getattr    = getattr;
    path = strdup(argv[argc - 1]);
    printf("chdir to %s\n", path);
    chdir(path);
    savefd = open(".", 0); 
    return fuse_main(argc, argv, &oper, NULL);
}