readdir.c
changeset 0 7d3c07f8acfb
child 1 9ccc1574a367
equal deleted inserted replaced
-1:000000000000 0:7d3c07f8acfb
       
     1 #include <dirent.h>
       
     2 #include "dl.h"
       
     3 
       
     4 /* shameless stolen from
       
     5  * http://uberhip.com/people/godber/interception/html/slide_6.html
       
     6  * and of course from the manpage of dlopen(3)
       
     7  */
       
     8 
       
     9 
       
    10 struct dirent* readdir(DIR *dirp)
       
    11 {
       
    12 
       
    13     static struct dirent* (*orig)(DIR *);
       
    14     struct dirent *dent;
       
    15 
       
    16     if (!orig) 
       
    17 	orig = get_original_function("libc.so.6", "readdir64");
       
    18 
       
    19     dent = (*orig)(dirp);
       
    20 
       
    21     /* skip selected entries */
       
    22     if (dent && dent->d_name[0] == 'M') 
       
    23 	dent = (*orig)(dirp);
       
    24 
       
    25     return dent;
       
    26 }