diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2018-02-25 15:30:49 +0200 |
---|---|---|
committer | Jari Vetoniemi <mailroxas@gmail.com> | 2018-02-25 15:30:49 +0200 |
commit | 856490fb5352e53adbe6b4fba23763500de10e02 (patch) | |
tree | 3300ff572f95fdc3c41ccb2629218ba45e18df9b | |
parent | 3896c6584ea17227ca309a05d6b22124a4bccd96 (diff) |
libc-verbose: Add more functions
-rw-r--r-- | src/libc-verbose.h | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/src/libc-verbose.h b/src/libc-verbose.h index bb03686..517e7ce 100644 --- a/src/libc-verbose.h +++ b/src/libc-verbose.h @@ -22,6 +22,13 @@ bionic_rename(const char *old, const char *fresh) return rename(old, fresh); } +int +bionic_access(const char *path, int amode) +{ + verbose("%s (%d)", path, amode); + return access(path, amode); +} + FILE* bionic_fopen(const char *path, const char *mode) { @@ -29,6 +36,13 @@ bionic_fopen(const char *path, const char *mode) return fopen(path, mode); } +int +bionic_mkdir(const char *path, mode_t mode) +{ + verbose("%s -> %u", path, mode); + return mkdir(path, mode); +} + DIR* bionic_opendir(const char *path) { @@ -39,22 +53,22 @@ bionic_opendir(const char *path) int bionic_sprintf(char *str, const char *fmt, ...) { - verbose("%s", fmt); va_list ap; va_start(ap, fmt); int r = vsprintf(str, fmt, ap); va_end(ap); + verbose("%s == %s", fmt, str); return r; } int bionic_snprintf(char *str, size_t size, const char *fmt, ...) { - verbose("%s (%zu)", fmt, size); va_list ap; va_start(ap, fmt); int r = vsnprintf(str, size, fmt, ap); va_end(ap); + verbose("%s (%zu) == %s", fmt, size, str); return r; } @@ -66,6 +80,13 @@ bionic_strlen(const char *str) } char* +bionic_strchr(const char *str, int c) +{ + verbose("%s %c", str, c); + return strchr(str, c); +} + +char* bionic_strcpy(char *dest, const char *src) { verbose("%s", src); @@ -115,3 +136,37 @@ bionic_readlink(const char *path, char *buf, size_t bufsize) verbose("%s", path); return readlink(path, buf, bufsize); } + +int +bionic_unlink(const char *path) +{ + verbose("%s", path); + return unlink(path); +} + +size_t +bionic_fread(void *ptr, size_t size, size_t nmemb, FILE *stream) +{ + char buf[256], fname[256] = {0}; + snprintf(buf, sizeof(buf), "/proc/self/fd/%d", fileno(stream)); + readlink(buf, fname, sizeof(fname)); + verbose("%s (%d)\n%p, %zu, %zu, %p", fname, fileno(stream), ptr, size, nmemb, stream); + return fread(ptr, size, nmemb, stream); +} + +size_t +bionic_fwrite(void *ptr, size_t size, size_t nmemb, FILE *stream) +{ + char buf[256], fname[256] = {0}; + snprintf(buf, sizeof(buf), "/proc/self/fd/%d", fileno(stream)); + readlink(buf, fname, sizeof(fname)); + verbose("%s (%d)\n%p, %zu, %zu, %p", fname, fileno(stream), ptr, size, nmemb, stream); + return fwrite(ptr, size, nmemb, stream); +} + +char* +bionic_getenv(const char *name) +{ + verbose("%s", name); + return getenv(name); +} |