TS_EXPORT int open(const char *path, int flags, ...) { const char *p; char buf[PATH_MAX * 2]; static int (*_open)(const char *path, int flags, ...); if (!get_rootpath(__func__)) return -1; _open = get_libc_func("open"); p = trap_path(path, buf); if (p == NULL) return -1; if (flags & O_CREAT) { mode_t mode; va_list ap; va_start(ap, flags); mode = va_arg(ap, mode_t); va_end(ap); _open(p, flags, mode); } return _open(p, flags); }
int uname(struct utsname *buf) { int ret; char *env = NULL; uname_t real_uname = (uname_t) get_libc_func("uname"); ret = real_uname((struct utsname *) buf); strncpy(buf->release, ((env = getenv("UTS_RELEASE")) == NULL) ? UTS_RELEASE : env, 65); return ret; }
TS_EXPORT FILE *fopen(const char *path, const char *mode) { const char *p; char buf[PATH_MAX * 2]; static int (*_fopen)(const char *path, const char *mode); if (!get_rootpath(__func__)) return NULL; _fopen = get_libc_func("fopen"); p = trap_path(path, buf); if (p == NULL) return NULL; return (void *) (long) (*_fopen)(p, mode); }
TS_EXPORT DIR *opendir(const char *path) { const char *p; char buf[PATH_MAX * 2]; static int (*_opendir)(const char *path); if (!get_rootpath(__func__)) return NULL; _opendir = get_libc_func("opendir"); p = trap_path(path, buf); if (p == NULL) return NULL; return (void *)(long)(*_opendir)(p); }
TS_EXPORT int access(const char *path, int mode) { const char *p; char buf[PATH_MAX * 2]; static int (*_access)(const char *path, int mode); if (!get_rootpath(__func__)) return -1; _access = get_libc_func("access"); p = trap_path(path, buf); if (p == NULL) return -1; return _access(p, mode); }
TS_EXPORT int stat64(const char *path, struct stat64 *st) { const char *p; char buf[PATH_MAX * 2]; static int (*_stat64)(const char *path, struct stat64 *buf); if (!get_rootpath(__func__)) return -1; _stat64 = get_libc_func("stat64"); p = trap_path(path, buf); if (p == NULL) return -1; return _stat64(p, st); }
TS_EXPORT int __xstat(int ver, const char *path, struct stat *st) { const char *p; char buf[PATH_MAX * 2]; static int (*_xstat)(int __ver, const char *__filename, struct stat *__stat_buf); if (!get_rootpath(__func__)) return -1; _xstat = get_libc_func("__xstat"); p = trap_path(path, buf); if (p == NULL) return -1; return _xstat(ver, p, st); }