File/Calls substitution like LD_PRELOAD

Does there is usual utility which makes a substitution on some calls like execve and open? Like LD_PRELOAD for calls.

Example:

  • we have prog_A which uses prog_B.
  • some days ago prog_B was updated and now prog_A failed!(
  • usual solution is the next:

    $: mv /usr/bin/prog_b /usr/bin/prog_B.new
    $: ln -s /usr/bin/prog_b.old /usr/bin/prog_b
    $: ./prog_a                                       # now run 
    

    but sometimes it's uncomfortably and dirty solution. In some stories the correct way to do so:

    $: util "execve+open+stat:/usr/bin/prog_b=/usr/bin/prog_b.old" ./prog_a
    

    where execve,open & stat are system calls. What is the name of this util?

    Answers


    I just write a special FILE_PRELOAD utility to solve my problem.

    $: FILE_PRELOAD -C "execve+open+stat:/usr/bin/prog_b:/usr/bin/prog_b.old" ./prog_a
    

    it generates c++ code, then compiles it and then LD_PRELOAD the result lib.so file before run ./prog_a.

    Using it you can hook the next calls:

    1. open,fopen,fopen64
    2. opendir,mkdir,rmdir
    3. execve
    4. unlink,unlinkat
    5. stat,lstat,lstat64,_lxstat,_lxstat64,stat64
    6. _xstat,_xstat64,__fxstatat
    7. freopen,freopen64

    Please, run docs/tut.sh firstly (it's a tutorial for FP utility).


    Need Your Help

    causing cpp (C preprocessor) to remove C++ comments on Mac OS X

    osx gcc preprocessor c++

    I have a user report (unfortunately can't verify it due to lack of appropriate machine) that the C preprocessor (cpp) command on Mac OS X 10.6.4 doesn't remove C++/C99 double slash // comments from...

    SQL Update row column with random lookup value

    sql-server sql-update

    I am trying to update a lead table to assign a random person from a lookup table. Here is the generic schema: