Loading ifs/include/preload/preload.hpp +3 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ extern "C" { #define ld_fopen fopen #define ld_creat creat #define ld_unlink unlink #define ld_close close #define ld___close __close Loading @@ -35,6 +36,8 @@ extern "C" { #define ld_stat stat #define ld_fstat fstat #define ld_access access #define ld_puts puts #define ld_write write Loading ifs/main.cpp +14 −1 Original line number Diff line number Diff line Loading @@ -2,10 +2,18 @@ #include "daemon/adafs_daemon.hpp" #include <csignal> using namespace std; namespace po = boost::program_options; static bool shutdown_please = false; void shutdown_handler(int dummy) { shutdown_please = true; } int main(int argc, const char* argv[]) { Loading Loading @@ -97,12 +105,17 @@ int main(int argc, const char* argv[]) { #ifndef MARGOIPC run_daemon(); // blocks here until application loop is exited TODO don't know yet how it'll be closed :D #else bool shutdown_please = false; signal(SIGINT, shutdown_handler); signal(SIGTERM, shutdown_handler); signal(SIGKILL, shutdown_handler); while (!shutdown_please) { sleep(1); } ADAFS_DATA->spdlogger()->info("Shutting done signal encountered. Shutting down ..."); #endif destroy_enviroment(); Loading ifs/src/preload/preload.cpp +31 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ void* libc_open; void* libc_fopen; //void* libc_creat; //unused void* libc_unlink; void* libc_close; //void* libc___close; //unused Loading @@ -40,6 +41,8 @@ void* libc_close; void* libc_stat; void* libc_fstat; void* libc_access; void* libc_puts; void* libc_write; Loading Loading @@ -82,7 +85,6 @@ int ld_open(const char* path, int flags, ...) { return -1; } } ipc_send_open(path, flags, mode, ipc_open_id); return (reinterpret_cast<decltype(&open)>(libc_open))(path, flags, mode); } Loading @@ -102,9 +104,22 @@ FILE* ld_fopen(const char* path, const char* mode) { } int ld_creat(const char* path, mode_t mode) { // DAEMON_DEBUG(debug_fd, "ld_creat called with path %s with mode %d\n", path, mode); return ld_open(path, O_CREAT | O_WRONLY | O_TRUNC, mode); } int ld_unlink(const char* path) __THROW { // DAEMON_DEBUG(debug_fd, "ld_unlink called with path %s\n", path); if (is_fs_path(path)) { #ifndef MARGOIPC #else #endif } return (reinterpret_cast<decltype(&unlink)>(libc_unlink))(path); } int ld_close(int fd) { if (file_map.exist(fd)) { // TODO call daemon and return (do we even need to) Loading Loading @@ -150,6 +165,17 @@ int ld_fstat(int fd, struct stat* buf) { return (reinterpret_cast<decltype(&fstat)>(libc_fstat))(fd, buf); } int ld_access(const char* path, int mode) __THROW { if (is_fs_path(path)) { #ifndef MARGOIPC #else #endif } return (reinterpret_cast<decltype(&access)>(libc_access))(path, mode); } int ld_puts(const char* str) { return (reinterpret_cast<decltype(&puts)>(libc_puts))(str); } Loading Loading @@ -349,12 +375,16 @@ void init_preload(void) { libc_open = dlsym(libc, "open"); libc_fopen = dlsym(libc, "fopen"); libc_unlink = dlsym(libc, "unlink"); libc_close = dlsym(libc, "close"); // libc___close = dlsym(libc, "__close"); libc_stat = dlsym(libc, "stat"); libc_fstat = dlsym(libc, "fstat"); libc_access = dlsym(libc, "access"); libc_puts = dlsym(libc, "puts"); libc_write = dlsym(libc, "write"); Loading Loading
ifs/include/preload/preload.hpp +3 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ extern "C" { #define ld_fopen fopen #define ld_creat creat #define ld_unlink unlink #define ld_close close #define ld___close __close Loading @@ -35,6 +36,8 @@ extern "C" { #define ld_stat stat #define ld_fstat fstat #define ld_access access #define ld_puts puts #define ld_write write Loading
ifs/main.cpp +14 −1 Original line number Diff line number Diff line Loading @@ -2,10 +2,18 @@ #include "daemon/adafs_daemon.hpp" #include <csignal> using namespace std; namespace po = boost::program_options; static bool shutdown_please = false; void shutdown_handler(int dummy) { shutdown_please = true; } int main(int argc, const char* argv[]) { Loading Loading @@ -97,12 +105,17 @@ int main(int argc, const char* argv[]) { #ifndef MARGOIPC run_daemon(); // blocks here until application loop is exited TODO don't know yet how it'll be closed :D #else bool shutdown_please = false; signal(SIGINT, shutdown_handler); signal(SIGTERM, shutdown_handler); signal(SIGKILL, shutdown_handler); while (!shutdown_please) { sleep(1); } ADAFS_DATA->spdlogger()->info("Shutting done signal encountered. Shutting down ..."); #endif destroy_enviroment(); Loading
ifs/src/preload/preload.cpp +31 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ void* libc_open; void* libc_fopen; //void* libc_creat; //unused void* libc_unlink; void* libc_close; //void* libc___close; //unused Loading @@ -40,6 +41,8 @@ void* libc_close; void* libc_stat; void* libc_fstat; void* libc_access; void* libc_puts; void* libc_write; Loading Loading @@ -82,7 +85,6 @@ int ld_open(const char* path, int flags, ...) { return -1; } } ipc_send_open(path, flags, mode, ipc_open_id); return (reinterpret_cast<decltype(&open)>(libc_open))(path, flags, mode); } Loading @@ -102,9 +104,22 @@ FILE* ld_fopen(const char* path, const char* mode) { } int ld_creat(const char* path, mode_t mode) { // DAEMON_DEBUG(debug_fd, "ld_creat called with path %s with mode %d\n", path, mode); return ld_open(path, O_CREAT | O_WRONLY | O_TRUNC, mode); } int ld_unlink(const char* path) __THROW { // DAEMON_DEBUG(debug_fd, "ld_unlink called with path %s\n", path); if (is_fs_path(path)) { #ifndef MARGOIPC #else #endif } return (reinterpret_cast<decltype(&unlink)>(libc_unlink))(path); } int ld_close(int fd) { if (file_map.exist(fd)) { // TODO call daemon and return (do we even need to) Loading Loading @@ -150,6 +165,17 @@ int ld_fstat(int fd, struct stat* buf) { return (reinterpret_cast<decltype(&fstat)>(libc_fstat))(fd, buf); } int ld_access(const char* path, int mode) __THROW { if (is_fs_path(path)) { #ifndef MARGOIPC #else #endif } return (reinterpret_cast<decltype(&access)>(libc_access))(path, mode); } int ld_puts(const char* str) { return (reinterpret_cast<decltype(&puts)>(libc_puts))(str); } Loading Loading @@ -349,12 +375,16 @@ void init_preload(void) { libc_open = dlsym(libc, "open"); libc_fopen = dlsym(libc, "fopen"); libc_unlink = dlsym(libc, "unlink"); libc_close = dlsym(libc, "close"); // libc___close = dlsym(libc, "__close"); libc_stat = dlsym(libc, "stat"); libc_fstat = dlsym(libc, "fstat"); libc_access = dlsym(libc, "access"); libc_puts = dlsym(libc, "puts"); libc_write = dlsym(libc, "write"); Loading