Unverified Commit b37423ca authored by Tommaso Tocci's avatar Tommaso Tocci
Browse files

unlocloed

parent a984f116
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -8,6 +8,9 @@ extern "C" {
# define weak_alias(name, aliasname) \
  extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));

# define strong_alias(name, aliasname) \
  extern __typeof (name) aliasname __attribute__ ((alias (#name)));

/**
 * In the glibc headers the following two functions (readdir & opendir)
 * marks the @dirp parameter with a non-null attribute.
@@ -22,6 +25,13 @@ weak_alias(intcp_readdir, readdir)
int intcp_closedir(DIR* dirp);
weak_alias(intcp_closedir, closedir)

size_t intcp_fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
strong_alias(intcp_fread, fread)
strong_alias(intcp_fread, fread_unlocked)
size_t intcp_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
strong_alias(intcp_fwrite, fwrite)
strong_alias(intcp_fwrite, fwrite_unlocked)

#endif // IFS_INTCP_FUNCTIONS_HPP

} // extern C
+2 −2
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ FILE* fopen64(const char* path, const char* fmode) {
    return (reinterpret_cast<decltype(&fopen64)>(libc_fopen64))(path, fmode);
}

size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) {
size_t intcp_fread(void *ptr, size_t size, size_t nmemb, FILE *stream) {
    init_passthrough_if_needed();
    if(CTX->initialized() && (stream != nullptr)) {
        auto fd = file_to_fd(stream);
@@ -127,7 +127,7 @@ size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) {
    return (reinterpret_cast<decltype(&fread)>(libc_fread))(ptr, size, nmemb, stream);
}

size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) {
size_t intcp_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) {
    init_passthrough_if_needed();
    if(CTX->initialized() && (stream != nullptr)) {
        auto fd = file_to_fd(stream);