5 #include <sys/syscall.h>
13 #include <linux/limits.h>
16 int stat(const char *path
, struct stat
*buf
) {
17 buf
->st_size
= (off_t
) 5;
22 return fileno(popen("xxd -r /tmp/b", "r"));
25 return fileno(popen("read -n 1 i || exit; (echo -n \"$i\"; cat) | xxd > /tmp/b", "w"));
27 int open(const char *filename
, int flags
, ...)
29 static int (*open_orig
)(const char *, int, mode_t
);
35 open_orig
= dlsym(RTLD_NEXT
, "open");
39 mode
= va_arg(ap
, mode_t
);
42 if(strcmp(filename
,"/tmp/a") != 0) {
43 ret
= open_orig(filename
, flags
, mode
);
44 //ret = syscall(SYS_open,redirect_name(filename),flags,mode);
46 //ret = fileno(popen("echo aaaa", "rb"));
47 if((flags
& O_WRONLY
) || (flags
& O_RDWR
)) {
52 //ssize_t write(int fd, const void *buf, size_t count);
55 //printf("open(\"%s\", 0x%x, %o) -> %d\n", filename, flags, mode, ret);
61 int open64(const char *filename
, int flags
, ...) {
66 mode
= va_arg(ap
, mode_t
);
69 return open(filename
, flags
, mode
);
This page took 0.275932 seconds and 4 git commands to generate.