Search code examples
clinuxstat

Intercepting stat()


I have successfuly intercepted calls to read(),write(),open(),unlink(),rename(), creat() but somehow with exactly the same semantics intercepting stat() is not taking place. I have changed the execution environmnet using LD_PRELOAD.

Am I missing something?

The code is quite huge, which part of it will be most helpful to post so you can help?

Thanks.

Edit: I kept the interposed stat() wrapper simple to check if it works.

int stat(const char *path,struct stat *buff)
{
    printf("client invoke: stat %s",path);
    return 1;
}

Solution

  • Compile a function that calls stat(); see what reference(s) are generated (nm -g stat.o). Then you'll have a better idea of which function(s) to interpose. Hint: it probably isn't called stat().