Loading src/client/gkfs_libc.cpp +65 −64 Original line number Diff line number Diff line /* * Copyright 2000-2024 Felix Garcia Carballeira, Diego Camarmas Alonso, * Alejandro Calderon Mateos, Luis Miguel Sanchez Garcia, Borja Bergua Guerra * * This file is part of Expand. * * Expand is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Expand is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Expand. If not, see <http://www.gnu.org/licenses/>. * * Modifications to support GekkoFS done by : * Copyright 2018-2025, Barcelona Supercomputing Center (BSC), Spain * Copyright 2015-2025, Johannes Gutenberg Universitaet Mainz, Germany * * This software was partially supported by the * EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu). * * This software was partially supported by the * ADA-FS project under the SPPEXA project funded by the DFG. * * SPDX-License-Identifier: LGPL-3.0-or-later Copyright 2018-2025, Barcelona Supercomputing Center (BSC), Spain Copyright 2015-2025, Johannes Gutenberg Universitaet Mainz, Germany This software was partially supported by the EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu). This software was partially supported by the ADA-FS project under the SPPEXA project funded by the DFG. This software was partially supported by the the European Union’s Horizon 2020 JTI-EuroHPC research and innovation programme, by the project ADMIRE (Project ID: 956748, admire-eurohpc.eu) This project was partially promoted by the Ministry for Digital Transformation and the Civil Service, within the framework of the Recovery, Transformation and Resilience Plan - Funded by the European Union -NextGenerationEU. This file is part of GekkoFS' POSIX interface. GekkoFS' POSIX interface is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. GekkoFS' POSIX interface is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with GekkoFS' POSIX interface. If not, see <https://www.gnu.org/licenses/>. SPDX-License-Identifier: LGPL-3.0-or-later */ #include <iostream> #include <dlfcn.h> #include <cstdio> Loading Loading @@ -443,10 +451,6 @@ DLSYM_WRAPPER(int, scandir, DLSYM_WRAPPER(int, symlink, (const char* path1, const char* path2), (path1, path2), "symlink") DLSYM_WRAPPER(int, symlinkat, (int dfd, const char* path1, int dfd2, const char* path2), (dfd, path1, dfd2, path2), "symlinkat") // NEED HAS_SYMLINKS DLSYM_WRAPPER(ssize_t, readlink, (const char* path, char* buf, size_t bufsize), (path, buf, bufsize), "readlink") Loading Loading @@ -1162,6 +1166,7 @@ int rename(const char* oldpath, const char* newpath) { initializeGekko(); // Is path from GekkoFS? DEBUG_INFO("rename {} --> {}", oldpath, newpath); if(CTX->interception_enabled()) { std::string resolved_old; std::string resolved_new; Loading @@ -1173,11 +1178,16 @@ rename(const char* oldpath, const char* newpath) { case PathStatus::Internal: switch(rstatus_new) { case PathStatus::Internal: DEBUG_INFO("[GKFS] {} {} {}", "Renaming", resolved_old, resolved_new); DEBUG_INFO("[GKFS] {} {}", resolved_old, resolved_new); #ifdef HAS_RENAME return gkfs::syscall::gkfs_rename(resolved_old, resolved_new); #else errno = ENOTSUP; return -1; #endif default: // Try normal open. Loading Loading @@ -2245,30 +2255,6 @@ symlink(const char* path1, const char* path2) { GKFS_FALLBACK(symlink, path1, path2); } int symlinkat(int dfd, const char* path1, int dfd2, const char* path2) { initializeGekko(); if(CTX->interception_enabled()) { std::string resolved; if(resolve_gkfs_path(dfd, path1, resolved) == PathStatus::Internal) { DEBUG_INFO("[GKFS] path 1 internal {}", resolved); std::string resolved2; if(resolve_gkfs_path(dfd2, path2, resolved2) == PathStatus::Internal) { DEBUG_INFO("[GKFS] path 2 internal {}", resolved2); #ifdef HAS_SYMLINKS // In Gekko we invert the parameters. return gkfs::syscall::gkfs_mk_symlink(resolved2, resolved); #else DEBUG_INFO("[GKFS] symlinks not supported/compiled"); errno = ENOTSUP; return -1; #endif } } } GKFS_FALLBACK(symlinkat, dfd, path1, dfd2, path2); } #ifdef HAS_SYMLINKS ssize_t readlink(const char* path, char* buf, size_t bufsize) { Loading Loading @@ -2479,10 +2465,15 @@ getcwd(char* buffer, size_t size) { initializeGekko(); if(CTX->interception_enabled()) { if(size == 0) { if(buffer == nullptr) { if(size != 0) buffer = (char*) malloc(size); else { // allocate buffer big enough buffer = (char*) malloc(CTX->cwd().size()); size = CTX->cwd().size(); } } if(CTX->cwd().size() + 1 > size) { errno = ERANGE; return NULL; Loading Loading @@ -2528,7 +2519,12 @@ renameat(int olddirfd, const char* oldpath, int newdirfd, const char* newpath) { if(resolve_gkfs_path(newdirfd, newpath, resolved2) == PathStatus::Internal) { DEBUG_INFO("[GKFS] {}", resolved2); #ifdef HAS_RENAME return gkfs::syscall::gkfs_rename(resolved, resolved2); #else errno = ENOTSUP; return -1; #endif } } } Loading @@ -2549,7 +2545,12 @@ renameat2(int olddirfd, const char* oldpath, int newdirfd, const char* newpath, if(resolve_gkfs_path(newdirfd, newpath, resolved2) == PathStatus::Internal) { DEBUG_INFO("[GKFS] {}", resolved2); #ifdef HAS_RENAME return gkfs::syscall::gkfs_rename(resolved, resolved2); #else errno = ENOTSUP; return -1; #endif } } } Loading Loading
src/client/gkfs_libc.cpp +65 −64 Original line number Diff line number Diff line /* * Copyright 2000-2024 Felix Garcia Carballeira, Diego Camarmas Alonso, * Alejandro Calderon Mateos, Luis Miguel Sanchez Garcia, Borja Bergua Guerra * * This file is part of Expand. * * Expand is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Expand is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Expand. If not, see <http://www.gnu.org/licenses/>. * * Modifications to support GekkoFS done by : * Copyright 2018-2025, Barcelona Supercomputing Center (BSC), Spain * Copyright 2015-2025, Johannes Gutenberg Universitaet Mainz, Germany * * This software was partially supported by the * EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu). * * This software was partially supported by the * ADA-FS project under the SPPEXA project funded by the DFG. * * SPDX-License-Identifier: LGPL-3.0-or-later Copyright 2018-2025, Barcelona Supercomputing Center (BSC), Spain Copyright 2015-2025, Johannes Gutenberg Universitaet Mainz, Germany This software was partially supported by the EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu). This software was partially supported by the ADA-FS project under the SPPEXA project funded by the DFG. This software was partially supported by the the European Union’s Horizon 2020 JTI-EuroHPC research and innovation programme, by the project ADMIRE (Project ID: 956748, admire-eurohpc.eu) This project was partially promoted by the Ministry for Digital Transformation and the Civil Service, within the framework of the Recovery, Transformation and Resilience Plan - Funded by the European Union -NextGenerationEU. This file is part of GekkoFS' POSIX interface. GekkoFS' POSIX interface is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. GekkoFS' POSIX interface is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with GekkoFS' POSIX interface. If not, see <https://www.gnu.org/licenses/>. SPDX-License-Identifier: LGPL-3.0-or-later */ #include <iostream> #include <dlfcn.h> #include <cstdio> Loading Loading @@ -443,10 +451,6 @@ DLSYM_WRAPPER(int, scandir, DLSYM_WRAPPER(int, symlink, (const char* path1, const char* path2), (path1, path2), "symlink") DLSYM_WRAPPER(int, symlinkat, (int dfd, const char* path1, int dfd2, const char* path2), (dfd, path1, dfd2, path2), "symlinkat") // NEED HAS_SYMLINKS DLSYM_WRAPPER(ssize_t, readlink, (const char* path, char* buf, size_t bufsize), (path, buf, bufsize), "readlink") Loading Loading @@ -1162,6 +1166,7 @@ int rename(const char* oldpath, const char* newpath) { initializeGekko(); // Is path from GekkoFS? DEBUG_INFO("rename {} --> {}", oldpath, newpath); if(CTX->interception_enabled()) { std::string resolved_old; std::string resolved_new; Loading @@ -1173,11 +1178,16 @@ rename(const char* oldpath, const char* newpath) { case PathStatus::Internal: switch(rstatus_new) { case PathStatus::Internal: DEBUG_INFO("[GKFS] {} {} {}", "Renaming", resolved_old, resolved_new); DEBUG_INFO("[GKFS] {} {}", resolved_old, resolved_new); #ifdef HAS_RENAME return gkfs::syscall::gkfs_rename(resolved_old, resolved_new); #else errno = ENOTSUP; return -1; #endif default: // Try normal open. Loading Loading @@ -2245,30 +2255,6 @@ symlink(const char* path1, const char* path2) { GKFS_FALLBACK(symlink, path1, path2); } int symlinkat(int dfd, const char* path1, int dfd2, const char* path2) { initializeGekko(); if(CTX->interception_enabled()) { std::string resolved; if(resolve_gkfs_path(dfd, path1, resolved) == PathStatus::Internal) { DEBUG_INFO("[GKFS] path 1 internal {}", resolved); std::string resolved2; if(resolve_gkfs_path(dfd2, path2, resolved2) == PathStatus::Internal) { DEBUG_INFO("[GKFS] path 2 internal {}", resolved2); #ifdef HAS_SYMLINKS // In Gekko we invert the parameters. return gkfs::syscall::gkfs_mk_symlink(resolved2, resolved); #else DEBUG_INFO("[GKFS] symlinks not supported/compiled"); errno = ENOTSUP; return -1; #endif } } } GKFS_FALLBACK(symlinkat, dfd, path1, dfd2, path2); } #ifdef HAS_SYMLINKS ssize_t readlink(const char* path, char* buf, size_t bufsize) { Loading Loading @@ -2479,10 +2465,15 @@ getcwd(char* buffer, size_t size) { initializeGekko(); if(CTX->interception_enabled()) { if(size == 0) { if(buffer == nullptr) { if(size != 0) buffer = (char*) malloc(size); else { // allocate buffer big enough buffer = (char*) malloc(CTX->cwd().size()); size = CTX->cwd().size(); } } if(CTX->cwd().size() + 1 > size) { errno = ERANGE; return NULL; Loading Loading @@ -2528,7 +2519,12 @@ renameat(int olddirfd, const char* oldpath, int newdirfd, const char* newpath) { if(resolve_gkfs_path(newdirfd, newpath, resolved2) == PathStatus::Internal) { DEBUG_INFO("[GKFS] {}", resolved2); #ifdef HAS_RENAME return gkfs::syscall::gkfs_rename(resolved, resolved2); #else errno = ENOTSUP; return -1; #endif } } } Loading @@ -2549,7 +2545,12 @@ renameat2(int olddirfd, const char* oldpath, int newdirfd, const char* newpath, if(resolve_gkfs_path(newdirfd, newpath, resolved2) == PathStatus::Internal) { DEBUG_INFO("[GKFS] {}", resolved2); #ifdef HAS_RENAME return gkfs::syscall::gkfs_rename(resolved, resolved2); #else errno = ENOTSUP; return -1; #endif } } } Loading