diff --git a/.clang-format b/.clang-format index 637628d62..b1c7449a8 100644 --- a/.clang-format +++ b/.clang-format @@ -8,11 +8,11 @@ AlignConsecutiveMacros: AlignTrailingComments: Kind: Always OverEmptyLines: 2 -BreakBeforeBraces: Custom -BraceWrapping: - SplitEmptyFunction: false - AfterControlStatement: Never - AfterFunction: true - AfterStruct: true - AfterUnion: true - BeforeElse: true +# BreakBeforeBraces: Custom +# BraceWrapping: +# SplitEmptyFunction: false +# AfterControlStatement: Never +# AfterFunction: true +# AfterStruct: true +# AfterUnion: true +# BeforeElse: true diff --git a/.gitignore b/.gitignore index 96cbc8d6e..6da26feb1 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,6 @@ src/xpn_server/Makefile src/.vscode .vscode/settings.json test/integrity/xpn/circs +.vscode +build +install \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index ac0162816..bfe94a5c0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,3 +2,7 @@ path = docker url = https://github.com/xpn-arcos/xpn-docker.git branch = master +[submodule "libs/lfi"] + path = libs/lfi + url = https://github.com/dariomnz/lfi.git + branch = master diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..dea95e4f3 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,98 @@ +cmake_minimum_required(VERSION 3.16) + +project(XPN VERSION 3.0.0 LANGUAGES C CXX) + +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + +# add_compile_options("-DDEBUG") +add_compile_options("-D_GNU_SOURCE" "-DMPICH_SKIP_MPICXX") +# add_compile_options("-D_GNU_SOURCE" "-DMPICH_SKIP_MPICXX" "-D_REENTRANT") +add_compile_options("-fPIC" "-O2" "-g" "-g3" "-ggdb" "-Wall" "-Wextra") + +option(ENABLE_MPI_SERVER "Enable the mpi_server module" OFF) +if(ENABLE_MPI_SERVER) + message(STATUS "ENABLE_MPI_SERVER : ${ENABLE_MPI_SERVER}") + add_compile_options("-DENABLE_MPI_SERVER") + set(MPI_PATH ${ENABLE_MPI_SERVER}) + find_library(MPI_LIBRARY NAMES mpi PATHS ${MPI_PATH}/lib /usr/lib /usr/local/lib) + find_path(MPI_INCLUDE_DIR mpi.h PATHS ${MPI_PATH}/include /usr/include /usr/local/include) + message(STATUS "MPI_LIBRARY : ${MPI_LIBRARY}") + message(STATUS "MPI_INCLUDE_DIR : ${MPI_INCLUDE_DIR}") +else() + message(STATUS "ENABLE_MPI_SERVER : false") +endif(ENABLE_MPI_SERVER) + +option(ENABLE_FABRIC_SERVER "Enable the fabric_server module" OFF) +if(ENABLE_FABRIC_SERVER) + message(STATUS "ENABLE_FABRIC_SERVER : ${ENABLE_FABRIC_SERVER}") + add_compile_options("-DENABLE_FABRIC_SERVER") + set(LIBFABRIC_PATH ${ENABLE_FABRIC_SERVER}) + add_subdirectory(libs/lfi) +else() + message(STATUS "ENABLE_FABRIC_SERVER : false") +endif(ENABLE_FABRIC_SERVER) + +option(ENABLE_MQTT_SERVER "Enable the mq_server module" OFF) +if(ENABLE_MQTT_SERVER) + message(STATUS "ENABLE_MQTT_SERVER : ${ENABLE_MQTT_SERVER}") + add_compile_options("-DENABLE_MQTT_SERVER") + set(MOSQUITTO_PATH ${ENABLE_MQTT_SERVER}) + find_library(MOSQUITTO_LIBRARY NAMES mosquitto PATHS ${MOSQUITTO_PATH}/lib /usr/lib /usr/local/lib) + find_path(MOSQUITTO_INCLUDE_DIR mosquitto.h PATHS ${MOSQUITTO_PATH}/include /usr/include /usr/local/include) + message(STATUS "MOSQUITTO_LIBRARY : ${MOSQUITTO_LIBRARY}") + message(STATUS "MOSQUITTO_INCLUDE_DIR : ${MOSQUITTO_INCLUDE_DIR}") +else() + message(STATUS "ENABLE_MQTT_SERVER : false") +endif(ENABLE_MQTT_SERVER) + +link_libraries("pthread" "dl") + +add_subdirectory(src/bypass) +# add_compile_options("-DDEBUG") +add_subdirectory(src/base_cpp) +add_subdirectory(src/xpn_client) +add_subdirectory(src/xpn_server) +add_subdirectory(src/xpn_controller) +add_subdirectory(src/utils) + + +option(ENABLE_FUSE "Enable the fuse module" OFF) +if(ENABLE_FUSE) + message(STATUS "ENABLE_FUSE : ${ENABLE_FUSE}") + add_compile_options("-DENABLE_FUSE") + set(FUSE_PATH ${ENABLE_FUSE}) + find_library(FUSE_LIBRARY NAMES fuse3 PATHS ${FUSE_PATH}/lib /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu "${FUSE_LIBRARY}") + find_path(FUSE_INCLUDE_DIR fuse.h PATHS ${FUSE_PATH}/include /usr/include /usr/local/include PATH_SUFFIXES fuse3) + message(STATUS "FUSE_LIBRARY : ${FUSE_LIBRARY}") + message(STATUS "FUSE_INCLUDE_DIR : ${FUSE_INCLUDE_DIR}") + add_subdirectory(src/connector_fuse) +else() + message(STATUS "ENABLE_FUSE : false") +endif(ENABLE_FUSE) + + +option(BUILD_TESTS "Build the test" OFF) +if(BUILD_TESTS) + message(STATUS "BUILD_TESTS : true") + enable_testing() + add_subdirectory(test) +else() + message(STATUS "BUILD_TESTS : false") +endif(BUILD_TESTS) + + +install(CODE " + message(STATUS \"Create_symlink: from \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib to \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib64\") + execute_process(COMMAND ln -s -f -T \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib64) +") + +unset(ENABLE_MPI_SERVER CACHE) +unset(ENABLE_FABRIC_SERVER CACHE) +unset(ENABLE_MQTT_SERVER CACHE) +unset(ENABLE_FUSE CACHE) +unset(BUILD_TESTS CACHE) \ No newline at end of file diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index e2491d043..000000000 --- a/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -SUBDIRS = src/base src/xpn_client src/utils src/bypass src/xpn_server -EXTRA_DIST = AUTHORS COPYING README.md diff --git a/configure.ac b/configure.ac deleted file mode 100644 index c3b731f18..000000000 --- a/configure.ac +++ /dev/null @@ -1,342 +0,0 @@ -# -# Expand's configure.ac -# --------------------- -# -# Process this file with autoconf to produce a configure script. -# - -# -# begin -# -AC_INIT([Expand],[3.3.0],[fgcarbal@inf.uc3m.es],[expand]) -AC_CONFIG_AUX_DIR(./config) -AC_CONFIG_HEADERS([include/config.h]) -AC_PROG_INSTALL -AC_PROG_RANLIB -AC_PROG_LN_S - - - -# -# Canonicalize the configuration name. -# -AC_CANONICAL_TARGET -AC_CANONICAL_HOST -AC_CANONICAL_BUILD - -AM_INIT_AUTOMAKE([1.0 foreign subdir-objects]) -AM_CONDITIONAL([am__fastdepCC], [test x$am__fastdepCC = xam__fastdepCC]) -AM_CONDITIONAL([AMDEP], [test x$amdep = xamdep]) -AM_PROG_AR - - - -# -# Check for compiler -# -dnl If the environment variable CC is set, its value will be taken as the name of the C compiler to use. -dnl Otherwise, search for a C compiler under a series of likely names, trying gcc and cc first. -dnl Regardless, the output variable CC is set to the chosen compiler. - -AC_PROG_CC([cc gcc icc mpifcc mpicc]) -AM_PROG_CC_C_O - -MPICC_INTEL=$(mpicc --version | grep "Intel" | wc -l) -if test "x$MPICC_INTEL" == "x1"; then - AC_DEFINE([HAVE_ICC], [1], [we have icc as mpicc compiler]) -fi - -MPICC_ANY=$(mpicc --version | wc -l) -if test "$MPICC_ANY" -ne "0"; then - AC_DEFINE([HAVE_MPICC], [1], [we have an mpicc compiler]) -fi - -AC_SUBST(CC) - - -# -# Check for compiler -# - -AC_PROG_MAKE_SET - -if test "$target_os" = "IRIX6.5" -o "$target_os" = "irix6.5" -then - MAKE="gmake" -else - MAKE="make" -fi - -AC_SUBST(MAKE) - - - -# -# Checks for libraries. -# -AC_CHECK_LIB(pthread,pthread_create) -AC_CHECK_LIB(dl,dlopen) -AC_CHECK_LIB(mosquitto,mosquitto_lib_init) - - - -# -# Checks for header files. -# -## AC_CHECK_INCLUDES_DEFAULT -AC_PROG_EGREP - -AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS(fcntl.h string.h strings.h unistd.h sys/ioctl.h time.h sys/time.h netinet/tcp.h netinet/in.h pthread.h sys/param.h dirent.h rpc/rpc.h rpc/clnt.h rpc/types.h mpi.h mosquitto.h) - - - -# -# Checks for typedefs, structures, and compiler characteristics. -# -AC_C_CONST -AC_CHECK_HEADERS_ONCE([sys/time.h]) - -AC_CHECK_TYPE(ptrdiff_t,long) -AC_TYPE_PID_T -AC_TYPE_SIZE_T -AC_CHECK_SIZEOF(unsigned short,2) -AC_CHECK_SIZEOF(unsigned,4) -AC_CHECK_SIZEOF(unsigned long,8) -AC_CHECK_SIZEOF(char *,4) -AC_CHECK_SIZEOF(ptrdiff_t,4) -AC_CHECK_SIZEOF(size_t,4) -AC_SYS_LARGEFILE - - - -# -# Checks for library functions. -# -AC_FUNC_VPRINTF -AC_CHECK_FUNCS(gethostname gettimeofday select socket strdup strerror) -AC_CHECK_FUNCS(memcmp memcpy memmove memset) - - - -# -# Set initial variables depending on $target_cpu, $target_os, etc. -# - -CFLAGS_IPATH="-I../../bin/mosquitto/include " -CFLAGS_IPATH+="-I../../../bin/mosquitto/include -I../../../xpn/include -I../../../xpn/include/xpn_client -I../../../xpn/include/base " -CFLAGS_IPATH+="-I../../../../bin/mosquitto/include -I../../../../xpn/include -I../../../../xpn/include/xpn_client -I../../../../xpn/include/base " - -CFLAGS_LPATH="-L../../bin/mosquitto/lib -L../../xpn/lib " -CFLAGS_LPATH+="-L../../../bin/mosquitto/lib -L../../../xpn/lib " -CFLAGS_LPATH+="-L../../../../bin/mosquitto/lib -L../../../../xpn/lib " - - CFLAGS_DEBUG="-g -O3 -Wall -Wextra" -#CFLAGS_DEBUG="-g -Wall -Wextra" -#CFLAGS_DEBUG="-g -g3 -ggdb -Wall -Wextra" - -CFLAGS_CDEFS="" -CFLAGS_SWITCHES="" - - -AC_MSG_RESULT("$target_os"); -case "$target_os" in - Linux* | linux*) - OS="__LINUX__" - CFLAGS_CDEFS+=" -D_GNU_SOURCE" - ;; - AIX* | aix*) - OS="__AIX__" - CFLAGS_CDEFS+=" -D_LARGE_FILES=1" - ;; - IRIX* | irix*) - OS="__IRIX__" - ;; - *) - OS="__LINUX__" - AC_MSG_RESULT("GNU/Linux operating by default will be used."); - ;; -esac - -AC_CHECK_SIZEOF([int *]) -SIZEOF_INT_P=$ac_cv_sizeof_int_p -if test "x$SIZEOF_INT_P" == "x8"; then - CFLAGS_CDEFS+=" -DHAVE_64BITS " - AC_MSG_RESULT("64-bits by default will be used."); -else - CFLAGS_CDEFS+=" -DHAVE_32BITS" - AC_MSG_RESULT("32-bits by default will be used."); -fi - - -LIBLINK=$LIBS -CDEFS="$CFLAGS_CDEFS -D_REENTRANT -DHAVE_CONFIG_H" -CFLAGS="$CFLAGS_SWITCHES $CFLAGS_DEBUG -Wall -Wextra -fPIC -std=c11 $CDEFS $CFLAGS_IPATH" - -AC_MSG_RESULT("CFLAGS so far: "$CFLAGS); -AC_MSG_RESULT("CDEFS so far: "$CDEFS); -AC_MSG_RESULT("LIBLINK so far: "$LIBLINK); - -AC_SUBST(OS) -AC_SUBST(CFLAGS) -AC_SUBST(CDEFS) -AC_SUBST(LIBLINK) - - - -# -# Set Include_Flags -# -INCLUDEFLAGS="\ --I\$(top_srcdir)/include \ --I\$(top_srcdir)/include/base \ --I\$(top_srcdir)/include/bypass \ --I\$(top_srcdir)/include/xpn_client/ \ --I\$(top_srcdir)/include/xpn_client/xpn \ --I\$(top_srcdir)/include/xpn_client/xpn/xpn_simple \ --I\$(top_srcdir)/include/xpn_client/nfi \ --I\$(top_srcdir)/include/xpn_client/nfi/nfi_local \ --I\$(top_srcdir)/include/xpn_client/nfi/nfi_xpn_server \ --I\$(top_srcdir)/include/xpn_server/ \ --I\$(top_srcdir)/include/xpn_server/mpi_server/ \ --I\$(top_srcdir)/include/xpn_server/sck_server/" - - -### BEGIN OF NFS BLOCK. Do not remove this line. ### -# -# Defines the necessary variables if nfs is enabled. -# -AC_ARG_ENABLE( [nfs], - [AS_HELP_STRING([--enable-nfs],[Enable NFS v2 module.])], - [ - [CDEFS="$CDEFS -DENABLE_NFS"] - [INCLUDEFLAGS="$INCLUDEFLAGS -I\$(top_srcdir)/include/xpn_client/nfi/nfi_nfs"] - [NFI_NFS="nfi_nfs"] - [NFI_NFS_OBJECTS="\$(NFI_NFS_OBJECTS)"] - ] -) -AC_SUBST(NFI_NFS) -AC_SUBST(NFI_NFS_OBJECTS) -AM_CONDITIONAL([ENABLE_NFS], [test "$NFI_NFS" = "nfi_nfs"]) -### END OF NFS BLOCK. Do not remove this line. ### - - -### BEGIN OF NFS3 BLOCK. Do not remove this line. ### -# -# Defines the necessary variables if nfs3 is enabled. -# -AC_ARG_ENABLE( [nfs3], - [AS_HELP_STRING([--enable-nfs3],[Enable NFS v3 module.])], - [ - [CDEFS="$CDEFS -DENABLE_NFS3"] - [INCLUDEFLAGS="$INCLUDEFLAGS -I\$(top_srcdir)/include/xpn_client/nfi/nfi_nfs3"] - [NFI_NFS3="nfi_nfs3"] - [NFI_NFS3_OBJECTS="\$(NFI_NFS3_OBJECTS)"] - ] -) -AC_SUBST(NFI_NFS3) -AC_SUBST(NFI_NFS3_OBJECTS) -AM_CONDITIONAL([ENABLE_NFS3], [test "$NFI_NFS3" = "nfi_nfs3"]) -### END OF NFS3 BLOCK. Do not remove this line. ### - - -### BEGIN OF MPI_SERVER BLOCK. Do not remove this line. ### -# -# Defines the necessary variables if mpi_server is enabled. -# -AC_ARG_ENABLE( [mpi_server], - [AS_HELP_STRING([--enable-mpi_server@<:@=/path/to/mpi/@:>@ (Don't use '~')],[Enable mpi_server module.])], - [ - [case "${enableval}" in - yes) CC="mpicc";; - no) CC="mpicc" ;; - *) CC="$enableval" ;; - esac] - [CDEFS="$CDEFS -DENABLE_MPI_SERVER"] - [INCLUDEFLAGS="$INCLUDEFLAGS -I\$(top_srcdir)/include/xpn_client/nfi/nfi_mpi_server"] - [NFI_MPI_SERVER="nfi_mpi_server"] - [NFI_MPI_SERVER_OBJECTS="\$(NFI_MPI_SERVER_OBJECTS)"] - ] -) -AC_SUBST(CC) -AC_SUBST(NFI_MPI_SERVER) -AC_SUBST(NFI_MPI_SERVER_OBJECTS) -AM_CONDITIONAL([ENABLE_MPI_SERVER], [test "$NFI_MPI_SERVER" = "nfi_mpi_server"]) -### END OF MPI_SERVER BLOCK. Do not remove this line. ### - - -### BEGIN OF SCK_SERVER BLOCK. Do not remove this line. ### -# -# Defines the necessary variables if sck_server is enabled. -# -AC_ARG_ENABLE( [sck_server], - [AS_HELP_STRING([--enable-sck_server],[Enable sck_server module.])], - [ - [CDEFS="$CDEFS -DENABLE_SCK_SERVER"] - [INCLUDEFLAGS="$INCLUDEFLAGS -I\$(top_srcdir)/include/xpn_client/nfi/nfi_sck_server"] - [NFI_SCK_SERVER="nfi_sck_server"] - [NFI_SCK_SERVER_OBJECTS="\$(NFI_SCK_SERVER_OBJECTS)"] - ] -) -AC_SUBST(NFI_SCK_SERVER) -AC_SUBST(NFI_SCK_SERVER_OBJECTS) -AM_CONDITIONAL([ENABLE_SCK_SERVER], [test "$NFI_SCK_SERVER" = "nfi_sck_server"]) -### END OF SCK_SERVER BLOCK. Do not remove this line. ### - - -### BEGIN OF MQTT BLOCK. Do not remove this line. ### -# -# Defines the necessary variables if mq_server is enabled. -# -AC_ARG_ENABLE( [mosquitto], - [AS_HELP_STRING([--enable-mosquitto],[Enable mosquitto module.])], - [ - [CDEFS="$CDEFS -DENABLE_SCK_SERVER -DENABLE_MOSQUITTO -DHAVE_MOSQUITTO_H"] - [INCLUDEFLAGS="$INCLUDEFLAGS -I\$(top_srcdir)/include/xpn_client/nfi/nfi_sck_server"] - [NFI_SCK_SERVER="nfi_sck_server"] - [NFI_SCK_SERVER_OBJECTS="\$(NFI_SCK_SERVER_OBJECTS)"] - [LIBLINK+=" -lmosquitto"] - [LIBS=$CFLAGS_LPATH" "$LIBS" -lmosquitto"] - ] -) -AC_SUBST(NFI_SCK_SERVER) -AC_SUBST(NFI_SCK_SERVER_OBJECTS) -AC_SUBST(LIBLINK) -AC_SUBST(LIBS) -AM_CONDITIONAL([ENABLE_SCK_SERVER], [test "$NFI_SCK_SERVER" = "nfi_sck_server"]) -### END OF MQTT BLOCK. Do not remove this line. ### - - -CPPFLAGS="$CDEFS $INCLUDEFLAGS $M_HEADERS $CPPFLAGS" -LDFLAGS="$LIBLINK $LIBS" -AC_SUBST(CPPFLAGS) -AC_SUBST(LDFLAGS) -AC_SUBST(LIBS) -AC_SUBST(M_HEADERS) - - - -# -# Build makefile and headers... -# -AC_CONFIG_FILES([ \ - Makefile \ - src/base/Makefile \ - src/xpn_client/Makefile \ - src/utils/Makefile \ - src/bypass/Makefile \ - src/xpn_server/Makefile \ - test/integrity/xpn/Makefile \ - test/integrity/xpn-iot/Makefile \ - test/integrity/xpn-conf/Makefile \ - test/integrity/mpi_connect_accept/Makefile \ - test/integrity/bypass_c/Makefile \ - test/integrity/xpn_metadata/Makefile \ - test/performance/xpn/Makefile \ - test/performance/iop/Makefile \ - test/performance/mpi_pingpong/Makefile \ - test/performance/xpn-fault-tolerant/Makefile \ - ]) - -AC_OUTPUT - diff --git a/docker b/docker index 9e0aefdf7..1c441b23a 160000 --- a/docker +++ b/docker @@ -1 +1 @@ -Subproject commit 9e0aefdf7f72e20a8e6b578110d43817399b366a +Subproject commit 1c441b23a0f83cacc99c4b773a635c0830bcb199 diff --git a/docs/index.html b/docs/index.html deleted file mode 120000 index 5bc112887..000000000 --- a/docs/index.html +++ /dev/null @@ -1 +0,0 @@ -html/index.html \ No newline at end of file diff --git a/docs/xpn_server_monitor.md b/docs/xpn_server_monitor.md new file mode 100644 index 000000000..dd28d1e07 --- /dev/null +++ b/docs/xpn_server_monitor.md @@ -0,0 +1,52 @@ +# xpn_server_monitor + +The xpn_server_monitor tool is responsible for collecting the aggregate data statistics of the servers in a csv file. + +### This tool requieres to set two enviromental variables: +```bash +# Flag to activate statistical data collection +export XPN_STATS=1 +# Variable with a existing path to the directory that will store the data +export XPN_STATS_DIR= +# Variable with the path to the config file +export XPN_CONFIG= +``` + +## An example of use is as follows: +```bash +# Flag to activate/desactivate (optional) +DO_STATS=0 + +if [[ "$DO_STATS" -eq 1 ]]; then + # Set the env flags + # Create the necesary directories + export XPN_STATS=1 + export XPN_STATS_DIR= + + mkdir -p $XPN_STATS_DIR +fi + +############################################ +# Create configuration and start the servers +############################################ + +if [[ "$DO_STATS" -eq 1 ]]; then + # Start the monitor, it need to run in the background + xpn_server_monitor & +fi + +###################### +# Run the applications +###################### + +if [[ "$DO_STATS" -eq 1 ]]; then + # Stop the monitor + xpn_server_monitor stop +fi + +################## +# Stop the servers +################## +``` + + diff --git a/include/all_system.h b/include/all_system.h deleted file mode 100644 index 67a06f298..000000000 --- a/include/all_system.h +++ /dev/null @@ -1,224 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos - * - * 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 . - * - */ - - -#ifndef _ALL_H_SYSTEM_H -#define _ALL_H_SYSTEM_H - - - /* ... Include / Inclusion ........................................... */ - - // Get config*.h - #if defined(HAVE_CONFIG_H) - #include "config.h" - #endif - - // Include common headers - #include - #include - #include - #include - #include - #include - #include - - #include - #include - - #include - - // Include detected headers - #ifndef NOT_TO_USE_STDLIB_H - #include - #endif - - #if defined(HAVE_SYS_PARAM_H) - #include - #endif - - #if defined(HAVE_DIRENT_H) - #ifndef __USE_XOPEN - #define __USE_XOPEN - #endif - #include - #endif - - #if defined(HAVE_STRINGS_H) - #include - #endif - - #if defined(HAVE_STRING_H) - #include - #endif - - #if defined(HAVE_PTHREAD_H) - #include - #endif - - #if defined(HAVE_NETINET_TCP_H) - #include - #endif - - #if defined(HAVE_NETINET_IN_H) - #include - #include - #include - #include - #endif - - #if defined(HAVE_UNISTD_H) - #include - #endif - - #if defined(HAVE_SYS_TIME_H) - #include - #endif - - #if defined(HAVE_TIME_H) - #include - #endif - - #if defined(HAVE_RPC_RPC_H) - #include - #endif - - #if defined(HAVE_RPC_CLNT_H) - #include - #endif - - #if defined(HAVE_RPC_TYPES_H) - #include - #endif - - #if defined(HAVE_FCNTL_H) - #ifndef NOT_TO_USE_FCNTL_H - #include - #endif - #endif - - #ifdef ENABLE_MPI_SERVER - #include - #endif - #if defined(HAVE_MPI_H) - #include - #endif - - #if defined(HAVE_MOSQUITTO_H) - #include - #endif - - #ifndef __USE_GNU - #define __USE_GNU - #endif - #include - - - /* ... Types / Tipos ................................................. */ - -#if !defined(HAVE_64BITS) - #define off64_t __off_t - #define uid_t __uid_t - #define gid_t __gid_t - #define mode_t __mode_t - - #define h_addr h_addr_list[0] /* for backward compatibility */ - - #define u_long unsigned long -#endif - - - /* ... Const / Const ................................................. */ - - // Common sizes - #ifndef KB - #define KB (1024) - #endif - - #ifndef MB - #define MB (KB*KB) - #endif - - #ifndef GB - #define GB (KB*KB*KB) - #endif - - #ifndef TRUE - #define TRUE 1 - #endif - - #ifndef FALSE - #define FALSE 0 - #endif - - #ifndef LARGEFILE_SOURCE - #define LARGEFILE_SOURCE 1 - #endif - - // Other definitions - #if !defined(NULL_DEVICE_PATH) - #define NULL_DEVICE_PATH "/dev/null" - #endif - - #if !defined(PATH_MAX) - #define PATH_MAX 1024 - #endif - - #if !defined(MAX_BUFFER_SIZE) - #define MAX_BUFFER_SIZE (1*MB) - #endif - - #define PROTOCOL_MAXLEN 20 - - #if !defined(HAVE_FCNTL_H) - #define O_ACCMODE 0003 - #define O_RDONLY 00 - #define O_WRONLY 01 - #define O_RDWR 02 - #define O_CREAT 0100 /* not fcntl */ - #define O_EXCL 0200 /* not fcntl */ - #define O_NOCTTY 0400 /* not fcntl */ - #define O_TRUNC 01000 /* not fcntl */ - #define O_APPEND 02000 - #define O_NONBLOCK 04000 - #define O_NDELAY O_NONBLOCK - #define O_SYNC 010000 - #define O_FSYNC O_SYNC - #define O_ASYNC 020000 - #endif - - - #if !defined(O_DIRECTORY) - #define O_DIRECTORY 040000 - #define O_LARGEFILE __O_LARGEFILE - #endif - - - /* ... Debug / Depuraci'on ........................................... */ - - // Get "base_debug.h" - #include "base_debug.h" - - - /* ................................................................... */ - - -#endif /* _ALL_H_SYSTEM_H */ - diff --git a/include/base/base_debug.h b/include/base/base_debug.h deleted file mode 100644 index 763fa6342..000000000 --- a/include/base/base_debug.h +++ /dev/null @@ -1,100 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _XPN_DEBUG_H -#define _XPN_DEBUG_H - - /* ... Include / Inclusion ........................................... */ - - #include - #include - #include "profiler.h" - - - /* ... Const / Const ................................................. */ - - //Set debug configuration - - extern int xpn_debug; // In src/xpn/xpn_simple/xpncore/xpn_init.c - - #define PRINT_TRACE \ - if (xpn_debug) { \ - fprintf (stderr, "[%s:%d]\n", __FILE__, __LINE__); \ - } - - #define XPN_DEBUG_COMMON_HEADER fprintf (stderr, "[%s][%s:%d] ", __func__, __FILE__, __LINE__); - - #define XPN_DEBUG(format, ...) \ - if (xpn_debug) { \ - XPN_DEBUG_COMMON_HEADER \ - fprintf (stderr, format, ## __VA_ARGS__); \ - fprintf (stderr, "\n"); \ - } - - #define XPN_DEBUG_BEGIN_CUSTOM(format, ...) \ - if (xpn_debug) { \ - XPN_DEBUG_COMMON_HEADER \ - fprintf (stderr, "Begin %s", __func__); \ - fprintf (stderr, "("); \ - fprintf (stderr, format, ## __VA_ARGS__); \ - fprintf (stderr, ")"); \ - fprintf (stderr, "\n"); \ - }; XPN_PROFILER_DEFAULT_BEGIN(); - - #define XPN_DEBUG_END_CUSTOM(format, ...) \ - if (xpn_debug) { \ - XPN_DEBUG_COMMON_HEADER \ - fprintf (stderr, "End %s", __func__); \ - fprintf (stderr, "("); \ - fprintf (stderr, format, ## __VA_ARGS__); \ - fprintf (stderr, ")"); \ - fprintf (stderr, "errno=%d %s", errno, strerror(errno)); \ - fprintf (stderr, "\n"); \ - }; XPN_PROFILER_DEFAULT_END_CUSTOM(format, ## __VA_ARGS__); - - #define XPN_DEBUG_BEGIN XPN_DEBUG("Begin %s()", __func__); XPN_PROFILER_DEFAULT_BEGIN(); - #define XPN_DEBUG_END XPN_DEBUG("End %s(), errno=%d %s", __func__, errno, strerror(errno)); XPN_PROFILER_DEFAULT_END(); - - #define XPN_DEBUG_BEGIN_ARGS1(...) XPN_DEBUG("Begin %s(%s)", __func__, ## __VA_ARGS__); XPN_PROFILER_DEFAULT_BEGIN(); - #define XPN_DEBUG_END_ARGS1(...) XPN_DEBUG("End %s(%s), errno=%d %s", __func__, ## __VA_ARGS__, errno, strerror(errno)); XPN_PROFILER_DEFAULT_END_CUSTOM("%s", ## __VA_ARGS__); - - #define XPN_DEBUG_BEGIN_ARGS2(...) XPN_DEBUG("Begin %s(%s, %s)", __func__, ## __VA_ARGS__); XPN_PROFILER_DEFAULT_BEGIN(); - #define XPN_DEBUG_END_ARGS2(...) XPN_DEBUG("End %s(%s, %s), errno=%d %s", __func__, ## __VA_ARGS__, errno, strerror(errno)); XPN_PROFILER_DEFAULT_END_CUSTOM("%s, %s", ## __VA_ARGS__); - - #if defined(DEBUG) - // base - // nfi - #define DEBUG_NFI - #define DEBUG_MNT - #define DEBUG_NFS - #define DEBUG_NFSW - #define DEBUG_NFS_ERR - #define DEBUG_NFS_ERRW - // xpn - #define XPN_DEBUG - #endif - - - /* ................................................................... */ - -#endif - diff --git a/include/base/base_lib.h b/include/base/base_lib.h deleted file mode 100644 index da1e1f75b..000000000 --- a/include/base/base_lib.h +++ /dev/null @@ -1,48 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _BASE_H_ -#define _BASE_H_ - - /* ... Include / Inclusion ........................................... */ - - #include "debug_tags.h" - #include "trace_tags.h" - #include "debug_msg.h" - #include "trace_msg.h" - - #include "filesystem.h" - #include "time_misc.h" - #include "math_misc.h" - - #include "darray.h " - #include "dtable.h" - - #include "string_misc.h" - #include "path_misc.h" - #include "urlstr.h" - - - /* ................................................................... */ - -#endif - diff --git a/include/base/darray.h b/include/base/darray.h deleted file mode 100644 index 1bacaedf7..000000000 --- a/include/base/darray.h +++ /dev/null @@ -1,173 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef DARRAY_H -#define DARRAY_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include - - - /* ... Consts / Constantes ............................................ */ - - // type sizes - #define c_POINTER sizeof(T_POINTER) - #define c_POINTERTABLA sizeof(t_pointerDArray) - - typedef - void *T_POINTER; - - typedef - T_POINTER *t_pointerDArray; // Dynamic array, NULL end - - - /* ... Data structures / Estructuras de datos ........................ */ - - - /* ... Functions / Funciones ......................................... */ - - - int8_t DARRAY_InsEndDarray ( /*INOUT*/ t_pointerDArray *t, - /*INOUT*/ long *n, - /*IN*/ T_POINTER gptr ); - /* - Inserts 'gptr' at the end of 't', with '(*n)' eltos and - adds one more ( (*n) = (*n) + 1 ) */ - /* - Inserta el puntero 'gptr' al final de la tabla 't' - que tiene ya 'n' punteros. En la funcion se incrementa - en uno 'n', pues al final, tendra un elemento mas : 'gptr' */ - - int8_t DARRAY_DelEndDarray ( /*INOUT*/ t_pointerDArray *t, - /*INOUT*/ long *n, - /*INOUT*/ T_POINTER *delGPtr ); - /* - It deletes last element of 't' and subtracts one element - ( (*n) = (*n) - 1 ) */ - /* - Borra el ultimo elemento de la tabla 't', decrementa el - numero de elementos en tabla ('n') y coloca en el parametro - delGPtr el elemento borrado, por si nos interesa */ - - int8_t DARRAY_DelBeginDarray ( /*INOUT*/ t_pointerDArray *t, - /*INOUT*/ long *n, - /*INOUT*/ T_POINTER *delGPtr ); - /* - */ - /* - Borra el primer elemento de la tabla 't', decrementa el - numero de elementos en tabla ('n') y coloca en el parametro - delGPtr el elemento borrado, por si nos interesa */ - - int8_t DARRAY_DelNFromDarray ( /*IN*/ t_pointerDArray *t, - /*INOUT*/ long *n, - /*IN*/ long orden, - /*INOUT*/ T_POINTER *delGPtr ); - /* - */ - /* - Borra el elemento de posicion 'orden' de la tabla 't', decrementa - el numero de elementos en tabla ('n') y coloca en el parametro - delGPtr el elemento borrado, por si nos interesa */ - - int8_t DARRAY_ChangeNFromDarray ( /*IN*/ t_pointerDArray *t, - /*INOUT*/ long *n, - /*IN*/ long orden, - /*INOUT*/ T_POINTER nPtr ); - /* - */ - /* - Cambia Darray[orden] a 'nPtr' */ - - int8_t DARRAY_FreeEltosDarray ( /*INOUT*/ t_pointerDArray *t, - /*INOUT*/ long *n, - /*IN*/ void (*freef)(T_POINTER) ); - /* - */ - /* - Se recorre la tabla, del 0..N aplicando la funcion 'freef' - sobre cada elemento. Cuando ha terminado, hace un 'free(t)' */ - - T_POINTER DARRAY_GetNFromDarray ( /*IN*/ t_pointerDArray t, - /*IN*/ long orden ); - /* - */ - /* - Retorna el elemento que ocupa la posicion 'orden' en la tabla. - OJO, si orden es 3, retorna t[3] (es decir, el cuarto) - NO comprueba que se salga de los limites del array. */ - - T_POINTER DARRAY_FindEltoDarray ( /*IN*/ t_pointerDArray t, - /*INOUT*/ long n, - /*IN*/ T_POINTER gptr, - /*IN*/ int8_t (*findf)(T_POINTER,T_POINTER) ); - /* - */ - /* - Busca el array dinamico, el primer elemento que haga que, - (*findf)(gptr,. - * - */ - - -#ifndef DEBUG_MSG_H -#define DEBUG_MSG_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "string_misc.h" - - - /* ... Const / Const ................................................. */ - - // debug messages - #ifdef DEBUG - #define debug_error(...) debug_msg_printf(1, __FILE__, __LINE__, stderr, __VA_ARGS__) - #define debug_warning(...) debug_msg_printf(2, __FILE__, __LINE__, stderr, __VA_ARGS__) - #define debug_info(...) debug_msg_printf(3, __FILE__, __LINE__, stdout, __VA_ARGS__) - #else - #define debug_error(...) - #define debug_warning(...) - #define debug_info(...) - #endif - - // Current function - #define DEBUG_BEGIN() \ - debug_info("Begin %s()\n", __func__) - - #define DEBUG_END() \ - debug_info("End %s(), errno=%d\n", __func__, errno) - - - /* ... Data structures / Estructuras de datos ........................ */ - - - /* ... Functions / Funciones ......................................... */ - - // Debug API - - void debug_msg_init ( void ); - int debug_msg_printf ( int src_type, char *src_fname, long src_line, FILE *fd, char *msg_fmt, ... ); - - - // Extra Debug API - - /** - * - * Set 'printer' dispacher. - * @param printer the printer function to be used. - * @return nothing. - * - */ - void DEBUG_MSG_setPrinter - ( - /*IN*/ int (*printer) (const char *, va_list) - ); - - /** - * - * Write a message using the format and the argument list given to it. - * @param line the line of code where message is generated. - * @param name the file name at the code where message is generated. - * @param pid the process that send this message. - * @param type the type of message. - * @param fto the message format. - * @param vl the argument list. - * @return nothing. - * - */ - void DEBUG_MSG_VPrintF - ( - /*IN*/ int line, - /*IN*/ char *name, - /*IN*/ long pid, - /*IN*/ int type, - /*IN*/ char *fto, - /*IN*/ va_list vl - ); - - /** - * - * Write a message using the format and arguments given to it. - * @param line the line of code where message is generated. - * @param name the file name at the code where message is generated. - * @param pid the process that send this message. - * @param type the type of message. - * @param fto the message format. - * @return nothing. - * - */ - void DEBUG_MSG_PrintF - ( - /*IN*/ int line, - /*IN*/ char *name, - /*IN*/ long pid, - /*IN*/ int type, - /*IN*/ char *fto, - ... - ); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/base/debug_tags.h b/include/base/debug_tags.h deleted file mode 100644 index d5d68aeb6..000000000 --- a/include/base/debug_tags.h +++ /dev/null @@ -1,62 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef DEBUG_TAGS_H -#define DEBUG_TAGS_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - - - /* ... Consts / Constantes ........................................... */ - - #define INFO __LINE__,__FILE__,getpid(),100 - #define WARNING __LINE__,__FILE__,getpid(),101 - #define ERROR __LINE__,__FILE__,getpid(),102 - - #define DEFCON_1 __LINE__,__FILE__,getpid(),110 - #define DEFCON_2 __LINE__,__FILE__,getpid(),110 - #define DEFCON_3 __LINE__,__FILE__,getpid(),111 - #define DEFCON_4 __LINE__,__FILE__,getpid(),111 - #define DEFCON_5 __LINE__,__FILE__,getpid(),112 - #define DEFCON_6 __LINE__,__FILE__,getpid(),112 - - - /* ... Data structures / Estructuras de datos ........................ */ - - - /* ... Functions / Funciones ......................................... */ - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/base/dtable.h b/include/base/dtable.h deleted file mode 100644 index 396bb2650..000000000 --- a/include/base/dtable.h +++ /dev/null @@ -1,72 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _DTABLE_H -#define _DTABLE_H - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "darray.h" - - - /* ... Constants / Constantes ........................................ */ - - #define c_DTABLE_T sizeof(dtable_t) - #define c_DTELTO_T sizeof(dtelto_t) - - #define c_DTABLE_T_NULL {NULL,0,-1} - - - /* ... Data structures / Estructuras de datos ........................ */ - - typedef struct - { - void *dt_info; - int next_free; - int myself; - } dtelto_t; - - typedef struct - { - t_pointerDArray dtable; - long neltos; - long free_list; - } dtable_t; - - - /* ... Functions / Funciones ......................................... */ - - int dtable_insert ( dtable_t *dt, void *dt_info ); - int dtable_delete ( dtable_t *dt, int fd ); - void *dtable_get ( dtable_t *dt, int fd ); - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/base/filesystem.h b/include/base/filesystem.h deleted file mode 100644 index 7b3960004..000000000 --- a/include/base/filesystem.h +++ /dev/null @@ -1,87 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _FILESYSTEM_H_ -#define _FILESYSTEM_H_ - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "syscall_proxies.h" - #include "base/utils.h" - #include - #include - #include - - - /* ... Const / Const ................................................. */ - - // - // -> In xpn_client, this line must be added at the beginning: - // filesystem_low_set(RTLD_NEXT) ; - // -> BUT in mpi_server, this line must be added at the beginning: - // filesystem_low_set(RTLD_DEFAULT) ; - // -> In order to close in a thread (background), then use: - // #define ASYNC_CLOSE 1 - // - - - /* ... Data structures / Estructuras de datos ........................ */ - - typedef off_t offset_t; - - - /* ... Functions / Funciones ......................................... */ - - int filesystem_low_set ( void * new_rtld ) ; - //int filesystem_init ( void ); - //int filesystem_destroy ( void ); - - int filesystem_creat ( char *pathname, mode_t mode ); - int filesystem_open ( char *pathname, int flags ); - int filesystem_open2 ( char *pathname, int flags, mode_t mode ); - int filesystem_close ( int fd ); - int filesystem_fsync ( int fd ); - - ssize_t filesystem_read ( int read_fd2, void *buffer, size_t buffer_size ); - ssize_t filesystem_write ( int write_fd2, void *buffer, size_t num_bytes_to_write ); - - int filesystem_mkdir ( char *pathname, mode_t mode ); - int filesystem_rmdir ( char *pathname ); - int filesystem_mkpath ( char *pathname ); - - DIR *filesystem_opendir ( char *name ); - long filesystem_telldir ( DIR *dirp ); - void filesystem_seekdir ( DIR *dirp, long loc ); - struct dirent *filesystem_readdir ( DIR *dirp ); - int filesystem_closedir ( DIR *dirp ); - - int filesystem_rename ( char *old_pathname, char *new_pathname ); - off_t filesystem_lseek ( int fd, off_t offset, int whence ); - int filesystem_unlink ( char *pathname ); - int filesystem_stat ( char *pathname, struct stat *sinfo ); - - - /* ...................................................................... */ - -#endif - diff --git a/include/base/math_misc.h b/include/base/math_misc.h deleted file mode 100644 index ece0cec47..000000000 --- a/include/base/math_misc.h +++ /dev/null @@ -1,98 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _MATH_MISC_H -#define _MATH_MISC_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - - - /* ... Functions / Funciones ......................................... */ - - int MATH_MISC_hash - ( - char *file, - int nServ - ); - - int MATH_MISC_locateInRAID5withInternalParity - ( - int i, // block index - int m, // how many servers - int *SP, // Server for Parity - int *IP, // Index for Parity - int *SD, // Server for Data - int *ID // Index for Data - ); - - int MATH_MISC_locateInRAID5withExternalParity - ( - int i, // block index - int m, // how many servers - int *SP, // Server for Parity - int *IP, // Index for Parity - int *SD, // Server for Data - int *ID // Index for Data - ); - - int MATH_MISC_Xor - ( - char *block_result, - char *block_1, - char *block_2, - int block_size - ); - - int MATH_MISC_Xor3 - ( - char *block_result, - char *block_1, - char *block_2, - char *block_3, - int block_size - ); - - int MATH_MISC_XorN - ( - char *block_result, - char **blocks, - int nblocks, - int block_size - ); - - - /* .................................................................... */ - - - #ifdef __cplusplus - } - #endif - -#endif /* _MATH_MISC_H */ - diff --git a/include/base/ns.h b/include/base/ns.h deleted file mode 100644 index cdc6d0f58..000000000 --- a/include/base/ns.h +++ /dev/null @@ -1,70 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos - * - * 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 . - * - */ - - -#ifndef _NS_H_ -#define _NS_H_ - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/utils.h" - #include "base/service_socket.h" - - - /* ... Const / Const ................................................. */ - - #ifndef MPI_SERVER_DNS_FILE_DEFAULT - #define MPI_SERVER_DNS_FILE_DEFAULT "/tmp/mpi_dns.txt" - #endif - - #ifndef SCK_SERVER_DNS_FILE_DEFAULT - #define SCK_SERVER_DNS_FILE_DEFAULT "/tmp/sck_dns.txt" - #endif - - #ifndef MQ_SERVER_DNS_FILE_DEFAULT - #define MQ_SERVER_DNS_FILE_DEFAULT "/tmp/mq_dns.txt" - #endif - - #ifndef MAX_MQ_SERVER_NODES - #define MAX_MQ_SERVER_NODES 256 - #endif - - #ifndef CONST_TEMP - #define CONST_TEMP 1024 - #endif - - - /* ... Functions / Funciones ......................................... */ - - int ns_get_hostname ( char * srv_name ) ; - int ns_get_host_ip ( char * ip, size_t ip_size ) ; - - int ns_publish ( char * dns_file, char * protocol, char * param_srv_name, char * srv_ip, char * port_name ) ; - int ns_unpublish ( char * dns_file, char * protocol, char * param_srv_name ) ; - int ns_lookup ( char * protocol, char * param_srv_name, char * srv_ip, char * port_name ) ; - - - /* ................................................................... */ - - -#endif - diff --git a/include/base/path_misc.h b/include/base/path_misc.h deleted file mode 100644 index 72f7017c0..000000000 --- a/include/base/path_misc.h +++ /dev/null @@ -1,62 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _PATH_MISC_H_ -#define _PATH_MISC_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/string_misc.h" - #include - - - /* ... Functions / Funciones ......................................... */ - - int hash (const char *file, int nServ, int isfile); - - int getFirstDir ( char *dir, char *path); - long getSizeFactor ( char *name ); - - // get the last name of a path and erase the file name - int getNameFile(char *file, char *dir); - - // get the first name of the path and erase the part name - int getNamePart(char *part, char *dir); - - // erase the initial dir used in the url - int getDirWithURL(char *url, char *dir); - - - /* .................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif /* _PATH_MISC_H */ - diff --git a/include/base/profiler.h b/include/base/profiler.h deleted file mode 100644 index 8ad322029..000000000 --- a/include/base/profiler.h +++ /dev/null @@ -1,104 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _XPN_PROFILER_H -#define _XPN_PROFILER_H - - /* ... Include / Inclusion ........................................... */ - - #include - #include - #include "time_misc.h" - #include "filesystem.h" - - extern int xpn_profiler_fd; // In src/xpn/xpn_simple/xpncore/xpn_init.c - extern int xpn_profiler; // In src/xpn/xpn_simple/xpncore/xpn_init.c - - - /* ... Const / Const ................................................. */ - - #define XPN_PROFILER_HEADER "{\"otherData\": {},\"traceEvents\":[{}\n" - #define XPN_PROFILER_FOOTER "]}\n" - - - #define XPN_PROFILER_BEGIN(name_file) \ - if (xpn_profiler) { \ - char buf[PATH_MAX]; \ - sprintf(buf, "%s%ld.json", name_file, pthread_self()); \ - xpn_profiler_fd = filesystem_open2(buf, O_WRONLY | O_CREAT, S_IRWXU); \ - if (xpn_profiler_fd > 0) { \ - filesystem_write(xpn_profiler_fd, (void *)XPN_PROFILER_HEADER, strlen(XPN_PROFILER_HEADER)); \ - } \ - } - - #define XPN_PROFILER_END() \ - if (xpn_profiler) { \ - filesystem_write(xpn_profiler_fd, (void *)XPN_PROFILER_FOOTER, strlen(XPN_PROFILER_FOOTER)); \ - filesystem_close(xpn_profiler_fd); \ - } - - #define XPN_PROFILER_WRITE_CUSTOM(start_time, elapsed_time, format, ...) \ - if (xpn_profiler) { \ - if (xpn_profiler_fd >= 0) { \ - char xpn_profiler_aux_buff[PATH_MAX*2]; \ - char xpn_profiler_aux_buff2[PATH_MAX]; \ - snprintf(xpn_profiler_aux_buff2, PATH_MAX, format, ## __VA_ARGS__); \ - snprintf(xpn_profiler_aux_buff, PATH_MAX*2, ",{" \ - "\"cat\":\"function\"," \ - "\"dur\":%ld," \ - "\"name\":\"%s(%s)\"," \ - "\"ph\":\"X\"," \ - "\"pid\":%d," \ - "\"tid\":%ld," \ - "\"ts\":%ld" \ - "}\n", \ - elapsed_time, __func__, xpn_profiler_aux_buff2, getpid(), pthread_self(), start_time); \ - filesystem_write(xpn_profiler_fd, xpn_profiler_aux_buff, strlen(xpn_profiler_aux_buff)); \ - } \ - } - - #define XPN_PROFILER_NAME_BEGIN(name) \ - struct timeval name##_start_timer; \ - if (xpn_profiler) { \ - TIME_MISC_Timer(&name##_start_timer); \ - } - - #define XPN_PROFILER_NAME_END_CUSTOM(name, format, ...) \ - if (xpn_profiler) { \ - struct timeval name##_end_timer; \ - struct timeval name##_dif_timer; \ - TIME_MISC_Timer(&name##_end_timer); \ - TIME_MISC_DiffTime(&name##_start_timer,&name##_end_timer,&name##_dif_timer); \ - long name##_start_us = (long) TIME_MISC_TimevaltoMicroLong(&name##_start_timer); \ - long name##_dif_us = (long) TIME_MISC_TimevaltoMicroLong(&name##_dif_timer); \ - XPN_PROFILER_WRITE_CUSTOM(name##_start_us, name##_dif_us, format, ## __VA_ARGS__) \ - } - - #define XPN_PROFILER_DEFAULT_BEGIN() XPN_PROFILER_NAME_BEGIN(default); - #define XPN_PROFILER_DEFAULT_END() XPN_PROFILER_NAME_END_CUSTOM(default, " "); - #define XPN_PROFILER_DEFAULT_END_CUSTOM(format, ...) XPN_PROFILER_NAME_END_CUSTOM(default, format, ## __VA_ARGS__); - - - /* ................................................................... */ - -#endif - diff --git a/include/base/service_socket.h b/include/base/service_socket.h deleted file mode 100644 index f12df5764..000000000 --- a/include/base/service_socket.h +++ /dev/null @@ -1,63 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos - * - * 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 . - * - */ - - -#ifndef _SERVICE_SOCKET_H_ -#define _SERVICE_SOCKET_H_ - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/utils.h" - #include "base/socket.h" - - - /* ... Const / Const ................................................. */ - - // NS base on sockets - #define DEFAULT_XPN_SCK_PORT 3456 - #define DEFAULT_XPN_SCK_IPV SCK_IP4 - - #define SOCKET_ACCEPT_CODE_MPI 100 - #define SOCKET_ACCEPT_CODE_SCK_CONN 151 - #define SOCKET_ACCEPT_CODE_SCK_NO_CONN 152 - #define SOCKET_FINISH_CODE 750 - #define SOCKET_FINISH_CODE_AWAIT 751 - - #ifdef MPI_MAX_PORT_NAME - #define MAX_PORT_NAME_LENGTH MPI_MAX_PORT_NAME - #else - #define MAX_PORT_NAME_LENGTH 256 - #endif - - - /* ... Functions / Funciones ......................................... */ - - int sersoc_do_send_recv ( char * srv_name, int port, int req_id, char *res_val ) ; - int sersoc_do_send ( char * srv_name, int port, int req_id ) ; - - int sersoc_lookup_port_name ( char * srv_name, char * port_name, int socket_accept_code ) ; - - - /* ................................................................... */ - -#endif - diff --git a/include/base/socket.h b/include/base/socket.h deleted file mode 100644 index dd74e42f6..000000000 --- a/include/base/socket.h +++ /dev/null @@ -1,77 +0,0 @@ - -/* - * Copyright 2000-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _SOCKET_H_ -#define _SOCKET_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "debug_msg.h" - #include "utils.h" - #include "socket_ip4.h" - #include "socket_ip6.h" - - #include - #include - #include - #include - - - /* ... Const / Const ................................................. */ - - // values for ip_version - #define SCK_IP4 4 - #define SCK_IP6 6 - - - /* ... Functions / Funciones ......................................... */ - - int socket_send ( int socket, void * buffer, int size ); - int socket_recv ( int socket, void * buffer, int size ); - - int socket_setopt_data ( int socket ) ; - int socket_setopt_service ( int socket ) ; - - int socket_server_create ( int *out_socket, int port, int ip_version ); - int socket_server_accept ( int socket, int *out_conection_socket, int ip_version ); - int socket_client_connect ( char *srv_name, int port, int *out_socket, int ip_version ); - int socket_client_connect_with_retries ( char *srv_name, char *port_name, int *out_socket, int n_retries, int ip_version ) ; - int socket_close ( int socket ); - - int socket_gethostname ( char * srv_name, int socket_mode ) ; - int socket_gethostbyname ( char * ip, size_t ip_size, char * srv_name, int socket_mode ) ; - int socket_getsockname ( char * port_name, int in_socket, int socket_mode ) ; - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/base/socket_ip4.h b/include/base/socket_ip4.h deleted file mode 100644 index 564961760..000000000 --- a/include/base/socket_ip4.h +++ /dev/null @@ -1,56 +0,0 @@ - -/* - * Copyright 2000-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _SOCKET_IP4_H_ -#define _SOCKET_IP4_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "debug_msg.h" - #include "utils.h" - - - /* ... Functions / Funciones ......................................... */ - - int socket_ip4_server_create ( int *out_socket, int port ); - int socket_ip4_server_accept ( int socket, int * out_conection_socket ) ; - int socket_ip4_client_connect ( char * srv_name, int port, int *out_socket ) ; - int socket_ip4_client_connect_with_retries ( char * srv_name, char *port_name, int *out_socket, int n_retries ) ; - - int socket_ip4_gethostname ( char * srv_name ) ; - int socket_ip4_gethostbyname ( char * ip, size_t ip_size, char * srv_name ) ; - int socket_ip4_getsockname ( char * port_name, int new_socket ) ; - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/base/socket_ip6.h b/include/base/socket_ip6.h deleted file mode 100644 index ec19ea66c..000000000 --- a/include/base/socket_ip6.h +++ /dev/null @@ -1,58 +0,0 @@ - -/* - * Copyright 2000-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Elias Del Pozo Puñal - * - * 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 . - * - */ - - -#ifndef _SOCKET_IP6_H_ -#define _SOCKET_IP6_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "debug_msg.h" - #include "utils.h" - - #include - - - /* ... Functions / Funciones ......................................... */ - - int socket_ip6_server_create ( int *out_socket, int port ) ; - int socket_ip6_server_accept ( int socket, int *out_conection_socket ) ; - int socket_ip6_client_connect ( char *srv_name, int port, int *out_socket ) ; - int socket_ip6_client_connect_with_retries ( char *srv_name, char *port_name, int *out_socket, int n_retries ) ; - - int socket_ip6_gethostname ( char * srv_name ) ; - int socket_ip6_gethostbyname ( char * ip, size_t ip_size, char * srv_name ) ; - int socket_ip6_getsockname ( char * port_name, int new_socket ) ; - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/base/string_misc.h b/include/base/string_misc.h deleted file mode 100644 index a47b8e818..000000000 --- a/include/base/string_misc.h +++ /dev/null @@ -1,119 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _STRING_MISC_H_ -#define _STRING_MISC_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - - - /* ... Functions / Funciones ......................................... */ - - /** - * Return the string length of 'str'. - * - * @param str the string. - * @return the string length. - * - */ - long STRING_MISC_StrLen ( /*IN*/ char *str ); - - /** - * Return true if and only if the strings 'str1' and 'str2' are equals. - * - * @param str1 the first string. - * @param str2 the second string. - * @return true (1) iff are equals or false (0) in other case. - * - */ - int8_t STRING_MISC_Equal ( /*IN*/ char *str1, - /*IN*/ char *str2 ); - - /** - * Return a string clone of 'str'. - * - * @param str the string. - * @return a clone of 'str'. - * - */ - char *STRING_MISC_StrDup ( /*IN*/ char *str ); - - /** - * - * Like 'strlen' but also accept a string with format. - * - * @params string format. - * @params format params. - * @return string legth. - * - */ - int STRING_MISC_StrLenF - ( - /*IN*/ char *format, - /*IN*/ va_list argl - ); - - /** - * - * Like vsprintf, but request dynamic memory to write string elements into. - * - * @params string format. - * @params format params. - * @return string pointer or NULL if error. - * - */ - char *STRING_MISC_Dvsprintf - ( - /*IN*/ char *format, - /*IN*/ va_list argl - ); - - /** - * - * Like before, but with variable arguments. - * - * @params string format. - * @return string pointer or NULL if error. - * - */ - char *STRING_MISC_Dsprintf - ( - /*IN*/ char *format, - ... - ); - - - /* .................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif /* _STRING_MISC_H */ - diff --git a/include/base/syscall_proxies.h b/include/base/syscall_proxies.h deleted file mode 100644 index d29c7e28a..000000000 --- a/include/base/syscall_proxies.h +++ /dev/null @@ -1,155 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _SYSCALL_PROXIES_H -#define _SYSCALL_PROXIES_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include - #include - #include - - #include - #include - - #include "utils.h" - - - /* ... Functions / Funciones ......................................... */ - - // File API - int dlsym_open (char *path, int flags); - int dlsym_open2 (char *path, int flags, mode_t mode); - int dlsym___open_2 (char *path, int flags); - int dlsym_close (int fd); - - int dlsym_creat (const char *path, mode_t mode); - int dlsym_ftruncate (int fd, off_t length); - int dlsym_mkstemp (char *template); - - ssize_t dlsym_read (int fd, void *buf, size_t nbyte); - ssize_t dlsym_write (int fd, void *buf, size_t nbyte); - - ssize_t dlsym_pread (int fd, void *buf, size_t count, off_t offset); - ssize_t dlsym_pwrite (int fd, const void *buf, size_t count, off_t offset); - - off_t dlsym_lseek (int fd, off_t offset, int whence); - - int dlsym_fstat (int ver, int fd, struct stat *buf); - int dlsym_stat (int ver, const char *path, struct stat *buf); - int dlsym_lstat (int ver, const char *path, struct stat *buf); - int dlsym_fstatat (int dfd, const char *path, struct stat *buf, int flags); - int dlsym_statfs (const char *path, struct statfs *buf); - - int dlsym_rename (const char *old_path, const char *new_path); - int dlsym_unlink (char *path); - int dlsym_remove (char *path); - - - // File API (stdio) - FILE* dlsym_fopen (const char *filename, const char *mode); - FILE* dlsym_fdopen (int fd, const char *mode); - int dlsym_fclose (FILE *stream); - - size_t dlsym_fread (void *ptr, size_t size, size_t nmemb, FILE *stream); - size_t dlsym_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream); - - int dlsym_fseek (FILE *stream, long int offset, int whence); - long dlsym_ftell (FILE *stream); - void dlsym_rewind (FILE *stream); - int dlsym_feof (FILE *stream); - - - // Directory API - DIR* dlsym_opendir (char *dirname); - int dlsym_closedir (DIR* dirp); - - long dlsym_telldir (DIR *dirp); - void dlsym_seekdir (DIR *dirp, long loc); - - struct dirent * dlsym_readdir (DIR *dirp); - - int dlsym_mkdir (char *path, mode_t mode); - int dlsym_rmdir (char *path); - - - // Proccess API - int dlsym_fork (void); - - int dlsym_pipe (int pipefd[2]); - - int dlsym_dup (int fd); - int dlsym_dup2 (int fd, int fd2); - - void dlsym_exit (int status); - - - // Manager API - int dlsym_chdir (char * path); - int dlsym_chmod ( char *path, mode_t mode); - int dlsym_fchmod (int fd, mode_t mode); - int dlsym_chown (char *path, uid_t owner, gid_t group); - int dlsym_fcntl (int fd, int cmd, long arg); - int dlsym_access (const char *path, int mode); - char *dlsym_realpath (const char *restrict path, char *restrict resolved_path); - int dlsym_fsync (int fd); - int dlsym_flock (int fd, int operation); - - - // Memory API - void *dlsym_mmap (void *addr, size_t length, int prot, int flags, int fd, off_t offset); - - - // 64 bits -#if defined(HAVE_64BITS) - int dlsym_open64 (char *path, int flags, mode_t mode); - ssize_t dlsym_pread64 (int fd, void *buf, size_t count, off_t offset); - ssize_t dlsym_pwrite64 (int fd, const void *buf, size_t count, off_t offset); - - off64_t dlsym_lseek64 (int fd, off64_t offset, int whence); - - int dlsym_statfs64 (const char *path, struct statfs64 *buf); - int dlsym_fstatat64 (int dfd, const char *path, struct stat64 *buf, int flags); - int dlsym_xstat64 (int ver, const char *path, struct stat64 *buf); - int dlsym_lxstat64 (int ver, const char *path, struct stat64 *buf); - int dlsym_fxstat64 (int ver, int fd, struct stat64 *buf); - - DIR* dlsym_opendir64 (char *dirname); - struct dirent64 * dlsym_readdir64 (DIR *dirp); -#endif - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/base/time_misc.h b/include/base/time_misc.h deleted file mode 100644 index d4ad8a853..000000000 --- a/include/base/time_misc.h +++ /dev/null @@ -1,87 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _TIME_MISC_H -#define _TIME_MISC_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include - - - /* ... Const / Const ................................................. */ - - #define USECPSEC 1000000 - - - /* ... Functions / Funciones ......................................... */ - - void TIME_MISC_Timer - ( - struct timeval * t - ); - - void TIME_MISC_DiffTime - ( - struct timeval * to, - struct timeval * tn, - struct timeval * dif - ); - - void TIME_MISC_AddTime - ( - struct timeval * to, - struct timeval * tn, - struct timeval * sum - ); - - float TIME_MISC_TimevaltoFloat - ( - struct timeval* timet - ); - - float TIME_MISC_TimevaltoMicro - ( - struct timeval* timet - ); - - long TIME_MISC_TimevaltoMicroLong - ( - struct timeval* timet - ); - - - /* ................................................................... */ - - - #ifdef __cplusplus - } - #endif - -#endif /* _TIME_MISC_H */ - diff --git a/include/base/trace_msg.h b/include/base/trace_msg.h deleted file mode 100644 index 84c644086..000000000 --- a/include/base/trace_msg.h +++ /dev/null @@ -1,106 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef TRACE_MSG_H -#define TRACE_MSG_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "string_misc.h" - #include "trace_tags.h" - - - /* ... Functions / Funciones ......................................... */ - - /** - * - * Establece el gestor de impresión de mensajes. - * Set 'printer' dispacher. - * @param printer the printer function to be used. - * @return nothing. - * - */ - void TRACE_MSG_setPrinter - ( - /*IN*/ int (*printer) (const char *, va_list) - ); - - /** - * - * Escribe un mensaje, usando formato y lista - * de argumentos variables. - * Write a message using the format and the argument list given to it. - * @param line the line of code where message is generated. - * @param name the file name at the code where message is generated. - * @param pid the process that send this message. - * @param type the type of message. - * @param fto the message format. - * @param vl the argument list. - * @return nothing. - * - */ - void TRACE_MSG_VPrintF - ( - /*IN*/ int line, - /*IN*/ char *name, - /*IN*/ long pid, - /*IN*/ int type, - /*IN*/ char *fto, - /*IN*/ va_list vl - ); - - /** - * - * Escribe una tira CON FORMATO usando PrintMsg. - * Write a message using the format and arguments given to it. - * @param line the line of code where message is generated. - * @param name the file name at the code where message is generated. - * @param pid the process that send this message. - * @param type the type of message. - * @param fto the message format. - * @return nothing. - * - */ - void TRACE_MSG_PrintF - ( - /*IN*/ int line, - /*IN*/ char *name, - /*IN*/ long pid, - /*IN*/ int type, - /*IN*/ char *fto, - ... - ); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/base/urlstr.h b/include/base/urlstr.h deleted file mode 100644 index 091e65865..000000000 --- a/include/base/urlstr.h +++ /dev/null @@ -1,56 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _URLSTR_H -#define _URLSTR_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "string_misc.h" - #include "path_misc.h" - - - /* ... Functions / Funciones ......................................... */ - - int ParseURL ( char *url, - char *protocol, - char *login, - char *passwd, - char *server, - char *port, - char *dir) ; - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/base/utils.h b/include/base/utils.h deleted file mode 100644 index 5e6977f4b..000000000 --- a/include/base/utils.h +++ /dev/null @@ -1,66 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _UTILS_H -#define _UTILS_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include - #include - #include - #include "base/debug_msg.h" - - - /* ... Const / Const ................................................. */ - - // Check arguments - #define FREE_AND_NULL(ptr) \ - if ((ptr) != NULL) { free((ptr)); (ptr) = NULL; } - - #define NULL_RET_ERR(ptr, set_errno) \ - if (NULL == (ptr)) { errno=set_errno; return -1; } - - - /* ... Functions / Funciones ......................................... */ - - // time - long utils_get_time ( void ) ; - - // enviroment variables - int utils_getenv_int ( char *env_name, int default_value ) ; - int utils_str2int ( char *str_name, int default_value ) ; - - - /* .................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/base/workers.h b/include/base/workers.h deleted file mode 100644 index ec786a1eb..000000000 --- a/include/base/workers.h +++ /dev/null @@ -1,67 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos - * - * 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 . - * - */ - - -#ifndef _WORKERS_H_ -#define _WORKERS_H_ - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/debug_msg.h" - #include "base/trace_msg.h" - #include "workers_common.h" - #include "workers_ondemand.h" - #include "workers_pool.h" - - - /* ... Const / Const ................................................. */ - - // No threads are executed - #define TH_NOT 0 - // A pool of N threads is executed where there is an intermediate queue and there are producers and consumers of operations. - #define TH_POOL 1 - // A thread is created according to an operation. That is, on demand. - #define TH_OP 2 - - - /* ... Data structures / Estructuras de datos ........................ */ - - typedef struct - { - worker_ondemand_t w1; - worker_pool_t w2; - int thread_mode; - } worker_t; - - - /* ... Functions / Funciones ......................................... */ - - int base_workers_init ( worker_t *w, int thread_mode ); - void base_workers_destroy ( worker_t *w ); - - int base_workers_launch ( worker_t *w, struct st_th *th_arg, void (*worker_function)(struct st_th) ); - int base_workers_wait ( worker_t *w, struct st_th *th_arg ); - - - /* ................................................................... */ - -#endif diff --git a/include/base/workers_common.h b/include/base/workers_common.h deleted file mode 100644 index 5379e154c..000000000 --- a/include/base/workers_common.h +++ /dev/null @@ -1,73 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos - * - * 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 . - * - */ - - -#ifndef _WORKERS_COMMON_H_ -#define _WORKERS_COMMON_H_ - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/debug_msg.h" - - - /* ... Const / Const ................................................. */ - - #define MAX_THREADS 2048 - #define MAX_OPERATIONS 1024 - #define STACK_SIZE (256*KB) - - - /* ... Data structures / Estructuras de datos ........................ */ - - struct st_th - { - void *params; - void (*function)(struct st_th); - - // server stuff - int id; - int type_op; - int rank_client_id; - int tag_client_id; - long sd; - void *comm; - int close4me; - int server_type; - - // w: worker_ondemand/worker_pool as void * - void *w; - // v: original st_th as void * - void *v; - - // client stuff - pthread_t th_worker; - pthread_mutex_t m_wait; - pthread_cond_t c_wait; - int r_wait; - int wait4me; // (wait4me==1) ? launch + wait : launch - }; - - - /* ................................................................... */ - -#endif - diff --git a/include/base/workers_ondemand.h b/include/base/workers_ondemand.h deleted file mode 100644 index 7b4bf3eb5..000000000 --- a/include/base/workers_ondemand.h +++ /dev/null @@ -1,55 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos - * - * 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 . - * - */ - - -#ifndef _WORKERS_ONDEMAND_H_ -#define _WORKERS_ONDEMAND_H_ - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "workers_common.h" - - - /* ... Data structures / Estructuras de datos ........................ */ - - typedef struct - { - // number of active threads (launch + destroy) - int busy_worker; - pthread_mutex_t m_worker; - pthread_cond_t c_worker; - pthread_cond_t c_nworkers; - long n_workers; - } worker_ondemand_t; - - - /* ... Functions / Funciones ......................................... */ - - int worker_ondemand_init ( worker_ondemand_t *w ); - void workers_ondemand_destroy ( worker_ondemand_t *w ); - - int worker_ondemand_launch ( worker_ondemand_t *w, struct st_th *th_arg, void (*worker_function)(struct st_th) ); - int worker_ondemand_wait ( struct st_th *th_arg ); - - /* ................................................................... */ - -#endif diff --git a/include/base/workers_pool.h b/include/base/workers_pool.h deleted file mode 100644 index f27fc741c..000000000 --- a/include/base/workers_pool.h +++ /dev/null @@ -1,73 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos - * - * 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 . - * - */ - - -#ifndef _WORKERS_POOL_H_ -#define _WORKERS_POOL_H_ - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "workers_common.h" - - - /* ... Const / Const ................................................. */ - - // Thread count multiplier - #define POOL_OVERSUSCRIPTION 2 - // End pool - #define TH_FINALIZE 200 - - - /* ... Data structures / Estructuras de datos ........................ */ - - typedef struct - { - pthread_mutex_t m_pool; - pthread_cond_t c_pool_no_full; - pthread_cond_t c_poll_no_empty; - pthread_mutex_t m_pool_end; - - int POOL_MAX_THREADS; - pthread_t *thid; - - struct st_th operations_buffer[MAX_OPERATIONS]; - int n_operation; - int deq_pos; - int enq_pos; - int pool_end; - } worker_pool_t; - - - /* ... Functions / Funciones ......................................... */ - - int worker_pool_init ( worker_pool_t *w ); - void worker_pool_destroy ( worker_pool_t *w ); - - void worker_pool_enqueue ( worker_pool_t *w, struct st_th *th_arg, void (*worker_function)(struct st_th)); - struct st_th worker_pool_dequeue ( worker_pool_t *w ); - - int worker_pool_wait ( struct st_th *th_arg ); - - - /* ................................................................... */ - -#endif diff --git a/include/bypass/xpn_bypass.h b/include/bypass/xpn_bypass.h deleted file mode 100644 index 8dc2be7c4..000000000 --- a/include/bypass/xpn_bypass.h +++ /dev/null @@ -1,259 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos - * - * 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 . - * - */ - - -#ifndef _XPN_BYPASS_H_ -#define _XPN_BYPASS_H_ - - /* ... Include / Inclusion ........................................... */ - - #ifndef _GNU_SOURCE - #define _GNU_SOURCE - #endif - - #include "config.h" - - #include - #include - #include - #include - #include - #include - - #include "xpn.h" - #include "syscall_proxies.h" - - #include - #include - -#if defined(HAVE_MPI_H) - #include "mpi.h" -#endif - //#include //Mutex - - - /* ... Const / Const ................................................. */ - - #ifndef _STAT_VER - #define _STAT_VER 0 - #endif - - - //#define RTLD_NEXT ((void *) -1l) - #define MAX_FDS 10000 - #define MAX_DIRS 10000 - #define PLUSXPN 1000 - - //#undef __USE_FILE_OFFSET64 - //#undef __USE_LARGEFILE64 - - - #define FD_FREE 0 - #define FD_SYS 1 - #define FD_XPN 2 - - - // Types - #define O_ACCMODE 00000003 - #define O_RDONLY 00000000 - #define O_WRONLY 00000001 - #define O_RDWR 00000002 - #ifndef O_CREAT - #define O_CREAT 00000100 // not fcntl - #endif - #ifndef O_EXCL - #define O_EXCL 00000200 // not fcntl - #endif - #ifndef O_NOCTTY - #define O_NOCTTY 00000400 // not fcntl - #endif - #ifndef O_TRUNC - #define O_TRUNC 00001000 // not fcntl - #endif - #ifndef O_APPEND - #define O_APPEND 00002000 - #endif - #ifndef O_NONBLOCK - #define O_NONBLOCK 00004000 - #endif - #ifndef O_DSYNC - #define O_DSYNC 00010000 // used to be O_SYNC, see below - #endif - #ifndef FASYNC - #define FASYNC 00020000 // fcntl, for BSD compatibility - #endif - #ifndef O_DIRECT - #define O_DIRECT 00040000 // direct disk access hint - #endif - #ifndef O_LARGEFILE - #define O_LARGEFILE 00100000 - #endif - #ifndef O_DIRECTORY - #define O_DIRECTORY 00200000 // must be a directory - #endif - #ifndef O_NOFOLLOW - #define O_NOFOLLOW 00400000 // don't follow links - #endif - #ifndef O_NOATIME - #define O_NOATIME 01000000 - #endif - #ifndef O_CLOEXEC - #define O_CLOEXEC 02000000 // set close_on_exec */ - #endif - - - /* ... Data structures / Estructuras de datos ........................ */ - - struct __dirstream - { - int fd; // File descriptor. - //__libc_lock_define (, lock) // Mutex lock for this structure. //TODO - size_t allocation; // Space allocated for the block. - size_t size; // Total valid data in the block. - size_t offset; // Current offset into the block. - off_t filepos; // Position of next entry to read. - // Directory block. - char data[0] __attribute__ ((aligned (__alignof__ (void*)))); - - char * path; - }; - - struct generic_fd - { - int type; - int real_fd; - // int is_file; - }; - - - /* ... Functions / Funciones ......................................... */ - - // File API - - int open ( const char *path, int flags, ... ); - int __open_2 ( const char *path, int flags, ... ); - int creat ( const char *path, mode_t mode ); - int mkstemp ( char *template ); - int close ( int fd ); - - int ftruncate ( int fildes, off_t length ); - - ssize_t read ( int fildes, void *buf, size_t nbyte ); - ssize_t write ( int fildes, const void *buf, size_t nbyte ); - - ssize_t pread ( int fd, void *buf, size_t count, off_t offset ); - ssize_t pwrite ( int fd, const void *buf, size_t count, off_t offset ); - - off_t lseek ( int fildes, off_t offset, int whence ); - - int stat ( const char *path, struct stat *buf ); - int statfs ( const char *path, struct statfs *buf ); - int __lxstat ( int ver, const char *path, struct stat *buf ); - int __xstat ( int ver, const char *path, struct stat *buf ); - int fstat ( int fd, struct stat *buf ); - int __fxstat ( int ver, int fd, struct stat *buf ); - int __fxstatat ( int ver, int dirfd, const char *path, struct stat *buf, int flags ); - - int rename ( const char *old_path, const char *new_path ); - int unlink ( const char *path ); - int remove ( const char *path ); - - - // File API (stdio) - - FILE * fopen ( const char *path, const char *mode ); - FILE * fdopen ( int fd, const char *mode ); - int fclose ( FILE *stream ); - - size_t fread ( void *ptr, size_t size, size_t nmemb, FILE *stream ); - size_t fwrite ( const void *ptr, size_t size, size_t nmemb, FILE *stream ); - - int fseek ( FILE *stream, long int offset, int whence ); - long ftell ( FILE *stream ); - void rewind ( FILE *stream ); - int feof ( FILE *stream ); - - - // Directory API - - int mkdir ( const char *path, mode_t mode ); - DIR * opendir ( const char *dirname ); - - struct dirent *readdir ( DIR *dirp ); - - int closedir ( DIR *dirp ); - int rmdir ( const char *path ); - - - // Proccess API - - int fork ( void ); - int dup ( int fildes ); - int dup2 ( int fildes, int fildes2 ); - void exit ( int status ); - - - // Manager API - - int chdir ( const char *path ); - int chmod ( const char *path, mode_t mode ); - int fchmod ( int fildes, mode_t mode ); - int chown ( const char *path, uid_t owner, gid_t group ); - int fcntl ( int fd, int cmd, long arg ); - int access ( const char *path, int mode ); - char * realpath ( const char *restrict path, char *restrict resolved_path ); - char * __realpath_chk ( const char * path, char * resolved_path, size_t resolved_len ); - int fsync ( int fd ); - int flock ( int fd, int operation ); - - - // MPI API - - #if defined(HAVE_MPI_H) - int MPI_Init ( int *argc, char ***argv ); - int MPI_Init_thread ( int *argc, char ***argv, int required, int *provided ); - int MPI_Finalize (void); - #endif - - - // 64-bits API - -#if defined(HAVE_64BITS) - int open64 ( const char *path, int flags, ... ); - ssize_t pread64 ( int fd, void *buf, size_t count, off_t offset ); - ssize_t pwrite64 ( int fd, const void *buf, size_t count, off_t offset ); - - off64_t lseek64 ( int fd, off64_t offset, int whence ); - - int statfs64 ( const char *path, struct statfs64 *buf ); - int __lxstat64 ( int ver, const char *path, struct stat64 *buf ); - int __xstat64 ( int ver, const char *path, struct stat64 *buf ); - int __fxstat64 ( int ver, int fildes, struct stat64 *buf ); - int __fxstatat64 ( int ver, int dirfd, const char *path, struct stat64 *buf, int flags ); - - struct dirent64 *readdir64 ( DIR *dirp ); -#endif - - - /* ................................................................... */ - -#endif - diff --git a/include/config.h.in b/include/config.h.in deleted file mode 100644 index d2302c9fd..000000000 --- a/include/config.h.in +++ /dev/null @@ -1,192 +0,0 @@ -/* include/config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the header file. */ -#undef HAVE_DIRENT_H - -/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ -#undef HAVE_DOPRNT - -/* Define to 1 if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define to 1 if you have the `gethostname' function. */ -#undef HAVE_GETHOSTNAME - -/* Define to 1 if you have the `gettimeofday' function. */ -#undef HAVE_GETTIMEOFDAY - -/* we have icc as mpicc compiler */ -#undef HAVE_ICC - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the `dl' library (-ldl). */ -#undef HAVE_LIBDL - -/* Define to 1 if you have the `mosquitto' library (-lmosquitto). */ -#undef HAVE_LIBMOSQUITTO - -/* Define to 1 if you have the `pthread' library (-lpthread). */ -#undef HAVE_LIBPTHREAD - -/* Define to 1 if you have the `memcmp' function. */ -#undef HAVE_MEMCMP - -/* Define to 1 if you have the `memcpy' function. */ -#undef HAVE_MEMCPY - -/* Define to 1 if you have the `memmove' function. */ -#undef HAVE_MEMMOVE - -/* Define to 1 if you have the `memset' function. */ -#undef HAVE_MEMSET - -/* Define to 1 if you have the header file. */ -#undef HAVE_MOSQUITTO_H - -/* we have an mpicc compiler */ -#undef HAVE_MPICC - -/* Define to 1 if you have the header file. */ -#undef HAVE_MPI_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_NETINET_IN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_NETINET_TCP_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_PTHREAD_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_RPC_CLNT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_RPC_RPC_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_RPC_TYPES_H - -/* Define to 1 if you have the `select' function. */ -#undef HAVE_SELECT - -/* Define to 1 if you have the `socket' function. */ -#undef HAVE_SOCKET - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDIO_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the `strdup' function. */ -#undef HAVE_STRDUP - -/* Define to 1 if you have the `strerror' function. */ -#undef HAVE_STRERROR - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_IOCTL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_PARAM_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TIME_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have that is POSIX.1 compatible. */ -#undef HAVE_SYS_WAIT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_TIME_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if you have the `vprintf' function. */ -#undef HAVE_VPRINTF - -/* Name of package */ -#undef PACKAGE - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* The size of `char *', as computed by sizeof. */ -#undef SIZEOF_CHAR_P - -/* The size of `int *', as computed by sizeof. */ -#undef SIZEOF_INT_P - -/* The size of `ptrdiff_t', as computed by sizeof. */ -#undef SIZEOF_PTRDIFF_T - -/* The size of `size_t', as computed by sizeof. */ -#undef SIZEOF_SIZE_T - -/* The size of `unsigned', as computed by sizeof. */ -#undef SIZEOF_UNSIGNED - -/* The size of `unsigned long', as computed by sizeof. */ -#undef SIZEOF_UNSIGNED_LONG - -/* The size of `unsigned short', as computed by sizeof. */ -#undef SIZEOF_UNSIGNED_SHORT - -/* Define to 1 if all of the C90 standard headers exist (not just the ones - required in a freestanding environment). This macro is provided for - backward compatibility; new code need not use it. */ -#undef STDC_HEADERS - -/* Version number of package */ -#undef VERSION - -/* Number of bits in a file offset, on hosts where this is settable. */ -#undef _FILE_OFFSET_BITS - -/* Define for large files, on AIX-style hosts. */ -#undef _LARGE_FILES - -/* Define to empty if `const' does not conform to ANSI C. */ -#undef const - -/* Define as a signed integer type capable of holding a process identifier. */ -#undef pid_t - -/* Define to `long' if does not define. */ -#undef ptrdiff_t - -/* Define to `unsigned int' if does not define. */ -#undef size_t diff --git a/include/stamp-h1 b/include/stamp-h1 deleted file mode 100644 index b330768e9..000000000 --- a/include/stamp-h1 +++ /dev/null @@ -1 +0,0 @@ -timestamp for include/config.h diff --git a/include/xpn_client/nfi/nfi.h b/include/xpn_client/nfi/nfi.h deleted file mode 100644 index f500a1137..000000000 --- a/include/xpn_client/nfi/nfi.h +++ /dev/null @@ -1,165 +0,0 @@ - -/* - * Copyright 2000-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Luis Miguel Sanchez Garcia, Borja Bergua Guerra, Dario Muñoz Muñoz - * - * 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 . - * - */ - -#ifndef _NFI_H -#define _NFI_H - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "debug_msg.h" - #include "workers.h" - #include "xpn_metadata.h" - - - /* ... Const / Const ................................................. */ - - // PROTOCOLS - /* - #define LOCAL 1 - #define NFS 2 - #define NFS3 3 - #define MQ_SERVER 9 - #define MPI_SERVER 10 - */ - - // TYPE FILES - #define NFIFILE 0 - #define NFIDIR 1 - #define NFINULL -1 - - - /* ... Data structures / Estructuras de datos ........................ */ - - // info of the servers - struct nfi_ops; - struct nfi_worker; - - struct nfi_server - { - int id; // id of the server - //int protocol; // protocol // It is never used - char *server; // server address - char *url; // URL of this server -> protocol - // + server - // + path + more info (port, ...) - int block_size; - void *private_info; // info private - struct nfi_ops *ops; // operations - struct nfi_worker *wrk; // this struct has the thread - - int error; // For fault tolerance - - // Execution configuration - int xpn_thread; - int xpn_session_file; - int xpn_session_dir; - - int keep_connected; // keep connection between operations - }; - - struct nfi_attr_server - { - int type; - int size; - void *private_info; - struct nfi_attr_server *next; - }; - - struct nfi_info - { - u_long at_size; - u_long at_bsize; - u_long at_blocks; - u_long at_bfree; - u_long at_bavail; - }; - - struct nfi_attr - { - dev_t st_dev; // ID of device containing file - ino_t st_ino; // inode number - - int at_type; // FILE or DIR - mode_t at_mode; // protection - nlink_t at_nlink; // number of hard links - uid_t at_uid; // user ID of owner - gid_t at_gid; // group ID of owner - off_t at_size; // total size, in bytes - u_long at_blksize; // blocksize for filesystem I/O - u_long at_blocks; // number of blocks allocated - time_t at_atime; // time of last access - time_t at_mtime; // time of last modification - time_t at_ctime; // time of last status change - void *private_info; - }; - - struct nfi_fhandle - { - int type; // file or directory - char *url; // url of DIR or FILE - struct nfi_server *server; // server - void *priv_fh; // pointer to private filehandle - int has_mqtt; // has MQTT - }; - - // Forward declaration - struct xpn_metadata; - - struct nfi_ops - { - int (*nfi_reconnect) (struct nfi_server *serv); - int (*nfi_disconnect)(struct nfi_server *serv); - int (*nfi_destroy)(struct nfi_server *serv); - int (*nfi_getattr) (struct nfi_server *serv, struct nfi_fhandle *fh, struct nfi_attr *attr); - int (*nfi_setattr) (struct nfi_server *serv, struct nfi_fhandle *fh, struct nfi_attr *attr); - int (*nfi_open) (struct nfi_server *serv, char *url, int flags, mode_t mode, struct nfi_fhandle *fho); - int (*nfi_create) (struct nfi_server *serv, char *url, mode_t mode, struct nfi_attr *attr, struct nfi_fhandle *fh); - int (*nfi_close) (struct nfi_server *serv, struct nfi_fhandle *fh); - int (*nfi_remove) (struct nfi_server *serv, char *url); - int (*nfi_rename) (struct nfi_server *serv, char *old_url, char *new_url); - ssize_t (*nfi_read) (struct nfi_server *serv, struct nfi_fhandle *fh, void *buffer, off_t offset, size_t size); - ssize_t (*nfi_write) (struct nfi_server *serv, struct nfi_fhandle *fh, void *buffer, off_t offset, size_t size); - int (*nfi_mkdir) (struct nfi_server *serv, char *url, mode_t mode, struct nfi_attr *attr, struct nfi_fhandle *fh); - int (*nfi_rmdir) (struct nfi_server *serv, char *url); - int (*nfi_opendir) (struct nfi_server *serv, char *url, struct nfi_fhandle *fho); - int (*nfi_readdir) (struct nfi_server *serv, struct nfi_fhandle *fhd, struct dirent *entry); - int (*nfi_closedir) (struct nfi_server *serv, struct nfi_fhandle *fh); - int (*nfi_statfs) (struct nfi_server *serv, struct nfi_info *inf); - int (*nfi_read_mdata) (struct nfi_server *serv, char *url, struct xpn_metadata *mdata); - int (*nfi_write_mdata) (struct nfi_server *serv, char *url, struct xpn_metadata *mdata, int only_file_size); - }; - - - /* ... Functions / Funciones ......................................... */ - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/xpn_client/nfi/nfi_lib.h b/include/xpn_client/nfi/nfi_lib.h deleted file mode 100644 index 7aa2c6f85..000000000 --- a/include/xpn_client/nfi/nfi_lib.h +++ /dev/null @@ -1,53 +0,0 @@ - -/* - * Copyright 2000-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Luis Miguel Sanchez Garcia, Borja Bergua Guerra, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _NFI_LIB_H_ -#define _NFI_LIB_H_ - - /* ... Include / Inclusion ........................................... */ - - #include "nfi.h" - #include "nfi_worker.h" - #include "base/path_misc.h" - - /* protocols */ - #include "nfi_local.h" - #include "nfi_xpn_server.h" - - // BEGIN OF ENABLE_MODULE BLOCK. Do not remove this line. // - // BEGIN OF ENABLE_NFS BLOCK. Do not remove this line. // - #ifdef ENABLE_NFS - #include "nfi_nfs.h" - #endif - // END OF ENABLE_NFS BLOCK. Do not remove this line. // - // BEGIN OF ENABLE_NFS3 BLOCK. Do not remove this line. // - #ifdef ENABLE_NFS3 - #include "nfi_nfs3.h" - #endif - // END OF ENABLE_NFS3 BLOCK. Do not remove this line. // - // END OF ENABLE_MODULE BLOCK. Do not remove this line. // - - - /* ................................................................... */ - -#endif - diff --git a/include/xpn_client/nfi/nfi_local/nfi_local.h b/include/xpn_client/nfi/nfi_local/nfi_local.h deleted file mode 100644 index 319488897..000000000 --- a/include/xpn_client/nfi/nfi_local/nfi_local.h +++ /dev/null @@ -1,101 +0,0 @@ - -/* - * Copyright 2000-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Luis Miguel Sanchez Garcia, Borja Bergua Guerra, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _NFI_LOCAL_H -#define _NFI_LOCAL_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/filesystem.h" - #include "base/path_misc.h" - #include "base/urlstr.h" - #include "nfi/nfi.h" - #include "nfi_worker.h" - - - /* ... Const / Const ................................................. */ - - #define ASYNC_CLOSE 1 - #define FILESYSTEM_DLSYM 1 - - - /* ... Data structures / Estructuras de datos ........................ */ - - struct nfi_local_server - { - char path[PATH_MAX]; - void * private_info_server; - }; - - struct nfi_local_fhandle - { - char path[PATH_MAX]; - long telldir; - int fd; - DIR *dir; - }; - - - /* ... Functions / Funciones ......................................... */ - - int nfi_local_init ( char *url, struct nfi_server *serv, struct nfi_attr_server *attr ); - int nfi_local_destroy ( struct nfi_server *server ); - - int nfi_local_connect ( struct nfi_server *serv, char *url, char* prt, char* server, char* dir ); - int nfi_local_reconnect ( struct nfi_server *server ); - int nfi_local_disconnect ( struct nfi_server *server ); - - int nfi_local_create ( struct nfi_server *server, char *url, mode_t mode, struct nfi_attr *attr, struct nfi_fhandle *fh ); - int nfi_local_open ( struct nfi_server *server, char *url, int flags, mode_t mode, struct nfi_fhandle *fho ); - ssize_t nfi_local_read ( struct nfi_server *server, struct nfi_fhandle *fh, void *buffer, off_t offset, size_t size ); - ssize_t nfi_local_write ( struct nfi_server *server, struct nfi_fhandle *fh, void *buffer, off_t offset, size_t size ); - int nfi_local_close ( struct nfi_server *server, struct nfi_fhandle *fh ); - int nfi_local_remove ( struct nfi_server *server, char *url ); - int nfi_local_rename ( struct nfi_server *server, char *old_url, char *new_url ); - - int nfi_local_getattr ( struct nfi_server *server, struct nfi_fhandle *fh, struct nfi_attr *attr ); - int nfi_local_setattr ( struct nfi_server *server, struct nfi_fhandle *fh, struct nfi_attr *attr ); - - int nfi_local_mkdir ( struct nfi_server *server, char *url, mode_t mode, struct nfi_attr *attr, struct nfi_fhandle *fh ); - int nfi_local_opendir ( struct nfi_server *server, char *url, struct nfi_fhandle *fho ); - int nfi_local_readdir ( struct nfi_server *server, struct nfi_fhandle *fhd, struct dirent *entry ); - int nfi_local_closedir ( struct nfi_server *server, struct nfi_fhandle *fh ); - int nfi_local_rmdir ( struct nfi_server *server, char *url ); - - int nfi_local_statfs ( struct nfi_server *server, struct nfi_info *inf ); - - int nfi_local_read_mdata ( struct nfi_server *server, char *url, struct xpn_metadata *mdata ); - int nfi_local_write_mdata ( struct nfi_server *server, char *url, struct xpn_metadata *mdata, int only_file_size ); - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/xpn_client/nfi/nfi_mpi_server/nfi_mpi_server_comm.h b/include/xpn_client/nfi/nfi_mpi_server/nfi_mpi_server_comm.h deleted file mode 100644 index b6053e63e..000000000 --- a/include/xpn_client/nfi/nfi_mpi_server/nfi_mpi_server_comm.h +++ /dev/null @@ -1,59 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _NFI_MPI_SERVER_COMM_H_ -#define _NFI_MPI_SERVER_COMM_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/utils.h" - #include "base/ns.h" - #include "base/socket.h" - #include "base/service_socket.h" - #include "xpn_server/xpn_server_ops.h" - - - /* ... Functions / Funciones ......................................... */ - - int nfi_mpi_server_comm_init ( int xpn_thread ); - int nfi_mpi_server_comm_destroy ( ); - - int nfi_mpi_server_comm_connect ( char *srv_name, char *port_name, MPI_Comm *out_comm); - int nfi_mpi_server_comm_disconnect ( MPI_Comm *fd ); - - ssize_t nfi_mpi_server_comm_write_operation ( MPI_Comm fd, int op ); - ssize_t nfi_mpi_server_comm_write_data ( MPI_Comm fd, char *data, ssize_t size ); - ssize_t nfi_mpi_server_comm_read_data ( MPI_Comm fd, char *data, ssize_t size ); - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_client/nfi/nfi_nfs/nfi_nfs.h b/include/xpn_client/nfi/nfi_nfs/nfi_nfs.h deleted file mode 100644 index 953950925..000000000 --- a/include/xpn_client/nfi/nfi_nfs/nfi_nfs.h +++ /dev/null @@ -1,94 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _NFI_NFS_H -#define _NFI_NFS_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/path_misc.h" - #include "nfi/nfi.h" - #include "nfi/nfi_nfs/nfs.h" - #include "nfi/nfi_nfs/nfi_nfs_err.h" - - - /* ... Data structures / Estructuras de datos ........................ */ - - struct nfi_nfs_server - { - CLIENT *cl; - fhandle fh; - }; - - struct nfi_nfs_fhandle - { - int eofdir; - nfscookie cookie; - fhandle fh; - }; - - - /* ... Functions / Funciones ......................................... */ - - void NFItoNFSattr (fattr *nfs_att,struct nfi_attr *nfi_att); - void NFStoNFIattr (struct nfi_attr *nfi_att, fattr *nfs_att); - void NFStoNFIInfo (struct nfi_info *nfi_inf, struct nfs_info *nfs_inf); - - int nfi_nfs_init (char *url, struct nfi_server *serv, struct nfi_attr_server *attr); - int nfi_nfs_destroy (struct nfi_server *server); - - int nfi_nfs_reconnect (struct nfi_server *server); - int nfi_nfs_disconnect (struct nfi_server *server); - - int nfi_nfs_getattr (struct nfi_server *server, struct nfi_fhandle *fh, struct nfi_attr *attr); - int nfi_nfs_setattr (struct nfi_server *server, struct nfi_fhandle *fh, struct nfi_attr *attr); - - int nfi_nfs_open (struct nfi_server *server, char *url, struct nfi_fhandle *fho); - int nfi_nfs_close (struct nfi_server *server, struct nfi_fhandle *fh); - ssize_t nfi_nfs_read (struct nfi_server *server, struct nfi_fhandle *fh, void *buffer, off_t offset, size_t size); - ssize_t nfi_nfs_write (struct nfi_server *server, struct nfi_fhandle *fh, void *buffer, off_t offset, size_t size); - - int nfi_nfs_create (struct nfi_server *server, char *url, struct nfi_attr *attr, struct nfi_fhandle *fh); - int nfi_nfs_remove (struct nfi_server *server, char *url); - int nfi_nfs_rename (struct nfi_server *server, char *old_url, char *new_url); - int nfi_nfs_mkdir (struct nfi_server *server, char *url, struct nfi_attr *attr, struct nfi_fhandle *fh); - int nfi_nfs_rmdir (struct nfi_server *server, char *url); - int nfi_nfs_opendir (struct nfi_server *server, char *url, struct nfi_fhandle *fho); - int nfi_nfs_readdir (struct nfi_server *server, struct nfi_fhandle *fhd, char *entry , unsigned char *type); - int nfi_nfs_closedir (struct nfi_server *server, struct nfi_fhandle *fh); - int nfi_nfs_statfs (struct nfi_server *server, struct nfi_info *inf); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_client/nfi/nfi_nfs/nfi_nfs_err.h b/include/xpn_client/nfi/nfi_nfs/nfi_nfs_err.h deleted file mode 100644 index 123ba9c5e..000000000 --- a/include/xpn_client/nfi/nfi_nfs/nfi_nfs_err.h +++ /dev/null @@ -1,72 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _NFI_NFS_ERR_H_ -#define _NFI_NFS_ERR_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "nfs.h" - - - /* ... Const / Const ................................................. */ - - enum nfi_nfs_err - { - NFSERR_PARAM = 0, - NFSERR_MEMORY = 1, - NFSERR_URL = 2, - NFSERR_MNTCONNECTION = 3, - NFSERR_MOUNT = 4, - NFSERR_NFSCONNECTION = 5, - NFSERR_GETATTR = 6, - NFSERR_LOOKUP = 7, - NFSERR_READ = 8, - NFSERR_WRITE = 9, - NFSERR_CREATE = 10, - NFSERR_REMOVE = 11, - NFSERR_MKDIR = 12, - NFSERR_READDIR = 13, - NFSERR_STATFS = 14, - }; - - - /* ... Data structures / Estructuras de datos ........................ */ - - - /* ... Functions / Funciones ......................................... */ - - void nfs_err(int err); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/xpn_client/nfi/nfi_nfs/nfs.h b/include/xpn_client/nfi/nfi_nfs/nfs.h deleted file mode 100644 index b5988552c..000000000 --- a/include/xpn_client/nfi/nfi_nfs/nfs.h +++ /dev/null @@ -1,680 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - -#ifndef _NFS_H_ -#define _NFS_H_ - - #include "all_system.h" - #include "base/path_misc.h" - - #define NFS_TCP 1 - #define NFS_UDP 0 - - /* tamaño del buffer de envio de datos */ - #define SENDSZ (unsigned int) (128*1024) - /* tamaño del buffer de recepción de datos */ - #define RECVSZ (unsigned int) (128*1024) - - #define MNTPATHLEN 1024 - #define MNTNAMLEN 255 - - #define NFSPATHLEN MNTPATHLEN - - /* tamaño de los manejadores en bytes */ - #define FHSIZE 32 - - /* numero de programa del servicio mount */ - #define MOUNT1_PROGRAM ((u_long)100005) - /* version de programa del servicio mount */ - #define MOUNT1_VERSION ((u_long)1) - - - /* numero de programa del servicio nfs */ - #define NFS2_PROGRAM ((u_long)100003) - /* version de programa del servicio nfs */ - #define NFS2_VERSION ((u_long)2) - - - /************************************************************************************************************/ - /************************************************************************************************************/ - - - #ifdef __cplusplus - extern "C" { - #endif - - - - typedef char fhandle[FHSIZE]; - - typedef char *nfs_dirpath; - - typedef char *nfs_name; - - struct fhd { - char fh[FHSIZE]; - }; - typedef struct fhd fhd; - - struct fhstatus { - u_long status; - union { - fhandle directory; - } fhstatus_u; - }; - typedef struct fhstatus fhstatus; - - typedef struct mountbody *mountlist; - - struct mountbody { - nfs_name ml_hostname; - nfs_dirpath ml_directory; - mountlist ml_next; - }; - typedef struct mountbody mountbody; - - typedef struct groupnode *groups; - - struct groupnode { - nfs_name gr_name; - groups gr_next; - }; - typedef struct groupnode groupnode; - - typedef struct exportnode *exports; - - struct exportnode { - nfs_dirpath ex_dir; - groups ex_groups; - exports ex_next; - }; - typedef struct exportnode exportnode; - #define MAXDATA 8192 - #define NFSMAXPATHLEN 1024 - #define NFSMAXNAMLEN 255 - #define COOKIESIZE 4 - - typedef char *filename; - - typedef char *path; - - typedef char nfscookie[COOKIESIZE]; - - typedef struct { - u_long nfsdata_len; - char *nfsdata_val; - } nfsdata; - - enum nfs_stat { - /* OK */ - NFS_OK = 0, - /* errores de nfs */ - NFSERR_PERM = 1, - NFSERR_NOENT = 2, - NFSERR_IO = 5, - NFSERR_NXIO = 6, - NFSERR_ACCES = 13, - NFSERR_EXIST = 17, - NFSERR_NODEV = 19, - NFSERR_NOTDIR = 20, - NFSERR_ISDIR = 21, - NFSERR_FBIG = 27, - NFSERR_NOSPC = 28, - NFSERR_ROFS = 30, - NFSERR_NAMETOOLONG = 63, - NFSERR_NOTEMPTY = 66, - NFSERR_DQUOT = 69, - NFSERR_STALE = 70, - NFSERR_WFLUSH = 99, - /* */ - NFSERR_NULL = -3, - NFSERR_CONNECT = -7, - NFSERR_EOFDIR = -47, - /* */ - /* - XPNERR_NULL = -3, - XPNERR_FILESERVER = -4, - XPNERR_CONNECT = -7, - XPNERR_FILEOPEN = -8, - XPNERR_FILEMODE = -9, - XPNERR_FORMAT = -10, - XPNERR_DISTSERVER = -11, - XPNERR_DIRMNT = -12, - XPNERR_SVRMOUNT = -14, - XPNERR_DIRMOUNT = -15, - XPNERR_FULLTABLEFILE = -18, - XPNERR_NOTENTRY = -24, - XPNERR_FULLTABLEINIT = -25, - XPNERR_FULLTABLEDIR = -26, - XPNERR_NODEFINED = -29, - XPNERR_NORESOLVHOST = -31, - XPNERR_OFFSET = -32, - XPNERR_ISDIR = -34, - XPNERR_ISFILE = -42, - XPNERR_DIRMOUNTPART = -37, - XPNERR_INTERNAL = -38, - XPNERR_DISTPART = -39, - XPNERR_FULLTABLEHEADER = -41, - XPNERR_EMPTYTABLE = -43, - XPNERR_INVALIDFILE = -45, - XPNERR_INVALIDCAB = -46, - XPNERR_EOFDIR = -47, - XPNERR_FILEXIST = -48, - XPNERR_NOUNLOCK = -49, - XPNERR_NOLOCK = -50, - XPNERR_PATHFORMAT = -51, - XPNERR_INVALARG = -52, - XPNERR_NOIMPLEMENTED = -53, - XPNERR_USED = -54, - */ - }; - typedef enum nfs_stat nfs_stat; - - enum ftype { - NFNON = 0, - NFREG = 1, - NFDIR = 2, - NFBLK = 3, - NFCHR = 4, - NFLNK = 5, - }; - typedef enum ftype ftype; - - struct timevalNfs { - u_long seconds; - u_long useconds; - }; - typedef struct timevalNfs timevalNfs; - - struct fattr { - ftype type; - u_long mode; - u_long nlink; - u_long uid; - u_long gid; - u_long size; - u_long blocksize; - u_long rdev; - u_long blocks; - u_long fsid; - u_long fileid; - timevalNfs atime; - timevalNfs mtime; - timevalNfs ctime; - }; - typedef struct fattr fattr; - - struct sattr { - u_long mode; - u_long uid; - u_long gid; - u_long size; - timevalNfs atime; - timevalNfs mtime; - }; - typedef struct sattr sattr; - - struct attrstat { - nfs_stat status; - union { - fattr attributes; - } attrstat_u; - }; - typedef struct attrstat attrstat; - - struct diropargs { - fhandle dir; - filename name; - }; - typedef struct diropargs diropargs; - - struct diropok { - fhandle file; - fattr attributes; - }; - typedef struct diropok diropok; - - struct diropres { - nfs_stat status; - union { - diropok fhand_attr; - } diropres_u; - }; - typedef struct diropres diropres; - - struct sattrargs { - fhandle file; - sattr attributes; - }; - typedef struct sattrargs sattrargs; - - struct readlinkres { - nfs_stat status; - union { - path data; - } readlinkres_u; - }; - typedef struct readlinkres readlinkres; - - struct readargs { - fhandle file; - u_long offset; - u_long count; - u_long totalcount; - }; - typedef struct readargs readargs; - - struct datosRes { - fattr attributes; - nfsdata data; - }; - typedef struct datosRes datosRes; - - struct readres { - nfs_stat status; - union { - datosRes fich_read; - } readres_u; - }; - typedef struct readres readres; - - struct writeargs { - fhandle file; - u_long beginoffset; - u_long offset; - u_long totalcount; - nfsdata data; - }; - typedef struct writeargs writeargs; - - struct createargs { - diropargs where; - sattr attributes; - }; - typedef struct createargs createargs; - - struct renameargs { - diropargs from; - diropargs to; - }; - typedef struct renameargs renameargs; - - struct linkargs { - fhandle from; - diropargs to; - }; - typedef struct linkargs linkargs; - - struct symlinkargs { - diropargs from; - path to; - sattr attributes; - }; - typedef struct symlinkargs symlinkargs; - - struct readdirargs { - fhandle dir; - nfscookie cookie; - u_long count; - }; - typedef struct readdirargs readdirargs; - - struct entry { - u_long fileid; - filename name; - nfscookie cookie; - struct entry *nextentry; - }; - typedef struct entry entry; - - struct readdirok { - entry *entries; - bool_t eof; - }; - typedef struct readdirok readdirok; - - struct readdirres { - nfs_stat status; - union { - readdirok entradasDir; - } readdirres_u; - }; - typedef struct readdirres readdirres; - - struct nfs_info { - u_long tsize; - u_long bsize; - u_long blocks; - u_long bfree; - u_long bavail; - }; - typedef struct nfs_info nfs_info; - - struct statfsres { - nfs_stat status; - union { - struct nfs_info inf; - } statfsres_u; - }; - typedef struct statfsres statfsres; - - - - - - #if defined(__STDC__) || defined(__cplusplus) - #define MOUNTPROC_NULL 0 - extern enum clnt_stat mountproc_null_1(void *, void *, CLIENT *); - extern bool_t mountproc_null_1_svc(void *, void *, struct svc_req *); - #define MOUNTPROC_MNT 1 - extern enum clnt_stat mountproc_mnt_1(nfs_dirpath *, fhstatus *, CLIENT *); - extern bool_t mountproc_mnt_1_svc(nfs_dirpath *, fhstatus *, struct svc_req *); - #define MOUNTPROC_DUMP 2 - extern enum clnt_stat mountproc_dump_1(void *, mountlist *, CLIENT *); - extern bool_t mountproc_dump_1_svc(void *, mountlist *, struct svc_req *); - #define MOUNTPROC_UMNT 3 - extern enum clnt_stat mountproc_umnt_1(nfs_dirpath *, void *, CLIENT *); - extern bool_t mountproc_umnt_1_svc(nfs_dirpath *, void *, struct svc_req *); - #define MOUNTPROC_UMNTALL 4 - extern enum clnt_stat mountproc_umntall_1(void *, void *, CLIENT *); - extern bool_t mountproc_umntall_1_svc(void *, void *, struct svc_req *); - #define MOUNTPROC_EXPORT 5 - extern enum clnt_stat mountproc_export_1(void *, exports *, CLIENT *); - extern bool_t mountproc_export_1_svc(void *, exports *, struct svc_req *); - extern int mountprog_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t); - - #else /* K&R C */ - #define MOUNTPROC_NULL 0 - extern enum clnt_stat mountproc_null_1(); - extern bool_t mountproc_null_1_svc(); - #define MOUNTPROC_MNT 1 - extern enum clnt_stat mountproc_mnt_1(); - extern bool_t mountproc_mnt_1_svc(); - #define MOUNTPROC_DUMP 2 - extern enum clnt_stat mountproc_dump_1(); - extern bool_t mountproc_dump_1_svc(); - #define MOUNTPROC_UMNT 3 - extern enum clnt_stat mountproc_umnt_1(); - extern bool_t mountproc_umnt_1_svc(); - #define MOUNTPROC_UMNTALL 4 - extern enum clnt_stat mountproc_umntall_1(); - extern bool_t mountproc_umntall_1_svc(); - #define MOUNTPROC_EXPORT 5 - extern enum clnt_stat mountproc_export_1(); - extern bool_t mountproc_export_1_svc(); - extern int mountprog_1_freeresult (); - #endif /* K&R C */ - - - - - #if defined(__STDC__) || defined(__cplusplus) - #define NFSPROC_NULL 0 - extern enum clnt_stat nfsproc_null_2(void *, void *, CLIENT *); - extern bool_t nfsproc_null_2_svc(void *, void *, struct svc_req *); - #define NFSPROC_GETATTR 1 - extern enum clnt_stat nfsproc_getattr_2(char *, attrstat *, CLIENT *); - extern bool_t nfsproc_getattr_2_svc(char *, attrstat *, struct svc_req *); - #define NFSPROC_SETATTR 2 - extern enum clnt_stat nfsproc_setattr_2(sattrargs *, attrstat *, CLIENT *); - extern bool_t nfsproc_setattr_2_svc(sattrargs *, attrstat *, struct svc_req *); - #define NFSPROC_ROOT 3 - extern enum clnt_stat nfsproc_root_2(void *, void *, CLIENT *); - extern bool_t nfsproc_root_2_svc(void *, void *, struct svc_req *); - #define NFSPROC_LOOKUP 4 - extern enum clnt_stat nfsproc_lookup_2(diropargs *, diropres *, CLIENT *); - extern bool_t nfsproc_lookup_2_svc(diropargs *, diropres *, struct svc_req *); - #define NFSPROC_READLINK 5 - extern enum clnt_stat nfsproc_readlink_2(char *, readlinkres *, CLIENT *); - extern bool_t nfsproc_readlink_2_svc(char *, readlinkres *, struct svc_req *); - #define NFSPROC_READ 6 - extern enum clnt_stat nfsproc_read_2(readargs *, readres *, CLIENT *); - extern bool_t nfsproc_read_2_svc(readargs *, readres *, struct svc_req *); - #define NFSPROC_WRITECACHE 7 - extern enum clnt_stat nfsproc_writecache_2(void *, void *, CLIENT *); - extern bool_t nfsproc_writecache_2_svc(void *, void *, struct svc_req *); - #define NFSPROC_WRITE 8 - extern enum clnt_stat nfsproc_write_2(writeargs *, attrstat *, CLIENT *); - extern bool_t nfsproc_write_2_svc(writeargs *, attrstat *, struct svc_req *); - #define NFSPROC_CREATE 9 - extern enum clnt_stat nfsproc_create_2(createargs *, diropres *, CLIENT *); - extern bool_t nfsproc_create_2_svc(createargs *, diropres *, struct svc_req *); - #define NFSPROC_REMOVE 10 - extern enum clnt_stat nfsproc_remove_2(diropargs *, nfs_stat *, CLIENT *); - extern bool_t nfsproc_remove_2_svc(diropargs *, nfs_stat *, struct svc_req *); - #define NFSPROC_RENAME 11 - extern enum clnt_stat nfsproc_rename_2(renameargs *, nfs_stat *, CLIENT *); - extern bool_t nfsproc_rename_2_svc(renameargs *, nfs_stat *, struct svc_req *); - #define NFSPROC_LINK 12 - extern enum clnt_stat nfsproc_link_2(linkargs *, nfs_stat *, CLIENT *); - extern bool_t nfsproc_link_2_svc(linkargs *, nfs_stat *, struct svc_req *); - #define NFSPROC_SYMLINK 13 - extern enum clnt_stat nfsproc_symlink_2(symlinkargs *, nfs_stat *, CLIENT *); - extern bool_t nfsproc_symlink_2_svc(symlinkargs *, nfs_stat *, struct svc_req *); - #define NFSPROC_MKDIR 14 - extern enum clnt_stat nfsproc_mkdir_2(createargs *, diropres *, CLIENT *); - extern bool_t nfsproc_mkdir_2_svc(createargs *, diropres *, struct svc_req *); - #define NFSPROC_RMDIR 15 - extern enum clnt_stat nfsproc_rmdir_2(diropargs *, nfs_stat *, CLIENT *); - extern bool_t nfsproc_rmdir_2_svc(diropargs *, nfs_stat *, struct svc_req *); - #define NFSPROC_READDIR 16 - extern enum clnt_stat nfsproc_readdir_2(readdirargs *, readdirres *, CLIENT *); - extern bool_t nfsproc_readdir_2_svc(readdirargs *, readdirres *, struct svc_req *); - extern int nfs_program_2_freeresult (SVCXPRT *, xdrproc_t, caddr_t); - #define NFSPROC_STATFS 17 - extern enum clnt_stat nfsproc_statfs_2(char *, statfsres *, CLIENT *); - extern bool_t nfsproc_statfs_2_svc(char *, statfsres *, struct svc_req *); - extern int nfs_program_2_freeresult (SVCXPRT *, xdrproc_t, caddr_t); - - - #else /* K&R C */ - #define NFSPROC_NULL 0 - extern enum clnt_stat nfsproc_null_2(); - extern bool_t nfsproc_null_2_svc(); - #define NFSPROC_GETATTR 1 - extern enum clnt_stat nfsproc_getattr_2(); - extern bool_t nfsproc_getattr_2_svc(); - #define NFSPROC_SETATTR 2 - extern enum clnt_stat nfsproc_setattr_2(); - extern bool_t nfsproc_setattr_2_svc(); - #define NFSPROC_ROOT 3 - extern enum clnt_stat nfsproc_root_2(); - extern bool_t nfsproc_root_2_svc(); - #define NFSPROC_LOOKUP 4 - extern enum clnt_stat nfsproc_lookup_2(); - extern bool_t nfsproc_lookup_2_svc(); - #define NFSPROC_READLINK 5 - extern enum clnt_stat nfsproc_readlink_2(); - extern bool_t nfsproc_readlink_2_svc(); - #define NFSPROC_READ 6 - extern enum clnt_stat nfsproc_read_2(); - extern bool_t nfsproc_read_2_svc(); - #define NFSPROC_WRITECACHE 7 - extern enum clnt_stat nfsproc_writecache_2(); - extern bool_t nfsproc_writecache_2_svc(); - #define NFSPROC_WRITE 8 - extern enum clnt_stat nfsproc_write_2(); - extern bool_t nfsproc_write_2_svc(); - #define NFSPROC_CREATE 9 - extern enum clnt_stat nfsproc_create_2(); - extern bool_t nfsproc_create_2_svc(); - #define NFSPROC_REMOVE 10 - extern enum clnt_stat nfsproc_remove_2(); - extern bool_t nfsproc_remove_2_svc(); - #define NFSPROC_RENAME 11 - extern enum clnt_stat nfsproc_rename_2(); - extern bool_t nfsproc_rename_2_svc(); - #define NFSPROC_LINK 12 - extern enum clnt_stat nfsproc_link_2(); - extern bool_t nfsproc_link_2_svc(); - #define NFSPROC_SYMLINK 13 - extern enum clnt_stat nfsproc_symlink_2(); - extern bool_t nfsproc_symlink_2_svc(); - #define NFSPROC_MKDIR 14 - extern enum clnt_stat nfsproc_mkdir_2(); - extern bool_t nfsproc_mkdir_2_svc(); - #define NFSPROC_RMDIR 15 - extern enum clnt_stat nfsproc_rmdir_2(); - extern bool_t nfsproc_rmdir_2_svc(); - #define NFSPROC_READDIR 16 - extern enum clnt_stat nfsproc_readdir_2(); - extern bool_t nfsproc_readdir_2_svc(); - extern int nfs_program_2_freeresult (); - #define NFSPROC_STATFS 17 - extern enum clnt_stat nfsproc_statfs_2(); - extern bool_t nfsproc_statfs_2_svc(); - extern int nfs_program_2_freeresult (); - #endif /* K&R C */ - - /* the xdr functions */ - - #if defined(__STDC__) || defined(__cplusplus) - extern bool_t xdr_fhandle (XDR *, fhandle); - extern bool_t xdr_dirpath (XDR *, nfs_dirpath*); - extern bool_t xdr_name (XDR *, nfs_name*); - extern bool_t xdr_fhd (XDR *, fhd*); - extern bool_t xdr_fhstatus (XDR *, fhstatus*); - extern bool_t xdr_mountlist (XDR *, mountlist*); - extern bool_t xdr_mountbody (XDR *, mountbody*); - extern bool_t xdr_groups (XDR *, groups*); - extern bool_t xdr_groupnode (XDR *, groupnode*); - extern bool_t xdr_exports (XDR *, exports*); - extern bool_t xdr_exportnode (XDR *, exportnode*); - extern bool_t xdr_filename (XDR *, filename*); - extern bool_t xdr_path (XDR *, path*); - extern bool_t xdr_nfscookie (XDR *, nfscookie); - extern bool_t xdr_nfsdata (XDR *, nfsdata*); - extern bool_t xdr_nfs_stat (XDR *, nfs_stat*); - extern bool_t xdr_ftype (XDR *, ftype*); - extern bool_t xdr_timevalNfs (XDR *, timevalNfs*); - extern bool_t xdr_fattr (XDR *, fattr*); - extern bool_t xdr_sattr (XDR *, sattr*); - extern bool_t xdr_attrstat (XDR *, attrstat*); - extern bool_t xdr_diropargs (XDR *, diropargs*); - extern bool_t xdr_diropok (XDR *, diropok*); - extern bool_t xdr_diropres (XDR *, diropres*); - extern bool_t xdr_sattrargs (XDR *, sattrargs*); - extern bool_t xdr_readlinkres (XDR *, readlinkres*); - extern bool_t xdr_readargs (XDR *, readargs*); - extern bool_t xdr_datosRes (XDR *, datosRes*); - extern bool_t xdr_readres (XDR *, readres*); - extern bool_t xdr_writeargs (XDR *, writeargs*); - extern bool_t xdr_createargs (XDR *, createargs*); - extern bool_t xdr_renameargs (XDR *, renameargs*); - extern bool_t xdr_linkargs (XDR *, linkargs*); - extern bool_t xdr_symlinkargs (XDR *, symlinkargs*); - extern bool_t xdr_readdirargs (XDR *, readdirargs*); - extern bool_t xdr_entry (XDR *, entry*); - extern bool_t xdr_readdirok (XDR *, readdirok*); - extern bool_t xdr_readdirres (XDR *, readdirres*); - extern bool_t xdr_nfs_info (XDR *, nfs_info*); - extern bool_t xdr_statfsres (XDR *, statfsres*); - - #else /* K&R C */ - extern bool_t xdr_fhandle (); - extern bool_t xdr_dirpath (); - extern bool_t xdr_name (); - extern bool_t xdr_fhd (); - extern bool_t xdr_fhstatus (); - extern bool_t xdr_mountlist (); - extern bool_t xdr_mountbody (); - extern bool_t xdr_groups (); - extern bool_t xdr_groupnode (); - extern bool_t xdr_exports (); - extern bool_t xdr_exportnode (); - extern bool_t xdr_filename (); - extern bool_t xdr_path (); - extern bool_t xdr_nfscookie (); - extern bool_t xdr_nfsdata (); - extern bool_t xdr_nfs_stat (); - extern bool_t xdr_ftype (); - extern bool_t xdr_timevalNfs (); - extern bool_t xdr_fattr (); - extern bool_t xdr_sattr (); - extern bool_t xdr_attrstat (); - extern bool_t xdr_diropargs (); - extern bool_t xdr_diropok (); - extern bool_t xdr_diropres (); - extern bool_t xdr_sattrargs (); - extern bool_t xdr_readlinkres (); - extern bool_t xdr_readargs (); - extern bool_t xdr_datosRes (); - extern bool_t xdr_readres (); - extern bool_t xdr_writeargs (); - extern bool_t xdr_createargs (); - extern bool_t xdr_renameargs (); - extern bool_t xdr_linkargs (); - extern bool_t xdr_symlinkargs (); - extern bool_t xdr_readdirargs (); - extern bool_t xdr_entry (); - extern bool_t xdr_readdirok (); - extern bool_t xdr_readdirres (); - - #endif /* K&R C */ - - #ifdef __cplusplus - } - #endif - - - CLIENT* create_connection_mount(char *name, int type); - - void close_connection_mount(CLIENT *cl); - - int nfs_mount(char *dir, fhandle fhand, CLIENT *cl ); - - int nfs_umount(char *path, CLIENT *cl); - - int nfs_export(exports* ,CLIENT *cl); - - - - - CLIENT* create_connection_nfs(char *name, int type); - - void close_connection_nfs(CLIENT *cl); - - int nfs_getattr(fhandle fh, fattr *fatt, CLIENT *cl); - - int nfs_setattr(fhandle fh, fattr *fatt, CLIENT *cl); - - int nfs_lookup(fhandle fhin, char *path , fhandle fhout, fattr *att, CLIENT *cl); - - ssize_t nfs_read(fhandle fh, void *data, off_t offset, size_t size, CLIENT *cl); - - ssize_t nfs_write(fhandle fh, void *data, off_t offset, size_t size, CLIENT *cl); - - int nfs_create(fhandle fhin, char *file, mode_t mode, fhandle fhout, fattr *at, CLIENT *cl); - - int nfs_remove(fhandle fh, char *file, CLIENT *cl); - - int nfs_rename(fhandle fh, char *name, fhandle fhR, char *nameR, CLIENT *cl); - - int nfs_mkdir(fhandle fhin, char *dir, mode_t mode, fhandle fhout, fattr *att, CLIENT *cl); - - int nfs_rmdir(fhandle fh, char *dir, CLIENT *cl); - - int nfs_readdir(fhandle fh, nfscookie cookie, char *entry, CLIENT *cl); - - int nfs_statfs(fhandle arg, struct nfs_info *inf, CLIENT *cl); - - -#endif /* _NFS_H */ diff --git a/include/xpn_client/nfi/nfi_nfs3/nfi_nfs3.h b/include/xpn_client/nfi/nfi_nfs3/nfi_nfs3.h deleted file mode 100644 index 89eff77d2..000000000 --- a/include/xpn_client/nfi/nfi_nfs3/nfi_nfs3.h +++ /dev/null @@ -1,83 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _NFI_NFS3_H -#define _NFI_NFS3_H - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/path_misc.h" - #include "nfi/nfi.h" - #include "nfi/nfi_nfs3/nfs3.h" - #include "nfi/nfi_nfs3/nfi_nfs3_err.h" - - - /* ... Data structures / Estructuras de datos ........................ */ - - struct nfi_nfs3_server - { - CLIENT *cl; - fhandle3 fh; - }; - - struct nfi_nfs3_fhandle - { - int eofdir; - cookieverf3 cookie; - fhandle3 fh; - }; - - - /* ... Functions / Funciones ......................................... */ - - void NFItoNFS3attr (fattr3 *nfs_att,struct nfi_attr *nfi_att); - void NFS3toNFIattr (struct nfi_attr *nfi_att, fattr3 *nfs_att); - void NFS3toNFIInfo (struct nfi_info *nfi_inf, fsinfo3resok *nfs_inf); - - int nfi_nfs3_init (char *url, struct nfi_server *serv, struct nfi_attr_server *attr); - int nfi_nfs3_destroy (struct nfi_server *server); - - int nfi_nfs3_reconnect (struct nfi_server *server); - int nfi_nfs3_disconnect (struct nfi_server *server); - - int nfi_nfs3_getattr (struct nfi_server *server, struct nfi_fhandle *fh, struct nfi_attr *attr); - int nfi_nfs3_setattr (struct nfi_server *server, struct nfi_fhandle *fh, struct nfi_attr *attr); - int nfi_nfs3_open (struct nfi_server *server, char *url, struct nfi_fhandle *fho); - int nfi_nfs3_close (struct nfi_server *server, struct nfi_fhandle *fh); - ssize_t nfi_nfs3_read (struct nfi_server *server, struct nfi_fhandle *fh, void *buffer, off_t offset, size_t size); - ssize_t nfi_nfs3_write (struct nfi_server *server, struct nfi_fhandle *fh, void *buffer, off_t offset, size_t size); - int nfi_nfs3_create (struct nfi_server *server, char *url, struct nfi_attr *attr, struct nfi_fhandle *fh); - int nfi_nfs3_remove (struct nfi_server *server, char *url); - int nfi_nfs3_rename (struct nfi_server *server, char *old_url, char *new_url); - int nfi_nfs3_mkdir (struct nfi_server *server, char *url, struct nfi_attr *attr, struct nfi_fhandle *fh); - int nfi_nfs3_rmdir (struct nfi_server *server, char *url); - int nfi_nfs3_opendir (struct nfi_server *server, char *url, struct nfi_fhandle *fho); - int nfi_nfs3_readdir (struct nfi_server *server, struct nfi_fhandle *fhd, char *entry , unsigned char *type); - int nfi_nfs3_closedir (struct nfi_server *server, struct nfi_fhandle *fh); - int nfi_nfs3_statfs (struct nfi_server *server, struct nfi_info *inf); - - - /* ................................................................... */ - -#endif - diff --git a/include/xpn_client/nfi/nfi_nfs3/nfi_nfs3_err.h b/include/xpn_client/nfi/nfi_nfs3/nfi_nfs3_err.h deleted file mode 100644 index 5efd45c36..000000000 --- a/include/xpn_client/nfi/nfi_nfs3/nfi_nfs3_err.h +++ /dev/null @@ -1,62 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _NFI_NFS3_ERR_H_ -#define _NFI_NFS3_ERR_H_ - - /* ... Include / Inclusion ........................................... */ - - #include "nfs3.h" - - - /* ... Const / Const ................................................. */ - - enum nfi_nfs3_err - { - NFS3ERR_PARAM = 0, - NFS3ERR_MEMORY = 1, - NFS3ERR_URL = 2, - NFS3ERR_MNTCONNECTION = 3, - NFS3ERR_MOUNT = 4, - NFS3ERR_NFSCONNECTION = 5, - NFS3ERR_GETATTR = 6, - NFS3ERR_SETATTR = 7, - NFS3ERR_LOOKUP = 8, - NFS3ERR_READ = 9, - NFS3ERR_WRITE = 10, - NFS3ERR_CREATE = 11, - NFS3ERR_REMOVE = 12, - NFS3ERR_MKDIR = 13, - NFS3ERR_READDIR = 14, - NFS3ERR_STATFS = 15, - }; - - - /* ... Data structures / Estructuras de datos ........................ */ - - - /* ... Functions / Funciones ......................................... */ - - - /* ................................................................... */ - -#endif diff --git a/include/xpn_client/nfi/nfi_nfs3/nfs3.h b/include/xpn_client/nfi/nfi_nfs3/nfs3.h deleted file mode 100644 index 133c5975e..000000000 --- a/include/xpn_client/nfi/nfi_nfs3/nfs3.h +++ /dev/null @@ -1,1196 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - -/* - * Please do not edit this file. - * It was generated using rpcgen. - */ - -#ifndef _NFS3_PROT_H_RPCGEN -#define _NFS3_PROT_H_RPCGEN - -#include "all_system.h" -#include "base/path_misc.h" - -#define NFS3_TCP 1 -#define NFS3_UDP 0 - -/* tamaño del buffer de envio de datos */ -#define NFS3_SENDSZ (unsigned int) (128*1024) -/* tamaño del buffer de recepción de datos */ -#define NFS3_RECVSZ (unsigned int) (128*1024) - -#ifdef __cplusplus -extern "C" { -#endif - - -#define NFS3ERR_EOFDIR -10011 - -#define MAXDATA3 (1024*32) -#define MNTPATHLEN 1024 -#define MNTNAMLEN 255 -#define FHSIZE3 64 - -typedef struct { - u_int fhandle3_len; - char *fhandle3_val; -} fhandle3; - -typedef char *nfs3_dirpath; - -typedef char *nfs3_name; - -enum mountstat3 { - MNT3_OK = 0, - MNT3ERR_PERM = 1, - MNT3ERR_NOENT = 2, - MNT3ERR_IO = 5, - MNT3ERR_ACCES = 13, - MNT3ERR_NOTDIR = 20, - MNT3ERR_INVAL = 22, - MNT3ERR_NAMETOOLONG = 63, - MNT3ERR_NOTSUPP = 10004, - MNT3ERR_SERVERFAULT = 10006, -}; -typedef enum mountstat3 mountstat3; - -struct mountres3_ok { - fhandle3 fhandle; - struct { - u_int auth_flavors_len; - int *auth_flavors_val; - } auth_flavors; -}; -typedef struct mountres3_ok mountres3_ok; - -struct mountres3 { - mountstat3 fhs_status; - union { - mountres3_ok mountinfo; - } mountres3_u; -}; -typedef struct mountres3 mountres3; - -typedef struct mountbody3 *mountlist3; - -struct mountbody3 { - nfs3_name ml_hostname; - nfs3_dirpath ml_directory; - mountlist3 ml_next; -}; -typedef struct mountbody3 mountbody3; - -typedef struct groupnode3 *groups3; - -struct groupnode3 { - nfs3_name gr_name; - groups3 gr_next; -}; -typedef struct groupnode3 groupnode3; - -typedef struct exportnode3 *exports3; - -struct exportnode3 { - nfs3_dirpath ex_dir; - groups3 ex_groups3; - exports3 ex_next; -}; -typedef struct exportnode3 exportnode3; - -#define MOUNT3_PROGRAM 100005 -#define MOUNT3_VERSION 3 - -#if defined(__STDC__) || defined(__cplusplus) -#define MOUNTPROC3_NULL 0 -extern enum clnt_stat mountproc3_null_3(void *, void *, CLIENT *); -extern bool_t mountproc3_null_3_svc(void *, void *, struct svc_req *); -#define MOUNTPROC3_MNT 1 -extern enum clnt_stat mountproc3_mnt_3(nfs3_dirpath *, mountres3 *, CLIENT *); -extern bool_t mountproc3_mnt_3_svc(nfs3_dirpath *, mountres3 *, struct svc_req *); -#define MOUNTPROC3_DUMP 2 -extern enum clnt_stat mountproc3_dump_3(void *, mountlist3 *, CLIENT *); -extern bool_t mountproc3_dump_3_svc(void *, mountlist3 *, struct svc_req *); -#define MOUNTPROC3_UMNT 3 -extern enum clnt_stat mountproc3_umnt_3(nfs3_dirpath *, void *, CLIENT *); -extern bool_t mountproc3_umnt_3_svc(nfs3_dirpath *, void *, struct svc_req *); -#define MOUNTPROC3_UMNTALL 4 -extern enum clnt_stat mountproc3_umntall_3(void *, void *, CLIENT *); -extern bool_t mountproc3_umntall_3_svc(void *, void *, struct svc_req *); -#define MOUNTPROC3_EXPORT 5 -extern enum clnt_stat mountproc3_export_3(void *, exports3 *, CLIENT *); -extern bool_t mountproc3_export_3_svc(void *, exports3 *, struct svc_req *); -extern int mount_program_3_freeresult (SVCXPRT *, xdrproc_t, caddr_t); - -#else /* K&R C */ -#define MOUNTPROC3_NULL 0 -extern enum clnt_stat mountproc3_null_3(); -extern bool_t mountproc3_null_3_svc(); -#define MOUNTPROC3_MNT 1 -extern enum clnt_stat mountproc3_mnt_3(); -extern bool_t mountproc3_mnt_3_svc(); -#define MOUNTPROC3_DUMP 2 -extern enum clnt_stat mountproc3_dump_3(); -extern bool_t mountproc3_dump_3_svc(); -#define MOUNTPROC3_UMNT 3 -extern enum clnt_stat mountproc3_umnt_3(); -extern bool_t mountproc3_umnt_3_svc(); -#define MOUNTPROC3_UMNTALL 4 -extern enum clnt_stat mountproc3_umntall_3(); -extern bool_t mountproc3_umntall_3_svc(); -#define MOUNTPROC3_EXPORT 5 -extern enum clnt_stat mountproc3_export_3(); -extern bool_t mountproc3_export_3_svc(); -extern int mount_program_3_freeresult (); -#endif /* K&R C */ - -/* the xdr functions */ - -#if defined(__STDC__) || defined(__cplusplus) -extern bool_t xdr_fhandle3 (XDR *, fhandle3*); -extern bool_t xdr_dirpath (XDR *, nfs3_dirpath*); -extern bool_t xdr_name (XDR *, nfs3_name*); -extern bool_t xdr_mountstat3 (XDR *, mountstat3*); -extern bool_t xdr_mountres3_ok (XDR *, mountres3_ok*); -extern bool_t xdr_mountres3 (XDR *, mountres3*); -extern bool_t xdr_mountlist3 (XDR *, mountlist3*); -extern bool_t xdr_mountbody3 (XDR *, mountbody3*); -extern bool_t xdr_groups3 (XDR *, groups3*); -extern bool_t xdr_groupnode3 (XDR *, groupnode3*); -extern bool_t xdr_exports3 (XDR *, exports3*); -extern bool_t xdr_exportnode3 (XDR *, exportnode3*); - -#else /* K&R C */ -extern bool_t xdr_fhandle3 (); -extern bool_t xdr_dirpath (); -extern bool_t xdr_name (); -extern bool_t xdr_mountstat3 (); -extern bool_t xdr_mountres3_ok (); -extern bool_t xdr_mountres3 (); -extern bool_t xdr_mountlist3 (); -extern bool_t xdr_mountbody3 (); -extern bool_t xdr_groups3 (); -extern bool_t xdr_groupnode3 (); -extern bool_t xdr_exports3 (); -extern bool_t xdr_exportnode3 (); - -#endif /* K&R C */ - -#ifdef __cplusplus -} -#endif - -/*****************************************************/ - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef uint64_t uint64; - -typedef int64_t int64; - -typedef u_int uint32; - -typedef int int32; -#define NFS3_FHSIZE FHSIZE3 -#define NFS3_COOKIEVERFSIZE 8 -#define NFS3_CREATEVERFSIZE 8 -#define NFS3_WRITEVERFSIZE 8 - -typedef char *filename3; - -typedef char *nfspath3; - -typedef char cookieverf3[NFS3_COOKIEVERFSIZE]; - -typedef char createverf3[NFS3_CREATEVERFSIZE]; - -typedef char writeverf3[NFS3_WRITEVERFSIZE]; - -enum nfsstat3 { - NFS3_OK = 0, - NFS3ERR_PERM = 1, - NFS3ERR_NOENT = 2, - NFS3ERR_IO = 5, - NFS3ERR_NXIO = 6, - NFS3ERR_ACCES = 13, - NFS3ERR_EXIST = 17, - NFS3ERR_XDEV = 18, - NFS3ERR_NODEV = 19, - NFS3ERR_NOTDIR = 20, - NFS3ERR_ISDIR = 21, - NFS3ERR_INVAL = 22, - NFS3ERR_FBIG = 27, - NFS3ERR_NOSPC = 28, - NFS3ERR_ROFS = 30, - NFS3ERR_MLINK = 31, - NFS3ERR_NAMETOOLONG = 63, - NFS3ERR_NOTEMPTY = 66, - NFS3ERR_DQUOT = 69, - NFS3ERR_STALE = 70, - NFS3ERR_REMOTE = 71, - NFS3ERR_BADHANDLE = 10001, - NFS3ERR_NOT_SYNC = 10002, - NFS3ERR_BAD_COOKIE = 10003, - NFS3ERR_NOTSUPP = 10004, - NFS3ERR_TOOSMALL = 10005, - NFS3ERR_SERVERFAULT = 10006, - NFS3ERR_BADTYPE = 10007, - NFS3ERR_JUKEBOX = 10008, - NFS3ERR_FPRINTNOTFOUND = 10009, - NFS3ERR_ABORTED = 10010, -}; -typedef enum nfsstat3 nfsstat3; - -enum ftype3 { - NF3REG = 1, - NF3DIR = 2, - NF3BLK = 3, - NF3CHR = 4, - NF3LNK = 5, - NF3SOCK = 6, - NF3FIFO = 7, -}; -typedef enum ftype3 ftype3; - -struct specdata3 { - uint32 major; - uint32 minor; -}; -typedef struct specdata3 specdata3; -/* -struct nfs_fh3 { - struct { - u_int data_len; - char *data_val; - } data; -}; -typedef struct nfs_fh3 nfs_fh3; -*/ - - -struct nfstime3 { - uint32 seconds; - uint32 nseconds; -}; -typedef struct nfstime3 nfstime3; - -struct fattr3 { - ftype3 type; - uint32 mode; - uint32 nlink; - uint32 uid; - uint32 gid; - uint64 size; - uint64 used; - specdata3 rdev; - uint64 fsid; - uint64 fileid; - nfstime3 atime; - nfstime3 mtime; - nfstime3 ctime; -}; -typedef struct fattr3 fattr3; - -struct post_op_attr { - bool_t present; - union { - fattr3 attributes; - } post_op_attr_u; -}; -typedef struct post_op_attr post_op_attr; - -struct wcc_attr { - uint64 size; - nfstime3 mtime; - nfstime3 ctime; -}; -typedef struct wcc_attr wcc_attr; - -struct pre_op_attr { - bool_t present; - union { - wcc_attr attributes; - } pre_op_attr_u; -}; -typedef struct pre_op_attr pre_op_attr; - -struct wcc_data { - pre_op_attr before; - post_op_attr after; -}; -typedef struct wcc_data wcc_data; - -struct post_op_fh3 { - bool_t present; - union { - fhandle3 handle; - } post_op_fh3_u; -}; -typedef struct post_op_fh3 post_op_fh3; - -struct set_uint32 { - bool_t set; - union { - uint32 val; - } set_uint32_u; -}; -typedef struct set_uint32 set_uint32; - -struct set_uint64 { - bool_t set; - union { - uint64 val; - } set_uint64_u; -}; -typedef struct set_uint64 set_uint64; - -enum time_how { - DONT_CHANGE = 0, - SET_TO_SERVER_TIME = 1, - SET_TO_CLIENT_TIME = 2, -}; -typedef enum time_how time_how; - -struct set_time { - time_how set; - union { - nfstime3 time; - } set_time_u; -}; -typedef struct set_time set_time; - -struct sattr3 { - set_uint32 mode; - set_uint32 uid; - set_uint32 gid; - set_uint64 size; - set_time atime; - set_time mtime; -}; -typedef struct sattr3 sattr3; - -struct diropargs3 { - fhandle3 dir; - filename3 name; -}; -typedef struct diropargs3 diropargs3; - -struct diropres3ok { - post_op_fh3 obj; - post_op_attr obj_attributes; - wcc_data dir_wcc; -}; -typedef struct diropres3ok diropres3ok; - -struct diropres3 { - nfsstat3 status; - union { - diropres3ok resok; - wcc_data resfail; - } diropres3_u; -}; -typedef struct diropres3 diropres3; - -struct wccstat3 { - nfsstat3 status; - union { - wcc_data wcc; - } wccstat3_u; -}; -typedef struct wccstat3 wccstat3; - -struct getattr3res { - nfsstat3 status; - union { - fattr3 attributes; - } getattr3res_u; -}; -typedef struct getattr3res getattr3res; - -struct sattrguard3 { - bool_t check; - union { - nfstime3 ctime; - } sattrguard3_u; -}; -typedef struct sattrguard3 sattrguard3; - -struct setattr3args { - fhandle3 object; - sattr3 new_attributes; - sattrguard3 guard; -}; -typedef struct setattr3args setattr3args; - -struct lookup3resok { - fhandle3 object; - post_op_attr obj_attributes; - post_op_attr dir_attributes; -}; -typedef struct lookup3resok lookup3resok; - -struct lookup3res { - nfsstat3 status; - union { - lookup3resok resok; - post_op_attr resfail; - } lookup3res_u; -}; -typedef struct lookup3res lookup3res; -#define ACCESS3_READ 0x0001 -#define ACCESS3_LOOKUP 0x0002 -#define ACCESS3_MODIFY 0x0004 -#define ACCESS3_EXTEND 0x0008 -#define ACCESS3_DELETE 0x0010 -#define ACCESS3_EXECUTE 0x0020 - -struct access3args { - fhandle3 object; - uint32 access; -}; -typedef struct access3args access3args; - -struct access3resok { - post_op_attr obj_attributes; - uint32 access; -}; -typedef struct access3resok access3resok; - -struct access3res { - nfsstat3 status; - union { - access3resok resok; - post_op_attr resfail; - } access3res_u; -}; -typedef struct access3res access3res; - -struct readlink3resok { - post_op_attr symlink_attributes; - nfspath3 data; -}; -typedef struct readlink3resok readlink3resok; - -struct readlink3res { - nfsstat3 status; - union { - readlink3resok resok; - post_op_attr resfail; - } readlink3res_u; -}; -typedef struct readlink3res readlink3res; - -struct read3args { - fhandle3 file; - uint64 offset; - uint32 count; -}; -typedef struct read3args read3args; - -struct read3resok { - post_op_attr file_attributes; - uint32 count; - bool_t eof; - struct { - u_int data_len; - char *data_val; - } data; -}; -typedef struct read3resok read3resok; - -struct read3res { - nfsstat3 status; - union { - read3resok resok; - post_op_attr resfail; - } read3res_u; -}; -typedef struct read3res read3res; - -enum stable_how { - UNSTABLE = 0, - DATA_SYNC = 1, - FILE_SYNC = 2, -}; -typedef enum stable_how stable_how; - -struct write3args { - fhandle3 file; - uint64 offset; - uint32 count; - stable_how stable; - struct { - u_int data_len; - char *data_val; - } data; -}; -typedef struct write3args write3args; - -struct write3resok { - wcc_data file_wcc; - uint32 count; - stable_how committed; - writeverf3 verf; -}; -typedef struct write3resok write3resok; - -struct write3res { - nfsstat3 status; - union { - write3resok resok; - wcc_data resfail; - } write3res_u; -}; -typedef struct write3res write3res; - -enum createmode3 { - UNCHECKED = 0, - GUARDED = 1, - EXCLUSIVE = 2, -}; -typedef enum createmode3 createmode3; - -struct createhow3 { - createmode3 mode; - union { - sattr3 obj_attributes; - createverf3 verf; - } createhow3_u; -}; -typedef struct createhow3 createhow3; - -struct create3args { - diropargs3 where; - createhow3 how; -}; -typedef struct create3args create3args; - -struct mkdir3args { - diropargs3 where; - sattr3 attributes; -}; -typedef struct mkdir3args mkdir3args; - -struct symlinkdata3 { - sattr3 symlink_attributes; - nfspath3 symlink_data; -}; -typedef struct symlinkdata3 symlinkdata3; - -struct symlink3args { - diropargs3 where; - symlinkdata3 symlink; -}; -typedef struct symlink3args symlink3args; - -struct devicedata3 { - sattr3 dev_attributes; - specdata3 spec; -}; -typedef struct devicedata3 devicedata3; - -struct mknoddata3 { - ftype3 type; - union { - devicedata3 device; - sattr3 pipe_attributes; - } mknoddata3_u; -}; -typedef struct mknoddata3 mknoddata3; - -struct mknod3args { - diropargs3 where; - mknoddata3 what; -}; -typedef struct mknod3args mknod3args; - -struct rename3args { - diropargs3 from; - diropargs3 to; -}; -typedef struct rename3args rename3args; - -struct rename3wcc { - wcc_data fromdir_wcc; - wcc_data todir_wcc; -}; -typedef struct rename3wcc rename3wcc; - -struct rename3res { - nfsstat3 status; - union { - rename3wcc res; - } rename3res_u; -}; -typedef struct rename3res rename3res; - -struct link3args { - fhandle3 file; - diropargs3 link; -}; -typedef struct link3args link3args; - -struct link3wcc { - post_op_attr file_attributes; - wcc_data linkdir_wcc; -}; -typedef struct link3wcc link3wcc; - -struct link3res { - nfsstat3 status; - union { - link3wcc res; - } link3res_u; -}; -typedef struct link3res link3res; - -struct readdir3args { - fhandle3 dir; - uint64 cookie; - cookieverf3 cookieverf; - uint32 count; -}; -typedef struct readdir3args readdir3args; - -struct entry3 { - uint64 fileid; - filename3 name; - uint64 cookie; - struct entry3 *nextentry; -}; -typedef struct entry3 entry3; - -struct dirlist3 { - entry3 *entries; - bool_t eof; -}; -typedef struct dirlist3 dirlist3; - -struct readdir3resok { - post_op_attr dir_attributes; - cookieverf3 cookieverf; - dirlist3 reply; -}; -typedef struct readdir3resok readdir3resok; - -struct readdir3res { - nfsstat3 status; - union { - readdir3resok resok; - post_op_attr resfail; - } readdir3res_u; -}; -typedef struct readdir3res readdir3res; - -struct readdirplus3args { - fhandle3 dir; - uint64 cookie; - cookieverf3 cookieverf; - uint32 dircount; - uint32 maxcount; -}; -typedef struct readdirplus3args readdirplus3args; - -struct entryplus3 { - uint64 fileid; - filename3 name; - uint64 cookie; - post_op_attr name_attributes; - post_op_fh3 name_handle; - struct entryplus3 *nextentry; -}; -typedef struct entryplus3 entryplus3; - -struct dirlistplus3 { - entryplus3 *entries; - bool_t eof; -}; -typedef struct dirlistplus3 dirlistplus3; - -struct readdirplus3resok { - post_op_attr dir_attributes; - cookieverf3 cookieverf; - dirlistplus3 reply; -}; -typedef struct readdirplus3resok readdirplus3resok; - -struct readdirplus3res { - nfsstat3 status; - union { - readdirplus3resok resok; - post_op_attr resfail; - } readdirplus3res_u; -}; -typedef struct readdirplus3res readdirplus3res; - -struct fsstat3resok { - post_op_attr obj_attributes; - uint64 tbytes; - uint64 fbytes; - uint64 abytes; - uint64 tfiles; - uint64 ffiles; - uint64 afiles; - uint32 invarsec; -}; -typedef struct fsstat3resok fsstat3resok; - -struct fsstat3res { - nfsstat3 status; - union { - fsstat3resok resok; - post_op_attr resfail; - } fsstat3res_u; -}; -typedef struct fsstat3res fsstat3res; -#define FSF3_LINK 0x0001 -#define FSF3_SYMLINK 0x0002 -#define FSF3_HOMOGENEOUS 0x0008 -#define FSF3_CANSETTIME 0x0010 - -struct fsinfo3resok { - post_op_attr obj_attributes; - uint32 rtmax; - uint32 rtpref; - uint32 rtmult; - uint32 wtmax; - uint32 wtpref; - uint32 wtmult; - uint32 dtpref; - uint64 maxfilesize; - nfstime3 time_delta; - uint32 properties; -}; -typedef struct fsinfo3resok fsinfo3resok; - -struct fsinfo3res { - nfsstat3 status; - union { - fsinfo3resok resok; - post_op_attr resfail; - } fsinfo3res_u; -}; -typedef struct fsinfo3res fsinfo3res; - -struct pathconf3resok { - post_op_attr obj_attributes; - uint32 linkmax; - uint32 name_max; - bool_t no_trunc; - bool_t chown_restricted; - bool_t case_insensitive; - bool_t case_preserving; -}; -typedef struct pathconf3resok pathconf3resok; - -struct pathconf3res { - nfsstat3 status; - union { - pathconf3resok resok; - post_op_attr resfail; - } pathconf3res_u; -}; -typedef struct pathconf3res pathconf3res; - -struct commit3args { - fhandle3 file; - uint64 offset; - uint32 count; -}; -typedef struct commit3args commit3args; - -struct commit3resok { - wcc_data file_wcc; - writeverf3 verf; -}; -typedef struct commit3resok commit3resok; - -struct commit3res { - nfsstat3 status; - union { - commit3resok resok; - wcc_data resfail; - } commit3res_u; -}; -typedef struct commit3res commit3res; - -#define NFS3_PROGRAM 100003 -#define NFS3_VERSION 3 - -#if defined(__STDC__) || defined(__cplusplus) -#define NFSPROC3_NULL 0 -extern enum clnt_stat nfsproc3_null_3(void *, void *, CLIENT *); -extern bool_t nfsproc3_null_3_svc(void *, void *, struct svc_req *); -#define NFSPROC3_GETATTR 1 -extern enum clnt_stat nfsproc3_getattr_3(fhandle3 *, getattr3res *, CLIENT *); -extern bool_t nfsproc3_getattr_3_svc(fhandle3 *, getattr3res *, struct svc_req *); -#define NFSPROC3_SETATTR 2 -extern enum clnt_stat nfsproc3_setattr_3(setattr3args *, wccstat3 *, CLIENT *); -extern bool_t nfsproc3_setattr_3_svc(setattr3args *, wccstat3 *, struct svc_req *); -#define NFSPROC3_LOOKUP 3 -extern enum clnt_stat nfsproc3_lookup_3(diropargs3 *, lookup3res *, CLIENT *); -extern bool_t nfsproc3_lookup_3_svc(diropargs3 *, lookup3res *, struct svc_req *); -#define NFSPROC3_ACCESS 4 -extern enum clnt_stat nfsproc3_access_3(access3args *, access3res *, CLIENT *); -extern bool_t nfsproc3_access_3_svc(access3args *, access3res *, struct svc_req *); -#define NFSPROC3_READLINK 5 -extern enum clnt_stat nfsproc3_readlink_3(fhandle3 *, readlink3res *, CLIENT *); -extern bool_t nfsproc3_readlink_3_svc(fhandle3 *, readlink3res *, struct svc_req *); -#define NFSPROC3_READ 6 -extern enum clnt_stat nfsproc3_read_3(read3args *, read3res *, CLIENT *); -extern bool_t nfsproc3_read_3_svc(read3args *, read3res *, struct svc_req *); -#define NFSPROC3_WRITE 7 -extern enum clnt_stat nfsproc3_write_3(write3args *, write3res *, CLIENT *); -extern bool_t nfsproc3_write_3_svc(write3args *, write3res *, struct svc_req *); -#define NFSPROC3_CREATE 8 -extern enum clnt_stat nfsproc3_create_3(create3args *, diropres3 *, CLIENT *); -extern bool_t nfsproc3_create_3_svc(create3args *, diropres3 *, struct svc_req *); -#define NFSPROC3_MKDIR 9 -extern enum clnt_stat nfsproc3_mkdir_3(mkdir3args *, diropres3 *, CLIENT *); -extern bool_t nfsproc3_mkdir_3_svc(mkdir3args *, diropres3 *, struct svc_req *); -#define NFSPROC3_SYMLINK 10 -extern enum clnt_stat nfsproc3_symlink_3(symlink3args *, diropres3 *, CLIENT *); -extern bool_t nfsproc3_symlink_3_svc(symlink3args *, diropres3 *, struct svc_req *); -#define NFSPROC3_MKNOD 11 -extern enum clnt_stat nfsproc3_mknod_3(mknod3args *, diropres3 *, CLIENT *); -extern bool_t nfsproc3_mknod_3_svc(mknod3args *, diropres3 *, struct svc_req *); -#define NFSPROC3_REMOVE 12 -extern enum clnt_stat nfsproc3_remove_3(diropargs3 *, wccstat3 *, CLIENT *); -extern bool_t nfsproc3_remove_3_svc(diropargs3 *, wccstat3 *, struct svc_req *); -#define NFSPROC3_RMDIR 13 -extern enum clnt_stat nfsproc3_rmdir_3(diropargs3 *, wccstat3 *, CLIENT *); -extern bool_t nfsproc3_rmdir_3_svc(diropargs3 *, wccstat3 *, struct svc_req *); -#define NFSPROC3_RENAME 14 -extern enum clnt_stat nfsproc3_rename_3(rename3args *, rename3res *, CLIENT *); -extern bool_t nfsproc3_rename_3_svc(rename3args *, rename3res *, struct svc_req *); -#define NFSPROC3_LINK 15 -extern enum clnt_stat nfsproc3_link_3(link3args *, link3res *, CLIENT *); -extern bool_t nfsproc3_link_3_svc(link3args *, link3res *, struct svc_req *); -#define NFSPROC3_READDIR 16 -extern enum clnt_stat nfsproc3_readdir_3(readdir3args *, readdir3res *, CLIENT *); -extern bool_t nfsproc3_readdir_3_svc(readdir3args *, readdir3res *, struct svc_req *); -#define NFSPROC3_READDIRPLUS 17 -extern enum clnt_stat nfsproc3_readdirplus_3(readdirplus3args *, readdirplus3res *, CLIENT *); -extern bool_t nfsproc3_readdirplus_3_svc(readdirplus3args *, readdirplus3res *, struct svc_req *); -#define NFSPROC3_FSSTAT 18 -extern enum clnt_stat nfsproc3_fsstat_3(fhandle3 *, fsstat3res *, CLIENT *); -extern bool_t nfsproc3_fsstat_3_svc(fhandle3 *, fsstat3res *, struct svc_req *); -#define NFSPROC3_FSINFO 19 -extern enum clnt_stat nfsproc3_fsinfo_3(fhandle3 *, fsinfo3res *, CLIENT *); -extern bool_t nfsproc3_fsinfo_3_svc(fhandle3 *, fsinfo3res *, struct svc_req *); -#define NFSPROC3_PATHCONF 20 -extern enum clnt_stat nfsproc3_pathconf_3(fhandle3 *, pathconf3res *, CLIENT *); -extern bool_t nfsproc3_pathconf_3_svc(fhandle3 *, pathconf3res *, struct svc_req *); -#define NFSPROC3_COMMIT 21 -extern enum clnt_stat nfsproc3_commit_3(commit3args *, commit3res *, CLIENT *); -extern bool_t nfsproc3_commit_3_svc(commit3args *, commit3res *, struct svc_req *); -extern int nfs_program_3_freeresult (SVCXPRT *, xdrproc_t, caddr_t); - -#else /* K&R C */ -#define NFSPROC3_NULL 0 -extern enum clnt_stat nfsproc3_null_3(); -extern bool_t nfsproc3_null_3_svc(); -#define NFSPROC3_GETATTR 1 -extern enum clnt_stat nfsproc3_getattr_3(); -extern bool_t nfsproc3_getattr_3_svc(); -#define NFSPROC3_SETATTR 2 -extern enum clnt_stat nfsproc3_setattr_3(); -extern bool_t nfsproc3_setattr_3_svc(); -#define NFSPROC3_LOOKUP 3 -extern enum clnt_stat nfsproc3_lookup_3(); -extern bool_t nfsproc3_lookup_3_svc(); -#define NFSPROC3_ACCESS 4 -extern enum clnt_stat nfsproc3_access_3(); -extern bool_t nfsproc3_access_3_svc(); -#define NFSPROC3_READLINK 5 -extern enum clnt_stat nfsproc3_readlink_3(); -extern bool_t nfsproc3_readlink_3_svc(); -#define NFSPROC3_READ 6 -extern enum clnt_stat nfsproc3_read_3(); -extern bool_t nfsproc3_read_3_svc(); -#define NFSPROC3_WRITE 7 -extern enum clnt_stat nfsproc3_write_3(); -extern bool_t nfsproc3_write_3_svc(); -#define NFSPROC3_CREATE 8 -extern enum clnt_stat nfsproc3_create_3(); -extern bool_t nfsproc3_create_3_svc(); -#define NFSPROC3_MKDIR 9 -extern enum clnt_stat nfsproc3_mkdir_3(); -extern bool_t nfsproc3_mkdir_3_svc(); -#define NFSPROC3_SYMLINK 10 -extern enum clnt_stat nfsproc3_symlink_3(); -extern bool_t nfsproc3_symlink_3_svc(); -#define NFSPROC3_MKNOD 11 -extern enum clnt_stat nfsproc3_mknod_3(); -extern bool_t nfsproc3_mknod_3_svc(); -#define NFSPROC3_REMOVE 12 -extern enum clnt_stat nfsproc3_remove_3(); -extern bool_t nfsproc3_remove_3_svc(); -#define NFSPROC3_RMDIR 13 -extern enum clnt_stat nfsproc3_rmdir_3(); -extern bool_t nfsproc3_rmdir_3_svc(); -#define NFSPROC3_RENAME 14 -extern enum clnt_stat nfsproc3_rename_3(); -extern bool_t nfsproc3_rename_3_svc(); -#define NFSPROC3_LINK 15 -extern enum clnt_stat nfsproc3_link_3(); -extern bool_t nfsproc3_link_3_svc(); -#define NFSPROC3_READDIR 16 -extern enum clnt_stat nfsproc3_readdir_3(); -extern bool_t nfsproc3_readdir_3_svc(); -#define NFSPROC3_READDIRPLUS 17 -extern enum clnt_stat nfsproc3_readdirplus_3(); -extern bool_t nfsproc3_readdirplus_3_svc(); -#define NFSPROC3_FSSTAT 18 -extern enum clnt_stat nfsproc3_fsstat_3(); -extern bool_t nfsproc3_fsstat_3_svc(); -#define NFSPROC3_FSINFO 19 -extern enum clnt_stat nfsproc3_fsinfo_3(); -extern bool_t nfsproc3_fsinfo_3_svc(); -#define NFSPROC3_PATHCONF 20 -extern enum clnt_stat nfsproc3_pathconf_3(); -extern bool_t nfsproc3_pathconf_3_svc(); -#define NFSPROC3_COMMIT 21 -extern enum clnt_stat nfsproc3_commit_3(); -extern bool_t nfsproc3_commit_3_svc(); -extern int nfs_program_3_freeresult (); -#endif /* K&R C */ - -/* the xdr functions */ - -#if defined(__STDC__) || defined(__cplusplus) -extern bool_t xdr_uint64 (XDR *, uint64*); -extern bool_t xdr_int64 (XDR *, int64*); -extern bool_t xdr_uint32 (XDR *, uint32*); -extern bool_t xdr_int32 (XDR *, int32*); -extern bool_t xdr_filename3 (XDR *, filename3*); -extern bool_t xdr_nfspath3 (XDR *, nfspath3*); -extern bool_t xdr_cookieverf3 (XDR *, cookieverf3); -extern bool_t xdr_createverf3 (XDR *, createverf3); -extern bool_t xdr_writeverf3 (XDR *, writeverf3); -extern bool_t xdr_nfsstat3 (XDR *, nfsstat3*); -extern bool_t xdr_ftype3 (XDR *, ftype3*); -extern bool_t xdr_specdata3 (XDR *, specdata3*); -extern bool_t xdr_fhandle3 (XDR *, fhandle3*); -extern bool_t xdr_nfstime3 (XDR *, nfstime3*); -extern bool_t xdr_fattr3 (XDR *, fattr3*); -extern bool_t xdr_post_op_attr (XDR *, post_op_attr*); -extern bool_t xdr_wcc_attr (XDR *, wcc_attr*); -extern bool_t xdr_pre_op_attr (XDR *, pre_op_attr*); -extern bool_t xdr_wcc_data (XDR *, wcc_data*); -extern bool_t xdr_post_op_fh3 (XDR *, post_op_fh3*); -extern bool_t xdr_set_uint32 (XDR *, set_uint32*); -extern bool_t xdr_set_uint64 (XDR *, set_uint64*); -extern bool_t xdr_time_how (XDR *, time_how*); -extern bool_t xdr_set_time (XDR *, set_time*); -extern bool_t xdr_sattr3 (XDR *, sattr3*); -extern bool_t xdr_diropargs3 (XDR *, diropargs3*); -extern bool_t xdr_diropres3ok (XDR *, diropres3ok*); -extern bool_t xdr_diropres3 (XDR *, diropres3*); -extern bool_t xdr_wccstat3 (XDR *, wccstat3*); -extern bool_t xdr_getattr3res (XDR *, getattr3res*); -extern bool_t xdr_sattrguard3 (XDR *, sattrguard3*); -extern bool_t xdr_setattr3args (XDR *, setattr3args*); -extern bool_t xdr_lookup3resok (XDR *, lookup3resok*); -extern bool_t xdr_lookup3res (XDR *, lookup3res*); -extern bool_t xdr_access3args (XDR *, access3args*); -extern bool_t xdr_access3resok (XDR *, access3resok*); -extern bool_t xdr_access3res (XDR *, access3res*); -extern bool_t xdr_readlink3resok (XDR *, readlink3resok*); -extern bool_t xdr_readlink3res (XDR *, readlink3res*); -extern bool_t xdr_read3args (XDR *, read3args*); -extern bool_t xdr_read3resok (XDR *, read3resok*); -extern bool_t xdr_read3res (XDR *, read3res*); -extern bool_t xdr_stable_how (XDR *, stable_how*); -extern bool_t xdr_write3args (XDR *, write3args*); -extern bool_t xdr_write3resok (XDR *, write3resok*); -extern bool_t xdr_write3res (XDR *, write3res*); -extern bool_t xdr_createmode3 (XDR *, createmode3*); -extern bool_t xdr_createhow3 (XDR *, createhow3*); -extern bool_t xdr_create3args (XDR *, create3args*); -extern bool_t xdr_mkdir3args (XDR *, mkdir3args*); -extern bool_t xdr_symlinkdata3 (XDR *, symlinkdata3*); -extern bool_t xdr_symlink3args (XDR *, symlink3args*); -extern bool_t xdr_devicedata3 (XDR *, devicedata3*); -extern bool_t xdr_mknoddata3 (XDR *, mknoddata3*); -extern bool_t xdr_mknod3args (XDR *, mknod3args*); -extern bool_t xdr_rename3args (XDR *, rename3args*); -extern bool_t xdr_rename3wcc (XDR *, rename3wcc*); -extern bool_t xdr_rename3res (XDR *, rename3res*); -extern bool_t xdr_link3args (XDR *, link3args*); -extern bool_t xdr_link3wcc (XDR *, link3wcc*); -extern bool_t xdr_link3res (XDR *, link3res*); -extern bool_t xdr_readdir3args (XDR *, readdir3args*); -extern bool_t xdr_entry3 (XDR *, entry3*); -extern bool_t xdr_dirlist3 (XDR *, dirlist3*); -extern bool_t xdr_readdir3resok (XDR *, readdir3resok*); -extern bool_t xdr_readdir3res (XDR *, readdir3res*); -extern bool_t xdr_readdirplus3args (XDR *, readdirplus3args*); -extern bool_t xdr_entryplus3 (XDR *, entryplus3*); -extern bool_t xdr_dirlistplus3 (XDR *, dirlistplus3*); -extern bool_t xdr_readdirplus3resok (XDR *, readdirplus3resok*); -extern bool_t xdr_readdirplus3res (XDR *, readdirplus3res*); -extern bool_t xdr_fsstat3resok (XDR *, fsstat3resok*); -extern bool_t xdr_fsstat3res (XDR *, fsstat3res*); -extern bool_t xdr_fsinfo3resok (XDR *, fsinfo3resok*); -extern bool_t xdr_fsinfo3res (XDR *, fsinfo3res*); -extern bool_t xdr_pathconf3resok (XDR *, pathconf3resok*); -extern bool_t xdr_pathconf3res (XDR *, pathconf3res*); -extern bool_t xdr_commit3args (XDR *, commit3args*); -extern bool_t xdr_commit3resok (XDR *, commit3resok*); -extern bool_t xdr_commit3res (XDR *, commit3res*); - -#else /* K&R C */ -extern bool_t xdr_uint64 (); -extern bool_t xdr_int64 (); -extern bool_t xdr_uint32 (); -extern bool_t xdr_int32 (); -extern bool_t xdr_filename3 (); -extern bool_t xdr_nfspath3 (); -extern bool_t xdr_cookieverf3 (); -extern bool_t xdr_createverf3 (); -extern bool_t xdr_writeverf3 (); -extern bool_t xdr_nfsstat3 (); -extern bool_t xdr_ftype3 (); -extern bool_t xdr_specdata3 (); -extern bool_t xdr_fhandle3 (); -extern bool_t xdr_nfstime3 (); -extern bool_t xdr_fattr3 (); -extern bool_t xdr_post_op_attr (); -extern bool_t xdr_wcc_attr (); -extern bool_t xdr_pre_op_attr (); -extern bool_t xdr_wcc_data (); -extern bool_t xdr_post_op_fh3 (); -extern bool_t xdr_set_uint32 (); -extern bool_t xdr_set_uint64 (); -extern bool_t xdr_time_how (); -extern bool_t xdr_set_time (); -extern bool_t xdr_sattr3 (); -extern bool_t xdr_diropargs3 (); -extern bool_t xdr_diropres3ok (); -extern bool_t xdr_diropres3 (); -extern bool_t xdr_wccstat3 (); -extern bool_t xdr_getattr3res (); -extern bool_t xdr_sattrguard3 (); -extern bool_t xdr_setattr3args (); -extern bool_t xdr_lookup3resok (); -extern bool_t xdr_lookup3res (); -extern bool_t xdr_access3args (); -extern bool_t xdr_access3resok (); -extern bool_t xdr_access3res (); -extern bool_t xdr_readlink3resok (); -extern bool_t xdr_readlink3res (); -extern bool_t xdr_read3args (); -extern bool_t xdr_read3resok (); -extern bool_t xdr_read3res (); -extern bool_t xdr_stable_how (); -extern bool_t xdr_write3args (); -extern bool_t xdr_write3resok (); -extern bool_t xdr_write3res (); -extern bool_t xdr_createmode3 (); -extern bool_t xdr_createhow3 (); -extern bool_t xdr_create3args (); -extern bool_t xdr_mkdir3args (); -extern bool_t xdr_symlinkdata3 (); -extern bool_t xdr_symlink3args (); -extern bool_t xdr_devicedata3 (); -extern bool_t xdr_mknoddata3 (); -extern bool_t xdr_mknod3args (); -extern bool_t xdr_rename3args (); -extern bool_t xdr_rename3wcc (); -extern bool_t xdr_rename3res (); -extern bool_t xdr_link3args (); -extern bool_t xdr_link3wcc (); -extern bool_t xdr_link3res (); -extern bool_t xdr_readdir3args (); -extern bool_t xdr_entry3 (); -extern bool_t xdr_dirlist3 (); -extern bool_t xdr_readdir3resok (); -extern bool_t xdr_readdir3res (); -extern bool_t xdr_readdirplus3args (); -extern bool_t xdr_entryplus3 (); -extern bool_t xdr_dirlistplus3 (); -extern bool_t xdr_readdirplus3resok (); -extern bool_t xdr_readdirplus3res (); -extern bool_t xdr_fsstat3resok (); -extern bool_t xdr_fsstat3res (); -extern bool_t xdr_fsinfo3resok (); -extern bool_t xdr_fsinfo3res (); -extern bool_t xdr_pathconf3resok (); -extern bool_t xdr_pathconf3res (); -extern bool_t xdr_commit3args (); -extern bool_t xdr_commit3resok (); -extern bool_t xdr_commit3res (); - -#endif /* K&R C */ - -#ifdef __cplusplus -} -#endif - - - - -CLIENT* create_connection_mount3(char *name, int type); - -void close_connection_mount3(CLIENT *cl); - -int nfs3_mount(char *dir, fhandle3 *fhand, CLIENT *cl ); - -int nfs3_umount(char *path, CLIENT *cl); - -int nfs3_export(exports3* ,CLIENT *cl); - - - - -CLIENT* create_connection_nfs3(char *name, int type); - -void close_connection_nfs3(CLIENT *cl); - -int nfs3_getattr(fhandle3 *fh, fattr3 *fatt, CLIENT *cl); - -int nfs3_setattr(fhandle3 *fh, fattr3 *fatt, CLIENT *cl); - -int nfs3_lookup(fhandle3 *fhin, char *path , fhandle3 *fhout, fattr3 *att, CLIENT *cl); - -ssize_t nfs3_read(fhandle3 *fh, void *data, off_t offset, size_t size, CLIENT *cl); - -ssize_t nfs3_write(fhandle3 *fh, void *data, off_t offset, size_t size, CLIENT *cl); - -int nfs3_create(fhandle3 *fhin, char *file, mode_t mode, fhandle3 *fhout, fattr3 *at, CLIENT *cl); - -int nfs3_remove(fhandle3 *fh, char *file, CLIENT *cl); - -int nfs3_rename(fhandle3 *fh, char *name, fhandle3 *fhR, char *nameR, CLIENT *cl); - -int nfs3_mkdir(fhandle3 *fhin, char *dir, mode_t mode, fhandle3 *fhout, fattr3 *att, CLIENT *cl); - -int nfs3_rmdir(fhandle3 *fh, char *dir, CLIENT *cl); - -int nfs3_readdir(fhandle3 *fh, cookieverf3 cookie, char *entry, CLIENT *cl); - -int nfs3_statfs(fhandle3 *arg, fsinfo3resok *inf, CLIENT *cl); - -#endif /* !_NFS3_PROT_H_RPCGEN */ diff --git a/include/xpn_client/nfi/nfi_ops.h b/include/xpn_client/nfi/nfi_ops.h deleted file mode 100644 index 75549f8f7..000000000 --- a/include/xpn_client/nfi/nfi_ops.h +++ /dev/null @@ -1,98 +0,0 @@ - -/* - * Copyright 2000-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Luis Miguel Sanchez Garcia, Borja Bergua Guerra, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _NFI_OPS_H_ -#define _NFI_OPS_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "nfi_worker_task.h" - #include "nfi_worker.h" - - - /* ... Const / Const ................................................. */ - - enum nfi_work{ - noop = -1, - op_open = 0, - op_create = 1, - op_read = 2, - op_write = 3, - op_close = 4, - op_remove = 5, - op_rename = 6, - op_getattr = 7, - op_setattr = 8, - - op_mkdir = 20, - op_rmdir = 21, - op_opendir = 22, - op_readdir = 23, - op_closedir = 24, - - op_statfs = 60, - - op_read_mdata = 70, - op_write_mdata = 71 - }; - - - /* ... Functions / Funciones ......................................... */ - - void nfi_do_operation ( struct st_th th_arg ); - - int nfi_worker_do_open ( struct nfi_worker *wrk, char *url, int flags, mode_t mode, struct nfi_fhandle *fho ); - int nfi_worker_do_create ( struct nfi_worker *wrk, char *url, mode_t mode, struct nfi_attr *attr, struct nfi_fhandle *fh ); - int nfi_worker_do_read ( struct nfi_worker *wrk, struct nfi_fhandle *fh, struct nfi_worker_io *io,int n ); - int nfi_worker_do_write ( struct nfi_worker *wrk, struct nfi_fhandle *fh, struct nfi_worker_io *io,int n ); - int nfi_worker_do_close ( struct nfi_worker *wrk, struct nfi_fhandle *fh ); - - int nfi_worker_do_remove ( struct nfi_worker *wrk, char *url ); - int nfi_worker_do_rename ( struct nfi_worker *wrk, char *old_url, char *new_url ); - int nfi_worker_do_getattr ( struct nfi_worker *wrk, struct nfi_fhandle *fh, struct nfi_attr *attr ); - int nfi_worker_do_setattr ( struct nfi_worker *wrk, struct nfi_fhandle *fh, struct nfi_attr *attr ); - - int nfi_worker_do_mkdir ( struct nfi_worker *wrk, char *url, mode_t mode, struct nfi_attr *attr, struct nfi_fhandle *fh ); - int nfi_worker_do_opendir ( struct nfi_worker *wrk, char *url, struct nfi_fhandle *fho ); - int nfi_worker_do_readdir ( struct nfi_worker *wrk, struct nfi_fhandle *fhd, struct dirent *entry ); - int nfi_worker_do_closedir ( struct nfi_worker *wrk, struct nfi_fhandle *fh ); - int nfi_worker_do_rmdir ( struct nfi_worker *wrk, char *url ); - - int nfi_worker_do_statfs ( struct nfi_worker *wrk, struct nfi_info *inf ); - - int nfi_worker_do_read_mdata ( struct nfi_worker *wrk, char *url, struct xpn_metadata *mdata ); - int nfi_worker_do_write_mdata ( struct nfi_worker *wrk, char *url, struct xpn_metadata *mdata, int only_file_size ); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_client/nfi/nfi_sck_server/nfi_sck_server_comm.h b/include/xpn_client/nfi/nfi_sck_server/nfi_sck_server_comm.h deleted file mode 100644 index efcbaab0a..000000000 --- a/include/xpn_client/nfi/nfi_sck_server/nfi_sck_server_comm.h +++ /dev/null @@ -1,54 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _NFI_SCK_SERVER_COMM_H_ -#define _NFI_SCK_SERVER_COMM_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/utils.h" - #include "base/ns.h" - #include "socket.h" - #include "xpn_server/xpn_server_ops.h" - - - /* ... Functions / Funciones ......................................... */ - - int nfi_sck_server_comm_connect ( char * srv_name, char * port_name, int *out_socket ); - int nfi_sck_ip4_server_comm_connect ( char * srv_name, char * port_name, int *out_socket ); - int nfi_sck_ip6_server_comm_connect ( char * srv_name, char * port_name, int *out_socket ); - int nfi_sck_server_comm_disconnect ( int socket, int keep_connected ); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_client/nfi/nfi_worker.h b/include/xpn_client/nfi/nfi_worker.h deleted file mode 100644 index e40aa6470..000000000 --- a/include/xpn_client/nfi/nfi_worker.h +++ /dev/null @@ -1,59 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos - * - * 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 . - * - */ - - -#ifndef _NFI_WORKER_H_ -#define _NFI_WORKER_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "nfi_worker_task.h" - - - /* ... Functions / Funciones ......................................... */ - - int nfi_worker_init ( struct nfi_worker *wrk, struct nfi_server *serv, int thread ); - int nfi_worker_thread ( struct nfi_worker *wrk, int flag ); - ssize_t nfi_worker_wait ( struct nfi_worker *wrk ); - int nfi_worker_end ( struct nfi_worker *wrk ); - int nfi_worker_destroy ( ); - - - // NEW ////////////////////////////////////////// - int nfiworker_init (struct nfi_server *serv) ; - int nfiworker_launch ( void (*worker_function)(struct st_th), struct nfi_worker *wrk ); - ssize_t nfiworker_wait ( struct nfi_worker *wrk ); - void nfiworker_destroy (struct nfi_server *serv); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_client/nfi/nfi_worker_task.h b/include/xpn_client/nfi/nfi_worker_task.h deleted file mode 100644 index 527577cde..000000000 --- a/include/xpn_client/nfi/nfi_worker_task.h +++ /dev/null @@ -1,102 +0,0 @@ - -/* - * Copyright 2000-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Luis Miguel Sanchez Garcia, Borja Bergua Guerra, Dario Muñoz Muñoz - * - * 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 . - * - */ - -#ifndef _NFI_WORKER_TASK_H_ -#define _NFI_WORKER_TASK_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "debug_msg.h" - #include "workers.h" - #include "nfi.h" - - - /* ... Data structures / Estructuras de datos ........................ */ - - struct nfi_worker_io - { - off_t offset; - size_t size; - void *buffer; - }; - - struct nfi_worker_args - { - int operation; - ssize_t result; - int worker_errno; - - char url [PATH_MAX]; - int flags; - mode_t mode; - int master_node; - int is_master_node; - - char virtual_path [PATH_MAX]; - char storage_path [PATH_MAX]; - char newurl [PATH_MAX]; - struct nfi_fhandle * fh; - struct nfi_attr * attr; - int opt; - - struct nfi_info * inf; - - int n_io; - struct nfi_worker_io * io; - struct dirent * entry; - unsigned char * type; - struct xpn_metadata * mdata; - int mdata_only_file_size; - }; - - struct nfi_worker - { - int thread; - - // OLD - pthread_t pth; - pthread_mutex_t mt; - pthread_cond_t cnd; - int ready; - - // NEW - worker_t wb ; - struct st_th warg ; - - struct nfi_server *server; - struct nfi_worker_args arg; // TODO: Convert this into a list of 'struct nfi_worker_args' to make Expand reentrant - }; - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_client/nfi/nfi_xpn_server/nfi_mq_server_comm.h b/include/xpn_client/nfi/nfi_xpn_server/nfi_mq_server_comm.h deleted file mode 100644 index 33e2e754a..000000000 --- a/include/xpn_client/nfi/nfi_xpn_server/nfi_mq_server_comm.h +++ /dev/null @@ -1,52 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Elias Del Pozo Puñal, Alejandro Calderon Mateos, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _NFI_MQ_SERVER_COMM_H_ -#define _NFI_MQ_SERVER_COMM_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "utils.h" - #include "nfi_xpn_server.h" - #include "xpn_server_params.h" - - - /* ... Functions / Funciones ......................................... */ - - void nfi_mq_server_init ( struct nfi_xpn_server *server_aux ); - void nfi_mq_server_destroy ( struct nfi_xpn_server *server_aux ); - ssize_t nfi_mq_server_publish ( struct nfi_xpn_server *server_aux, struct nfi_xpn_server_fhandle *fh_aux, void * buffer, off_t offset, size_t size ); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_client/nfi/nfi_xpn_server/nfi_xpn_server.h b/include/xpn_client/nfi/nfi_xpn_server/nfi_xpn_server.h deleted file mode 100644 index a3dc2144c..000000000 --- a/include/xpn_client/nfi/nfi_xpn_server/nfi_xpn_server.h +++ /dev/null @@ -1,132 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _NFI_XPN_SERVER_H_ -#define _NFI_XPN_SERVER_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/utils.h" - #include "base/path_misc.h" - #include "base/urlstr.h" - #include "base/workers.h" - #include "base/ns.h" - #include "base/service_socket.h" - #include "nfi.h" - #include "nfi_local.h" - #include "nfi_worker.h" - #include "xpn_server/xpn_server_conf.h" - #include "xpn_server/xpn_server_ops.h" - - - /* ... Data structures / Estructuras de datos ........................ */ - - struct nfi_xpn_server - { - // client identification - int size; - int rank; - - // client execution configuration - int xpn_thread; - int xpn_locality; - int locality; - - // MQTT usage - int xpn_mosquitto_mode; - int xpn_mosquitto_qos; - - #ifdef HAVE_MOSQUITTO_H - struct mosquitto * mqtt; - #endif - - int keep_connected; - - // server comm - int server_type; // it can be XPN_SERVER_TYPE_MPI, XPN_SERVER_TYPE_SCK - #ifdef ENABLE_MPI_SERVER - MPI_Comm server_comm; // For mpi_server - #endif - #ifdef ENABLE_SCK_SERVER - int server_socket; // For sck_server - #endif - // server port - char port_name [MAX_PORT_NAME_LENGTH]; - char srv_name [MAX_PORT_NAME_LENGTH]; - - // server arguments - int argc; - char **argv; - }; - - struct nfi_xpn_server_fhandle - { - char path[PATH_MAX]; - long telldir; - DIR *dir; - int fd; - }; - - - /* ... Functions / Funciones ......................................... */ - - int nfi_xpn_server_init ( char *url, struct nfi_server *serv, int server_type ); - int nfi_xpn_server_destroy ( struct nfi_server *server ); - - int nfi_xpn_server_connect ( struct nfi_server *server, char *url, char* prt, char* serv, char* dir ); - int nfi_xpn_server_reconnect ( struct nfi_server *server ); - int nfi_xpn_server_disconnect ( struct nfi_server *server ); - - int nfi_xpn_server_create ( struct nfi_server *server, char *url, mode_t mode, struct nfi_attr *attr, struct nfi_fhandle *fh ); - int nfi_xpn_server_open ( struct nfi_server *server, char *url, int flags, mode_t mode, struct nfi_fhandle *fho ); - ssize_t nfi_xpn_server_read ( struct nfi_server *server, struct nfi_fhandle *fh, void *buffer, off_t offset, size_t size ); - ssize_t nfi_xpn_server_write ( struct nfi_server *server, struct nfi_fhandle *fh, void *buffer, off_t offset, size_t size ); - int nfi_xpn_server_close ( struct nfi_server *server, struct nfi_fhandle *fh ); - int nfi_xpn_server_remove ( struct nfi_server *server, char *url ); - int nfi_xpn_server_rename ( struct nfi_server *server, char *old_url, char *new_url ); - - int nfi_xpn_server_getattr ( struct nfi_server *server, struct nfi_fhandle *fh, struct nfi_attr *attr ); - int nfi_xpn_server_setattr ( struct nfi_server *server, struct nfi_fhandle *fh, struct nfi_attr *attr ); - - int nfi_xpn_server_mkdir ( struct nfi_server *server, char *url, mode_t mode, struct nfi_attr *attr, struct nfi_fhandle *fh ); - int nfi_xpn_server_opendir ( struct nfi_server *server, char *url, struct nfi_fhandle *fho ); - int nfi_xpn_server_readdir ( struct nfi_server *server, struct nfi_fhandle *fhd, struct dirent *entry ); - int nfi_xpn_server_closedir ( struct nfi_server *server, struct nfi_fhandle *fhd ); - int nfi_xpn_server_rmdir ( struct nfi_server *server, char *url ); - - int nfi_xpn_server_statfs ( struct nfi_server *server, struct nfi_info *inf ); - - int nfi_xpn_server_read_mdata ( struct nfi_server *serv, char *url, struct xpn_metadata *mdata ); - int nfi_xpn_server_write_mdata ( struct nfi_server *serv, char *url, struct xpn_metadata *mdata, int only_file_size ); - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/xpn_client/nfi/nfi_xpn_server/nfi_xpn_server_comm.h b/include/xpn_client/nfi/nfi_xpn_server/nfi_xpn_server_comm.h deleted file mode 100644 index 88176f643..000000000 --- a/include/xpn_client/nfi/nfi_xpn_server/nfi_xpn_server_comm.h +++ /dev/null @@ -1,59 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _NFI_XPN_SERVER_COMM_H_ -#define _NFI_XPN_SERVER_COMM_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "nfi_xpn_server.h" - #include "base/utils.h" - #include "base/ns.h" - #include "base/socket.h" - - - /* ... Functions / Funciones ......................................... */ - - int nfi_xpn_server_comm_init ( struct nfi_xpn_server *params ); - int nfi_xpn_server_comm_destroy ( struct nfi_xpn_server *params ); - - int nfi_xpn_server_comm_connect ( struct nfi_xpn_server *params ); - int nfi_xpn_server_comm_disconnect ( struct nfi_xpn_server *params ); - - int nfi_xpn_server_comm_write_operation ( struct nfi_xpn_server *params, int op); - ssize_t nfi_xpn_server_comm_write_data ( struct nfi_xpn_server *params, char *data, ssize_t size ); - ssize_t nfi_xpn_server_comm_read_data ( struct nfi_xpn_server *params, char *data, ssize_t size ); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_client/xpn/xpn_lib.h b/include/xpn_client/xpn/xpn_lib.h deleted file mode 100644 index 6fcc85fee..000000000 --- a/include/xpn_client/xpn/xpn_lib.h +++ /dev/null @@ -1,68 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos - * - * 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 . - * - */ - - -#ifndef _XPN_LIB_H_ -#define _XPN_LIB_H_ - - /* ... Include / Inclusion ........................................... */ - - #include "xpn_simple/xpn_simple_lib.h" - - - /* ... Functions / Funciones ......................................... */ - - /* - char* xpn_getcwd (char *path, size_t size); - int xpn_mkdir (const char *path, mode_t perm) ; - int xpn_rmdir (const char *path) ; - - ssize_t xpn_read (int fd, void *buffer, size_t size); - ssize_t xpn_write (int fd, const void *buffer, size_t size); - ssize_t xpn_pread (int fd, void *buffer, size_t size, off_t offset); - ssize_t xpn_pwrite (int fd, const void *buffer, size_t size, off_t offset); - ssize_t xpn_writev (int fildes, const struct iovec *iov, int iovcnt); - ssize_t xpn_readv (int fildes, const struct iovec *iov, int iovcnt); - off_t xpn_lseek (int fd, off_t offset, int flag); - - int xpn_creat (const char *path, mode_t perm); - int xpn_open (const char *path, int flags , ...); - int xpn_close (int fd); - int xpn_unlink (const char *path); - int xpn_rename (const char *path, const char *newpath); - int xpn_fstat (int fd, struct stat *sb); - int xpn_stat (const char *path, struct stat *sb); - int xpn_chown (const char *path, uid_t owner, gid_t group); - int xpn_fchown (int fd, uid_t owner, gid_t group); - int xpn_chmod (const char *path, mode_t mode); - int xpn_fchmod (int fd, mode_t mode); - int xpn_truncate (const char *path, off_t length); - int xpn_ftruncate (int fd, off_t length); - int xpn_dup (int fd); - - int xpn_dup2(int fd, int fd2); - */ - - - /* ................................................................... */ - -#endif - diff --git a/include/xpn_client/xpn/xpn_simple/xpn.h b/include/xpn_client/xpn/xpn_simple/xpn.h deleted file mode 100644 index 103a69700..000000000 --- a/include/xpn_client/xpn/xpn_simple/xpn.h +++ /dev/null @@ -1,68 +0,0 @@ - -/* - * Copyright 2000-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Luis Miguel Sanchez Garcia, Borja Bergua Guerra, Dario Muñoz Muñoz - * - * 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 . - * - */ - -#ifndef _XPN_H -#define _XPN_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "nfi/nfi.h" - #include "nfi/nfi_worker.h" - #include "nfi/nfi_ops.h" - #include "nfi/nfi_lib.h" - - - /* ... Const / Const ................................................. */ - - #define XPN_CONF "XPN_CONF" - - - /* ... Data structures / Estructuras de datos ........................ */ - - // Paralel struct partition - struct xpn_partition - { - int id; // id of partition - int replication_level; // replication_level of files :0, 1, 2,... - char name[PATH_MAX]; // name of partition - ssize_t block_size; // size of distribution used - - int data_nserv; // number of server - struct nfi_server *data_serv; // list of data servers in the partition - - int local_serv; // server with locality - }; - - /* ... Functions / Funciones ......................................... */ - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/xpn_client/xpn/xpn_simple/xpn_conf_reader.h b/include/xpn_client/xpn/xpn_simple/xpn_conf_reader.h deleted file mode 100644 index e95fb7f19..000000000 --- a/include/xpn_client/xpn/xpn_simple/xpn_conf_reader.h +++ /dev/null @@ -1,111 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _XPN_CONF_READER_H_ -#define _XPN_CONF_READER_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/utils.h" - #include "base/path_misc.h" - - - /* ... Defines / Definiciones ........................................ */ - - #define TOKEN 100 - #define OPEN_BRACKET 101 - #define CLOSE_BRACKET 102 - #define EQUAL 103 - #define COMMENT 104 - - #define MAX_TOKEN_LEN 1024 - - #define XPN_CONF "XPN_CONF" - #define XPN_CONF_DEFAULT "/etc/xpn/xpn.conf" - // #define XPN_CONF_DEFAULT "xpn.conf" - - #define XPN_CONF_TAG_PARTITION "[partition]" - #define XPN_CONF_TAG_PARTITION_NAME "partition_name" - #define XPN_CONF_TAG_REPLICATION_LEVEL "replication_level" - #define XPN_CONF_TAG_BLOCKSIZE "bsize" - #define XPN_CONF_TAG_SERVER_URL "server_url" - - #define XPN_CONF_DEFAULT_REPLICATION_LEVEL 0 - #define XPN_CONF_DEFAULT_BLOCKSIZE 512*KB - - - /* ... Data structures / Estructuras de datos ........................ */ - - struct conf_file_data_partition - { - char *partition_name; - int replication_level; - long bsize; - int server_n; // Array of number of servers in partition - char **servers; // The pointers to the servers - }; - - struct conf_file_data - { - long lines_n; // Number of lines - int partition_n; // Number of partitions - struct conf_file_data_partition *partitions ; - }; - - - /* ... Functions / Funciones ......................................... */ - - int skip_spaces ( FILE *fp, long *line ) ; - int read_token ( FILE *fp, char *tok, long *line ) ; - int next_token ( FILE *fp, char *tok, long *line ) ; - - int xpn_conf_reader_load ( struct conf_file_data *conf_data, char *fname ) ; - int xpn_conf_reader_free ( struct conf_file_data *conf_data ) ; - int xpn_conf_reader_show ( FILE *fd, struct conf_file_data *conf_data ) ; - - int xpn_conf_reader_get_num_partitions ( struct conf_file_data *conf_data ) ; - int xpn_conf_reader_get_num_servers ( struct conf_file_data *conf_data, int partition_index ) ; - int xpn_conf_reader_get_server ( struct conf_file_data *conf_data, char *value, int partition, int server ) ; - int xpn_conf_reader_get_value ( struct conf_file_data *conf_data, int partition_index, char *key, char *value ) ; - - // Old API - int XpnConfLoad ( struct conf_file_data *conf_data ); - void XpnConfFree ( struct conf_file_data *conf_data ); - - int XpnConfGetServer ( struct conf_file_data *conf_data, char *value, int partition, int server ) ; - int XpnConfGetValue ( struct conf_file_data *conf_data, char *key, char *value, int partition ); - int XpnConfGetNumPartitions ( struct conf_file_data *conf_data ); - int XpnConfGetNumServers ( struct conf_file_data *conf_data, int partition_index ); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/xpn_client/xpn/xpn_simple/xpn_cwd.h b/include/xpn_client/xpn/xpn_simple/xpn_cwd.h deleted file mode 100644 index ec368b25f..000000000 --- a/include/xpn_client/xpn/xpn_simple/xpn_cwd.h +++ /dev/null @@ -1,61 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _XPN_CWD_H -#define _XPN_CWD_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "xpn.h" - #include "xpn_policy_cwd.h" - - - /* ... Data structures / Estructuras de datos ........................ */ - - struct xpn_cwd { - char xpn_cwd_path[PATH_MAX]; - }; - - extern struct xpn_cwd xpn_cwddir; - - - /* ... Functions / Funciones ......................................... */ - - void xpn_init_cwd(); - - char* xpn_simple_getcwd(char *path, size_t size) ; - int xpn_simple_chdir(char *path) ; - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_client/xpn/xpn_simple/xpn_dir.h b/include/xpn_client/xpn/xpn_simple/xpn_dir.h deleted file mode 100644 index 9037e6ff7..000000000 --- a/include/xpn_client/xpn/xpn_simple/xpn_dir.h +++ /dev/null @@ -1,50 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _XPN_DIR_H -#define _XPN_DIR_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "xpn.h" - #include "xpn_policy_init.h" - #include "xpn_policy_open.h" - - - /* ... Functions / Funciones ......................................... */ - - int xpn_simple_mkdir(const char *path, mode_t perm) ; - int xpn_simple_rmdir(const char *path) ; - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/xpn_client/xpn/xpn_simple/xpn_file.h b/include/xpn_client/xpn/xpn_simple/xpn_file.h deleted file mode 100644 index e73083524..000000000 --- a/include/xpn_client/xpn/xpn_simple/xpn_file.h +++ /dev/null @@ -1,106 +0,0 @@ - -/* - * Copyright 2000-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Luis Miguel Sanchez Garcia, Borja Bergua Guerra, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _XPN_FILE_H -#define _XPN_FILE_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "xpn.h" - #include "xpn_policy_init.h" - - - /* ... Const / Const ................................................. */ - - /* max number of file descriptors */ - #define XPN_MAX_FILE 1024 - - /* FILE or DIR */ - #define XPN_FILE 0 - #define XPN_DIR 1 - - - /* ... Data structures / Estructuras de datos ........................ */ - - struct xpn_fh - { - int n_nfih; - struct nfi_fhandle **nfih; // NFI handler - }; - - struct xpn_attr - { - int at_type; // FILE or DIR - mode_t at_mode; // protection - nlink_t at_nlink; // number of hard links - uid_t at_uid; // user ID of owner - gid_t at_gid; // group ID of owner - off_t at_size; // total size, in bytes - u_long at_blksize; // blocksize for filesystem I/O - u_long at_blocks; // number of blocks allocated - time_t at_atime; // time of last access - time_t at_mtime; // time of last modification - time_t at_ctime; // time of last status change - void *private_info; - }; - - // File table - struct xpn_filedesc - { - int id; // id of file - char path[PATH_MAX]; // absolute path - int type; // indicate FILE or DIR - int links; // number of links that this file has - int flags; // O_RDONLY, O_WRONLY,.... - mode_t mode; // S_IRUSR , S_IWUSR ,.... - struct xpn_partition *part; // partition - struct xpn_metadata *mdata; // metadata - struct xpn_attr attr; // attributes of the open file - off_t offset; // offset of the open file - ssize_t block_size; // size of distribution used - ssize_t size_threads; - struct xpn_fh *data_vfh; // virtual FH - struct stat st; - }; - - // global - extern struct xpn_filedesc *xpn_file_table[XPN_MAX_FILE]; - - - /* ... Functions / Funciones ......................................... */ - - int xpn_init_file_table ( void ); - int xpn_destroy_file_table ( void ); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/xpn_client/xpn/xpn_simple/xpn_init.h b/include/xpn_client/xpn/xpn_simple/xpn_init.h deleted file mode 100644 index 45f2d7e41..000000000 --- a/include/xpn_client/xpn/xpn_simple/xpn_init.h +++ /dev/null @@ -1,65 +0,0 @@ - -/* - * Copyright 2000-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Luis Miguel Sanchez Garcia, Borja Bergua Guerra, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _XPN_INIT_H -#define _XPN_INIT_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/path_misc.h" - #include "xpn_policy_init.h" - #include "xpn_cwd.h" - #include "xpn_file.h" - - - /* ... Const / Const ................................................. */ - - #define XPN_MAX_PART 128 - - - /* ... Data structures / Estructuras de datos ........................ */ - - extern struct xpn_partition xpn_parttable[XPN_MAX_PART]; - - - /* ... Functions / Funciones ......................................... */ - - int xpn_init_partition( void ); - - int xpn_simple_mark_error_server ( int index ) ; - int xpn_simple_destroy ( void ); - int xpn_simple_init ( void ); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/xpn_client/xpn/xpn_simple/xpn_metadata.h b/include/xpn_client/xpn/xpn_simple/xpn_metadata.h deleted file mode 100644 index ec82454f6..000000000 --- a/include/xpn_client/xpn/xpn_simple/xpn_metadata.h +++ /dev/null @@ -1,98 +0,0 @@ - -/* - * Copyright 2000-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Luis Miguel Sanchez Garcia, Borja Bergua Guerra, Dario Muñoz Muñoz - * - * 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 . - * - */ - -#ifndef _XPN_METADATA_H_ -#define _XPN_METADATA_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "nfi.h" - - /* ... Const / Const ................................................. */ - - #define XPN_HEADER_SIZE 8192 - - #define XPN_MAGIC_NUMBER "XPN" - #define XPN_METADATA_VERSION 1 - #define XPN_METADATA_MAX_RECONSTURCTIONS 40 - #define XPN_METADATA_DISTRIBUTION_ROUND_ROBIN 1 - - #define XPN_CHECK_MAGIC_NUMBER(mdata) \ - (((mdata)->magic_number[0] == XPN_MAGIC_NUMBER[0]) && \ - ((mdata)->magic_number[1] == XPN_MAGIC_NUMBER[1]) && \ - ((mdata)->magic_number[2] == XPN_MAGIC_NUMBER[2])) - - // metadata of xpn file - struct xpn_metadata - { - char magic_number[3]; - int version; // Version number - int type; // Type of file: file or directory - -#if !defined(HAVE_64BITS) - uint64_t block_size; // Size of block used - uint64_t file_size; // Size of the file - -#else - ssize_t block_size; // Size of block used - ssize_t file_size; // Size of the file - -#endif - - int replication_level; // Replication level of files: 0, 1, 2, ... - int first_node; // Server which has the first block - int distribution_policy; // Distribution policy of blocks, default: round-robin - int data_nserv[XPN_METADATA_MAX_RECONSTURCTIONS]; // Array of number of servers to reconstruct - int offsets[XPN_METADATA_MAX_RECONSTURCTIONS]; // Array indicating the block where new server configuration starts - }; - - // Forward declaration - struct nfi_server; - - /* ... Functions / Funciones ......................................... */ - - int XpnGetMetadataPos(struct xpn_metadata *mdata, int pos); - - void XpnPrintMetadata(struct xpn_metadata *mdata); - - int XpnCreateMetadata(struct xpn_metadata *mdata, int pd, const char *path); - int XpnCreateMetadataExtern(struct xpn_metadata *mdata, const char *path, int nserv, int block_size, int replication_level); - - int XpnReadMetadata(struct xpn_metadata *mdata, int nserv, struct nfi_server *servers, const char *path, int replication_level); - - int XpnUpdateMetadata(struct xpn_metadata *mdata, int nserv, struct nfi_server *servers, const char *path, int replication_level, int only_file_size); - - int xpn_simple_get_block_locality(char *path, off_t offset, int *url_c, char **url_v[]); - int xpn_simple_free_block_locality(int *url_c, char **url_v[]); - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/xpn_client/xpn/xpn_simple/xpn_open.h b/include/xpn_client/xpn/xpn_simple/xpn_open.h deleted file mode 100644 index 68f88d1d1..000000000 --- a/include/xpn_client/xpn/xpn_simple/xpn_open.h +++ /dev/null @@ -1,73 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _XPN_OPEN_H -#define _XPN_OPEN_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "xpn.h" - #include "xpn_file.h" - #include "xpn_policy_open.h" - #include "xpn_policy_cwd.h" - #include "xpn_init.h" - #include "xpn_rw.h" - #include "base/workers.h" - - - /* ... Functions / Funciones ......................................... */ - - FILE *xpn_fopencookie(const char *path, const char *mode); - - //int xpn_open(const char *path, int flags, ...); - int xpn_simple_open(const char *path, int flags, mode_t mode); - int xpn_simple_creat(const char *path, mode_t perm); - FILE *xpn_simple_fopen(const char *filename, const char *mode); - int xpn_simple_close(int fd); - int xpn_simple_unlink(const char *path); - int xpn_simple_rename(const char *path, const char *newpath); - int xpn_simple_fstat(int fd, struct stat *sb); - int xpn_simple_fclose(FILE *fp); - int xpn_simple_stat(const char *path, struct stat *sb); - int xpn_simple_chown( const char *path, uid_t owner, gid_t group); - int xpn_simple_fchown(int fd, uid_t owner, gid_t group); - int xpn_simple_chmod( const char *path, mode_t mode); - int xpn_simple_fchmod( int fd, mode_t mode); - int xpn_simple_truncate( const char *path, off_t length); - int xpn_simple_ftruncate( int fd, off_t length); - - int xpn_simple_dup(int fd); - int xpn_simple_dup2(int fd, int fd2); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/xpn_client/xpn/xpn_simple/xpn_opendir.h b/include/xpn_client/xpn/xpn_simple/xpn_opendir.h deleted file mode 100644 index 1ea1a842d..000000000 --- a/include/xpn_client/xpn/xpn_simple/xpn_opendir.h +++ /dev/null @@ -1,69 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _XPN_OPENDIR_H -#define _XPN_OPENDIR_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "xpn.h" - #include "xpn_open.h" - - - /* ... Data structures / Estructuras de datos ........................ */ - - struct __dirstream - { - int fd; // File descriptor. - //__libc_lock_define (, lock) // Mutex lock for this structure. //TODO - size_t allocation; // Space allocated for the block. - size_t size; // Total valid data in the block. - size_t offset; // Current offset into the block. - off_t filepos; // Position of next entry to read. - /* Directory block. */ - char data[0] __attribute__ ((aligned (__alignof__ (void*)))); - - char * path; - }; - - - /* ... Functions / Funciones ......................................... */ - - DIR * xpn_simple_opendir(const char *path); - int xpn_simple_closedir(DIR *dirp); - struct dirent * xpn_simple_readdir(DIR *dirp); - void xpn_simple_rewinddir(DIR *dirp); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_client/xpn/xpn_simple/xpn_policy_init.h b/include/xpn_client/xpn/xpn_simple/xpn_policy_init.h deleted file mode 100644 index 745a3ef2c..000000000 --- a/include/xpn_client/xpn/xpn_simple/xpn_policy_init.h +++ /dev/null @@ -1,51 +0,0 @@ - - /* - * Copyright 2000-2025 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 . - * - */ - -#ifndef _XPN_POLICY_INIT_H -#define _XPN_POLICY_INIT_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "xpn.h" - #include "xpn_init.h" - #include "xpn_conf_reader.h" - - - /* ... Functions / Funciones ......................................... */ - - int XpnInitServer ( struct conf_file_data *conf_data, struct xpn_partition * part, struct nfi_server * serv, int server_num ); - - struct xpn_partition * XpnSearchPart ( int pd ); - int XpnGetPartition ( char *path ); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/xpn_client/xpn/xpn_simple/xpn_policy_open.h b/include/xpn_client/xpn/xpn_simple/xpn_policy_open.h deleted file mode 100644 index 00be32d74..000000000 --- a/include/xpn_client/xpn/xpn_simple/xpn_policy_open.h +++ /dev/null @@ -1,81 +0,0 @@ - -/* - * Copyright 2000-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Luis Miguel Sanchez Garcia, Borja Bergua Guerra, Dario Muñoz Muñoz - * - * 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 . - * - */ - -#ifndef _XPN_POLICY_OPEN_H -#define _XPN_POLICY_OPEN_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "xpn_file.h" - #include "xpn_policy_rw.h" - - - /* ... Const / Const ................................................. */ - - #define XPN_META_SIZE (4*KB) - - /* ... Data structures / Estructuras de datos ........................ */ - - enum xpn_work{ - no_xpn_op = -1, - op_xpn_getattr = 0, - op_xpn_setattr = 1, - op_xpn_open = 2, - op_xpn_creat = 3, - op_xpn_close = 4, - op_xpn_remove = 5, - op_xpn_rename = 6, - op_xpn_read = 7, - op_xpn_write = 8, - op_xpn_mkdir = 9, - op_xpn_rmdir = 10, - op_xpn_opendir = 11, - op_xpn_readdir = 12, - op_xpn_closedir = 13, - op_xpn_statfs = 14, - }; - - - /* ... Functions / Funciones ......................................... */ - - void XpnGetURLServer( struct nfi_server *serv, const char *abs_path, char *url_serv); - - int XpnGetServers(int pd, int fd, struct nfi_server **servers); - - int XpnGetFh(struct xpn_metadata *mdata, struct nfi_fhandle **fh, struct nfi_server *servers, char *path); - int XpnGetFhDir(struct xpn_metadata *mdata, struct nfi_fhandle **fh, struct nfi_server *servers, char *path); - - int XpnGetAtribFd (int fd, struct stat *st); - int XpnGetAtribPath (char * path, struct stat *st); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/xpn_client/xpn/xpn_simple/xpn_policy_rw.h b/include/xpn_client/xpn/xpn_simple/xpn_policy_rw.h deleted file mode 100644 index ec209c8bc..000000000 --- a/include/xpn_client/xpn/xpn_simple/xpn_policy_rw.h +++ /dev/null @@ -1,64 +0,0 @@ - -/* - * Copyright 2000-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Luis Miguel Sanchez Garcia, Borja Bergua Guerra, Dario Muñoz Muñoz - * - * 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 . - * - */ - -#ifndef _XPN_POLICY_RW_H -#define _XPN_POLICY_RW_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "xpn_file.h" - #include "xpn_policy_open.h" - - - /* ... Functions / Funciones ......................................... */ - - void XpnCalculateBlockMdata(struct xpn_metadata *mdata, off_t offset, int replication, off_t *local_offset, int *serv); - void XpnCalculateBlock(int block_size, int replication_level, int nserv, off_t offset, int replication, int first_node, off_t *local_offset, int *serv); - void XpnCalculateBlockInvert(int block_size, int replication_level, int nserv, int serv, off_t local_offset, int first_node, off_t *offset, int *replication); - void XpnPrintBlockDistribution(int blocks, struct xpn_metadata *mdata); - - int XpnReadGetBlock(int fd, off_t offset, int serv_client, off_t *local_offset, int *serv); - int XpnWriteGetBlock(int fd, off_t offset, int replication, off_t *local_offset, int *serv); - - void *XpnReadBlocks (int fd, const void *buffer, size_t size, off_t offset, int serv_client, struct nfi_worker_io ***io_out, int **ion_out, int num_servers); - void XpnReadBlocksFinish(int fd, void *buffer, size_t size, off_t offset, int serv_client, struct nfi_worker_io ***io_out, int **ion_out, int num_servers, const void *new_buffer); - - void *XpnWriteBlocks (int fd, const void *buffer, size_t size, off_t offset, struct nfi_worker_io ***io_out, int **ion_out, int num_servers); - - ssize_t XpnReadGetTotalBytes (ssize_t *res_v, int num_servers); - ssize_t XpnWriteGetTotalBytes (ssize_t *res_v, int num_servers, struct nfi_worker_io ***io, int *ion, struct nfi_server *servers); - - ssize_t XpnGetRealFileSize(struct xpn_partition *part, struct nfi_attr *attr, int n_serv); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_client/xpn/xpn_simple/xpn_rw.h b/include/xpn_client/xpn/xpn_simple/xpn_rw.h deleted file mode 100644 index 2038a80ad..000000000 --- a/include/xpn_client/xpn/xpn_simple/xpn_rw.h +++ /dev/null @@ -1,77 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _XPN_RW_H -#define _XPN_RW_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "xpn.h" - #include "xpn_file.h" - #include "xpn_open.h" - #include "xpn_policy_rw.h" - #include "base/workers.h" - - - /* ... Functions / Funciones ......................................... */ - - ssize_t xpn_simple_read ( int fd, void *buffer, size_t size ); - ssize_t xpn_simple_write ( int fd, const void *buffer, size_t size ); - off_t xpn_simple_lseek ( int fd, off_t offset, int flag ); - - FILE *xpn_simple_fopen (const char *filename, const char *mode); - int xpn_simple_fclose (FILE *stream); - size_t xpn_simple_fread (void *ptr, size_t size, size_t nmemb, FILE *stream); - size_t xpn_simple_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream); - int xpn_simple_fseek (FILE *stream, long offset, int whence); - long xpn_simple_ftell (FILE *stream); - int xpn_simple_fflush (FILE *stream); - - ssize_t xpn_sread (int fd, const void *buffer, size_t size, off_t offset); - ssize_t xpn_pread (int fd, void *buffer, size_t size, off_t offset); - ssize_t xpn_swrite (int fd, const void *buffer, size_t size, off_t offset); - ssize_t xpn_pwrite (int fd, const void *buffer, size_t size, off_t offset); - ssize_t xpn_reader (void *cookie, char *buffer, size_t size); - ssize_t xpn_writer (void *cookie, const char *buffer, size_t size); - //int xpn_seeker (void *cookie, fpos_t *position, int whence); - int xpn_seeker (void *cookie, __off64_t *position, int whence); - int xpn_cleaner (void *cookie); - int xpn_fgetc (FILE *flujo); - char *xpn_fgets (char *s, int tam, FILE *flujo); - int xpn_fgetc (FILE *flujo); - void xpn_rewind (FILE *stream); - int xpn_ferror (FILE *stream); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_client/xpn/xpn_simple/xpn_simple_lib.h b/include/xpn_client/xpn/xpn_simple/xpn_simple_lib.h deleted file mode 100644 index 3377c8037..000000000 --- a/include/xpn_client/xpn/xpn_simple/xpn_simple_lib.h +++ /dev/null @@ -1,46 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _XPN_SIMPLE_LIB_H_ -#define _XPN_SIMPLE_LIB_H_ - - /* ... Include / Inclusion ........................................... */ - - #include "xpn_policy_init.h" - #include "xpn_policy_rw.h" - #include "xpn_policy_opendir.h" - #include "xpn_policy_cwd.h" - #include "xpn_policy_open.h" - - #include "xpn_init.h" - #include "xpn_open.h" - #include "xpn_rw.h" - #include "xpn_cwd.h" - #include "xpn_file.h" - #include "xpn_opendir.h" - #include "xpn_dir.h" - #include "xpn_stdio.h" - - - /* ................................................................... */ - -#endif diff --git a/include/xpn_client/xpn/xpn_simple/xpn_stdio.h b/include/xpn_client/xpn/xpn_simple/xpn_stdio.h deleted file mode 100644 index 875ca5e86..000000000 --- a/include/xpn_client/xpn/xpn_simple/xpn_stdio.h +++ /dev/null @@ -1,87 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _XPN_STDIO_H -#define _XPN_STDIO_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "xpn.h" - #include "xpn_policy_cwd.h" - - #include - #include - #include - #include - #include - - #include - - #include - #include - #include - #include - - #include "xpn_open.h" - #include - - - /* ... Data structures / Estructuras de datos ........................ */ - - extern struct xpn_filedesc *xpn_file_table[XPN_MAX_FILE]; - - - /* ... Functions / Funciones ......................................... */ - - /************************************************************************/ - FILE *xpn_fopencookie(const char *path, const char *mode); - /************************************************************************/ - - FILE *xpn_simple_fopen (const char *filename, const char *mode); - int xpn_simple_fclose (FILE *stream); - size_t xpn_simple_fread (void *ptr, size_t size, size_t nmemb, FILE *stream); - size_t xpn_simple_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream); - - int xpn_simple_fgetc (FILE *stream); - char *xpn_simple_fgets (char *s, int tam, FILE *stream); - int xpn_simple_getc (FILE *stream); - int xpn_simple_fseek (FILE *stream, long offset, int whence); - long xpn_simple_ftell (FILE *stream); - void xpn_simple_rewind (FILE *stream); - int xpn_simple_fflush (FILE *stream); - int xpn_simple_fileno ( FILE *stream ); - int xpn_simple_ferror (FILE *stream); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_client/xpn_api_mutex.h b/include/xpn_client/xpn_api_mutex.h deleted file mode 100644 index 480c210af..000000000 --- a/include/xpn_client/xpn_api_mutex.h +++ /dev/null @@ -1,60 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -#ifndef _XPN_API_MUTEX_H -#define _XPN_API_MUTEX_H - - #ifdef __cplusplus - extern "C" { - #endif - - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - - - /* ... Macros / Macros ............................................... */ - - #ifdef _REENTRANT - - extern pthread_mutex_t xpn_api_mutex ; - - #define XPN_API_LOCK() pthread_mutex_lock(&xpn_api_mutex) - #define XPN_API_UNLOCK() pthread_mutex_unlock(&xpn_api_mutex) - - #else - - #define XPN_API_LOCK() (0) - #define XPN_API_UNLOCK() (0) - - #endif - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_server/mpi_server/mpi_server_comm.h b/include/xpn_server/mpi_server/mpi_server_comm.h deleted file mode 100644 index 47068a0bb..000000000 --- a/include/xpn_server/mpi_server/mpi_server_comm.h +++ /dev/null @@ -1,56 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _MPI_SERVER_COMM_H_ -#define _MPI_SERVER_COMM_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/utils.h" - #include "base/time_misc.h" - - - /* ... Functions / Funciones ......................................... */ - - int mpi_server_comm_init ( int argc, char *argv[], int thread_mode, char * port_name ); - int mpi_server_comm_destroy ( char * port_name ); - - int mpi_server_comm_accept ( char * port_name, MPI_Comm **new_sd ); - int mpi_server_comm_disconnect ( MPI_Comm *fd ); - - ssize_t mpi_server_comm_read_operation ( MPI_Comm *fd, int *op, int *rank_client_id, int *tag_client_id ); - ssize_t mpi_server_comm_write_data ( MPI_Comm *fd, char *data, ssize_t size, int rank_client_id, int tag_client_id ); - ssize_t mpi_server_comm_read_data ( MPI_Comm *fd, char *data, ssize_t size, int rank_client_id, int tag_client_id ); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/xpn_server/sck_server/mq_server_comm.h b/include/xpn_server/sck_server/mq_server_comm.h deleted file mode 100644 index 51812ca3d..000000000 --- a/include/xpn_server/sck_server/mq_server_comm.h +++ /dev/null @@ -1,58 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Elias Del Pozo Puñal, Alejandro Calderon Mateos, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _MQ_SERVER_COMM_H_ -#define _MQ_SERVER_COMM_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include - - #include "base/utils.h" - #include "socket.h" - #include "mq_server_utils.h" - #include "xpn_server/xpn_server_params.h" - - - /* ... Functions / Funciones ......................................... */ - - #ifdef HAVE_MOSQUITTO_H - void on_message( __attribute__((__unused__)) struct mosquitto * mqtt, void * obj, const struct mosquitto_message * msg) ; - #endif - - int mq_server_mqtt_init ( xpn_server_param_st * params ) ; - int mq_server_mqtt_destroy ( xpn_server_param_st * params ) ; - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_server/sck_server/mq_server_ops.h b/include/xpn_server/sck_server/mq_server_ops.h deleted file mode 100644 index 27e1a3f61..000000000 --- a/include/xpn_server/sck_server/mq_server_ops.h +++ /dev/null @@ -1,52 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Elias Del Pozo Puñal, Alejandro Calderon Mateos, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _MQ_SERVER_OPS_H_ -#define _MQ_SERVER_OPS_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/utils.h" - #include "mq_server_utils.h" - #include "xpn_server_params.h" - #include "xpn_server_ops.h" - - - /* ... Functions / Funciones ......................................... */ - - void mq_server_op_subscribe ( xpn_server_param_st *params, struct st_xpn_server_msg *head ) ; - void mq_server_op_unsubscribe ( xpn_server_param_st *params, struct st_xpn_server_msg *head ) ; - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_server/sck_server/mq_server_utils.h b/include/xpn_server/sck_server/mq_server_utils.h deleted file mode 100644 index e2c735bca..000000000 --- a/include/xpn_server/sck_server/mq_server_utils.h +++ /dev/null @@ -1,82 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Elias Del Pozo Puñal, Alejandro Calderon Mateos, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _MQ_SERVER_UTILS_H_ -#define _MQ_SERVER_UTILS_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include - #include "base/utils.h" - - - /* ... Const / Constantes ............................................ */ - - #define QUEUE_MQ_SIZE 1000000 - - - /* ... Data Types / Tipo de datos .................................... */ - - typedef struct - { - char * topic; - char * msg; - } - ThreadData; - - typedef struct - { - ThreadData * queue[QUEUE_MQ_SIZE]; - int front; - int rear; - int count; - pthread_mutex_t mutex; - pthread_cond_t not_empty; - pthread_cond_t not_full; - } - CircularQueueMQ; - - - /* ... Functions / Funciones ......................................... */ - - double get_time (void) ; - double get_time_ops ( void ) ; - - void queue_mq_init ( void ) ; - void enqueue_mq ( ThreadData * client ) ; - ThreadData * dequeue_mq ( void ) ; - - - /* ................................................................... */ - - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_server/sck_server/sck_server_comm.h b/include/xpn_server/sck_server/sck_server_comm.h deleted file mode 100644 index 58eeb73af..000000000 --- a/include/xpn_server/sck_server/sck_server_comm.h +++ /dev/null @@ -1,56 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _SCK_SERVER_COMM_H_ -#define _SCK_SERVER_COMM_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/utils.h" - #include "base/time_misc.h" - #include "xpn_server/xpn_server_params.h" - - - /* ... Functions / Funciones ......................................... */ - - int sck_server_comm_init ( int *socket, char *port_name, int ipv ); - int sck_ip4_server_comm_init ( int *socket, char *port_name ); - int sck_ip6_server_comm_init ( int *socket, char *port_name ); - int sck_server_comm_accept ( int socket, int **new_socket, int ipv ); - int sck_ip4_server_comm_accept ( int socket, int **new_socket ); - int sck_ip6_server_comm_accept ( int socket, int **new_socket ); - int sck_server_comm_disconnect ( int *socket ); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_server/xpn_server_comm.h b/include/xpn_server/xpn_server_comm.h deleted file mode 100644 index 98a9bef96..000000000 --- a/include/xpn_server/xpn_server_comm.h +++ /dev/null @@ -1,75 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _XPN_SERVER_COMM_H_ -#define _XPN_SERVER_COMM_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/utils.h" - #include "base/time_misc.h" - #include "base/ns.h" - #include "socket.h" - #include "xpn_server_params.h" - #include "sck_server_comm.h" - #include "mq_server_comm.h" - #include "mq_server_ops.h" -#ifdef ENABLE_MPI_SERVER - #include "mpi_server_comm.h" -#endif -#ifdef ENABLE_MPI_SERVER - #include "sck_server_comm.h" -#endif - - - /* ... Const / Const ................................................. */ - - // connection type - #define XPN_SERVER_CONNECTION 0 - #define XPN_SERVER_CONNECTIONLESS 1 - - - /* ... Functions / Funciones ......................................... */ - - int xpn_server_comm_init ( int server_type, xpn_server_param_st *params ); - int xpn_server_comm_destroy ( int server_type, xpn_server_param_st *params ); - - int xpn_server_comm_accept ( int server_type, xpn_server_param_st * params, int connection_type, void ** new_sd ); - int xpn_server_comm_disconnect ( int server_type, void *sd ); - - ssize_t xpn_server_comm_read_operation ( int server_type, void *sd, int *op, int *rank_client_id, int *tag_client_id ); - ssize_t xpn_server_comm_write_data ( int server_type, void *sd, char *data, ssize_t size, int rank_client_id, int tag_client_id ); - ssize_t xpn_server_comm_read_data ( int server_type, void *sd, char *data, ssize_t size, int rank_client_id, int tag_client_id ); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif diff --git a/include/xpn_server/xpn_server_ops.h b/include/xpn_server/xpn_server_ops.h deleted file mode 100644 index 723b58f81..000000000 --- a/include/xpn_server/xpn_server_ops.h +++ /dev/null @@ -1,321 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _XPN_SERVER_OPS_H_ -#define _XPN_SERVER_OPS_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/filesystem.h" - #include "base/urlstr.h" - #include "base/utils.h" - #include "base/workers.h" - #include "xpn_metadata.h" - #include - - - /* ... Const / Const ................................................. */ - - /* Operations */ - - // File operations - #define XPN_SERVER_OPEN_FILE 0 - #define XPN_SERVER_CREAT_FILE 1 - #define XPN_SERVER_READ_FILE 2 - #define XPN_SERVER_WRITE_FILE 3 - #define XPN_SERVER_CLOSE_FILE 4 - #define XPN_SERVER_RM_FILE 5 - #define XPN_SERVER_RM_FILE_ASYNC 6 - #define XPN_SERVER_RENAME_FILE 7 - #define XPN_SERVER_GETATTR_FILE 8 - #define XPN_SERVER_SETATTR_FILE 9 - - // Directory operations - #define XPN_SERVER_MKDIR_DIR 20 - #define XPN_SERVER_RMDIR_DIR 21 - #define XPN_SERVER_RMDIR_DIR_ASYNC 22 - #define XPN_SERVER_OPENDIR_DIR 23 - #define XPN_SERVER_READDIR_DIR 24 - #define XPN_SERVER_CLOSEDIR_DIR 25 - - // FS Operations - #define XPN_SERVER_STATFS_DIR 60 - - // Metadata - #define XPN_SERVER_READ_MDATA 70 - #define XPN_SERVER_WRITE_MDATA 71 - #define XPN_SERVER_WRITE_MDATA_FILE_SIZE 72 - - // Connection operatons - #define XPN_SERVER_FINALIZE 80 - #define XPN_SERVER_DISCONNECT 81 - #define XPN_SERVER_END -1 - - - /* ... Data structures / Estructuras de datos ........................ */ - - /* Message struct */ - - struct st_xpn_server_status - { - int ret; - int server_errno; - }; - - struct st_xpn_server_path_flags - { - int flags; - mode_t mode; - char xpn_session; - int file_type; // 0 - SCK_FILE; 1 - MQ_FILE; - char path[PATH_MAX]; - }; - - struct st_xpn_server_path { - char path[PATH_MAX]; - }; - - struct st_xpn_server_close - { - int fd; - int file_type; // 0 - SCK_FILE; 1 - MQ_FILE; - // - // interoperability - #if !defined(HAVE_64BITS) - uint64_t dir; - #else - DIR * dir; - #endif - - char path[PATH_MAX]; - }; - - struct st_xpn_server_rw - { - offset_t offset; - int fd; - int file_type; // 0 - SCK_FILE; 1 - MQ_FILE; - - // interoperability - #if!defined(HAVE_64BITS) - uint64_t size; - #else - size_t size; - #endif - - char xpn_session; - char path[PATH_MAX]; - }; - - struct st_xpn_server_rw_req - { - // interoperability - #if!defined(HAVE_64BITS) - uint64_t size; - #else - ssize_t size; - #endif - - char last; - struct st_xpn_server_status status; - }; - - struct st_xpn_server_rename - { - char old_url[PATH_MAX]; - char new_url[PATH_MAX]; - }; - - struct st_xpn_server_setattr - { - struct stat attr; - char path[PATH_MAX]; - }; - - struct st_xpn_server_attr_req - { - struct stat attr; - struct st_xpn_server_status status_req; - char status; - }; - - struct st_xpn_server_readdir - { - long telldir; - DIR * dir; - char xpn_session; - char path[PATH_MAX]; - }; - - struct st_xpn_server_opendir_req - { - DIR * dir; - struct st_xpn_server_status status; - }; - - struct st_xpn_server_readdir_req - { - int end; //If end = 1 exist entry; 0 not exist - long telldir; - struct dirent ret; - struct st_xpn_server_status status; - }; - - struct st_xpn_server_read_mdata_req - { - struct xpn_metadata mdata; - struct st_xpn_server_status status; - }; - - struct st_xpn_server_write_mdata - { - struct xpn_metadata mdata; - char path[PATH_MAX]; - }; - - struct st_xpn_server_write_mdata_file_size - { - // interoperability - #if!defined(HAVE_64BITS) - uint64_t size; - #else - ssize_t size; - #endif - - char path[PATH_MAX]; - }; - - struct st_xpn_server_end { - char status; - }; - - struct st_xpn_server_msg - { - int type; - union - { - struct st_xpn_server_path_flags op_open; - struct st_xpn_server_path_flags op_creat; - struct st_xpn_server_close op_close; - struct st_xpn_server_rw op_read; - struct st_xpn_server_rw op_write; - struct st_xpn_server_path op_rm; - struct st_xpn_server_rename op_rename; - struct st_xpn_server_path op_getattr; - struct st_xpn_server_setattr op_setattr; - - struct st_xpn_server_path_flags op_mkdir; - struct st_xpn_server_path_flags op_opendir; - struct st_xpn_server_readdir op_readdir; - struct st_xpn_server_close op_closedir; - struct st_xpn_server_path op_rmdir; - - struct st_xpn_server_path op_read_mdata; - struct st_xpn_server_write_mdata op_write_mdata; - struct st_xpn_server_write_mdata_file_size op_write_mdata_file_size; - - struct st_xpn_server_end op_end; - } - u_st_xpn_server_msg; - }; - - - /* ... Functions / Funciones ......................................... */ - - static inline - const char * xpn_server_op2string(int op_code) - { - switch (op_code) - { - // File operations - case XPN_SERVER_OPEN_FILE: - return "OPEN"; - case XPN_SERVER_CREAT_FILE: - return "CREAT"; - case XPN_SERVER_READ_FILE: - return "READ"; - case XPN_SERVER_WRITE_FILE: - return "WRITE"; - case XPN_SERVER_CLOSE_FILE: - return "CLOSE"; - case XPN_SERVER_RM_FILE: - return "RM"; - case XPN_SERVER_RM_FILE_ASYNC: - return "RM_ASYNC"; - case XPN_SERVER_RENAME_FILE: - return "RENAME"; - case XPN_SERVER_GETATTR_FILE: - return "GETATTR"; - case XPN_SERVER_SETATTR_FILE: - return "SETATTR"; - // Directory operations - case XPN_SERVER_MKDIR_DIR: - return "MKDIR"; - case XPN_SERVER_RMDIR_DIR: - return "RMDIR"; - case XPN_SERVER_RMDIR_DIR_ASYNC: - return "RMDIR_ASYNC"; - case XPN_SERVER_OPENDIR_DIR: - return "OPENDIR"; - case XPN_SERVER_READDIR_DIR: - return "READDIR"; - case XPN_SERVER_CLOSEDIR_DIR: - return "CLOSEDIR"; - // FS Operations - case XPN_SERVER_STATFS_DIR: - return "STATFS"; - case XPN_SERVER_FINALIZE: - return "FINALIZE"; - // Metadata - case XPN_SERVER_READ_MDATA: - return "READ_METADATA"; - case XPN_SERVER_WRITE_MDATA: - return "WRITE_METADATA"; - case XPN_SERVER_WRITE_MDATA_FILE_SIZE: - return "WRITE_METADATA_FILE_SIZE"; - // Connection operatons - case XPN_SERVER_DISCONNECT: - return "DISCONNECT"; - case XPN_SERVER_END: - return "END"; - default: - return "Unknown"; - } - } - - int xpn_server_do_operation ( int server_type, struct st_th * th, int * the_end ); - - - /* ................................................................... */ - - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/include/xpn_server/xpn_server_params.h b/include/xpn_server/xpn_server_params.h deleted file mode 100644 index aeb092c64..000000000 --- a/include/xpn_server/xpn_server_params.h +++ /dev/null @@ -1,97 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Dario Muñoz Muñoz - * - * 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 . - * - */ - - -#ifndef _XPN_SERVER_PARAMS_H_ -#define _XPN_SERVER_PARAMS_H_ - - #ifdef __cplusplus - extern "C" { - #endif - - /* ... Include / Inclusion ........................................... */ - - #include "all_system.h" - #include "base/utils.h" - #include "base/service_socket.h" - #include "base/workers.h" - #include "xpn_server_conf.h" - - - /* ... Data structures / Estructuras de datos ........................ */ - - typedef struct - { - // server identification - int size; - int rank; - - char port_name[MAX_PORT_NAME_LENGTH]; - char srv_name [MAX_PORT_NAME_LENGTH]; - - // server configuration - char shutdown_file[PATH_MAX]; - int thread_mode_connections; - int thread_mode_operations; - int server_type; // it can be XPN_SERVER_TYPE_MPI, XPN_SERVER_TYPE_SCK - - #ifdef ENABLE_SCK_SERVER - char port_name_conn[MAX_PORT_NAME_LENGTH]; - int server_socket; - char port_name_no_conn[MAX_PORT_NAME_LENGTH]; - int server_socket_no_conn; - #endif - - int await_stop; - - // server arguments - int argc; - char **argv; - - // MQTT configuration - int mosquitto_mode; - int mosquitto_qos; - - #ifdef HAVE_MOSQUITTO_H - struct mosquitto * mqtt; - #endif - - // IPv4 or IPv6 - int ipv; - - } xpn_server_param_st; - - - /* ... Functions / Funciones ......................................... */ - - void xpn_server_params_show_usage ( void ); - int xpn_server_params_get ( xpn_server_param_st *params, int argc, char *argv[] ); - void xpn_server_params_show ( xpn_server_param_st *params ); - - - /* ................................................................... */ - - #ifdef __cplusplus - } - #endif - -#endif - diff --git a/libs/lfi b/libs/lfi new file mode 160000 index 000000000..b19ce9811 --- /dev/null +++ b/libs/lfi @@ -0,0 +1 @@ +Subproject commit b19ce98117ee93d77f51263bf895573200c4ca61 diff --git a/scripts/compile/build-me-platform-watch.sh b/scripts/compile/build-me-platform-watch.sh new file mode 100755 index 000000000..07a1fc720 --- /dev/null +++ b/scripts/compile/build-me-platform-watch.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# shellcheck disable=all +#set -x + +# +# Copyright 2020-2024 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos +# +# 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 . +# + + +# Header +echo "" +echo " platform" +echo " --------" +echo "" + + +BASE_PATH=$(dirname $0) +PLATFORM_NAME=$1 +PLATFORMS_AVAILABLE=$(ls -1 ${BASE_PATH}/platform | tr -d '\n' | sed 's/.sh/ | /g' | sed 's/| $//g') + + +# Check arguments +if [ "$#" != 1 ]; then + echo "" + echo " Usage:" + echo " $0 " + echo " Where:" + echo " * platform = $PLATFORMS_AVAILABLE" + echo "" + exit +fi + +# Do request +echo " Begin." + +if [ ! -f ${BASE_PATH}/platform/$1.sh ]; then + echo "" + echo " ERROR: unknown platform '"$1"' :-(" + echo "" + echo " Available platforms are:" + echo " $PLATFORMS_AVAILABLE" + echo "" + exit +else + source ${BASE_PATH}/watch_dir.sh + + while true; do + ${BASE_PATH}/platform/$1.sh + + echo "------------------------------------------" + echo "Build completed, watching for file changes" + echo "------------------------------------------" + + watch_dir ${BASE_PATH}/../.. + done +fi + +# Stop +echo " End." diff --git a/scripts/compile/build-me-xpn.sh b/scripts/compile/build-me-xpn.sh index 0600d2b01..ce38e5d78 100755 --- a/scripts/compile/build-me-xpn.sh +++ b/scripts/compile/build-me-xpn.sh @@ -24,9 +24,10 @@ function usage { echo "" echo " Usage:" - echo " $0 -m -i " + echo " $0 -m -l -i " echo " Where:" echo " * = full path where the mpicc is installed." + echo " * = full path where the libfabric is installed." echo " * = full path where XPN is going to be installed." echo "" } @@ -43,12 +44,14 @@ echo " Begin." ## base path BASE_PATH="$(dirname "$(readlink -f "$0")")" - +LIBFABRIC_PATH="" ## get arguments -while getopts "m:i:" opt; do +while getopts "m:l:i:" opt; do case "${opt}" in m) MPICC_PATH=${OPTARG} ;; + l) LIBFABRIC_PATH=${OPTARG} + ;; i) INSTALL_PATH=${OPTARG} ;; *) echo " Error:" @@ -75,6 +78,11 @@ fi # 2) XPN and dependencies... -"$BASE_PATH"/software/xpn.sh -m "$MPICC_PATH" -i "$INSTALL_PATH" -s "$BASE_PATH"/../../../xpn +if [ "$LIBFABRIC_PATH" == "" ]; then + "$BASE_PATH"/software/xpn.sh -m "$MPICC_PATH" -i "$INSTALL_PATH" -s "$BASE_PATH"/../../../xpn +else + "$BASE_PATH"/software/xpn.sh -m "$MPICC_PATH" -l "$LIBFABRIC_PATH" -i "$INSTALL_PATH" -s "$BASE_PATH"/../../../xpn +fi + echo " End." diff --git a/scripts/compile/platform/c3-dario-dmtcp.sh b/scripts/compile/platform/c3-dario-dmtcp.sh new file mode 100755 index 000000000..bedc68df5 --- /dev/null +++ b/scripts/compile/platform/c3-dario-dmtcp.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# shellcheck disable=all +# set -x + +# +# Copyright 2020-2024 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos +# +# 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 . +# + + +# 1) software (if needed)... +#spack load openmpi +#spack load mpich +#spack load pkg-config +module load cmake mpich +spack load autoconf + +# 2) working path... +MPICC_PATH=/opt/ohpc/pub/mpi/mpich-4.3.0-ofi +FABRIC_PATH=$HOME/dariomnz/bin/libfabric +DMTCP_PATH=$HOME/dariomnz/src/mana/dmtcp +INSTALL_PATH=$HOME/dariomnz/bin/ +BASE_PATH=$(dirname $0) + +export LD_LIBRARY_PATH=$MPICC_PATH/lib:$FABRIC_PATH/lib:$LD_LIBRARY_PATH +export PATH=$MPICC_PATH/bin:$PATH + +# 3) preconfigure build-me... +$BASE_PATH/../software/xpn.sh -m $MPICC_PATH -f $FABRIC_PATH -i $INSTALL_PATH -s $BASE_PATH/../../../../xpn -d $DMTCP_PATH +# $BASE_PATH/../software/ior.sh -m $MPICC_PATH/bin/mpicc -i $INSTALL_PATH -s $BASE_PATH/../../../../ior +# $BASE_PATH/../software/lz4.sh -m $MPICC_PATH/bin/mpicc -i $INSTALL_PATH -s $BASE_PATH/../../../../io500/build/pfind/lz4/ +# $BASE_PATH/../software/io500.sh -m $MPICC_PATH/bin/mpicc -i $INSTALL_PATH -s $BASE_PATH/../../../../io500 diff --git a/scripts/compile/platform/c3-dario.sh b/scripts/compile/platform/c3-dario.sh new file mode 100755 index 000000000..00eeebf58 --- /dev/null +++ b/scripts/compile/platform/c3-dario.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# shellcheck disable=all +# set -x + +# +# Copyright 2020-2024 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos +# +# 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 . +# + + +# 1) software (if needed)... +#spack load openmpi +#spack load mpich +#spack load pkg-config +module load cmake mpich +spack load autoconf m4 + +# 2) working path... +MPICC_PATH=/opt/ohpc/pub/mpi/mpich-4.3.0-ofi +FABRIC_PATH=$HOME/dariomnz/bin/libfabric +INSTALL_PATH=$HOME/dariomnz/bin/ +BASE_PATH=$(dirname $0) + +export LD_LIBRARY_PATH=$MPICC_PATH/lib:$FABRIC_PATH/lib:$LD_LIBRARY_PATH +export PATH=$MPICC_PATH/bin:$PATH + +# 3) preconfigure build-me... +$BASE_PATH/../software/xpn.sh -m $MPICC_PATH -f $FABRIC_PATH -i $INSTALL_PATH -s $BASE_PATH/../../../../xpn +# $BASE_PATH/../software/ior.sh -m $MPICC_PATH/bin/mpicc -i $INSTALL_PATH -s $BASE_PATH/../../../../ior +# $BASE_PATH/../software/lz4.sh -m $MPICC_PATH/bin/mpicc -i $INSTALL_PATH -s $BASE_PATH/../../../../io500/build/pfind/lz4/ +# $BASE_PATH/../software/io500.sh -m $MPICC_PATH/bin/mpicc -i $INSTALL_PATH -s $BASE_PATH/../../../../io500 diff --git a/scripts/compile/platform/unito-dario.sh b/scripts/compile/platform/unito-dario.sh index f5fb0316f..16d31be4d 100755 --- a/scripts/compile/platform/unito-dario.sh +++ b/scripts/compile/platform/unito-dario.sh @@ -25,17 +25,23 @@ # 1) software (if needed)... #spack load openmpi #spack load mpich -spack load pkg-config +#spack load pkg-config # 2) working path... #MPICC_PATH=$HOME/opt/spack/linux-ubuntu20.04-zen/gcc-9.4.0/openmpi-4.1.3-4bpvwm3lcbftmjki6en35c4i5od6wjbr/bin/mpicc #MPICC_PATH=$HOME/opt/spack/linux-ubuntu20.04-zen/gcc-9.4.0/mpich-4.0.2-a76rmlxbneoqdvemzjsyewp2akiiuxlj/bin/mpicc -MPICC_PATH=$HOME/dariomnz/bin/mpich/bin/mpicc +# MPICC_PATH=$HOME/dariomnz/bin/mpich/bin/mpicc +MPICC_PATH=$HOME/dariomnz/bin/mpich-ch4-fabric +FABRIC_PATH=/opt/libfabric +FABRIC_PATH=$HOME/dariomnz/bin/libfabric-2.0.0 INSTALL_PATH=$HOME/dariomnz/bin/ BASE_PATH=$(dirname $0) +export LD_LIBRARY_PATH=$HOME/dariomnz/bin/mpich-ch4-fabric/lib:$HOME/dariomnz/bin/libfabric-2.0.0/lib:$LD_LIBRARY_PATH +export PATH=$HOME/dariomnz/bin/mpich-ch4-fabric/bin:$PATH + # 3) preconfigure build-me... - $BASE_PATH/../software/xpn.sh -m $MPICC_PATH -i $INSTALL_PATH -s $BASE_PATH/../../../../xpn - $BASE_PATH/../software/ior.sh -m $MPICC_PATH -i $INSTALL_PATH -s $BASE_PATH/../../../../ior +$BASE_PATH/../software/xpn.sh -m $MPICC_PATH -f $FABRIC_PATH -i $INSTALL_PATH -s $BASE_PATH/../../../../xpn +# $BASE_PATH/../software/ior.sh -m $MPICC_PATH/mpicc -i $INSTALL_PATH -s $BASE_PATH/../../../../ior # $BASE_PATH/../software/lz4.sh -m $MPICC_PATH -i $INSTALL_PATH -s $BASE_PATH/../../../../io500/build/pfind/lz4/ -# $BASE_PATH/../software/io500.sh -m $MPICC_PATH -i $INSTALL_PATH -s $BASE_PATH/../../../../io500 +# $BASE_PATH/../software/io500.sh -m $MPICC_PATH/mpicc -i $INSTALL_PATH -s $BASE_PATH/../../../../io500 diff --git a/scripts/compile/software/xpn.sh b/scripts/compile/software/xpn.sh index 4e6cf40b0..24d2a9e2f 100755 --- a/scripts/compile/software/xpn.sh +++ b/scripts/compile/software/xpn.sh @@ -1,5 +1,6 @@ #!/bin/bash -#set -x +# set -x +set -e # # Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos @@ -24,24 +25,30 @@ function usage { echo "" echo " Usage:" - echo " $0 -m -i -s " + echo " $0 -m -l -i -s -d " echo " Where:" echo " * = full path where the mpicc is installed." + echo " * = full path where the libfabric is installed." echo " * = full path where XPN is going to be installed." echo " * = full path to the source code XPN." + echo " * = full path to the source code of DMTCP." echo "" } - +LIBFABRIC_PATH="" ## get arguments -while getopts "m:i:s:" opt; do +while getopts "m:f:i:s:d:" opt; do case "${opt}" in - m) MPICC_PATH=${OPTARG} + m) MPICC_PATH="-D ENABLE_MPI_SERVER=${OPTARG}" + ;; + f) LIBFABRIC_PATH=${OPTARG} ;; i) INSTALL_PATH=${OPTARG} ;; s) SRC_PATH=${OPTARG} ;; + d) DMTCP_PATH="-D DMTCP_PATH=${OPTARG}" + ;; *) echo " Error:" echo " * Unknown option: ${opt}" usage @@ -78,19 +85,28 @@ fi ## XPN echo " * XPN: preparing directories..." - rm -fr "${INSTALL_PATH}/xpn" -mkdir -p "${INSTALL_PATH}/xpn/lib64" -ln -s "${INSTALL_PATH}/xpn/lib64" "${INSTALL_PATH}/xpn/lib" + +rm -fr "${INSTALL_PATH}/xpn" echo " * XPN: compiling and installing..." +echo " * XPN mpi: $MPICC_PATH" +echo " * XPN libfabric: $LIBFABRIC_PATH" pushd . cd "$SRC_PATH" -export CC=${MPICC_PATH} -export MPICC=${MPICC_PATH} -ACLOCAL_FLAGS="-I /usr/share/aclocal/" autoreconf -v -i -s -W all -./configure --prefix="${INSTALL_PATH}/xpn" --enable-sck_server --enable-mpi_server="${MPICC_PATH}" -make clean -make -j 8 -#doxygen doc/doxygen-XPN.cfg -make install +# rm -r build +mkdir -p build +cd build + +GENERATOR="Unix Makefiles" +if command -v ninja &> /dev/null +then + GENERATOR="Ninja" +fi + +cmake -S .. -B . -D BUILD_TESTS=ON -D CMAKE_INSTALL_PREFIX="${INSTALL_PATH}/xpn" $MPICC_PATH -D ENABLE_FABRIC_SERVER="${LIBFABRIC_PATH}" -G "${GENERATOR}" $DMTCP_PATH + +cmake --build . -j "$(nproc)" + +cmake --install . + popd diff --git a/scripts/compile/watch_dir.sh b/scripts/compile/watch_dir.sh new file mode 100755 index 000000000..9a4764a73 --- /dev/null +++ b/scripts/compile/watch_dir.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +# Declare variables to hold the states in memory +declare -g current_state="" +declare -g previous_state="" +watch_dir() { + # Check if directory argument is provided + if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 + fi + + directory="$1" + + # Function to compare states and display changes + compare_states() { + if [ -n "$previous_state" ]; then + diff <(echo "$previous_state") <(echo "$current_state") | while read line; do + if [[ "$line" == "<"* ]]; then + echo "File modified: ${line:2}" + return 1 # Indicate changes found + elif [[ "$line" == ">"* ]]; then + echo "File added: ${line:2}" + return 1 # Indicate changes found + fi + done + if [ $? -eq "1" ]; then + return 0 # Indicate changes found + else + return 1 # Indicate no changes found + fi + else + return 1 # Indicate no changes found (first run) + fi + } + + # Main loop + while true; do + # start_time=$(date +%s.%N) + # Get current state of files and store in memory + current_state=$(find "$directory" -type f -not -path "*../build/*" -printf "%p %s %T+\n") + + # Compare states and display changes + compare_states + ret=$? + + # end_time=$(date +%s.%N) + # duration=$(echo "$end_time - $start_time" | bc) + # echo "Iteration took $duration seconds." + if [ $ret -eq "1" ]; then + sleep 2 # Wait 2 seconds before next check + else + echo "Changes detected. Exiting..." + previous_state="$current_state" # Move current state to previous state + break # Exit the loop + fi + + # Move current state to previous state + previous_state="$current_state" + done +} \ No newline at end of file diff --git a/scripts/dev-build.sh b/scripts/dev-build.sh new file mode 100755 index 000000000..0039091ad --- /dev/null +++ b/scripts/dev-build.sh @@ -0,0 +1,66 @@ + +set -x +set -e + +# intended usage from xpn root dir +# time ./scripts/dev-build.sh $(pwd)/build $(pwd)/install +if [ "$#" -ne 2 ]; then + echo "Usage: $0 " + exit 1 +fi + +cd $1 + +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$2/lib + +cmake -S .. -B . \ + -D BUILD_TESTS=true \ + -D CMAKE_INSTALL_PREFIX=$2 \ + -D CMAKE_C_COMPILER=gcc \ + -D CMAKE_CXX_COMPILER=g++ \ + -D ENABLE_MPI_SERVER=on \ + -D MPI_INCLUDE_DIR=/usr/include/x86_64-linux-gnu/mpich \ + -D ENABLE_FABRIC_SERVER=on \ + -D ENABLE_FUSE=on \ + -D ENABLE_MQTT_SERVER=on + +# cmake -S .. -B . \ +# -D BUILD_TESTS=true \ +# -D CMAKE_INSTALL_PREFIX=$2 \ +# -D CMAKE_C_COMPILER=gcc \ +# -D CMAKE_CXX_COMPILER=g++ \ +# -D ENABLE_MPI_SERVER=off \ +# -D ENABLE_FABRIC_SERVER=off \ +# -D ENABLE_MQ_SERVER=/usr/lib/x86_64-linux-gnu + +# cmake -S .. -B . \ +# -D BUILD_TESTS=true \ +# -D CMAKE_INSTALL_PREFIX=$2 \ +# -D CMAKE_C_COMPILER=gcc \ +# -D CMAKE_CXX_COMPILER=g++ \ +# -D ENABLE_MPI_SERVER=off \ +# -D ENABLE_FABRIC_SERVER=/home/lab/bin/libfabric \ +# -D ENABLE_MQ_SERVER=/usr/lib/x86_64-linux-gnu + +# cmake -S .. -B . \ +# -D BUILD_TESTS=true \ +# -D CMAKE_INSTALL_PREFIX=$2 \ +# -D CMAKE_C_COMPILER=gcc \ +# -D CMAKE_CXX_COMPILER=g++ \ +# -D ENABLE_MPI_SERVER=/usr/lib/x86_64-linux-gnu/mpich \ +# -D ENABLE_FABRIC_SERVER=/home/lab/bin/libfabric \ +# -D ENABLE_MQ_SERVER=/usr/lib/x86_64-linux-gnu + +# cmake -S .. -B . \ +# -D BUILD_TESTS=true \ +# -D CMAKE_INSTALL_PREFIX=$2 \ +# -D CMAKE_C_COMPILER=mpicc \ +# -D CMAKE_CXX_COMPILER=mpic++ \ +# -D ENABLE_MPI_SERVER=/usr/lib/x86_64-linux-gnu/mpich \ +# -D ENABLE_FABRIC_SERVER=off \ +# -D ENABLE_MQ_SERVER=/usr/lib/x86_64-linux-gnu +cmake --build . -j $(nproc) + +cmake --install . + +ctest \ No newline at end of file diff --git a/scripts/execute/mk_conf.sh b/scripts/execute/mk_conf.sh index 7d6215850..c8f65dc39 100755 --- a/scripts/execute/mk_conf.sh +++ b/scripts/execute/mk_conf.sh @@ -120,9 +120,10 @@ check_opts() { mk_conf_file_from_args() { echo "[partition]" > ${CONFNAME} - echo "bsize = ${XPN_PARTITION_BSIZE}" >> ${CONFNAME} - echo "replication_level = ${XPN_REPLICATION_LEVEL}" >> ${CONFNAME} - echo "partition_name = ${XPN_PARTITION_NAME}" >> ${CONFNAME} + echo "bsize = ${XPN_PARTITION_BSIZE}" >> ${CONFNAME} + echo "replication_level = ${XPN_REPLICATION_LEVEL}" >> ${CONFNAME} + echo "partition_name = ${XPN_PARTITION_NAME}" >> ${CONFNAME} + echo "controler_url = $(hostname)" >> ${CONFNAME} ITER=1 while read line diff --git a/scripts/execute/xpn.sh b/scripts/execute/xpn.sh index 2215b3956..4ca1ceb0a 100755 --- a/scripts/execute/xpn.sh +++ b/scripts/execute/xpn.sh @@ -97,7 +97,7 @@ start_xpn_servers() { if command -v srun &> /dev/null then # Create dir - srun -n "${NODE_NUM}" -N "${NODE_NUM}" \ + srun -n "${NODE_NUM}" -N "${NODE_NUM}" \ -w "${HOSTFILE}" \ mkdir -p ${XPN_STORAGE_PATH} @@ -105,7 +105,7 @@ start_xpn_servers() { srun -n "${NODE_NUM}" -N "${NODE_NUM}"\ -w "${HOSTFILE}" \ --export=ALL \ - "${BASE_DIR}"/../../src/xpn_server/xpn_server -s ${SERVER_TYPE} -t 1 "${ARGS}" & + "${BASE_DIR_BUILD}"/xpn_server/xpn_server -s ${SERVER_TYPE} -t pool "${ARGS}" & elif [[ ${SERVER_TYPE} == "mq" ]]; then srun -n "${NODE_NUM}" -N "${NODE_NUM}"\ -w "${HOSTFILE}" \ @@ -115,12 +115,12 @@ start_xpn_servers() { srun -n "${NODE_NUM}" -N "${NODE_NUM}"\ -w "${HOSTFILE}" \ --export=ALL \ - "${BASE_DIR}"/../../src/xpn_server/xpn_server -m 0 -t pool -s "sck" "${ARGS}" & + "${BASE_DIR_BUILD}"/xpn_server/xpn_server -m 0 -t pool -s "sck" "${ARGS}" & else - srun -n "${NODE_NUM}" -N "${NODE_NUM}" --mpi=none \ + srun -n "${NODE_NUM}" -N "${NODE_NUM}" --mpi=none \ -w "${HOSTFILE}" \ --export=ALL \ - "${BASE_DIR}"/../../src/xpn_server/xpn_server -s ${SERVER_TYPE} "${ARGS}" & + "${BASE_DIR_BUILD}"/xpn_server/xpn_server -s ${SERVER_TYPE} "${ARGS}" & fi else @@ -129,10 +129,10 @@ start_xpn_servers() { -hostfile "${HOSTFILE}" \ mkdir -p ${XPN_STORAGE_PATH} - if [[ ${SERVER_TYPE} == "sck" ]]; then + if [[ ${SERVER_TYPE} == "sck" || ${SERVER_TYPE} == "fabric" ]]; then mpiexec -np "${NODE_NUM}" \ -hostfile "${HOSTFILE}" \ - "${BASE_DIR}"/../../src/xpn_server/xpn_server -s ${SERVER_TYPE} -t pool "${ARGS}" & + "${BASE_DIR_BUILD}"/xpn_server/xpn_server -s ${SERVER_TYPE} -t pool "${ARGS}" & elif [[ ${SERVER_TYPE} == "mq" ]]; then mpiexec -np "${NODE_NUM}" \ -hostfile "${HOSTFILE}" \ @@ -140,14 +140,14 @@ start_xpn_servers() { sleep 2 mpiexec -np "${NODE_NUM}" \ -hostfile "${HOSTFILE}" \ - "${BASE_DIR}"/../../src/xpn_server/xpn_server -m 0 -t 1 -s "sck" "${ARGS}" & + "${BASE_DIR_BUILD}"/xpn_server/xpn_server -m 0 -t 1 -s "sck" "${ARGS}" & else for ((i=1; i<=$NODE_NUM; i++)) do line=$(head -n $i "$HOSTFILE" | tail -n 1) mpiexec -np 1 \ -host "${line}" \ - ${BASE_DIR}/../../src/xpn_server/xpn_server -s ${SERVER_TYPE} -t pool ${ARGS} & + "${BASE_DIR_BUILD}"/xpn_server/xpn_server -s ${SERVER_TYPE} -t pool ${ARGS} & done fi fi @@ -179,10 +179,10 @@ stop_xpn_servers() { if command -v srun &> /dev/null then srun -n 1 -N 1 \ - "${BASE_DIR}"/../../src/xpn_server/xpn_stop_server -s ${SERVER_TYPE} -f ${DEATH_FILE} + "${BASE_DIR_BUILD}"/xpn_server/xpn_stop_server -s ${SERVER_TYPE} -f ${DEATH_FILE} else mpiexec -np 1 \ - "${BASE_DIR}"/../../src/xpn_server/xpn_stop_server -s ${SERVER_TYPE} -f ${DEATH_FILE} + "${BASE_DIR_BUILD}"/xpn_server/xpn_stop_server -s ${SERVER_TYPE} -f ${DEATH_FILE} fi } @@ -196,10 +196,10 @@ await_stop_xpn_servers() { if command -v srun &> /dev/null then srun -n 1 -N 1 \ - "${BASE_DIR}"/../../src/xpn_server/xpn_stop_server -s ${SERVER_TYPE} -f ${DEATH_FILE} -w + "${BASE_DIR_BUILD}"/xpn_server/xpn_stop_server -s ${SERVER_TYPE} -f ${DEATH_FILE} -w else mpiexec -np 1 \ - "${BASE_DIR}"/../../src/xpn_server/xpn_stop_server -s ${SERVER_TYPE} -f ${DEATH_FILE} -w + "${BASE_DIR_BUILD}"/xpn_server/xpn_stop_server -s ${SERVER_TYPE} -f ${DEATH_FILE} -w fi } @@ -232,11 +232,11 @@ rebuild_xpn_servers() { if command -v srun &> /dev/null then # Create dir - srun -n "${NODE_NUM}" -N "${NODE_NUM}" \ + srun -n "${NODE_NUM}" -N "${NODE_NUM}" \ -w "${HOSTFILE}" \ mkdir -p ${XPN_STORAGE_PATH} hosts=$(cat ${DEATH_FILE} ${REBUILD_FILE} | sort | paste -sd "," -) - srun -n "${NODE_NUM_SUM}" \ + srun -n "${NODE_NUM_SUM}" \ -w "${hosts}" \ "${BASE_DIR}"/../../src/utils/xpn_rebuild_active_writer "${XPN_STORAGE_PATH}" "${DEATH_FILE}" "${REBUILD_FILE}" 524288 "${XPN_REPLICATION_LEVEL}" else @@ -262,7 +262,7 @@ preload_xpn() { # 1. Copy if command -v srun &> /dev/null then - srun -n "${NODE_NUM}" -N "${NODE_NUM}" \ + srun -n "${NODE_NUM}" -N "${NODE_NUM}" \ -w "${HOSTFILE}" \ "${BASE_DIR}"/../../src/utils/xpn_preload "${SOURCE_PATH}" "${XPN_STORAGE_PATH}" 524288 "${XPN_REPLICATION_LEVEL}" else @@ -282,7 +282,7 @@ flush_xpn() { # 1. Copy if command -v srun &> /dev/null then - srun -n "${NODE_NUM}" -N "${NODE_NUM}" \ + srun -n "${NODE_NUM}" -N "${NODE_NUM}" \ -w "${HOSTFILE}" \ "${BASE_DIR}"/../../src/utils/xpn_flush "${XPN_STORAGE_PATH}" "${DEST_PATH}" 524288 "${XPN_REPLICATION_LEVEL}" else @@ -304,7 +304,7 @@ expand_xpn() { # 1. Copy if command -v srun &> /dev/null then - srun -n "${NODE_NUM}" -N "${NODE_NUM}" \ + srun -n "${NODE_NUM}" -N "${NODE_NUM}" \ -w "${HOSTFILE}" \ "${BASE_DIR}"/../../src/utils/xpn_expand "${XPN_STORAGE_PATH}" "${NODE_NUM_REST}" else @@ -334,7 +334,7 @@ shrink_xpn() { # 1. Copy if command -v srun &> /dev/null then - srun -n "${NODE_NUM}" -N "${NODE_NUM}" \ + srun -n "${NODE_NUM}" -N "${NODE_NUM}" \ -w "${HOSTFILE}" \ "${BASE_DIR}"/../../src/utils/xpn_shrink "${XPN_STORAGE_PATH}" "${hostlist}" else @@ -375,7 +375,7 @@ usage_details() { echo "" echo " optional arguments:" echo " -h, --help Shows this help message and exits" - echo " -e, --execute Server type: mpi, sck or tcp." + echo " -S, --server_type Server type: mpi, sck or tcp." echo " -a, --args Add various additional daemon arguments." echo " -f, --foreground Starts the script in the foreground. Daemons are stopped by pressing 'q'." echo " -c, --config Path to configuration file." @@ -398,14 +398,14 @@ usage_details() { get_opts() { # Taken the general idea from https://stackoverflow.com/questions/70951038/how-to-use-getopt-long-option-in-bash-script mkconf_name=$(basename "$0") - mkconf_short_opt=e:r:w:s:t:x:d:k:p:n:a:c:m:l:o:q:b:fvh - mkconf_long_opt=execute:,rootdir:,workdir:,source_path:,destination_path:,xpn_storage_path:,numnodes:,args:,config:,deployment_file:,foreground_file,hostfile:,deathfile:,rebuildfile:,host:,replication_level:,block_size:,mqtt_conf_file:,verbose,help + mkconf_short_opt=S:r:w:s:t:x:d:k:p:n:a:c:m:l:o:q:b:fvh + mkconf_long_opt=server_type:,rootdir:,workdir:,source_path:,destination_path:,xpn_storage_path:,numnodes:,args:,config:,deployment_file:,foreground_file,hostfile:,deathfile:,rebuildfile:,host:,replication_level:,block_size:,mqtt_conf_file:,verbose,help TEMP=$(getopt -o $mkconf_short_opt --long $mkconf_long_opt --name "$mkconf_name" -- "$@") eval set -- "${TEMP}" while :; do case "${1}" in - -e | --execute ) SERVER_TYPE=$2; shift 2 ;; + -S | --server_type ) SERVER_TYPE=$2; shift 2 ;; -r | --rootdir ) DIR_ROOT=$2; shift 2 ;; -w | --workdir ) WORKDIR=$2; shift 2 ;; -s | --source_path ) SOURCE_PATH=$2; shift 2 ;; diff --git a/src/base/Makefile.am b/src/base/Makefile.am deleted file mode 100644 index 7cc633682..000000000 --- a/src/base/Makefile.am +++ /dev/null @@ -1,67 +0,0 @@ - -############# -# BASE # -############# - -BASE_HEADER= @top_srcdir@/include/base/base_lib.h \ - @top_srcdir@/include/base/darray.h \ - @top_srcdir@/include/base/debug_msg.h \ - @top_srcdir@/include/base/debug_tags.h \ - @top_srcdir@/include/base/dtable.h \ - @top_srcdir@/include/base/math_misc.h \ - @top_srcdir@/include/base/string_misc.h \ - @top_srcdir@/include/base/path_misc.h \ - @top_srcdir@/include/base/time_misc.h \ - @top_srcdir@/include/base/trace_msg.h \ - @top_srcdir@/include/base/trace_tags.h \ - @top_srcdir@/include/base/urlstr.h \ - @top_srcdir@/include/base/ns.h \ - @top_srcdir@/include/base/socket.h \ - @top_srcdir@/include/base/socket_ip4.h \ - @top_srcdir@/include/base/socket_ip6.h \ - @top_srcdir@/include/base/service_socket.h \ - @top_srcdir@/include/base/syscall_proxies.h \ - @top_srcdir@/include/base/filesystem.h \ - @top_srcdir@/include/base/workers.h \ - @top_srcdir@/include/base/workers_ondemand.h \ - @top_srcdir@/include/base/workers_pool.h\ - @top_srcdir@/include/base/utils.h - -BASE_SOURCE= @top_srcdir@/src/base/darray.c \ - @top_srcdir@/src/base/dtable.c \ - @top_srcdir@/src/base/math_misc.c \ - @top_srcdir@/src/base/trace_msg.c \ - @top_srcdir@/src/base/debug_msg.c \ - @top_srcdir@/src/base/string_misc.c \ - @top_srcdir@/src/base/path_misc.c \ - @top_srcdir@/src/base/time_misc.c \ - @top_srcdir@/src/base/urlstr.c \ - @top_srcdir@/src/base/ns.c \ - @top_srcdir@/src/base/socket.c \ - @top_srcdir@/src/base/socket_ip4.c \ - @top_srcdir@/src/base/socket_ip6.c \ - @top_srcdir@/src/base/service_socket.c \ - @top_srcdir@/src/base/syscall_proxies.c \ - @top_srcdir@/src/base/filesystem.c \ - @top_srcdir@/src/base/workers.c \ - @top_srcdir@/src/base/workers_ondemand.c \ - @top_srcdir@/src/base/workers_pool.c \ - @top_srcdir@/src/base/utils.c - - -############# -# LIBRARIES # -############# - -OBJEXT = o -lib_LIBRARIES = libbase.a -libbase_a_SOURCES = $(BASE_SOURCE) - -nobase_includedir = $(includedir)/base -nobase_include_HEADERS = $(BASE_HEADER) - -install-data-hook: - mkdir -p $(includedir) - [ -d $(includedir)/../../include ] && cp -a $(includedir)/../../include/* $(includedir)/ - [ -d $(includedir)/../../include ] && rm -fr $(includedir)/../../include - diff --git a/src/base/darray.c b/src/base/darray.c deleted file mode 100644 index 44913555a..000000000 --- a/src/base/darray.c +++ /dev/null @@ -1,475 +0,0 @@ - -/* - * Copyright 2020-2025 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 . - * - */ - - - /* ... Include / Inclusion ........................................... */ - - #include "base/darray.h" - - - /* ... Functions / Funciones ......................................... */ - - /** - * Insert the element 'gptr' into the end of the dynamic array '*t' - * that allready has '*n' elements. - * @param t a dynamic array. - * @param n number of elements in the dynamic array. - * @param gptr the element that has been inserted. - * @return true (1) if element is inserted and error (-1) if - * a problem is found. - * @see 'DARRAY_InsEndDarray2' if dynamic array is NULL terminated. - */ - int8_t DARRAY_InsEndDarray ( /*INOUT*/ t_pointerDArray *t, - /*INOUT*/ long *n, - /*IN*/ T_POINTER gptr ) - { - /* check params */ - if (NULL == n) - return (-1); - - /* Insert into the End of Darray */ - if ( (*t)==(t_pointerDArray)NULL ) - { - (*t) = (t_pointerDArray) malloc (2*c_POINTER) ; - if (NULL==(*t)) - return (-1); - - (*n) = 1 ; - (*t)[0] = gptr ; - (*t)[1] = (T_POINTER)NULL ; - } - else /* ( (*t) != (t_pointerDArray)NULL ) */ - { - t_pointerDArray taux ; - - (*n)++ ; - taux=(t_pointerDArray) realloc((*t),((*n)+1)*c_POINTER) ; - if (NULL==taux) - return (-1); - - (*t)=taux ; - taux[(*n)]=(T_POINTER)NULL ; - taux[(*n)-1]=gptr ; - } - - /* return ok */ - return (1) ; - } - - /** - * Remove the last element from the dynamic array '*t' of - * '*n' elements and return that element in '*delGPtr'. - * @param t a dynamic array. - * @param n number of elements in the dynamic array. - * @param delGPtr element that has been removed. - * @return true (1) if element is removed and error (-1) if - * a problem is found. - * @see 'DARRAY_DelBeginDarray' to remove the first element. - */ - int8_t DARRAY_DelEndDarray ( /*INOUT*/ t_pointerDArray *t, - /*INOUT*/ long *n, - /*INOUT*/ T_POINTER *delGPtr ) - { - /* check params */ - if (NULL == t) - return (-1); - if (NULL == (*t)) - return (-1); - if (NULL == n) - return (-1); - - /* DelEndDarray */ - if ((*n)!=0) - { - (*n)-- ; - (*delGPtr)=(*t)[(*n)] ; - (*t)[(*n)]=(T_POINTER)NULL ; - (*t)=(t_pointerDArray)realloc(*t,((*n)+1)*c_POINTER) ; - } - if ((*n)==0) - { - free(*t) ; - (*t)=(t_pointerDArray)(T_POINTER)NULL; - } - - /* return ok */ - return (1) ; - } - - /** - * Remove the first element from the dynamic array '*t' of - * '*n' elements and return that element in '*delGPtr'. - * @param t a dynamic array. - * @param n number of elements in the dynamic array. - * @param delGPtr element that has been removed. - * @return true (1) if element is removed and error (-1) if - * a problem is found. - * @see 'DARRAY_DelEndDarray' to remove the last element. - */ - int8_t DARRAY_DelBeginDarray ( /*INOUT*/ t_pointerDArray *t, - /*INOUT*/ long *n, - /*INOUT*/ T_POINTER *delGPtr ) - { - /* check params */ - if (NULL == t) - return (-1); - if (NULL == (*t)) - return (-1); - if (NULL == n) - return (-1); - - /* DelBeginDarray */ - if ((*n)!=0) - { - (*n)-- ; - (*delGPtr)=(*t)[0] ; - memmove( &((*t)[0]), - &((*t)[1]), - (*n)*c_POINTER ) ; - (*t)[(*n)]=(T_POINTER)NULL ; - (*t)=(t_pointerDArray)realloc(*t,((*n)+1)*c_POINTER) ; - - } - if ((*n)==0) - { - free(*t) ; - (*t)=NULL ; - } - - /* return ok */ - return (1) ; - } - - /** - * Remove the 'orden'th element from the dynamic array '*t' of - * '*n' elements and return that element in '*delGPtr'. - * @param t a dynamic array. - * @param n number of elements in the dynamic array. - * @param orden position (begin at 0) of element to remove. - * @param delGPtr element that has been removed. - * @return true (1) if element is removed and error (-1) if - * a problem is found. - * @see 'DARRAY_DelBeginDarray' to remove first element. - */ - int8_t DARRAY_DelNFromDarray ( /*IN*/ t_pointerDArray *t, - /*INOUT*/ long *n, - /*IN*/ long orden, - /*INOUT*/ T_POINTER *delGPtr ) - { - /* check params */ - if (NULL == t) - return (-1); - if (NULL == (*t)) - return (-1); - if (NULL == n) - return (-1); - if (orden>(*n)) - return (-1); - - /* _DelNFromDarray */ - if ((*n)!=0) - { - (*delGPtr)=(*t)[orden] ; - memmove( &((*t)[orden]), - &((*t)[orden+1]), - ((*n)-orden+1)*c_POINTER ) ; - (*n)-- ; - (*t)=(t_pointerDArray)realloc(*t,((*n)+1)*c_POINTER) ; - } - if ((*n)==0) - { - free(*t) ; - (*t) = NULL ; - } - - /* return ok */ - return (1) ; - } - - /** - * Change the value of 'orden'th element from the dynamic array '*t' of - * '*n' elements with value 'nPtr'. - * @param t a dynamic array. - * @param n number of elements in the dynamic array. - * @param orden position (begin at 0) of element to be changed. - * @param nPtr element that has been changed. - * @return true (1) if element is changed and error (-1) if - * a problem is found. - */ - int8_t DARRAY_ChangeNFromDarray ( /*IN*/ t_pointerDArray *t, - /*INOUT*/ long *n, - /*IN*/ long orden, - /*INOUT*/ T_POINTER nPtr ) - { - /* check params */ - if (NULL == t) - return (-1); - if (NULL == (*t)) - return (-1); - if (NULL == n) - return (-1); - if (orden>(*n)) - return (-1); - - /* ChangeNFromDarray */ - (*t)[orden] = nPtr ; - - /* return ok */ - return (1) ; - } - - /** - * Remove all '*n' elements from the dynamic array '*t' by using - * '*freef' function on each one. - * @param t a dynamic array. - * @param n number of elements in the dynamic array. - * @param freef the free function to be used. - * @return true (1) if elements are freeded and error (-1) if - * a problem is found. - */ - int8_t DARRAY_FreeEltosDarray ( /*INOUT*/ t_pointerDArray *t, - /*INOUT*/ long *n, - /*IN*/ void (*freef)(T_POINTER) ) - { - /* check params */ - if (NULL == t) - return (-1); - if (NULL == n) - return (-1); - - /* FreeEltosDarray */ - if ((*t)!=NULL) - { - long i ; - - for (i=0; (*t)[i]; i++) - { - freef( (*t)[i] ) ; - } - free(*t) ; - (*t) = NULL ; - } - (*n) = 0L ; - - /* return ok */ - return (1) ; - } - - /** - * Execute '*findf' function with 'gptr' as one parameter - * and i-th element as the other parameter, for all '*n' elements - * at the dynamic array '*t'. - * @param t a dynamic array. - * @param n number of elements in the dynamic array. - * @param gptr element for first param to 'findf'. - * @param findf function to be used to compare i-th element and 'gptr'. - * @return the element to be find or NULL. - */ - T_POINTER DARRAY_FindEltoDarray ( /*IN*/ t_pointerDArray t, - /*INOUT*/ long n, - /*IN*/ T_POINTER gptr, - /*IN*/ int8_t (*findf)(T_POINTER,T_POINTER) ) - { - long i ; - - /* FindEltoDarray */ - for (i=0; i. - * - */ - - -/* ... Include / Inclusion ........................................... */ - - #include "base/debug_msg.h" - - -/* ... Global variables / Variables globales ........................ */ - - int (*DEBUG_MSG_PrintMsg)(const char *, va_list) = NULL; - - -/* ... Functions / Funciones ......................................... */ - -// Debug API -void debug_msg_init ( void ) -{ - setbuf(stdout, NULL); - setbuf(stderr, NULL); -} - -int debug_msg_printf ( int src_type, char *src_fname, long src_line, FILE *fd, char *msg_fmt, ... ) -{ - va_list valist; - int ret; - - va_start(valist, msg_fmt); - switch (src_type) - { - case 3: - fprintf(fd, "[%s:%4ld] [INFO] ", src_fname, src_line); - ret = vfprintf(fd, msg_fmt, valist); - break; - - case 2: - fprintf(fd, "[%s:%4ld] [WARN] ", src_fname, src_line); - ret = vfprintf(fd, msg_fmt, valist); - break; - - case 1: - fprintf(fd, "[%s:%4ld] [ERROR] ", src_fname, src_line); - ret = vfprintf(fd, msg_fmt, valist); - break; - - default: - ret = vfprintf(fd, msg_fmt, valist); - break; - } - va_end(valist); - - //fflush(fd); - - return ret; -} - -// Extra Debug API -void DEBUG_MSG_setPrinter ( int (*printer) (const char *, va_list) ) -{ - DEBUG_MSG_PrintMsg = ( int (*)(const char *, va_list)) printer; -} - -void DEBUG_MSG_doPrint ( char *fto, ... ) -{ - if (DEBUG_MSG_PrintMsg != NULL) - { - va_list vl; - - va_start(vl,fto); - (*DEBUG_MSG_PrintMsg)(fto,vl); - va_end(vl); - } -} - -void DEBUG_MSG_VPrintF ( int line, char *name, long pid, int type, char *fto, va_list vl ) -{ - if (DEBUG_MSG_PrintMsg != NULL) - { - char *msg; - - msg = STRING_MISC_Dvsprintf(fto,vl); - DEBUG_MSG_doPrint("trace(%i,\"%s\",%li,%i,\"%s\").", line, name, pid, type, msg); - free(msg); - } -} - -void DEBUG_MSG_PrintF ( int line, char *name, long pid, int type, char *fto, ... ) -{ - if (DEBUG_MSG_PrintMsg != NULL) - { - va_list vl; - - va_start(vl,fto); - DEBUG_MSG_VPrintF(line,name,pid,type,fto,vl); - va_end(vl); - } -} - - -/* ................................................................... */ - diff --git a/src/base/dtable.c b/src/base/dtable.c deleted file mode 100644 index 731f10e2d..000000000 --- a/src/base/dtable.c +++ /dev/null @@ -1,149 +0,0 @@ - -/* - * Copyright 2020-2025 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 . - * - */ - - - /* ... Include / Inclusion ........................................... */ - - #include "base/dtable.h" - - - /* ... Functions / Funciones ......................................... */ - - /** - * Insert the element 'dt_info' into 'dt' dynamic table. - * @param dt a dynamic table. - * @param dt_info the element to be inserted. - * @return true (1) if element is inserted and error (-1) if - * a problem is found. - */ - int dtable_insert - ( - /*INOUT*/ dtable_t *dt, - /*IN*/ void *dt_info - ) - { - int8_t ret ; - dtelto_t *dtelto_aux ; - - /* check params */ - if (NULL == dt) - return (-1) ; - if (NULL == dt_info) - return (-1) ; - - /* insert element */ - if ((-1) == dt->free_list) - { - /* alloc a new element */ - dtelto_aux = (dtelto_t *)malloc(sizeof(dtelto_t)) ; - if (NULL == dtelto_aux) - { - return (-1) ; - } - - ret = DARRAY_InsEndDarray(&(dt->dtable), - &(dt->neltos), - dtelto_aux) ; - if (0 == ret) - { - free(dtelto_aux) ; - return (-1) ; - } - - dtelto_aux->dt_info = dt_info ; - dtelto_aux->myself = (dt->neltos) - 1 ; - dtelto_aux->next_free = (-1) ; - } - else - { - dtelto_aux = (dtelto_t *)DARRAY_GetNFromDarray(dt->dtable, - dt->free_list) ; - dt->free_list = dtelto_aux->next_free ; - - dtelto_aux->dt_info = dt_info ; - dtelto_aux->next_free = (-1) ; - } - - /* return index of this element */ - return dtelto_aux->myself ; - } - - /** - * Remove the element at 'fd' position into 'dt' dynamic table. - * @param dt a dynamic table. - * @param fd the element descriptor. - * @return true (1) if element is removed and error (-1) if - * a problem is found. - */ - int dtable_delete - ( - /*INOUT*/ dtable_t *dt, - /*IN*/ int fd - ) - { - dtelto_t *dtelto_aux ; - - /* check params */ - if (NULL == dt) - return (-1) ; - if (fd >= dt->neltos) - return (-1) ; - - /* delete element */ - dtelto_aux = (dtelto_t *)DARRAY_GetNFromDarray(dt->dtable,fd) ; - dtelto_aux->next_free = dt->free_list ; - dt->free_list = dtelto_aux->myself ; - - /* return ok */ - return (1) ; - } - - /** - * Get the element at 'fd' position into 'dt' dynamic table. - * @param dt a dynamic table. - * @param fd the element descriptor. - * @return true (1) if element is removed and error (-1) if - * a problem is found. - */ - void *dtable_get - ( - /*INOUT*/ dtable_t *dt, - /*IN*/ int fd - ) - { - dtelto_t *dtelto_aux ; - - /* check params */ - if (NULL == dt) - return NULL ; - if (fd >= dt->neltos) - return NULL ; - - /* get element */ - dtelto_aux = (dtelto_t *)DARRAY_GetNFromDarray(dt->dtable,fd) ; - - /* return the information */ - return dtelto_aux->dt_info ; - } - - - /* ................................................................... */ - diff --git a/src/base/filesystem.c b/src/base/filesystem.c deleted file mode 100644 index a1f02e777..000000000 --- a/src/base/filesystem.c +++ /dev/null @@ -1,714 +0,0 @@ - -/* - * Copyright 2020-2025 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 . - * - */ - - - /* ... Include / Inclusion ........................................... */ - - #include "filesystem.h" - - - /* ... Varibles ........................................... */ - - void * DLSYM_RTLD = RTLD_DEFAULT ; - - int (*fs_low_creat )(const char *, mode_t) = creat ; - int (*fs_low_open )(const char *, int, mode_t) = (int (*)(const char *, int, mode_t))open ; - int (*fs_low_close )(int) = close ; - int (*fs_low_fsync )(int) = fsync ; - ssize_t (*fs_low_read )(int, void*, size_t) = read ; - ssize_t (*fs_low_write )(int, const void*, size_t) = write ; - off_t (*fs_low_lseek )(int, off_t, int) = lseek ; - int (*fs_low_stat )(const char *, struct stat *) = stat ; - int (*fs_low_stat_dlsym )(int, const char *, struct stat *) = NULL ; - - int (*fs_low_mkdir )(const char *, mode_t) = mkdir ; - int (*fs_low_rmdir )(const char *) = rmdir ; - int (*fs_low_unlink )(const char *) = unlink ; - int (*fs_low_rename )(const char *, const char *) = rename ; - - DIR* (*fs_low_opendir )(const char *) = opendir ; - long (*fs_low_telldir )(DIR *) = telldir ; - void (*fs_low_seekdir )(DIR *, long) = seekdir ; - struct dirent * (*fs_low_readdir )(DIR *) = readdir ; - int (*fs_low_closedir )(DIR *) = closedir ; - -#if defined(HAVE_64BITS) - off64_t (*fs_low_lseek64 )(int, off64_t, int) = lseek64 ; -#endif - //pthread_attr_t filesystem_attr; - - - /* ... Functions / Funciones ......................................... */ - - - /* - * Internal - */ - -int aux_clear_dirs(char * path) -{ - char s[PATH_MAX]; - char ant = '\0' ; - int j = 0; - unsigned i = 0 ; - unsigned sl = 0 ; - - if (NULL == path) { - return -1; - } - - sl = strlen(path) ; - for (i = 0; i < sl; i++) - { - switch (path[i]) - { - case '/': - if (ant != '/') { - ant = s[j] = '/'; - j++; - } - break; - - default: - ant = s[j] = path[i]; - j++; - } - - s[j] = '\0'; - } - - strcpy(path, s); - return 0; -} - - -int aux_get_dirs(char * path, int n, char * s) -{ - long unsigned i = 0; - long j = 0, ant = -1, pos = -1; - int cont = -1; - char new_path[PATH_MAX]; - - if (path == NULL) { - return 0; - } - - strcpy(new_path, path); - path = new_path; - - aux_clear_dirs(path); - s[0] = '\0'; - - for (i = 0; i < strlen(path) && cont < (n + 1); i++) { - if (path[i] == '/') { - if (ant < 0) { - ant = pos = i; - } - pos = i; - cont++; - } - } - - if (cont < (n + 1)) { - return 0; - } - - for (j = ant; j < pos; j++) { - s[j] = path[j]; - } - - s[j] = '\0'; - - return strlen(s); -} - - -/* - * API - */ - -int filesystem_low_set ( void * new_rtld ) -{ - void * old_rtld = DLSYM_RTLD ; - - DEBUG_BEGIN(); - - if (RTLD_NEXT == new_rtld) DLSYM_RTLD = RTLD_NEXT ; - if (RTLD_DEFAULT == new_rtld) DLSYM_RTLD = RTLD_DEFAULT ; - if (old_rtld == new_rtld) return 1 ; - - fs_low_creat = (int (*)(const char *, mode_t)) dlsym(DLSYM_RTLD, "creat") ; - fs_low_open = (int (*)(const char *, int, mode_t)) dlsym(DLSYM_RTLD, "open") ; - fs_low_close = (int (*)(int)) dlsym(DLSYM_RTLD, "close") ; - fs_low_fsync = (int (*)(int)) dlsym(DLSYM_RTLD, "fsync") ; - fs_low_read = (ssize_t (*)(int, void*, size_t)) dlsym(DLSYM_RTLD, "read") ; - fs_low_write = (ssize_t (*)(int, const void*, size_t)) dlsym(DLSYM_RTLD, "write") ; - fs_low_lseek = (off_t (*)(int, off_t, int)) dlsym(DLSYM_RTLD, "lseek"); - -#if defined(HAVE_64BITS) - fs_low_lseek64 = (off64_t (*)(int, off64_t, int)) dlsym(DLSYM_RTLD, "lseek64") ; -#endif - fs_low_stat_dlsym = (int (*)(int, const char *, struct stat *)) dlsym(DLSYM_RTLD, "__xstat") ; - - fs_low_mkdir = (int (*)(const char *, mode_t)) dlsym(DLSYM_RTLD, "mkdir") ; - fs_low_rmdir = (int (*)(const char *)) dlsym(DLSYM_RTLD, "rmdir") ; - fs_low_unlink = (int (*)(const char *)) dlsym(DLSYM_RTLD, "unlink") ; - fs_low_rename = (int (*)(const char *, const char *)) dlsym(DLSYM_RTLD, "rename") ; - - fs_low_opendir = (DIR * (*)(const char *)) dlsym(DLSYM_RTLD, "opendir") ; - fs_low_telldir = (long (*)(DIR *)) dlsym(DLSYM_RTLD, "telldir") ; - fs_low_seekdir = (void (*)(DIR *, long)) dlsym(DLSYM_RTLD, "seekdir") ; - fs_low_readdir = (struct dirent * (*)(DIR *)) dlsym(DLSYM_RTLD, "readdir") ; - fs_low_closedir = (int (*)(DIR *)) dlsym(DLSYM_RTLD, "closedir") ; - - DEBUG_END(); - - // Return OK - return 1 ; -} - -/* -int filesystem_init ( void ) -{ - pthread_attr_init(&filesystem_attr); - int ret = pthread_attr_setdetachstate(&filesystem_attr, PTHREAD_CREATE_DETACHED); - if (ret !=0 ) { - //perror("pthread_attr_setdetachstate: "); - return ret; - } - - return 0; -} - -int filesystem_destroy ( void ) -{ - int ret = pthread_attr_destroy(&filesystem_attr); - if (ret !=0 ) { - //perror("pthread_attr_destroy: "); - return ret; - } - - return 0; -} -*/ - -void * filesystem_async_close(void * arg) -{ - // Try to close file - int ret = fs_low_close((int)(long) arg); - if (ret < 0) { - debug_warning("[FILE_POSIX]: async_close(fd:%d) -> %d\n", (int)(long) arg, ret); - //perror("async_close: ") ; - } - - pthread_exit(NULL); -} - -int filesystem_creat(char * pathname, mode_t mode) -{ - int ret; - - DEBUG_BEGIN(); - - // Check params - if (NULL == pathname) { - debug_warning("[FILE_POSIX]: pathname is NULL\n"); - } - if (0 == mode) { - debug_warning("[FILE_POSIX]: mode is zero\n"); - } - - // Try to creat the file - ret = fs_low_creat(pathname, mode); - if (ret < 0) { - debug_warning("[FILE_POSIX]: open(pathname:%s, mode:%d) -> %d\n", pathname, mode, ret); - //perror("open: ") ; - } - - DEBUG_END(); - - // Return OK/KO - return ret; -} - -int filesystem_open(char * pathname, int flags) -{ - int ret; - - DEBUG_BEGIN(); - - // Check params - if (NULL == pathname) { - debug_warning("[FILE_POSIX]: pathname is NULL\n"); - } - - // Try to open the file - ret = fs_low_open(pathname, flags, 0); - if (ret < 0) { - debug_warning("[FILE_POSIX]: open(pathname:%s, flags:%d) -> %d\n", pathname, flags, ret); - //perror("open: ") ; - } - - DEBUG_END(); - - // Return OK/KO - return ret; -} - -int filesystem_open2(char * pathname, int flags, mode_t mode) -{ - int ret; - - DEBUG_BEGIN(); - - // Check params - if (NULL == pathname) { - debug_warning("[FILE_POSIX]: pathname is NULL\n"); - } - - // Try to open the file - ret = fs_low_open(pathname, flags, mode); - if (ret < 0) { - debug_warning("[FILE_POSIX]: open2(pathname:%s, flags:%d, mode:%d) -> %d\n", pathname, flags, mode, ret); - //perror("open: ") ; - } - - DEBUG_END(); - - // Return OK/KO - return ret; -} - -int filesystem_close(int fd) -{ - int ret; - - DEBUG_BEGIN(); - - // Check params - if (fd < 0) { - debug_warning("[FILE_POSIX]: close file with fd < 0\n"); - } - - // Try to close file - #ifdef ASYNC_CLOSE - pthread_t thid; - - ret = pthread_create( & thid, NULL, filesystem_async_close, (void * )(long) fd); - ret = pthread_detach(thid); - - if (ret < 0) { - ret = fs_low_close(fd); - if (ret < 0) { - debug_warning("[FILE_POSIX]: close(fd:%d) -> %d\n", fd, ret); - //perror("close: ") ; - } - } - - #else - ret = fs_low_close(fd); - if (ret < 0) { - debug_warning("[FILE_POSIX]: close(fd:%d) -> %d\n", fd, ret); - //perror("close: ") ; - } - #endif - - DEBUG_END(); - - // Return OK/KO - return ret; -} - -int filesystem_fsync(int fd) -{ - int ret; - - DEBUG_BEGIN(); - - // Check params - if (fd < 0) { - debug_warning("[FILE_POSIX]: fsync file with fd < 0\n"); - } - - // Try to fsync the file - ret = fs_low_fsync(fd); - if (ret < 0) { - debug_warning("[FILE_POSIX]: fsync(fd:%d) -> %d\n", fd, ret); - } - - DEBUG_END(); - - // Return OK/KO - return ret; -} - -ssize_t filesystem_read(int read_fd2, void * buffer, size_t buffer_size) -{ - ssize_t read_num_bytes = -1; - ssize_t read_remaining_bytes = buffer_size; - void * read_buffer = buffer; - - // check arguments... - if (NULL == buffer) { - debug_warning("[FILE_POSIX]: read_buffer with NULL buffer\n"); - } - - while (read_remaining_bytes > 0) { - /* Read from local file... */ - read_num_bytes = fs_low_read(read_fd2, read_buffer, read_remaining_bytes); - - /* Check errors */ - if (read_num_bytes < 0) { - //perror("read: ") ; - debug_error("[FILE_POSIX]: read fails to read data.\n"); - return -1; - } - - /* Check end of file */ - if (read_num_bytes == 0) { - debug_error("[FILE_POSIX]: end of file, readed %ld.\n", (buffer_size - read_remaining_bytes)); - return (buffer_size - read_remaining_bytes); - } - - read_remaining_bytes = read_remaining_bytes - read_num_bytes; - read_buffer = (void * )((char * ) read_buffer + read_num_bytes); - } - - return buffer_size; -} - -ssize_t filesystem_write(int write_fd2, void * buffer, size_t num_bytes_to_write) -{ - ssize_t write_num_bytes = -1; - ssize_t write_remaining_bytes = num_bytes_to_write; - void * write_buffer = buffer; - - // check arguments... - if (NULL == buffer) { - debug_warning("[FILE_POSIX]: read_buffer with NULL buffer\n"); - } - - while (write_remaining_bytes > 0) - { - /* Write into local file (write_fd2)... */ - write_num_bytes = fs_low_write(write_fd2, write_buffer, write_remaining_bytes); - - /* Check errors */ - if (write_num_bytes < 0) { - //perror("write: ") ; - debug_error("[FILE_POSIX]: write fails to write data.\n"); - return -1; - } - - write_remaining_bytes = write_remaining_bytes - write_num_bytes; - write_buffer = (void * )((char * ) write_buffer + write_num_bytes); - } - - return num_bytes_to_write; -} - -int filesystem_rename(char * old_pathname, char * new_pathname) -{ - int ret; - - DEBUG_BEGIN(); - - // Check params - if (NULL == old_pathname) { - debug_warning("[FILE_POSIX]: old_pathname is NULL\n"); - } - if (NULL == new_pathname) { - debug_warning("[FILE_POSIX]: new_pathname is NULL\n"); - } - - // Try to open the file - ret = fs_low_rename(old_pathname, new_pathname); - if (ret < 0) { - debug_warning("[FILE_POSIX]: rename(old_pathname:%s, new_pathname:%s)\n", old_pathname, new_pathname); - //perror("rename: ") ; - } - - DEBUG_END(); - - // Return OK/KO - return ret; -} - -int filesystem_mkpath ( char * pathname ) -{ - int ret; - char dir[PATH_MAX]; - - DEBUG_BEGIN(); - - for (int i = 0; aux_get_dirs(pathname, i, dir) != 0; i++) { - ret = fs_low_mkdir(dir, 0770); - if (ret < 0) { - debug_warning("[FILE_POSIX]: cannot mkdir(%s)\n", dir); - //perror("mkdir: ") ; - } - } - - DEBUG_END(); - - // Return OK - return 1; -} - -int filesystem_mkdir ( char * pathname, mode_t mode ) -{ - int ret; - - DEBUG_BEGIN(); - - // Check params - if (NULL == pathname) { - debug_warning("[FILE_POSIX]: pathname is NULL\n"); - } - - // Try to mkdir - ret = fs_low_mkdir(pathname, mode); - if (ret < 0) { - debug_warning("[FILE_POSIX]: mkdir(pathname:%s, mode:%d) -> %d\n", pathname, mode, ret); - //perror("mkdir: ") ; - } - - DEBUG_END(); - - // Return OK/KO - return ret; -} - -int filesystem_rmdir ( char * pathname ) -{ - int ret; - - DEBUG_BEGIN(); - - // Check params - if (NULL == pathname) { - debug_warning("[FILE_POSIX]: pathname is NULL\n"); - } - - // Try to rmdir - ret = fs_low_rmdir(pathname); - if (ret < 0) { - debug_warning("[FILE_POSIX]: rmdir(pathname:%s) -> %d\n", pathname, ret); - //perror("rmdir: ") ; - } - - DEBUG_END(); - - // Return OK/KO - return ret; -} - -DIR * filesystem_opendir ( char * pathname ) -{ - DIR * ret; - - DEBUG_BEGIN(); - - // Check params - if (NULL == pathname) { - debug_warning("[FILE_POSIX]: pathname is NULL\n"); - } - - // Try to open the directory - ret = fs_low_opendir(pathname); - if (NULL == ret) { - debug_warning("[FILE_POSIX]: opendir(pathname:%s) -> %p\n", pathname, ret); - //perror("opendir: ") ; - } - - DEBUG_END(); - - // Return DIR* - return ret; -} - -long filesystem_telldir ( DIR * dirp ) -{ - long ret; - - DEBUG_BEGIN(); - - // Check params - if (NULL == dirp) { - debug_warning("[FILE_POSIX]: dirp is NULL\n"); - } - - ret = fs_low_telldir(dirp); - if (-1 == ret) { - debug_warning("[FILE_POSIX]: telldir(dirp:%p) -> %ld\n", dirp, ret); - //perror("telldir: ") ; - } - - DEBUG_END(); - - // Return DIR* - return ret; -} - -void filesystem_seekdir ( DIR * dirp, long loc ) -{ - DEBUG_BEGIN(); - - // Check params - if (NULL == dirp) { - debug_warning("[FILE_POSIX]: dirp is NULL\n"); - } - - fs_low_seekdir(dirp, loc); - - DEBUG_END(); -} - -struct dirent * filesystem_readdir ( DIR * dirp ) -{ - struct dirent * ret; - - DEBUG_BEGIN(); - - // Check params - if (NULL == dirp) { - debug_warning("[FILE_POSIX]: dirp is NULL\n"); - } - - // Try to read next entry of the directory - ret = fs_low_readdir(dirp); - if (NULL == ret) { - debug_warning("[FILE_POSIX]: readdir(dirp:%p) -> %p\n", dirp, ret); - //perror("readdir: ") ; - } - - DEBUG_END(); - - // Return DIR* - return ret; -} - -int filesystem_closedir ( DIR * dirp ) -{ - int ret; - - DEBUG_BEGIN(); - - // Check params - if (NULL == dirp) { - debug_warning("[FILE_POSIX]: dirp is NULL\n"); - } - - // Try to close the directory session - ret = fs_low_closedir(dirp); - if (ret < 0) { - debug_warning("[FILE_POSIX]: closedir(dirp:%p) -> %p\n", dirp, ret); - //perror("closedir: ") ; - } - - DEBUG_END(); - - // Return DIR* - return ret; -} - -off_t filesystem_lseek ( int fd, off_t offset, int whence ) -{ - off_t ret; - - DEBUG_BEGIN(); - - // Check params - if (fd < 0) { - debug_warning("[FILE_POSIX]: fd is negative\n"); - } - - // Try to lseek the file - ret = fs_low_lseek(fd, offset, whence); - if (ret == (off_t) -1) { - debug_warning("[FILE_POSIX]: lseek(fd:%s, offset:%ld, whence:%d) -> %d\n", fd, offset, whence, ret); - //perror("lseek: ") ; - } - - DEBUG_END(); - - // Return OK/KO - return ret; -} - -int filesystem_unlink ( char * pathname ) -{ - int ret; - - DEBUG_BEGIN(); - - // Check params - if (NULL == pathname) { - debug_warning("[FILE_POSIX]: pathname is NULL\n"); - } - - // Try to unlink a file - ret = fs_low_unlink(pathname); - if (ret < 0) { - debug_warning("[FILE_POSIX]: unlink(pathname:%s) -> %d\n", pathname, ret); - //perror("unlink: ") ; - } - - DEBUG_END(); - - // Return OK/KO - return ret; -} - -int filesystem_stat ( char * pathname, struct stat * sinfo ) -{ - int ret; - - DEBUG_BEGIN(); - - // Check params - if (NULL == pathname) { - debug_warning("[FILE_POSIX]: pathname is NULL\n"); - } - if (NULL == sinfo) { - debug_warning("[FILE_POSIX]: sinfo is NULL\n"); - } - - // Try to stat the file - if (fs_low_stat_dlsym != NULL){ - ret = fs_low_stat_dlsym(0, pathname, sinfo); - }else{ - ret = fs_low_stat(pathname, sinfo); - } - if (ret < 0) { - debug_warning("[FILE_POSIX]: stat(pathname:%s, sinfo:%p) -> %d\n", pathname, sinfo, ret); - //perror("stat: ") ; - } - - DEBUG_END(); - - // Return OK/KO - return ret; -} - - - /* ................................................................... */ - diff --git a/src/base/math_misc.c b/src/base/math_misc.c deleted file mode 100644 index b24ecef2b..000000000 --- a/src/base/math_misc.c +++ /dev/null @@ -1,280 +0,0 @@ - -/* - * Copyright 2020-2025 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 . - * - */ - - - /* ... Include / Inclusion ........................................... */ - - #include "base/math_misc.h" - - - /* ... Functions / Funciones ......................................... */ - - /** - * Compute server index associated to a file. - * @param file the file name. - * @param nServ number of servers for this file. - * @return hash value computed. - */ - int MATH_MISC_hash - ( - char *file, - int nServ - ) - { - int i,max; - long unsigned num; - - /* - * Check params... - */ - if (NULL == file) - return (-1); - - /* - * Compute hash... - */ - num=0; - max=strlen(file)-1; - for(i=0;i. - * - */ - - /* ... Include / Inclusion ........................................... */ - - #include "base/ns.h" - - - /* ... Functions / Funciones ......................................... */ - - int ns_get_hostname ( char * srv_name ) - { - int ret, ipv ; - - ipv = utils_getenv_int("XPN_SCK_IPV", DEFAULT_XPN_SCK_IPV); - ret = socket_gethostname(srv_name, ipv) ; - - return ret ; - } - - int ns_get_host_ip ( char * ip, size_t ip_size ) - { - int ret, ipv ; - char srv_name[HOST_NAME_MAX]; - - debug_info("[NS] [ns_get_host_ip] >> Begin\n"); - - ipv = utils_getenv_int("XPN_SCK_IPV", DEFAULT_XPN_SCK_IPV); - - ret = socket_gethostname(srv_name, ipv) ; - if (ret < 0) { - fprintf(stderr, "gethostname failed\n"); - return -1 ; - } - - ret = socket_gethostbyname(ip, ip_size, srv_name, ipv); - if (ret < 0) { - fprintf(stderr, "gethostbyname failed\n"); - return -1 ; - } - - debug_info("[NS] [ns_get_host_ip] srv_name: %s IP: %s\n", srv_name, ip); - debug_info("[NS] [ns_get_host_ip] >> End\n"); - - return ret ; - } - - - int ns_publish(char * dns_file, char * protocol, char * param_srv_name, char * srv_ip, char * port_name) - { - int ret; - FILE * dns_fd; - - debug_info("[NS] [ns_publish] >> Begin\n"); - - dns_fd = fopen(dns_file, "a+"); - if (NULL == dns_fd) { - perror("[NS] [ns_publish] ERROR: fopen on DNS File"); - return -1; - } - - ret = fprintf(dns_fd, "%s:%s %s:%s %s\n", protocol, param_srv_name, protocol, srv_ip, port_name); - if (ret < 0) { - fclose(dns_fd); - perror("[NS] [ns_publish] ERROR: fprintf on DNS File"); - return -1; - } - - fclose(dns_fd); - - debug_info("[NS] [ns_publish] >> End\n"); - return 0; - } - - int ns_unpublish(char * dns_file, char * protocol, char * param_srv_name) - { - FILE * dns_fd; - FILE * new_dns_fd; - char new_dns_file[PATH_MAX]; - int found = 0; - char aux_name[1024]; - char aux_name_2[1024]; - char port_name[HOST_NAME_MAX]; - - debug_info("[NS] [ns_unpublish] >> Begin\n"); - int res = 0; - - // open files - dns_fd = fopen(dns_file, "r"); - if (NULL == dns_fd) { - perror("[NS] [ns_unpublish] ERROR: DNS File"); - return -1; - } - - sprintf(new_dns_file, "%saux%d", dns_file, rand()); - - new_dns_fd = fopen(new_dns_file, "w"); - if (NULL == new_dns_fd) { - fclose(dns_fd); - perror("[NS] [ns_unpublish] ERROR: New DNS File"); - return -1; - } - - char aux_srv_name[2 * HOST_NAME_MAX]; - sprintf(aux_srv_name, "%s:%s", protocol, param_srv_name); - - // copy filtering... - while (fscanf(dns_fd, "%1000s %1000s %100s", aux_name, aux_name_2, port_name) != EOF) - { - if (strcmp(aux_name, aux_srv_name) == 0) { - // Not copy the line - found = 1; - } else { - // Copy the line - fprintf(new_dns_fd, "%s %s %s\n", aux_name, aux_name_2, port_name); - } - } - - if (0 == found) { - printf("Warning: Server %s not found\n", aux_name); - } - - // close files - fclose(new_dns_fd); - fclose(dns_fd); - - unlink(dns_file); - res = rename(new_dns_file, dns_file); - if (res != 0) { - debug_error("Error: in rename %s\n", strerror(errno)); - } - - debug_info("[NS] [ns_unpublish] >> End\n"); - - return res; - } - - int ns_lookup ( char * protocol, char * param_srv_name, char * srv_ip, char * port_name ) - { - int found = 0; - char aux_srv_name[1024]; - char prot_srv_name[1024]; - char aux_protocol[1024]; - char dns_file[PATH_MAX]; - FILE * dns_fd; - - debug_info("[NS] [ns_lookup] >> Begin\n"); - - // try to get the ns_file_name - char * dns_file_env = getenv("XPN_DNS"); - if (dns_file_env == NULL) - { - if (strcmp(protocol, "mpi_server") == 0) { - strcpy(dns_file, MPI_SERVER_DNS_FILE_DEFAULT); - } else if (strcmp(protocol, "sck_server") == 0) { - strcpy(dns_file, SCK_SERVER_DNS_FILE_DEFAULT); - } else if (strcmp(protocol, "mq_server") == 0) { - strcpy(dns_file, MQ_SERVER_DNS_FILE_DEFAULT); - } else { - printf("Unrecognized protocol '%s' !!\n", protocol); - } - } else { - strcpy(dns_file, dns_file_env); - } - - // try to open the ns_file_fd - dns_fd = fopen(dns_file, "r"); - if (dns_fd == NULL) { - return -1; - } - - sprintf(prot_srv_name, "%s:%s", protocol, param_srv_name); - - while (fscanf(dns_fd, "%1000s %[^:]:%100s %100s", aux_srv_name, aux_protocol, srv_ip, port_name) != EOF) - { - debug_info("[NS] [ns_lookup] %s %s:%s %s\n\n", aux_srv_name, aux_protocol, srv_ip, port_name); - - if (strcmp(aux_srv_name, prot_srv_name) == 0 || strcmp(srv_ip, param_srv_name) == 0) { - found = 1; - break; - } - } - - fclose(dns_fd); - - if (found == 0) { - return -1; - } - - debug_info("[NS] [ns_lookup] >> End\n"); - - return 0; - } - - - /* ................................................................... */ - diff --git a/src/base/path_misc.c b/src/base/path_misc.c deleted file mode 100644 index eaacce586..000000000 --- a/src/base/path_misc.c +++ /dev/null @@ -1,196 +0,0 @@ - -/* - * Copyright 2020-2025 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 . - * - */ - - - /* ... Include / Inclusion ........................................... */ - - #include "base/path_misc.h" - - - /* ... Functions / Funciones ......................................... */ - - int hash ( const char *path, int nServ, int isfile ) - { - int i,max; - int unsigned num; - char *aux_file; - char file[PATH_MAX]; - strncpy(file, path, PATH_MAX-1); - - // Get file name - if (isfile == 1){ - aux_file = basename(file); - }else{ - aux_file = dirname(file); - aux_file = basename(aux_file); - } - num = 0; - max = strlen(aux_file); - for (i = 0; i < max; i++) { - num += (int)aux_file[i]; - } - return (int)num % nServ; - } - - - int getFirstDir ( char *dir, char *path ) - { - int i, j; - - //printf("++ path = %s ++\n", path); - - i = 0; - while((path[i] != '\0')&&(path[i] != '/')){ - i++; - } - strncpy(dir, path , i); - - dir[i] = '\0'; - - //printf("++ dir = %s ++\n",dir); - - - while((path[i] != '\0')&&(path[i] == '/')){ - i++; - } - - j = 0; - while(path[i+j] != '\0'){ - - path[j] = path[i+j]; - j++; - } - - path[j] = '\0'; - //printf("++ dir = %s path = %s ++\n",dir, path); - return j; - } - - - long getSizeFactor ( char *name ) - { - switch (name[strlen(name)-1]) - { - case 'K': - case 'k': - return atoi(name)*KB; - - case 'M': - case 'm': - return atoi(name)*MB; - - case 'G': - case 'g': - return atoi(name)*GB; - - case 'B': - case 'b': - switch (name[strlen(name)-2]) - { - case 'K': - case 'k': - return atoi(name)*KB; - - case 'M': - case 'm': - return atoi(name)*MB; - - case 'G': - case 'g': - return atoi(name)*GB; - - default: - return 1; - } - - default: - return atoi(name); - } - } - - - int getNameFile ( char *file, char *dir ) - { - int i,j; - - i = strlen(dir); - if (i == 0) { - file[0]='\0'; - return 0; /* ? */ - } - - while ((i>=0)&&(dir[i] == '/')) { - i--; - } - if (i == 0) { - file[0]='\0'; - return 0; /* ? */ - } - - /* */ - j = i; - while ((j>=0)&&(dir[j] != '/')) { - j--; - } - - if (dir[j] == '/') { - j++; - } - - strncpy(file, dir+j, i-j); - - dir[j] = '\0'; - file[i-j] = '\0'; - - return 0; - } - - - int getNamePart ( char *part, char *dir ) - { - int i,j; - - // Printf("original dir = %s\n", dir); - if (dir[0] != '/') { - return -1; - } - - i = 1; - while((dir[i] != '\0')&&(dir[i] != '/')) { - i++; - } - - strncpy(part, dir+1, i-1); - part[i-1] = '\0'; - j = 0; - while (dir[i] != '\0') { - dir[j] = dir[i]; - j++; - i++; - } - - dir[j] = '\0'; - return 0; - } - - - /* ................................................................... */ - diff --git a/src/base/service_socket.c b/src/base/service_socket.c deleted file mode 100644 index 9483b35a6..000000000 --- a/src/base/service_socket.c +++ /dev/null @@ -1,131 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos - * - * 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 . - * - */ - - -/* ... Include / Inclusion ........................................... */ - - #include "base/service_socket.h" - - -/* ... Functions / Funciones ......................................... */ - -int sersoc_lookup_port_name ( char * srv_name, char * port_name, int socket_accept_code ) -{ - int ret = -1 ; - - // Lookup port name - debug_info("[SERSOC] [sersoc_lookup_port_name] >> Begin\n"); - - int port = utils_getenv_int("XPN_SCK_PORT", DEFAULT_XPN_SCK_PORT) ; - ret = sersoc_do_send_recv(srv_name, port, socket_accept_code, port_name) ; - - debug_info("[SERSOC] [sersoc_lookup_port_name] << End\n"); - return ret; -} - -int sersoc_do_send_recv ( char * srv_name, int port, int req_id, char *res_val ) -{ - int ret = -1 ; - int connection_socket ; - - debug_info("[SERSOC] [sersoc_do_send_recv] >> Begin\n"); - - - int ipv = utils_getenv_int("XPN_SCK_IPV", DEFAULT_XPN_SCK_IPV); - - // Lookup port name - ret = socket_client_connect(srv_name, port, &connection_socket, ipv); - if (ret < 0) - { - debug_error("[SERSOC] [sersoc_do_send_recv] ERROR: socket connect\n"); - return -1; - } - - ret = socket_send(connection_socket, &req_id, sizeof(int)); - if (ret < 0) - { - debug_error("[SERSOC] [sersoc_do_send_recv] ERROR: socket send\n"); - socket_close(connection_socket); - return -1; - } - - ret = socket_recv(connection_socket, res_val, MAX_PORT_NAME_LENGTH); - if (ret < 0) - { - debug_error("[SERSOC] [sersoc_do_send_recv] ERROR: socket read\n"); - socket_close(connection_socket); - return -1; - } - - ret = socket_close(connection_socket); - if (ret < 0) - { - debug_error("[SERSOC] [sersoc_do_send_recv] ERROR: socket close\n"); - return -1; - } - - debug_error("[SERSOC] [sersoc_do_send_recv] request to '%s' command '%d' -> response: %s\n", srv_name, req_id, res_val); - debug_info("[SERSOC] [sersoc_do_send_recv] << End\n"); - - return ret; -} - -int sersoc_do_send ( char * srv_name, int port, int req_id ) -{ - int ret = -1 ; - int connection_socket ; - - debug_info("[SERSOC] [sersoc_do_send] >> Begin\n"); - - int ipv = utils_getenv_int("XPN_SCK_IPV", DEFAULT_XPN_SCK_IPV); - - // Lookup port name - ret = socket_client_connect(srv_name, port, &connection_socket, ipv); - if (ret < 0) - { - debug_error("[SERSOC] [sersoc_do_send] ERROR: socket connect\n"); - return -1; - } - - ret = socket_send(connection_socket, &req_id, sizeof(int)); - if (ret < 0) - { - debug_error("[SERSOC] [sersoc_do_send] ERROR: socket send\n"); - socket_close(connection_socket); - return -1; - } - - ret = socket_close(connection_socket); - if (ret < 0) - { - debug_error("[SERSOC] [sersoc_do_send] ERROR: socket close\n"); - return -1; - } - - debug_error("[SERSOC] [sersoc_do_send] request to '%s' command '%d' -> response: %s\n", srv_name, req_id, res_val); - debug_info("[SERSOC] [sersoc_do_send] << End\n"); - - return ret; -} - - -/* ................................................................... */ - diff --git a/src/base/socket.c b/src/base/socket.c deleted file mode 100644 index 58ee08766..000000000 --- a/src/base/socket.c +++ /dev/null @@ -1,476 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Luis Miguel Sanchez Garcia, Borja Bergua Guerra, Dario Muñoz Muñoz - * - * 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 . - * - */ - - - /* ... Include / Inclusion ........................................... */ - - #include "base/socket.h" - - - /* ... Functions / Funciones ......................................... */ - - // - // Send/Recev - // - - int socket_send ( int socket, void * buffer, int size ) - { - int r; - int l = size; - - do - { - r = dlsym_write(socket, buffer, l); - if (r < 0) - { - if (EPIPE == errno) - printf("[SOCKET] [socket_send] ERROR: client closed the connection.\n") ; - else printf("[SOCKET] [socket_send] ERROR: socket send buffer size %d Failed\n", size) ; - - return -1; - } - - l = l - r; - buffer = (void *) ((char *)buffer + r) ; - - } while ((l > 0) && (r >= 0)); - - return size; - } - - int socket_recv ( int socket, void * buffer, int size ) - { - int r; - int l = size; - - do - { - r = dlsym_read(socket, buffer, l); - if (r < 0) - { - if (EPIPE == errno) - printf("[SOCKET] [socket_send] ERROR: client closed the connection abruptly\n") ; - else printf("[SOCKET] [socket_recv] ERROR: socket read buffer size %d Failed\n", size) ; - - return -1; - } - if (0 == r) - { - printf("[SOCKET] [socket_recv] WARN: end of file receive for socket '%d'\n", socket) ; - return 0; - } - - l = l - r; - buffer = (void *) ((char *)buffer + r) ; - - } while ((l > 0) && (r >= 0)); - - return size; - } - - - // - // setopt for data or server - // - - int socket_setopt_data ( int socket ) - { - int ret ; - int flag, val ; - - debug_info("[SOCKET] [socket_setopt_data] >> Begin\n"); - - // tcp_nodelay - flag = 1; - ret = setsockopt(socket, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag)); - if (ret < 0) { - perror("setsockopt: "); - return -1; - } - - // send_buffer: 1 MB - val = 1024 * 1024; // 1 MB - ret = setsockopt(socket, SOL_SOCKET, SO_SNDBUF, (char * ) &val, sizeof(int)); - if (ret < 0) { - perror("setsockopt: "); - return -1; - } - - // recv_buffer: 1 MB - val = 1024 * 1024; // 1 MB - ret = setsockopt(socket, SOL_SOCKET, SO_RCVBUF, (char * ) &val, sizeof(int)); - if (ret < 0) { - perror("setsockopt: "); - return -1; - } - - debug_info("[SOCKET] [socket_setopt_data] << End\n"); - return ret ; - } - - int socket_setopt_service ( int socket ) - { - int ret ; - int flag, val ; - - debug_info("[SOCKET] [socket_setopt_service] >> Begin\n"); - - // tcp_nodelay - flag = 1; - ret = setsockopt(socket, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag)); - if (ret < 0) { - printf("[SOCKET] [socket_setopt_service] ERROR: setsockopt for TCP_NODELAY fails\n"); - return -1; - } - - // sock_reuseaddr - val = 1; - ret = setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, (char * ) &val, sizeof(val)); - if (ret < 0) - { - printf("[SOCKET] [socket_setopt_service] ERROR: setsockopt for SO_REUSEADDR fails\n"); - return -1; - } - - debug_info("[SOCKET] [socket_setopt_service] << End\n"); - return ret ; - } - - - // - // server_create - // - - int socket_server_create ( int * out_socket, int port, int socket_mode ) - { - int ret = 0; - - debug_info("[SOCKET] [base_socket_init] >> Begin\n"); - - // check arguments... - if (NULL == out_socket) - { - debug_error("[SOCKET] [base_socket_init] ERROR: NULL out_socket\n"); - return -1; - } - - // initialize... - switch (socket_mode) - { - case SCK_IP4: - debug_info("[SOCKET] [base_socket_init] socket_ip4_server_create\n"); - ret = socket_ip4_server_create(out_socket, port); - break; - - case SCK_IP6: - debug_info("[SOCKET] [base_socket_init] socket_ip6_server_create\n"); - ret = socket_ip6_server_create(out_socket, port); - break; - - default: - debug_info("[SOCKET] [base_socket_init] ERROR: on socket_server_create(%d).\n", socket_mode); - return -1; - break; - } - - debug_info("[SOCKET] [base_socket_init] >> End\n"); - - return ret; - } - - - // - // accept / connect - // - - int socket_server_accept ( int socket, int * out_conection_socket, int socket_mode ) - { - int ret = 0; - - debug_info("[SOCKET] [socket_server_accept] >> Begin\n"); - - // check arguments... - if (NULL == out_conection_socket) - { - debug_error("[SOCKET] [socket_server_accept] ERROR: NULL out_socket\n"); - return -1; - } - - switch (socket_mode) - { - case SCK_IP4: - debug_info("[SOCKET] [socket_server_accept] socket_ip4_server_accept\n"); - ret = socket_ip4_server_accept(socket, out_conection_socket); - break; - - case SCK_IP6: - debug_info("[SOCKET] [socket_server_accept] socket_ip6_server_accept\n"); - ret = socket_ip6_server_accept(socket, out_conection_socket); - break; - - default: - debug_info("[SOCKET] [socket_server_accept] ERROR: on socket_server_accept(%d).\n", socket_mode); - return -1; - break; - } - - debug_info("[SOCKET] [socket_server_accept] >> End\n"); - - return ret; - } - - int socket_client_connect ( char * srv_name, int port, int * out_socket, int socket_mode ) - { - int ret = 0; - - debug_info("[SOCKET] [socket_client_connect] >> Begin\n"); - - // check arguments... - if (NULL == srv_name) - { - debug_error("[SOCKET] [socket_client_connect] ERROR: NULL srv_name\n"); - return -1; - } - - switch (socket_mode) - { - case SCK_IP4: - debug_info("[SOCKET] [socket_client_connect] socket_ip4_server_connect\n"); - ret = socket_ip4_client_connect(srv_name, port, out_socket); - break; - - case SCK_IP6: - debug_info("[SOCKET] [socket_client_connect] socket_ip6_server_connect\n"); - ret = socket_ip6_client_connect(srv_name, port, out_socket); - break; - - default: - debug_info("[SOCKET] [socket_client_connect] ERROR: on socket_client_connect(%d).\n", socket_mode); - return -1; - break; - } - - debug_info("[SOCKET] [socket_client_connect] >> End\n"); - - return ret; - } - - int socket_client_connect_retries ( int sd, int n_retries, struct sockaddr *ai_addr, socklen_t ai_addrlen ) - { - int ret, connect_retries ; - char cli_name[HOST_NAME_MAX]; - - // gethostname - ret = gethostname(cli_name, HOST_NAME_MAX); - if (ret < 0) { - perror("gethostname: ") ; - strcpy(cli_name, "unknown") ; - } - - // loop... - connect_retries = 0; - do - { - ret = connect(sd, ai_addr, ai_addrlen) ; - if (ret < 0) - { - if (connect_retries == 0) - { - printf("----------------------------------------------------------------\n"); - printf("Client '%s' waiting for server to be up and running...\n", cli_name); - printf("----------------------------------------------------------------\n\n"); - } - - connect_retries++; - sleep(2); - } - } while ((ret < 0) && (connect_retries < n_retries)); - - return ret ; - } - - int socket_client_connect_with_retries ( char *srv_name, char *port_name, int *out_socket, int n_retries, int socket_mode ) - { - int ret = 0; - - debug_info("[SOCKET] [socket_client_connect_with_retries] >> Begin\n"); - - // check arguments... - if (NULL == srv_name) { - debug_error("[SOCKET] [socket_client_connect_with_retries] ERROR: NULL srv_name\n"); - return -1; - } - if (NULL == port_name) { - debug_error("[SOCKET] [socket_client_connect_with_retries] ERROR: NULL port_name\n"); - return -1; - } - if (NULL == out_socket) { - debug_error("[SOCKET] [socket_client_connect_with_retries] ERROR: NULL out_socket\n"); - return -1; - } - - switch (socket_mode) - { - case SCK_IP4: - debug_info("[SOCKET] [socket_client_connect_with_retries] socket_ip4_server_connect\n"); - ret = socket_ip4_client_connect_with_retries(srv_name, port_name, out_socket, n_retries); - break; - - case SCK_IP6: - debug_info("[SOCKET] [socket_client_connect_with_retries] socket_ip6_server_connect\n"); - ret = socket_ip6_client_connect_with_retries(srv_name, port_name, out_socket, n_retries); - break; - - default: - debug_info("[SOCKET] [socket_client_connect_with_retries] ERROR: on socket_client_connect(%d).\n", socket_mode); - return -1; - break; - } - - debug_info("[SOCKET] [socket_client_connect_with_retries] >> End\n"); - - return ret; - } - - int socket_close ( int socket ) - { - int ret; - - ret = close(socket); - if (ret < 0) - { - printf("[SOCKET] [socket_close] ERROR: socket close Failed\n"); - return -1; - } - - return ret; - } - - - // - // address management - // - - int socket_gethostname ( char * srv_name, int socket_mode ) - { - int ret = 0; - - debug_info("[SOCKET] [socket_gethostname] >> Begin\n"); - - // check arguments... - if (NULL == srv_name) - { - debug_error("[SOCKET] [socket_gethostname] ERROR: NULL srv_name\n"); - return -1; - } - - switch (socket_mode) - { - case SCK_IP4: - debug_info("[SOCKET] [socket_gethostname] socket_gethostname\n"); - ret = socket_ip4_gethostname(srv_name) ; - break; - - case SCK_IP6: - debug_info("[SOCKET] [socket_gethostname] socket_gethostname\n"); - ret = socket_ip6_gethostname(srv_name) ; - break; - - default: - debug_info("[SOCKET] [socket_gethostname] ERROR: on socket_gethostname(%d).\n", socket_mode); - return -1; - break; - } - - return ret; - } - - int socket_gethostbyname ( char * ip, size_t ip_size, char * srv_name, int socket_mode ) - { - int ret = 0; - - debug_info("[SOCKET] [socket_gethostbyname] >> Begin\n"); - - // check arguments... - if (NULL == srv_name) - { - debug_error("[SOCKET] [socket_gethostbyname] ERROR: NULL srv_name\n"); - return -1; - } - - switch (socket_mode) - { - case SCK_IP4: - debug_info("[SOCKET] [socket_gethostbyname] socket_gethostbyname\n"); - ret = socket_ip4_gethostbyname(ip, ip_size, srv_name); - break; - - case SCK_IP6: - debug_info("[SOCKET] [socket_gethostbyname] socket_gethostbyname\n"); - ret = socket_ip6_gethostbyname(ip, ip_size, srv_name); - break; - - default: - debug_info("[SOCKET] [socket_gethostbyname] ERROR: on socket_gethostbyname(%d).\n", socket_mode); - return -1; - break; - } - - return ret; - } - - int socket_getsockname ( char * port_name, int in_socket, int socket_mode ) - { - int ret = 0; - - debug_info("[SOCKET] [socket_getsockname] >> Begin\n"); - - // check arguments... - if (NULL == port_name) - { - debug_error("[SOCKET] [socket_getsockname] ERROR: NULL srv_name\n"); - return -1; - } - - switch (socket_mode) - { - case SCK_IP4: - debug_info("[SOCKET] [socket_getsockname] socket_ip4_getsockname\n"); - ret = socket_ip4_getsockname(port_name, in_socket) ; - break; - - case SCK_IP6: - debug_info("[SOCKET] [socket_getsockname] socket_ip6_getsockname\n"); - ret = socket_ip6_getsockname(port_name, in_socket) ; - break; - - default: - debug_info("[SOCKET] [socket_getsockname] ERROR: on socket_mode for socket_gethostbyname(%d).\n", socket_mode); - return -1; - break; - } - - return ret; - } - - - /* ................................................................... */ - diff --git a/src/base/socket_ip4.c b/src/base/socket_ip4.c deleted file mode 100644 index 71be4d248..000000000 --- a/src/base/socket_ip4.c +++ /dev/null @@ -1,287 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Luis Miguel Sanchez Garcia, Borja Bergua Guerra, Dario Muñoz Muñoz - * - * 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 . - * - */ - - - /* ... Include / Inclusion ........................................... */ - - #include "base/socket_ip4.h" - - - /* ... Functions / Funciones ......................................... */ - - int socket_ip4_server_create ( int * out_socket, int port ) - { - int ret = 0; - struct sockaddr_in server_addr; - int server_socket, val ; - - // check arguments... - if (NULL == out_socket) - { - printf("[SOCKET_IP4] [socket_ip4_server_create] ERROR: NULL out_socket\n"); - return -1; - } - - // Socket init - debug_info("[SOCKET_IP4] [socket_server_create] Scoket init\n"); - - server_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (server_socket < 0) - { - printf("[SOCKET_IP4] [socket_server_create] ERROR: socket fails\n"); - return -1; - } - - // tcp_nodelay - debug_info(" [SOCKET_IP4] [socket_server_create] TCP nodelay\n"); - - val = 1; - ret = setsockopt(server_socket, IPPROTO_TCP, TCP_NODELAY, & val, sizeof(val)); - if (ret < 0) - { - printf("[SOCKET_IP4] [socket_server_create] ERROR: setsockopt for TCP_NODELAY fails\n"); - return -1; - } - - // sock_reuseaddr - debug_info(" [SOCKET_IP4] [socket_server_create] Socket reuseaddr nodelay\n"); - - val = 1; - ret = setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, (char * ) & val, sizeof(int)); - if (ret < 0) - { - printf("[SOCKET_IP4] [socket_server_create] ERROR: setsockopt for SO_REUSEADDR fails\n"); - return -1; - } - - // bind - debug_info("[SOCKET_IP4] [socket_server_create] Socket bind\n"); - - bzero((char * ) & server_addr, sizeof(server_addr)); - server_addr.sin_family = AF_INET; - server_addr.sin_addr.s_addr = INADDR_ANY; - server_addr.sin_port = htons(port); - - ret = bind(server_socket, (struct sockaddr * ) & server_addr, sizeof(server_addr)); - if (ret < 0) - { - printf("[SOCKET_IP4] [socket_server_create] ERROR: bind fails\n"); - return -1; - } - - - // listen - debug_info("[SOCKET_IP4] [socket_server_create] Socket listen\n"); - - ret = listen(server_socket, SOMAXCONN); - if (ret < 0) - { - printf("[SOCKET_IP4] [socket_server_create] ERROR: listen fails\n"); - return -1; - } - - // return new server_socket as *out_socket - *out_socket = server_socket; - return 0; - } - - int socket_ip4_server_accept ( int socket, int * out_conection_socket ) - { - struct sockaddr_in client_addr ; - socklen_t sock_size ; - - // check arguments... - if (NULL == out_conection_socket) - { - printf("[SOCKET_IP4] [socket_ip4_server_accept] ERROR: NULL out_conection_socket\n"); - return -1; - } - - // Accept - debug_info("[SOCKET_IP4] [socket_ip4_server_accept] Accept\n"); - - sock_size = sizeof(struct sockaddr_in); - *out_conection_socket = accept(socket, (struct sockaddr * ) & client_addr, & sock_size); - if (*out_conection_socket < 0) { - printf("[SOCKET_IP4] [socket_ip4_server_accept] ERROR: socket accept\n"); - return -1; - } - - debug_info("[SOCKET_IP4] [socket_ip4_server_accept] accepted for %d\n", *out_conection_socket); - - return 0; - } - - int socket_ip4_client_connect ( char * srv_name, int port, int * out_socket ) - { - int ret, client_fd; - struct sockaddr_in serv_addr; - struct hostent * hp; - - // check arguments... - if (NULL == out_socket) - { - printf("[SOCKET_IP4] [socket_ip4_client_connect] ERROR: NULL out_socket\n"); - return -1; - } - - // socket + gethostbyname + connect - client_fd = socket(AF_INET, SOCK_STREAM, 0); - if (client_fd < 0) - { - printf("[SOCKET_IP4] [socket_read] ERROR: socket creation error\n"); - return -1; - } - - hp = gethostbyname(srv_name); - if (hp == NULL) - { - printf("[SOCKET_IP4] [socket_read] ERROR: gethostbyname srv_name: %s\n", srv_name); - close(client_fd); - return -1; - } - - bzero((char * ) & serv_addr, sizeof(serv_addr)); - serv_addr.sin_family = AF_INET; - serv_addr.sin_port = htons(port); - memcpy( & (serv_addr.sin_addr), hp->h_addr, hp->h_length); - - ret = connect(client_fd, (struct sockaddr * ) &serv_addr, sizeof(serv_addr)); - if (ret < 0) - { - printf("[SOCKET_IP4] [socket_read] ERROR: socket connection failed to %s in port %d %s\n", srv_name, port, strerror(errno)); - close(client_fd); - return -1; - } - - *out_socket = client_fd; - return 0; - } - - int socket_ip4_client_connect_with_retries ( char * srv_name, char * port_name, int *out_socket, int n_retries ) - { - int ret; - struct hostent * hp; - struct sockaddr_in server_addr; - int socket_setopt_data ( int socket ) ; - int socket_client_connect_retries ( int sd, int n_retries, struct sockaddr *ai_addr, socklen_t ai_addrlen ) ; - - debug_info("[SOCKET] [socket_ip4_client_connect_with_retries] srv_name:%s port_name:%s\n", srv_name, port_name); - - // Socket... - *out_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (*out_socket < 0) { - perror("socket: "); - return -1; - } - - ret = socket_setopt_data(*out_socket) ; - if (ret < 0) { - close(*out_socket); - return -1; - } - - // get address with gethostbyname - hp = gethostbyname(srv_name); - if (hp == NULL) - { - fprintf(stderr, "nfi_sck_server_init: error gethostbyname %s (%s,%s)\n", srv_name, srv_name, port_name); - return -1; - } - - bzero((char * ) &server_addr, sizeof(server_addr)); - server_addr.sin_family = AF_INET; - server_addr.sin_port = htons(atoi(port_name)); - memcpy( & (server_addr.sin_addr), hp->h_addr, hp->h_length); - - // Connect with retries - ret = socket_client_connect_retries(*out_socket, n_retries, (struct sockaddr *)&server_addr, sizeof(server_addr)) ; - if (ret < 0) - { - printf("[SOCKET] [socket_ip4_client_connect_with_retries] ERROR: connect fails\n"); - close(*out_socket); - return -1; - } - - return ret; - } - - - // - // address management - // - - int socket_ip4_gethostname ( char * srv_name ) - { - int ret ; - - debug_info("[SOCKET_IP4] [socket_ip4_gethostname] >> Begin IPv4\n"); - ret = gethostname(srv_name, HOST_NAME_MAX); // get hostname - debug_info("[SOCKET_IP4] [socket_ip4_gethostname] >> End IPv4\n"); - - return ret ; - } - - int socket_ip4_gethostbyname ( char *ip, size_t ip_size, char *srv_name ) - { - struct hostent *srv_entry; - - if (ip == NULL) { - printf("[SOCKET_IP4] [socket_ip4_gethostbyname] ERROR: NULL ip argument\n"); - return -1; - } - - // Resolver nombre - srv_entry = gethostbyname(srv_name); - if (srv_entry == NULL) { - printf("[SOCKET_IP4] [socket_ip4_gethostbyname] ERROR: gethostbyname failed for '%s'\n", srv_name); - return -1; - } - - // Asegurarse de que haya al menos una IP - if (srv_entry->h_addr_list == NULL || srv_entry->h_addr_list[0] == NULL) { - printf("[SOCKET_IP4] [socket_ip4_gethostbyname] ERROR: No IP address found for '%s'\n", srv_name); - return -1; - } - - // Convertir a string y copiar a ip - const char *ip_local = inet_ntoa(*(struct in_addr *)srv_entry->h_addr_list[0]); - strncpy(ip, ip_local, ip_size - 1); - ip[ip_size - 1] = '\0'; // asegurarse de que esté terminada en null - - return 1; - } - - int socket_ip4_getsockname ( char * port_name, int new_socket ) - { - struct sockaddr_in server_addr; - - // get sockname - socklen_t len = sizeof(server_addr); - getsockname( new_socket, (struct sockaddr * ) &server_addr, &len); - sprintf(port_name, "%d", ntohs(server_addr.sin_port)); - - return 1; - } - - - /* ................................................................... */ - diff --git a/src/base/socket_ip6.c b/src/base/socket_ip6.c deleted file mode 100644 index 604339b1d..000000000 --- a/src/base/socket_ip6.c +++ /dev/null @@ -1,349 +0,0 @@ - -/* - * Copyright 2000-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Elias Del Pozo Puñal - * - * 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 . - * - */ - - - /* ... Include / Inclusion ........................................... */ - - #include "base/socket_ip6.h" - - - /* ... Functions / Funciones ......................................... */ - - int socket_ip6_server_create ( int * out_socket, int port ) - { - int ret = 0; - struct sockaddr_in6 server_addr; - int server_socket, val ; - - // check arguments... - if (NULL == out_socket) - { - printf("[SOCKET_IP6] [socket_ip6_server_create] ERROR: NULL out_socket\n"); - return -1; - } - - // socket - server_socket = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP); - if (server_socket < 0) - { - printf("[SOCKET_IP6] [socket_server_create] ERROR: socket fails\n"); - return -1; - } - - val = 1; - ret = setsockopt(server_socket, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)); - if (ret < 0) - { - printf("[SOCKET_IP6] [socket_server_create] ERROR: setsockopt fails\n"); - return -1; - } - - debug_info("[SOCKET_IP6] [socket_server_create] Socket reuseaddr\n"); - - val = 1; - ret = setsockopt(server_socket, SOL_SOCKET, SO_REUSEADDR, (char * ) &val, sizeof(int)); - if (ret < 0) - { - printf("[SOCKET_IP6] [socket_server_create] ERROR: setsockopt fails\n"); - return -1; - } - - // bind - debug_info("[SOCKET_IP6] [socket_server_create] Socket bind\n"); - - bzero((char * ) &server_addr, sizeof(server_addr)); - server_addr.sin6_family = AF_INET6; - server_addr.sin6_addr = in6addr_any; - server_addr.sin6_port = htons(port); - - ret = bind(server_socket, (struct sockaddr * ) &server_addr, sizeof(server_addr)); - if (ret < 0) - { - printf("[SOCKET_IP6] [socket_server_create] ERROR: bind fails\n"); - return -1; - } - - // listen - debug_info("[SOCKET_IP6] [socket_server_create] Socket listen\n"); - - ret = listen(server_socket, SOMAXCONN); - if (ret < 0) - { - printf("[SOCKET_IP6] [socket_server_create] ERROR: listen fails\n"); - return -1; - } - - *out_socket = server_socket; - return 0; - } - - int socket_ip6_server_accept ( int socket, int * out_conection_socket ) - { - struct sockaddr_in6 client_addr; - socklen_t sock_size ; - - // check arguments... - if (NULL == out_conection_socket) - { - printf("[SOCKET_IP6] [socket_ip6_server_accept] ERROR: NULL out_conection_socket\n"); - return -1; - } - - // Accept - debug_info("[SOCKET_IP6] [socket_ip6_server_accept] Accept\n"); - - sock_size = sizeof(struct sockaddr_in); - *out_conection_socket = accept(socket, (struct sockaddr * ) &client_addr, &sock_size); - if (*out_conection_socket < 0) { - printf("[SOCKET_IP6] [socket_accept_send] ERROR: socket accept\n"); - return -1; - } - - debug_info("[SOCKET_IP6] [socket_ip6_server_accept] accepted for %d\n", *out_conection_socket); - - return 0; - } - - - int socket_ip6_client_connect ( char *srv_name, int port, int *out_socket ) - { - int client_fd; - struct addrinfo hints, *res, *p; - char port_str[6]; // max port is 65535 - - // check arguments... - if (NULL == out_socket) - { - printf("[SOCKET_IP6] [socket_ip6_client_connect] ERROR: NULL out_socket\n"); - return -1; - } - - // connecting... - snprintf(port_str, sizeof(port_str), "%d", port); - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_INET6; // IPv6 only - hints.ai_socktype = SOCK_STREAM; // TCP - - int status = getaddrinfo(srv_name, port_str, &hints, &res); - if (status != 0) - { - fprintf(stderr, "[SOCKET_IP6] getaddrinfo error: %s\n", gai_strerror(status)); - return -1; - } - - for (p = res; p != NULL; p = p->ai_next) - { - client_fd = socket(p->ai_family, p->ai_socktype, p->ai_protocol); - if (client_fd == -1) { - continue; - } - - if (connect(client_fd, p->ai_addr, p->ai_addrlen) == 0) - { - // Success - *out_socket = client_fd; - freeaddrinfo(res); - return 0; - } - - close(client_fd); - } - - fprintf(stderr, "[SOCKET_IP6] Connection failed to %s on port %d\n", srv_name, port); - freeaddrinfo(res); - return -1; - } - - int socket_ip6_client_connect_with_retries ( char *srv_name, char *port_name, int *out_socket, int n_retries ) - { - int ret; - struct addrinfo hints, *res = NULL; - int socket_setopt_data ( int socket ) ; - int socket_client_connect_retries ( int sd, int n_retries, struct sockaddr *ai_addr, socklen_t ai_addrlen ) ; - - debug_info("[SOCKET] [socket_ip6_client_connect_with_retries] srv_name:%s port_name:%s\n", srv_name, port_name); - - // socket - *out_socket = socket(AF_INET6, SOCK_STREAM, IPPROTO_TCP); - if (*out_socket < 0) { - perror("socket: ") ; - return -1; - } - - ret = socket_setopt_data(*out_socket) ; - if (ret < 0) { - close(*out_socket); - return -1; - } - - // getaddrinfo - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_INET6; - hints.ai_socktype = SOCK_STREAM; - - ret = getaddrinfo(srv_name, port_name, &hints, &res); - if ( (ret != 0) || (res == NULL) ) { - fprintf(stderr, "getaddrinfo failed for %s:%s - %s\n", srv_name, port_name, gai_strerror(ret)); - close(*out_socket); - return -1; - } - - // Connect with retries - ret = socket_client_connect_retries(*out_socket, n_retries, res->ai_addr, res->ai_addrlen) ; - - freeaddrinfo(res); - - if (ret < 0) { - printf("[SOCKET] [socket_ip6_client_connect_with_retries] ERROR: connect fails\n"); - close(*out_socket); - return -1; - } - - return 0; - } - - - // - // address management - // - - int socket_ip6_gethostname ( char * srv_name ) - { - int ret ; - struct ifaddrs *ifaddr, *ifa ; - char ipstr[INET6_ADDRSTRLEN] ; - struct sockaddr_in6 *sa6 ; - - debug_info("[SOCKET_IP6] [socket_ip6_gethostname] >> Begin IPv6\n"); - - if (getifaddrs(&ifaddr) == -1) - { - perror("getifaddrs"); - return -1 ; - } - - debug_info("[NS] [ns_get_hostname] >> Successfully retrieved network interfaces"); - - for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) - { - // Skip empty and non-IPv6 - if (!ifa->ifa_addr) { - continue; - } - if (ifa->ifa_addr->sa_family != AF_INET6) { - continue; - } - - sa6 = (struct sockaddr_in6 *)ifa->ifa_addr; - - // Skip link-local and loopback - if (IN6_IS_ADDR_LINKLOCAL(&sa6->sin6_addr)) { - debug_info("[NS] [ns_get_hostname] >> Skipping link-local IPv6 address"); - continue; - } - if (IN6_IS_ADDR_LOOPBACK(&sa6->sin6_addr)) { - debug_info("[NS] [ns_get_hostname] >> Skipping loopback IPv6 address"); - continue; - } - - // inet_ntop... - inet_ntop(AF_INET6, &sa6->sin6_addr, ipstr, sizeof(ipstr)); - debug_info("[NS] [ns_get_hostname] >> Found global IPv6 address: %s", ipstr); - - ret = getnameinfo((struct sockaddr *)sa6, sizeof(*sa6), srv_name, sizeof(srv_name), NULL, 0, NI_NAMEREQD); - if (ret == 0) { - debug_info("Resolved hostname for IPv6 %s: %s", ipstr, hostname); - } - /* - if (ret == 0) { - debug_info("Resolved hostname for IPv6 %s: %s", ipstr, hostname); - break; // Stop after first valid result - } - else { - debug_info("Could not resolve name for %s: %s", ipstr, gai_strerror(ret)); - } - */ - } - - freeifaddrs(ifaddr); - - debug_info("[SOCKET_IP6] [socket_ip6_gethostname] >> End IPv6\n"); - - return 0 ; - } - - int socket_ip6_gethostbyname ( char *ip, size_t ip_size, char *srv_name ) - { - struct addrinfo hints, *res, *p; - int status; - struct sockaddr_in6 *ipv6 ; - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_INET6; // IPv6 only - hints.ai_socktype = SOCK_STREAM; // TCP - - // printf("%s %ld %s\n\n", ip, (long)ip_size, srv_name); - - status = getaddrinfo(srv_name, NULL, &hints, &res); - if (status != 0) - { - printf("[SOCKET_IP6] socket_ip6_gethostname"); - fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(status)); - return -1; - } - - for (p = res; p != NULL; p = p->ai_next) - { - if (p->ai_family == AF_INET6) - { - ipv6 = (struct sockaddr_in6 *)p->ai_addr; - if (inet_ntop(AF_INET6, &ipv6->sin6_addr, ip, ip_size)) - { - freeaddrinfo(res); - return 0; // Success - } - else - { - perror("inet_ntop"); - break; - } - } - } - - freeaddrinfo(res); - return -1; - } - - int socket_ip6_getsockname ( char * port_name, int new_socket ) - { - struct sockaddr_in6 server_addr; - - socklen_t len = sizeof(server_addr); - getsockname(new_socket, (struct sockaddr *)&server_addr, &len); - sprintf(port_name, "%d", ntohs(server_addr.sin6_port)); - - return 1; - } - - - /* ................................................................... */ - diff --git a/src/base/string_misc.c b/src/base/string_misc.c deleted file mode 100644 index 0ed6ae1da..000000000 --- a/src/base/string_misc.c +++ /dev/null @@ -1,196 +0,0 @@ - -/* - * Copyright 2020-2025 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 . - * - */ - - - /* ... Include / Inclusion ........................................... */ - - #include "base/string_misc.h" - - - /* ... Functions / Funciones ......................................... */ - - - /** - * Return the string length of 'str'. - * @param str the string. - * @return the string length. - */ - long STRING_MISC_StrLen ( /*IN*/ char *str ) - { - /* check params */ - if (str == NULL) - return 0L ; - - return (long)strlen(str) ; - } - - /** - * Return true if and only if the strings 'str1' and 'str2' are equals. - * @param str1 the first string. - * @param str2 the second string. - * @return true (1) iff are equals or false (0) in other case. - */ - int8_t STRING_MISC_Equal ( /*IN*/ char *str1, - /*IN*/ char *str2 ) - { - /* easy cases */ - if (str1 == str2) - return (1) ; - if ( (str1 == NULL) || (str2 == NULL) ) - return (0) ; - - /* use strcmp */ - if ( (strcmp(str1,str2) == 0) ) - return (1) ; - - return (0) ; - } - - /** - * Return a string clone of 'str'. - * @param str the string. - * @return a clone of 'str'. - */ - char *STRING_MISC_StrDup ( /*IN*/ char *str ) - { - int lenstr ; - char *pch ; - - /* check params */ - if (NULL == str) - return NULL; - - /* alloc memory for the clone... */ - lenstr = STRING_MISC_StrLen(str) + 1 ; - pch = (char *)malloc(lenstr) ; - if (NULL == pch) - return NULL; - - /* copy contents */ - memmove(pch,str,lenstr) ; - return pch ; - } - - /** - * - * Como 'strlen' pero permite usar - * un string con formato. - * - * Like 'strlen' but also accept - * a string with format. - * - * @param format string format. - * @param argl format params. - * @return string legth. - * - */ - int STRING_MISC_StrLenF - ( - /*IN*/ char *format, - /*IN*/ va_list argl - ) - { - int ineed ; - static FILE *nullfd = NULL ; - - if (nullfd == NULL) - { - nullfd = fopen (NULL_DEVICE_PATH,"w") ; - /* - * we will lost one file descriptor, - * because we never "fclose(nullfd)". - */ - } - - if (strchr(format,'%') != NULL) - { - ineed = vfprintf(nullfd,format,argl) ; - } - else /* only a string, not format */ - { - ineed = strlen(format) ; - } - - return ineed ; - } - - /** - * - * Actua igual que 'vsprintf', pero pide memoria - * dinamica para el string donde se imprime. - * Retorna NULL si no pudo. - * - * Like vsprintf, but request dynamic memory - * to write string elements. - * - * @param format string format. - * @param argl format params. - * @return string pointer or NULL if error. - * - */ - char *STRING_MISC_Dvsprintf - ( - /*IN*/ char *format, - /*IN*/ va_list argl - ) - { - char *baux ; - int ineed ; - - ineed = STRING_MISC_StrLenF(format,argl) ; - baux = (char *)malloc(ineed+1) ; - if (NULL == baux) - return NULL ; - - vsprintf(baux,format,argl) ; - - return baux ; - } - - /** - * - * Igual que la anterior, solo varia los argumentos - * - * Like before, but with open arguments. - * - * @param format string with message format. - * @return string pointer or NULL if error. - * - */ - char *STRING_MISC_Dsprintf - ( - /*IN*/ char *format, - ... - ) - { - char *saux ; - va_list varg ; - - va_start(varg,format) ; - saux = STRING_MISC_Dvsprintf(format,varg) ; - va_end(varg) ; - - return saux ; - } - - - /* ...................................................................... */ - diff --git a/src/base/syscall_proxies.c b/src/base/syscall_proxies.c deleted file mode 100644 index 050e08a5d..000000000 --- a/src/base/syscall_proxies.c +++ /dev/null @@ -1,1059 +0,0 @@ - -/* - * Copyright 2000-2025 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 . - * - */ - - -/* ... Include / Inclusion ........................................... */ - - #define __USE_GNU - #include "base/syscall_proxies.h" - - -/* ... Global variables / Variables globales ........................ */ - -int (*real_open )(char *, int, mode_t) = NULL; -int (*real___open_2)(char *, int) = NULL; -int (*real_creat )(const char *, mode_t) = NULL; -int (*real_mkstemp )(char*) = NULL; -int (*real_close )(int) = NULL; - -ssize_t (*real_read )(int, void*, size_t) = NULL; -ssize_t (*real_write)(int, const void*, size_t) = NULL; - -ssize_t (*real_pread )(int, void *, size_t, off_t) = NULL; -ssize_t (*real_pwrite )(int, const void *, size_t, off_t) = NULL; - -off_t (*real_lseek)(int, off_t, int) = NULL; -int (*real_ftruncate)(int, off_t) = NULL; - -int (*real_stat )(int, char *, struct stat *) = NULL; -int (*real_lstat )(int, char *, struct stat *) = NULL; -int (*real_fstat )(int, int, struct stat *) = NULL; -int (*real_fstatat )(int, const char *, struct stat *, int) = NULL; -int (*real_statfs )(const char *, struct statfs *) = NULL; - -int (*real_rename)(const char *, const char *) = NULL; -int (*real_unlink)(char *) = NULL; -int (*real_remove)(char *) = NULL; - -FILE* (*real_fopen )(const char *, const char *) = NULL; -FILE* (*real_fdopen)(int, const char *) = NULL; -int (*real_fclose)(FILE *) = NULL; - -size_t (*real_fread )(void *, size_t, size_t, FILE *) = NULL; -size_t (*real_fwrite)(const void *, size_t, size_t, FILE *) = NULL; - -int (*real_fseek )(FILE *, long int, int) = NULL; -long (*real_ftell )(FILE *) = NULL; -void (*real_rewind)(FILE *) = NULL; -int (*real_feof ) (FILE *) = NULL; - -DIR* (*real_opendir )(char*) = NULL; -long (*real_telldir )(DIR *) = NULL; -void (*real_seekdir )(DIR *, long) = NULL; -struct dirent * (*real_readdir )(DIR *) = NULL; -int (*real_closedir )(DIR *) = NULL; - -int (*real_mkdir)(char *, mode_t) = NULL; -int (*real_rmdir)(char *) = NULL; - -int (*real_fork)(void) = NULL; -int (*real_pipe)(int *) = NULL; -int (*real_dup)(int) = NULL; -int (*real_dup2)(int, int) = NULL; -void (*real_exit)(int) = NULL; -int (*real_chdir)(char *) = NULL; -int (*real_chmod)(char *, mode_t) = NULL; -int (*real_fchmod)(int, mode_t) = NULL; -int (*real_chown)(char *, uid_t, gid_t) = NULL; -int (*real_fcntl)(int, int, long) = NULL; -int (*real_access)(const char *, int) = NULL; -char* (*real_realpath)(const char *restrict, char *restrict) = NULL; -int (*real_fsync)(int) = NULL; -int (*real_flock)(int, int) = NULL; -void* (*real_mmap)(void *, size_t, int, int, int, off_t) = NULL; - - -#if defined(HAVE_64BITS) -struct dirent64 * (*real_readdir64)(DIR *) = NULL; -DIR* (*real_opendir64)(char*) = NULL; -int (*real_statfs64 )(const char *, struct statfs64 *) = NULL; -int (*real_fstatat64)(int, const char *, struct stat64 *, int) = NULL; -int (*real_fxstat64 )(int, int, struct stat64 *) = NULL; -int (*real_lxstat64 )(int, const char *, struct stat64 *) = NULL; -int (*real_xstat64 )(int, const char *, struct stat64 *) = NULL; -off64_t (*real_lseek64)(int, off64_t, int) = NULL; -ssize_t (*real_pread64 )(int, void *, size_t, off_t) = NULL; -int (*real_open64 )(char *, int, mode_t) = NULL; -ssize_t (*real_pwrite64)(int, const void *, size_t, off_t) = NULL; -#endif - -/* ... Functions / Funciones ......................................... */ - -// File API -int dlsym_open (char *path, int flags) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_open] >> Begin\n"); - - if (real_open == NULL) { - real_open = (int (*)(char *, int, mode_t)) dlsym(RTLD_NEXT, "open"); - } - - int fd = real_open((char *)path, flags, 0); - - debug_info("[SYSCALL_PROXIES] [dlsym_open] >> End\n"); - - return fd; -} - -int dlsym_open2 (char *path, int flags, mode_t mode) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_open2] >> Begin\n"); - - if (real_open == NULL) { - real_open = (int (*)(char *, int, mode_t)) dlsym(RTLD_NEXT, "open"); - } - - int fd = real_open((char *)path, flags, mode); - - debug_info("[SYSCALL_PROXIES] [dlsym_open2] >> End\n"); - - return fd; -} - -#if defined(HAVE_64BITS) -int dlsym_open64 (char *path, int flags, mode_t mode) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_open64] >> Begin\n"); - - if (real_open64 == NULL){ - real_open64 = (int (*)(char *, int, mode_t)) dlsym(RTLD_NEXT, "open64"); - } - - int fd = real_open64((char *)path, flags, mode); - - debug_info("[SYSCALL_PROXIES] [dlsym_open64] >> End\n"); - - return fd; -} -#endif - -int dlsym___open_2 (char *path, int flags) -{ - debug_info("[SYSCALL_PROXIES] [dlsym___open_2] >> Begin\n"); - - if (real___open_2 == NULL) { - real___open_2 = (int (*)(char *, int)) dlsym(RTLD_NEXT, "__open"); - } - - int fd = real___open_2((char *)path, flags); - - debug_info("[SYSCALL_PROXIES] [dlsym___open_2] >> End\n"); - - return fd; -} - -int dlsym_creat (const char *path, mode_t mode) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_creat] >> Begin\n"); - - if (real_creat == NULL) { - real_creat = (int (*)(const char *, mode_t)) dlsym(RTLD_NEXT, "creat"); - } - - int fd = real_creat(path,mode); - - debug_info("[SYSCALL_PROXIES] [dlsym_creat] >> End\n"); - - return fd; -} - -int dlsym_mkstemp (char *template) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_mkstemp] >> Begin\n"); - - if (real_mkstemp == NULL) { - real_mkstemp = (int(*)(char *)) dlsym(RTLD_NEXT, "mkstemp"); - } - - int ret = real_mkstemp(template); - - debug_info("[SYSCALL_PROXIES] [dlsym_mkstemp] >> End\n"); - - return ret; -} - -int dlsym_ftruncate (int fd, off_t length) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_ftruncate] >> Begin\n"); - - if (real_ftruncate == NULL){ - real_ftruncate = (int (*)(int, off_t)) dlsym(RTLD_NEXT, "ftruncate"); - } - - int ret = real_ftruncate(fd, length); - - debug_info("[SYSCALL_PROXIES] [dlsym_ftruncate] >> End\n"); - - return ret; -} - -ssize_t dlsym_read (int fd, void *buf, size_t nbyte) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_read] >> Begin\n"); - - if (real_read == NULL){ - real_read = (ssize_t (*)(int, void*, size_t)) dlsym(RTLD_NEXT, "read"); - } - - ssize_t ret = real_read(fd, buf, nbyte); - - debug_info("[SYSCALL_PROXIES] [dlsym_read] >> End\n"); - - return ret; -} - -ssize_t dlsym_write (int fd, void *buf, size_t nbyte) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_write] >> Begin\n"); - - if (real_write == NULL){ - real_write = (ssize_t (*)(int, const void*, size_t)) dlsym(RTLD_NEXT, "write"); - } - - ssize_t ret = real_write(fd, buf, nbyte); - - debug_info("[SYSCALL_PROXIES] [dlsym_write] >> End\n"); - - return ret; -} - -ssize_t dlsym_pread (int fd, void *buf, size_t count, off_t offset) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_pread] >> Begin\n"); - - if (real_pread == NULL){ - real_pread = (ssize_t (*)(int, void *, size_t, off_t)) dlsym(RTLD_NEXT, "pread"); - } - - ssize_t ret = real_pread(fd, buf, count, offset); - - debug_info("[SYSCALL_PROXIES] [dlsym_pread] >> End\n"); - - return ret; -} - -ssize_t dlsym_pwrite (int fd, const void *buf, size_t count, off_t offset) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_pwrite] >> Begin\n"); - - if (real_pwrite == NULL){ - real_pwrite = (ssize_t (*)(int, const void *, size_t, off_t)) dlsym(RTLD_NEXT, "pwrite"); - } - - ssize_t ret = real_pwrite(fd, buf, count, offset); - - debug_info("[SYSCALL_PROXIES] [dlsym_pwrite] >> End\n"); - - return ret; -} - - -#if defined(HAVE_64BITS) -ssize_t dlsym_pread64 (int fd, void *buf, size_t count, off_t offset) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_pread64] >> Begin\n"); - - if (real_pread64 == NULL){ - real_pread64 = (ssize_t (*)(int, void *, size_t, off_t)) dlsym(RTLD_NEXT, "pread64"); - } - - ssize_t ret = real_pread64(fd, buf, count, offset); - - debug_info("[SYSCALL_PROXIES] [dlsym_pread64] >> End\n"); - - return ret; -} - - -ssize_t dlsym_pwrite64 (int fd, const void *buf, size_t count, off_t offset) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_pwrite64] >> Begin\n"); - - if (real_pwrite64 == NULL){ - real_pwrite64 = (ssize_t (*)(int, const void *, size_t, off_t)) dlsym(RTLD_NEXT, "pwrite64"); - } - - ssize_t ret = real_pwrite64(fd, buf, count, offset); - - debug_info("[SYSCALL_PROXIES] [dlsym_pwrite64] >> End\n"); - - return ret; -} -#endif - -off_t dlsym_lseek (int fd, off_t offset, int whence) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_lseek] >> Begin\n"); - - if (real_lseek == NULL){ - real_lseek = (off_t (*)(int, off_t, int)) dlsym(RTLD_NEXT, "lseek"); - } - - off_t ret = real_lseek(fd, offset, whence); - - debug_info("[SYSCALL_PROXIES] [dlsym_lseek] >> End\n"); - - return ret; -} - -#if defined(HAVE_64BITS) -off64_t dlsym_lseek64 (int fd, off64_t offset, int whence) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_lseek64] >> Begin\n"); - - if (real_lseek64 == NULL){ - real_lseek64 = (off64_t (*)(int, off64_t, int)) dlsym(RTLD_NEXT, "lseek64"); - } - - off64_t ret = real_lseek64(fd, offset, whence); - - debug_info("[SYSCALL_PROXIES] [dlsym_lseek64] >> End\n"); - - return ret; -} - -int dlsym_lxstat64 (int ver, const char *path, struct stat64 *buf) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_lxstat64] >> Begin\n"); - - if (real_lxstat64 == NULL){ - real_lxstat64 = (int (*)(int, const char *, struct stat64 *)) dlsym(RTLD_NEXT, "__lxstat64"); - } - - int ret = real_lxstat64(ver,(char *)path, buf); - - debug_info("[SYSCALL_PROXIES] [dlsym_lxstat64] >> End\n"); - - return ret; -} - -int dlsym_xstat64 (int ver, const char *path, struct stat64 *buf) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_xstat64] >> Begin\n"); - - if (real_xstat64 == NULL){ - real_xstat64 = (int (*)(int, const char *, struct stat64 *)) dlsym(RTLD_NEXT, "__xstat64"); - } - - int ret = real_xstat64(ver,(char *)path, buf); - - debug_info("[SYSCALL_PROXIES] [dlsym_xstat64] >> End\n"); - - return ret; -} - -int dlsym_fxstat64 (int ver, int fd, struct stat64 *buf) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_fxstat64] >> Begin\n"); - - if (real_fxstat64 == NULL){ - real_fxstat64 = (int (*)(int, int, struct stat64 *)) dlsym(RTLD_NEXT, "__fxstat64"); - } - - int ret = real_fxstat64(ver,fd, buf); - - debug_info("[SYSCALL_PROXIES] [dlsym_fxstat64] >> End\n"); - - return ret; -} -#endif - -int dlsym_lstat (int ver, const char *path, struct stat *buf) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_lstat] >> Begin\n"); - - if (real_lstat == NULL){ - real_lstat = (int (*)(int, char *, struct stat *)) dlsym(RTLD_NEXT, "__lxstat"); - } - - int ret = real_lstat(ver,(char *)path, buf); - - debug_info("[SYSCALL_PROXIES] [dlsym_lstat] >> End\n"); - - return ret; -} - -int dlsym_stat (int ver, const char *path, struct stat *buf) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_stat] >> Begin\n"); - - if (real_stat == NULL){ - real_stat = (int (*)(int, char *, struct stat *)) dlsym(RTLD_NEXT, "__xstat"); - } - - int ret = real_stat(ver,(char *)path, buf); - - debug_info("[SYSCALL_PROXIES] [dlsym_stat] >> End\n"); - - return ret; -} - -int dlsym_fstat (int ver, int fd, struct stat *buf) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_fstat] >> Begin\n"); - - if (real_fstat == NULL){ - real_fstat = (int (*)(int, int, struct stat *)) dlsym(RTLD_NEXT, "__fxstat"); - } - - int ret = real_fstat(ver,fd, buf); - - debug_info("[SYSCALL_PROXIES] [dlsym_fstat] >> End\n"); - - return ret; -} - -int dlsym_fstatat (int dfd, const char *path, struct stat *buf, int flags) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_fstatat] >> Begin\n"); - - if (real_fstatat == NULL){ - real_fstatat = (int (*)(int, const char *, struct stat *, int)) dlsym(RTLD_NEXT, "fstatat"); - } - - int ret = real_fstatat(dfd,(char *)path, buf, flags); - - debug_info("[SYSCALL_PROXIES] [dlsym_fstatat] >> End\n"); - - return ret; -} - -#if defined(HAVE_64BITS) -int dlsym_fstatat64 (int dfd, const char *path, struct stat64 *buf, int flags) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_fstatat64] >> Begin\n"); - - if (real_fstatat64 == NULL){ - real_fstatat64 = (int (*)(int, const char *, struct stat64 *, int)) dlsym(RTLD_NEXT, "fstatat64"); - } - - int ret = real_fstatat64(dfd,(char *)path, buf, flags); - - debug_info("[SYSCALL_PROXIES] [dlsym_fstatat64] >> End\n"); - - return ret; -} -#endif - -int dlsym_statfs (const char *path, struct statfs *buf) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_statfs] >> Begin\n"); - - if (real_statfs == NULL){ - real_statfs = (int (*)(const char *, struct statfs *)) dlsym(RTLD_NEXT, "statfs"); - } - - int ret = real_statfs(path, buf); - - debug_info("[SYSCALL_PROXIES] [dlsym_statfs] >> End\n"); - - return ret; -} - - -#if defined(HAVE_64BITS) -int dlsym_statfs64 (const char *path, struct statfs64 *buf) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_statfs64] >> Begin\n"); - - if (real_statfs64 == NULL){ - real_statfs64 = (int (*)(const char *, struct statfs64 *)) dlsym(RTLD_NEXT, "statfs64"); - } - - int ret = real_statfs64(path, buf); - - debug_info("[SYSCALL_PROXIES] [dlsym_statfs64] >> End\n"); - - return ret; -} -#endif - -int dlsym_close (int fd) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_close] >> Begin\n"); - - if (real_close == NULL){ - real_close = (int (*)(int)) dlsym(RTLD_NEXT, "close"); - } - - int ret = real_close(fd); - - debug_info("[SYSCALL_PROXIES] [dlsym_close] >> End\n"); - - return ret; -} - -int dlsym_rename (const char *old_path, const char *new_path) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_rename] >> Begin\n"); - - if (real_rename == NULL){ - real_rename = (int (*)(const char *, const char *)) dlsym(RTLD_NEXT, "rename"); - } - - int ret = real_rename(old_path, new_path); - - debug_info("[SYSCALL_PROXIES] [dlsym_rename] >> End\n"); - - return ret; -} - -int dlsym_unlink (char *path) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_unlink] >> Begin\n"); - - if (real_unlink == NULL){ - real_unlink = (int (*)(char *)) dlsym(RTLD_NEXT, "unlink"); - } - - int ret = real_unlink((char *)path); - - debug_info("[SYSCALL_PROXIES] [dlsym_unlink] >> End\n"); - - return ret; -} - -int dlsym_remove (char *path) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_remove] >> Begin\n"); - - if (real_remove == NULL){ - real_remove = (int (*)(char *)) dlsym(RTLD_NEXT, "remove"); - } - - int ret = real_remove((char *)path); - - debug_info("[SYSCALL_PROXIES] [dlsym_remove] >> End\n"); - - return ret; -} - -// File API (stdio) -FILE* dlsym_fopen(const char *filename, const char *mode) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_fopen] >> Begin\n"); - - if (real_fopen == NULL) { - real_fopen = (FILE* (*)(const char *, const char *)) dlsym(RTLD_NEXT, "fopen"); - } - - FILE* fd = real_fopen((const char *) filename, mode); - - debug_info("[SYSCALL_PROXIES] [dlsym_fopen] >> End\n"); - - return fd; -} - -FILE* dlsym_fdopen(int fd, const char *mode) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_fdopen] >> Begin\n"); - - if (real_fdopen == NULL) { - real_fdopen = (FILE* (*)(int, const char *)) dlsym(RTLD_NEXT, "fdopen"); - } - - FILE* fp = real_fdopen(fd, mode); - - debug_info("[SYSCALL_PROXIES] [dlsym_fdopen] >> End\n"); - - return fp; -} - -int dlsym_fclose(FILE *stream) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_fclose] >> Begin\n"); - - if (real_fclose == NULL) { - real_fclose = (int (*)(FILE*)) dlsym(RTLD_NEXT, "fclose"); - } - - int ret = real_fclose(stream); - - debug_info("[SYSCALL_PROXIES] [dlsym_fclose] >> End\n"); - - return ret; -} - -size_t dlsym_fread(void *ptr, size_t size, size_t nmemb, FILE *stream) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_fread] >> Begin\n"); - - if (real_fread == NULL) { - real_fread = (size_t (*)(void *, size_t, size_t, FILE *)) dlsym(RTLD_NEXT, "fread"); - } - - size_t ret = real_fread(ptr, size, nmemb, stream); - - debug_info("[SYSCALL_PROXIES] [dlsym_fread] >> End\n"); - - return ret; -} - -size_t dlsym_fwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_fwrite] >> Begin\n"); - - if (real_fwrite == NULL) { - real_fwrite = (size_t (*)(const void *, size_t, size_t, FILE *)) dlsym(RTLD_NEXT, "fwrite"); - } - - size_t ret = real_fwrite(ptr, size, nmemb, stream); - - debug_info("[SYSCALL_PROXIES] [dlsym_fwrite] >> End\n"); - - return ret; -} - -int dlsym_fseek (FILE *stream, long int offset, int whence) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_fseek] >> Begin\n"); - - if (real_fseek == NULL) { - real_fseek = (int (*)(FILE *, long int, int)) dlsym(RTLD_NEXT, "fseek"); - } - - int ret = real_fseek(stream, offset, whence); - - debug_info("[SYSCALL_PROXIES] [dlsym_fseek] >> End\n"); - - return ret; -} - -long dlsym_ftell (FILE *stream) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_ftell] >> Begin\n"); - - if (real_ftell== NULL) { - real_ftell = (long (*)(FILE *)) dlsym(RTLD_NEXT, "ftell"); - } - - int ret = real_ftell(stream); - - debug_info("[SYSCALL_PROXIES] [dlsym_ftell] >> End\n"); - - return ret; -} - -void dlsym_rewind (FILE *stream) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_rewind] >> Begin\n"); - - if (real_rewind == NULL) { - real_rewind = (void(*)(FILE *)) dlsym(RTLD_NEXT, "rewind"); - } - - real_rewind(stream); - - debug_info("[SYSCALL_PROXIES] [dlsym_rewind] >> End\n"); -} - -int dlsym_feof (FILE *stream) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_feof] >> Begin\n"); - - if (real_feof== NULL) { - real_feof = (int (*)(FILE *)) dlsym(RTLD_NEXT, "feof"); - } - - int ret = real_feof(stream); - - debug_info("[SYSCALL_PROXIES] [dlsym_feof] >> End\n"); - - return ret; -} - -// Directory API -DIR* dlsym_opendir (char *dirname) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_opendir] >> Begin\n"); - - if (real_opendir == NULL){ - real_opendir = (DIR* (*)(char*)) dlsym(RTLD_NEXT, "opendir"); - } - - DIR* ret = real_opendir((char *)dirname); - - debug_info("[SYSCALL_PROXIES] [dlsym_opendir] >> End\n"); - - return ret; -} - -#if defined(HAVE_64BITS) -DIR* dlsym_opendir64 (char *dirname) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_opendir64] >> Begin\n"); - - if (real_opendir64 == NULL){ - real_opendir64 = (DIR* (*)(char*)) dlsym(RTLD_NEXT, "opendir64"); - } - - DIR* ret = real_opendir64((char *)dirname); - - debug_info("[SYSCALL_PROXIES] [dlsym_opendir64] >> End\n"); - - return ret; -} -#endif - -long dlsym_telldir (DIR *dirp) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_telldir] >> Begin\n"); - - if (real_telldir == NULL){ - real_telldir = (long (*)(DIR *)) dlsym(RTLD_NEXT, "telldir"); - } - - long ret = real_telldir((DIR *)dirp); - - debug_info("[SYSCALL_PROXIES] [dlsym_telldir] >> End\n"); - - return ret; -} - -void dlsym_seekdir (DIR *dirp, long loc) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_seekdir] >> Begin\n"); - - if (real_seekdir == NULL){ - real_seekdir = (void (*)(DIR *, long)) dlsym(RTLD_NEXT, "seekdir"); - } - - real_seekdir((DIR *)dirp, (long) loc); - - debug_info("[SYSCALL_PROXIES] [dlsym_seekdir] >> End\n"); -} - -int dlsym_mkdir (char *path, mode_t mode) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_mkdir] >> Begin\n"); - - if (real_mkdir == NULL){ - real_mkdir = (int (*)(char *, mode_t)) dlsym(RTLD_NEXT, "mkdir"); - } - - int ret = real_mkdir((char *)path,mode); - - debug_info("[SYSCALL_PROXIES] [dlsym_mkdir] >> End\n"); - - return ret; -} - -struct dirent * dlsym_readdir (DIR *dirp) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_readdir] >> Begin\n"); - - if (real_readdir == NULL){ - real_readdir = (struct dirent * (*)(DIR *)) dlsym(RTLD_NEXT, "readdir"); - } - - struct dirent * ret = real_readdir(dirp); - - debug_info("[SYSCALL_PROXIES] [dlsym_readdir] >> End\n"); - - return ret; -} - -#if defined(HAVE_64BITS) -struct dirent64 * dlsym_readdir64 (DIR *dirp) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_readdir64] >> Begin\n"); - - if (real_readdir64 == NULL){ - real_readdir64 = (struct dirent64 * (*)(DIR *)) dlsym(RTLD_NEXT, "readdir64"); - } - - struct dirent64 * ret = real_readdir64(dirp); - - debug_info("[SYSCALL_PROXIES] [dlsym_readdir64] >> End\n"); - - return ret; -} -#endif - -int dlsym_closedir (DIR* dirp) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_closedir] >> Begin\n"); - - if (real_closedir == NULL){ - real_closedir = (int (*)(DIR*)) dlsym(RTLD_NEXT, "closedir"); - } - - int ret = real_closedir(dirp); - - debug_info("[SYSCALL_PROXIES] [dlsym_closedir] >> End\n"); - - return ret; -} - -int dlsym_rmdir (char *path) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_rmdir] >> Begin\n"); - - if (real_rmdir == NULL){ - real_rmdir = (int (*)(char *)) dlsym(RTLD_NEXT, "rmdir"); - } - - int ret = real_rmdir((char *)path); - - debug_info("[SYSCALL_PROXIES] [dlsym_rmdir] >> End\n"); - - return ret; -} - -// Proccess API -int dlsym_fork (void) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_fork] >> Begin\n"); - - if (real_fork == NULL){ - real_fork = (int (*)()) dlsym(RTLD_NEXT, "fork"); - } - - int ret = real_fork(); - - debug_info("[SYSCALL_PROXIES] [dlsym_fork] >> End\n"); - - return ret; -} - -int dlsym_pipe (int pipefd[2]) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_pipe] >> Begin\n"); - - if (real_pipe == NULL){ - real_pipe = (int (*)(int *)) dlsym(RTLD_NEXT, "pipe"); - } - - int ret = real_pipe(pipefd); - - debug_info("[SYSCALL_PROXIES] [dlsym_pipe] >> End\n"); - - return ret; -} - -int dlsym_dup (int fd) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_dup] >> Begin\n"); - - if (real_dup == NULL){ - real_dup = (int (*)(int)) dlsym(RTLD_NEXT, "dup"); - } - - int ret = real_dup(fd); - - debug_info("[SYSCALL_PROXIES] [dlsym_dup] >> End\n"); - - return ret; -} - -int dlsym_dup2 (int fd, int fd2) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_dup2] >> Begin\n"); - - if (real_dup2 == NULL){ - real_dup2 = (int (*)(int, int)) dlsym(RTLD_NEXT, "dup2"); - } - - int ret = real_dup2(fd, fd2); - - debug_info("[SYSCALL_PROXIES] [dlsym_dup2] >> End\n"); - - return ret; -} - -void dlsym_exit (int status) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_exit] >> Begin\n"); - - if (real_exit == NULL){ - real_exit = (void (*)(int)) dlsym(RTLD_NEXT, "exit"); - } - - real_exit(status); - - debug_info("[SYSCALL_PROXIES] [dlsym_exit] >> End\n"); -} - -// File/Directory Metadata API -int dlsym_chdir (char * path) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_chdir] >> Begin\n"); - - if (real_chdir == NULL){ - real_chdir = (int (*)(char *)) dlsym(RTLD_NEXT, "chdir"); - } - - int ret = real_chdir((char *)path); - - debug_info("[SYSCALL_PROXIES] [dlsym_chdir] >> End\n"); - - return ret; -} - -int dlsym_chmod (char *path, mode_t mode) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_chmod] >> Begin\n"); - - if (real_chmod == NULL){ - real_chmod = (int (*)(char *, mode_t)) dlsym(RTLD_NEXT, "chmod"); - } - - int ret = real_chmod((char *)path, mode); - - debug_info("[SYSCALL_PROXIES] [dlsym_chmod] >> End\n"); - - return ret; -} - -int dlsym_fchmod (int fd, mode_t mode) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_fchmod] >> Begin\n"); - - if (real_fchmod == NULL){ - real_fchmod = (int (*)(int, mode_t)) dlsym(RTLD_NEXT, "fchmod"); - } - - int ret = real_fchmod(fd,mode); - - debug_info("[SYSCALL_PROXIES] [dlsym_fchmod] >> End\n"); - - return ret; -} - -int dlsym_chown (char *path, uid_t owner, gid_t group) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_chown] >> Begin\n"); - - if (real_chown == NULL){ - real_chown = (int (*)(char *, uid_t, gid_t)) dlsym(RTLD_NEXT, "chown"); - } - - int ret = real_chown((char *)path, owner, group); - - debug_info("[SYSCALL_PROXIES] [dlsym_chown] >> End\n"); - - return ret; -} - -int dlsym_fcntl (int fd, int cmd, long arg) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_fcntl] >> Begin\n"); - - if (real_fcntl == NULL){ - real_fcntl = (int (*)(int, int, long)) dlsym(RTLD_NEXT, "fcntl"); - } - - int ret = real_fcntl(fd, cmd, arg); - - debug_info("[SYSCALL_PROXIES] [dlsym_fcntl] >> End\n"); - - return ret; -} - -int dlsym_access (const char *path, int mode) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_access] >> Begin\n"); - - if (real_access == NULL) { - real_access = (int (*)(const char *, int)) dlsym(RTLD_NEXT, "access"); - } - - int ret = real_access((char *)path, mode); - - debug_info("[SYSCALL_PROXIES] [dlsym_access] >> End\n"); - - return ret; -} - -char *dlsym_realpath (const char *restrict path, char *restrict resolved_path) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_realpath] >> Begin\n"); - - if (real_realpath == NULL) { - real_realpath = (char* (*)(const char *restrict, char *restrict)) dlsym(RTLD_NEXT, "realpath"); - } - - char* ret = real_realpath((char *)path, (char *)resolved_path); - - debug_info("[SYSCALL_PROXIES] [dlsym_realpath] >> End\n"); - - return ret; -} - -int dlsym_fsync (int fd) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_fsync] >> Begin\n"); - - if (real_fsync == NULL){ - real_fsync = (int (*)(int)) dlsym(RTLD_NEXT, "fsync"); - } - - int ret = real_fsync(fd); - - debug_info("[SYSCALL_PROXIES] [dlsym_fsync] >> End\n"); - - return ret; -} - -int dlsym_flock (int fd, int operation) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_flock] >> Begin\n"); - - if (real_flock == NULL){ - real_flock = (int (*)(int, int)) dlsym(RTLD_NEXT, "fsync"); - } - - int ret = real_flock(fd, operation); - - debug_info("[SYSCALL_PROXIES] [dlsym_flock] >> End\n"); - - return ret; -} - -// Memory API -void *dlsym_mmap (void *addr, size_t length, int prot, int flags, int fd, off_t offset) -{ - debug_info("[SYSCALL_PROXIES] [dlsym_mmap] >> Begin\n"); - - if (real_mmap == NULL) { - real_mmap = (void *(*)(void *, size_t, int, int, int, off_t)) dlsym(RTLD_NEXT, "mmap"); - } - - char* ret = real_mmap(addr, length, prot, flags, fd, offset); - - debug_info("[SYSCALL_PROXIES] [dlsym_mmap] >> End\n"); - - return ret; -} - - -/* ................................................................... */ - diff --git a/src/base/time_misc.c b/src/base/time_misc.c deleted file mode 100644 index 3d3300004..000000000 --- a/src/base/time_misc.c +++ /dev/null @@ -1,133 +0,0 @@ - -/* - * Copyright 2020-2025 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 . - * - */ - - - /* ... Include / Inclusion ........................................... */ - - #include "base/time_misc.h" - - - /* ... Functions / Funciones ......................................... */ - - /** - * Get a timestamp 't' at current time. - * @param t the timestamp. - * @return nothing. - */ - void TIME_MISC_Timer - ( - struct timeval * t - ) - { - int i=0; - - while (gettimeofday(t, 0)==-1) - i++; - - if (i!=0) - printf("WARNING: fail to gettimeofday in '%d' times.\n",i+1); - } - - - /** - * Compute 'dig = tn - to'. - * @param to initial instant. - * @param tn final instant. - * @param dif the substaction value ('tn - to'). - * @return nothing. - */ - void TIME_MISC_DiffTime - ( - struct timeval * to, - struct timeval * tn, - struct timeval * dif - ) - { - long aux; - - aux = (tn->tv_usec - to->tv_usec) + USECPSEC; - dif->tv_usec = aux % USECPSEC; - dif->tv_sec = (tn->tv_sec - to->tv_sec) - (1 - (aux / USECPSEC)); - /* - if(dif->tv_sec<0) - { - printf("segundos:%d\n",dif->tv_sec); - exit(0); - } - */ - } - - - /** - * Compute 'sum = tn + to'. - * @param to initial instant. - * @param tn final instant. - * @param sum the addition value ('tn + to'). - * @return nothing. - */ - void TIME_MISC_AddTime - ( - struct timeval * to, - struct timeval * tn, - struct timeval * sum - ) - { - long aux; - - aux = tn->tv_usec + to->tv_usec; - sum->tv_usec = aux % USECPSEC; - sum->tv_sec = (tn->tv_sec + to->tv_sec) + (aux / USECPSEC); - } - - - /** - * Return a timestamp as seconds. - * @param timet the timestamp. - * @return timestamp as seconds. - */ - float TIME_MISC_TimevaltoFloat(struct timeval* timet) - { - return( (float)(timet->tv_sec + (float)timet->tv_usec/ (float)USECPSEC)); - } - - - /** - * Return a timestamp as microseconds. - * @param timet the timestamp. - * @return timestamp as microseconds. - */ - float TIME_MISC_TimevaltoMicro(struct timeval* timet) - { - return( (float)timet->tv_sec * (float)USECPSEC + (float)timet->tv_usec); - } - /** - * Return a timestamp as microseconds. - * @param timet the timestamp. - * @return timestamp as microseconds. - */ - long TIME_MISC_TimevaltoMicroLong(struct timeval* timet) - { - return( (long)timet->tv_sec * (long)USECPSEC + (long)timet->tv_usec); - } - - - /* ................................................................... */ - diff --git a/src/base/trace_msg.c b/src/base/trace_msg.c deleted file mode 100644 index 898ecf1ea..000000000 --- a/src/base/trace_msg.c +++ /dev/null @@ -1,106 +0,0 @@ - -/* - * Copyright 2020-2025 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 . - * - */ - - - /* ... Include / Inclusion ........................................... */ - - #include "base/trace_msg.h" - - - /* ... Globla var. / Variables glob. ................................. */ - - int (*TRACE_MSG_PrintMsg)(const char *, va_list) = NULL ; - - - /* ... Functions / Funciones ......................................... */ - - void TRACE_MSG_setPrinter - ( - /*IN*/ int (*printer) (const char *, va_list) - ) - { - TRACE_MSG_PrintMsg = ( int (*)(const char *, va_list)) printer ; - } - - void TRACE_MSG_doPrint - ( - /*IN*/ char *fto, - ... - ) - { - if (TRACE_MSG_PrintMsg != NULL) - { - va_list vl ; - - va_start(vl,fto) ; - (*TRACE_MSG_PrintMsg)(fto,vl) ; - va_end(vl) ; - } - } - - void TRACE_MSG_VPrintF - ( - /*IN*/ int line, - /*IN*/ char *name, - /*IN*/ long pid, - /*IN*/ int type, - /*IN*/ char *fto, - /*IN*/ va_list vl - ) - { - if (TRACE_MSG_PrintMsg != NULL) - { - char *msg ; - - msg = STRING_MISC_Dvsprintf(fto,vl) ; - TRACE_MSG_doPrint("trace(%i,\"%s\",%li,%i,\"%s\").", - line, - name, - pid, - type, - msg) ; - free(msg) ; - } - } - - void TRACE_MSG_PrintF - ( - /*IN*/ int line, - /*IN*/ char *name, - /*IN*/ long pid, - /*IN*/ int type, - /*IN*/ char *fto, - ... - ) - { - if (TRACE_MSG_PrintMsg != NULL) - { - va_list vl ; - - va_start(vl,fto) ; - TRACE_MSG_VPrintF(line,name,pid,type,fto,vl) ; - va_end(vl) ; - } - } - - - /* ................................................................... */ - diff --git a/src/base/urlstr.c b/src/base/urlstr.c deleted file mode 100644 index c2bd8f6a0..000000000 --- a/src/base/urlstr.c +++ /dev/null @@ -1,273 +0,0 @@ - -/* - * Copyright 2020-2025 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 . - * - */ - - - /* ... Include / Inclusion ........................................... */ - - #include "base/urlstr.h" - - - /* ... Functions / Funciones ......................................... */ - - int getURLProtocol ( char *url, char *protocol ) - { - int i,j; - - if (url == NULL) - { - printf("[%s:%d] ERROR: url is NULL\n", __FILE__, __LINE__); - return -1; - } - - // find ':' - i = 0; - while ((url[i] != '\0')&&(url[i] != ':')) { - i++; - } - j = i; - - if (url[i] != ':') - { - printf("[%s:%d] ERROR: missing ':' within the url.\n", __FILE__, __LINE__); - printf("Usage: protocol_name://server:port//dir\n"); - return -1; - } - - i++; - if (url[i] != '/') - { - printf("[%s:%d] ERROR: missing first '/' within the url.\n", __FILE__, __LINE__); - printf("Usage: protocol_name://server:port//dir\n"); - return -1; - } - - i++; - if (url[i] != '/') - { - printf("[%s:%d] ERROR: missing second '/' within the url.\n", __FILE__, __LINE__); - printf("Usage: protocol_name://server:port//dir\n"); - return -1; - } - - i++; - if (protocol != NULL) - { - strncpy(protocol, url, j); - protocol[j] = '\0'; - } - - return i; - } - - - int getURLServer(char *url, char *server) - { - int i,j; - - i = getURLProtocol(url, NULL) ; - if (i < 0) { - return -1; - } - - j = i; - while ((url[j]!='\0')&&(url[j]!=':')&&(url[j]!='/')) { - j++; - } - - if (server != NULL) { - strncpy(server, url+i, j-i); - server[j-i] = '\0'; - } - - return j; - } - - - int getURLPort ( char *url, char *port ) - { - int i, j; - - i=getURLServer(url, NULL) ; - if (i < 0) { - return -1; - } - - if (url[i] != ':') { - return -1; - } - - i++; - j = i; - while ((url[j]!='\0')&&(url[j]!='/')) { - j++; - } - - if (port != NULL) { - strncpy(port, url+i, j-i); - port[j-i] = '\0'; - } - - return j; - } - - - int getURLDir(char *url, char *dir) - { - int i; - - if ((i=getURLPort(url, NULL))<0) - { - if ((i=getURLServer(url, NULL))<0) - { - if((i=getURLProtocol(url, NULL))<0) - { - return -1; - } - } - } - - if (dir != NULL) { - strncpy(dir, url+i, strlen(url)-i); - dir[strlen(url)-i] = '\0'; - } - - return strlen(url); - } - - int clear_slash(char *path) - { - size_t i; - int j; - char ant = '\0', s[PATH_MAX]; - - j=0; - for (i=0; i < strlen(path); i++) - { - switch(path[i]) - { - case '/': - if(ant != '/'){ - ant = s[j] = '/'; - j++; - } - break; - - default: - ant = s[j] = path[i]; - j++; - } - - s[j] = '\0'; - } - - strcpy(path, s); - return 0; - } - - - int ParseURL( char *url, - char *protocol, char *login, char *passwd, char *server, char *port, char *dir ) - { - char *urlaux; - - urlaux = url; - if (protocol != NULL) - { - /* return the next position */ - if(getURLProtocol(urlaux, protocol)<0){ - return -1; - } - } - - urlaux = url; - if (server != NULL) - { - /* return the next position */ - if (getURLServer(urlaux, server)<0){ - return -1; - } - } - - login = login ; - passwd = passwd ; - - urlaux = url; - if (port != NULL) - { - /* return the next position */ - if (getURLPort(urlaux, port)<0) { - //Not mandatory - //return -1; - } - } - - urlaux = url; - if (dir != NULL) - { - /* return the next position */ - if (getURLDir(urlaux, dir)<0) { - return -1; - } - clear_slash(dir); - } - - return 0; - } - - - int getDirWithURL ( char *url, char *dir ) - { - char dir_aux[PATH_MAX]; /* change for a const*/ - int i,j; - - getURLDir(url, dir_aux); - - i = 0; - while ((dir_aux[i] != '\0')&&(dir_aux[i] == dir[i])) { - i++; - } - - if (dir_aux[i] != '\0') { - return -1; - } - if (dir_aux[i] == dir[i]) { - dir[0] = '/'; - dir[1] = '\0'; - return 0; - } - - j = 0; - while (dir[j+i]!='\0') { - dir[j] = dir[j+i]; - j++; - } - - dir[j] = '\0'; - if ((dir[j] == '/') &&(strlen(dir+j) == 1)) { - dir[j-1] = '\0'; - } - - return 0; - } - - - /* ................................................................... */ - diff --git a/src/base/utils.c b/src/base/utils.c deleted file mode 100644 index ade590784..000000000 --- a/src/base/utils.c +++ /dev/null @@ -1,84 +0,0 @@ - -/* - * Copyright 2020-2025 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 . - * - */ - - -/* ... Include / Inclusion ........................................... */ - - #include "utils.h" - - -/* ... Functions / Funciones ......................................... */ - - long utils_get_time ( void ) - { - struct timeval timenow; - - // get timestamp - gettimeofday(&timenow, NULL); - - // return timestamp - return (long)timenow.tv_sec * 1000 + (long)timenow.tv_usec / 1000; - } - - int utils_str2int ( char *str_value, int default_value ) - { - char *endptr; - int int_value; - - int_value = (int) strtol (str_value, &endptr, 10); - if ( (endptr == str_value) || (*endptr != '\0') ) - { - int_value = default_value ; - printf("[utils_str2int] warning: value '%s' is not a number\n", str_value); - } - - return int_value ; - } - - int utils_getenv_int ( char *env_name, int default_value ) - { - int env_int = default_value ; - - // env_name == NULL -> return default value - if (NULL == env_name) { - return default_value ; - } - - // getenv(...) == NULL -> return default value - char *env_value = getenv(env_name); - if (NULL == env_value) { - return default_value ; - } - - // strtol fails -> return default value - char *end ; - env_int = strtol(env_value, &end, 10); - if (*end != '\0') { - printf("[utils_getenv_int] warning: environmental variable '%s' value '%s' is not a number\n", env_name, env_value); - return default_value ; - } - - return env_int; - } - - -/* ................................................................... */ - diff --git a/src/base/workers.c b/src/base/workers.c deleted file mode 100644 index cb3798598..000000000 --- a/src/base/workers.c +++ /dev/null @@ -1,186 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos - * - * 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 . - * - */ - - -/* ... Include / Inclusion ........................................... */ - - #include "workers.h" - - -/* ... Functions / Funciones ......................................... */ - -int base_workers_init ( worker_t *w, int thread_mode ) -{ - debug_info("[WORKERS] [base_workers_init] >> Begin\n"); - - // check arguments... - if (NULL == w) - { - debug_error("[WORKERS] [base_workers_init] ERROR: NULL worker_t\n"); - return -1; - } - - // initialize... - w->thread_mode = thread_mode; - switch (w->thread_mode) - { - case TH_OP: - debug_info("[WORKERS] [base_workers_init] worker_ondemand_init\n"); - worker_ondemand_init(&(w->w1)); - break; - - case TH_POOL: - debug_info("[WORKERS] [base_workers_init] worker_pool_init\n"); - worker_pool_init(&(w->w2)); - break; - - case TH_NOT: - debug_info("[WORKERS] [base_workers_init] worker without threads init\n"); - break; - - default: - debug_info("[WORKERS] [base_workers_init] ERROR: on thread_mode(%d).\n", w->thread_mode); - return -1; - break; - } - - debug_info("[WORKERS] [base_workers_init] >> End\n"); - - return 1; -} - -int base_workers_launch ( worker_t *w, struct st_th *th_arg, void (*worker_function)(struct st_th) ) -{ - debug_info("[WORKERS] [base_workers_launch] >> Begin\n"); - - // check arguments... - if (NULL == w) - { - debug_error("[WORKERS] [base_workers_launch] ERROR: NULL worker_t\n"); - return -1; - } - - // lauch worker... - switch (w->thread_mode) - { - case TH_OP: - debug_info("[WORKERS] [base_workers_launch] worker_ondemand_launch\n"); - worker_ondemand_launch(&(w->w1), th_arg, worker_function ); - break; - - case TH_POOL: - debug_info("[WORKERS] [base_workers_launch] worker_pool_enqueue\n"); - worker_pool_enqueue(&(w->w2), th_arg, worker_function ); // Enqueue the operation on the buffer - break; - - case TH_NOT: - debug_info("[WORKERS] [base_workers_launch] worker without threads\n"); - worker_function(*th_arg); - break; - - default: - debug_info("[WORKERS] [base_workers_launch] ERROR: on thread_mode(%d).\n", w->thread_mode); - return -1; - break; - } - - debug_info("[WORKERS] [base_workers_launch] >> End id = %d\n", th_arg->id); - - return 1; -} - -int base_workers_wait ( worker_t *w, struct st_th *th_arg ) -{ - debug_info("[WORKERS] [base_workers_wait] >> Begin\n"); - - // check arguments... - if (NULL == w) - { - debug_error("[WORKERS] [base_workers_wait] ERROR: NULL worker_t\n"); - return -1; - } - - switch (w->thread_mode) - { - case TH_OP: - debug_info("[WORKERS] [base_workers_wait] worker_ondemand_wait\n"); - worker_ondemand_wait(th_arg); - break; - - case TH_POOL: - debug_info("[WORKERS] [base_workers_wait] worker_pool_wait\n"); - worker_pool_wait(th_arg); - break; - - case TH_NOT: - debug_info("[WORKERS] [base_workers_wait] worker_wait without threads\n"); - break; - - default: - debug_info("[WORKERS] [base_workers_wait] ERROR: on thread_mode(%d).\n", w->thread_mode); - return -1; - break; - } - - debug_info("[WORKERS] [base_workers_wait] >> End\n"); - - return 1; -} - -void base_workers_destroy ( worker_t *w ) -{ - debug_info("[WORKERS] [base_workers_destroy] >> Begin\n"); - - // check arguments... - if (NULL == w) - { - debug_error("[WORKERS] [base_workers_destroy] ERROR: NULL worker_t\n"); - return; - } - - // destroy... - switch (w->thread_mode) - { - case TH_OP: - debug_info("[WORKERS] [base_workers_destroy] workers_ondemand_destroy\n"); - workers_ondemand_destroy(&(w->w1)); - break; - - case TH_POOL: - debug_info("[WORKERS] [base_workers_destroy] worker_pool_destroy\n"); - worker_pool_destroy(&(w->w2)); // Destroy worker pool - break; - - case TH_NOT: - debug_info("[WORKERS] [base_workers_destroy] worker without threads\n"); - break; - - default: - debug_info("[WORKERS] [base_workers_destroy] ERROR: on thread_mode(%d).\n", w->thread_mode); - break; - } - - debug_info("[WORKERS] [base_workers_destroy] >> End\n"); -} - - -/* ................................................................... */ - diff --git a/src/base/workers_ondemand.c b/src/base/workers_ondemand.c deleted file mode 100644 index c3b8a8415..000000000 --- a/src/base/workers_ondemand.c +++ /dev/null @@ -1,217 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos - * - * 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 . - * - */ - - -/* ... Include / Inclusion ........................................... */ - - #include "workers_ondemand.h" - - -/* ... Auxiliar functions / Funciones auxiliares ......................................... */ - -void *worker_run ( void *arg ) -{ - struct st_th th; - - debug_info("[WORKERS_ONDEMAND] [worker_run] >> Begin\n"); - - // get initial pointers... - struct st_th *th_aux = (struct st_th *)arg; - if (NULL == th_aux) - { - debug_info("[WORKERS_ONDEMAND] [worker_run] ERROR: arg == NULL\n"); - return NULL; - } - - worker_ondemand_t *w_aux = (worker_ondemand_t *)th_aux->w; - if (NULL == w_aux) - { - debug_info("[WORKERS_ONDEMAND] [worker_run] ERROR: arg->w == NULL\n"); - return NULL; - } - - struct st_th *th_shadow = (struct st_th *)(th_aux->v); - if (NULL == th_shadow) - { - debug_info("[WORKERS_ONDEMAND] [worker_run] ERROR: arg->v == NULL\n"); - return NULL; - } - - // prolog: copy arguments and update n_workers - debug_info("[WORKERS_ONDEMAND] [worker_run] Copy arguments\n"); - - pthread_mutex_lock(&(w_aux->m_worker)); - memcpy(&th, arg, sizeof(struct st_th)); - w_aux->busy_worker = FALSE; - w_aux->n_workers++; - pthread_cond_broadcast(&(w_aux->c_worker)); // pthread_cond_signal(&c_worker); - pthread_mutex_unlock(&(w_aux->m_worker)); - - // do function code... - debug_info("[WORKERS_ONDEMAND] [worker_run] execute function\n"); - - th.function(th); - - // do wakeup worker_ondemand_wait(...) if needed - debug_info("[WORKERS_ONDEMAND] [worker_run] wait4me\n"); - - if ( TRUE == th.wait4me ) - { - pthread_mutex_lock(&(th_shadow->m_wait)); - th_shadow->r_wait = FALSE; - pthread_cond_broadcast(&(th_shadow->c_wait)); - pthread_mutex_unlock(&(th_shadow->m_wait)); - } - - // epilog: update n_workers - debug_info("[WORKERS_ONDEMAND] [worker_run] thread exit\n"); - - pthread_mutex_lock(&(w_aux->m_worker)); - w_aux->n_workers--; - pthread_cond_broadcast(&(w_aux->c_nworkers)); // pthread_cond_signal(&c_nworkers); - pthread_mutex_unlock(&(w_aux->m_worker)); - - pthread_exit(0); - - debug_info("[WORKERS_ONDEMAND] [worker_run] >> End\n"); - - return NULL; -} - - -/* ... Functions / Funciones ......................................... */ - -int worker_ondemand_init ( worker_ondemand_t *w ) -{ - debug_info("[WORKERS_ONDEMAND] [worker_ondemand_init] >> Begin\n"); - - w->busy_worker = TRUE; - w->n_workers = 0L; - - pthread_cond_init (&(w->c_worker), NULL); - pthread_cond_init (&(w->c_nworkers), NULL); - pthread_mutex_init(&(w->m_worker), NULL); - - debug_info("[WORKERS_ONDEMAND] [worker_ondemand_init] >> End\n"); - - return 0; -} - -int worker_ondemand_launch ( worker_ondemand_t *w, struct st_th *th_arg, void (*worker_function)(struct st_th) ) -{ - int ret; - pthread_attr_t th_attr; - pthread_t th_worker; - static int th_cont = 0; - - debug_info("[WORKERS_ONDEMAND] [worker_ondemand_launch] >> Begin\n"); - - pthread_attr_init(&th_attr); - pthread_attr_setdetachstate(&th_attr, PTHREAD_CREATE_DETACHED); - pthread_attr_setstacksize (&th_attr, STACK_SIZE); - w->busy_worker = TRUE; - - // prepare arguments... - th_arg->id = th_cont++; - th_arg->function = worker_function; - th_arg->w = (void *)w; - th_arg->v = (void *)th_arg; - - // create thread... - debug_info("[WORKERS_ONDEMAND] [worker_ondemand_launch] create_thread\n"); - - ret = pthread_create(&th_worker, &th_attr, (void *(*)(void *))(worker_run), (void *)th_arg); - if (ret != 0) - { - debug_error("[WORKERS_ONDEMAND] [worker_ondemand_launch] ERROR: pthread_create fail\n"); - perror("[WORKERS_ONDEMAND] [worker_ondemand_launch] ERROR: create_thread: "); - } - - // wait to copy args... - debug_info("[WORKERS_ONDEMAND] [worker_ondemand_launch] lock worker_run\n"); - - pthread_mutex_lock(&(w->m_worker)); - while (w->busy_worker == TRUE) - { - debug_info("[WORKERS_ONDEMAND] [worker_ondemand_launch] wait worker_run\n"); - pthread_cond_wait(&(w->c_worker), &(w->m_worker)); - } - - debug_info("[WORKERS_ONDEMAND] [worker_ondemand_launch] busy_worker= TRUE worker_run\n"); - - w->busy_worker = TRUE; - - debug_info("[WORKERS_ONDEMAND] [worker_ondemand_launch] unlock worker_run\n"); - - pthread_mutex_unlock(&(w->m_worker)); - - debug_info("[WORKERS_ONDEMAND] [worker_ondemand_launch] >> End\n"); - - return 0; -} - -int worker_ondemand_wait ( struct st_th *th_arg ) -{ - debug_info("[WORKERS_ONDEMAND] [worker_ondemand_wait] >> Begin\n"); - - pthread_mutex_lock(&(th_arg->m_wait)); - while (th_arg->r_wait == TRUE) { - pthread_cond_wait(&(th_arg->c_wait), &(th_arg->m_wait)); - } - - th_arg->r_wait = TRUE; - pthread_mutex_unlock(&(th_arg->m_wait)); - - debug_info("[WORKERS_ONDEMAND] [worker_ondemand_wait] >> End\n"); - - return 0; -} - -void workers_ondemand_destroy ( worker_ondemand_t *w ) -{ - debug_info("[WORKERS_ONDEMAND] [workers_ondemand_destroy] >> Begin\n"); - - // wait to n_workers be zero... - debug_info("[WORKERS_ONDEMAND] [workers_ondemand_destroy] lock workers_ondemand_wait\n"); - - pthread_mutex_lock(&(w->m_worker)); - while (w->n_workers != 0) - { - debug_info("[WORKERS_ONDEMAND] [workers_ondemand_destroy] wait workers_ondemand_wait\n"); - pthread_cond_wait(&(w->c_nworkers), &(w->m_worker)); - } - - debug_info("[WORKERS_ONDEMAND] [workers_ondemand_destroy] unlock workers_ondemand_wait\n"); - pthread_mutex_unlock(&(w->m_worker)); - - // destroy resources - debug_info("[WORKERS_ONDEMAND] [workers_ondemand_destroy] destroy resources\n"); - - pthread_cond_destroy (&(w->c_worker)); - pthread_cond_destroy (&(w->c_nworkers)); - pthread_mutex_destroy (&(w->m_worker)); - - debug_info("[WORKERS_ONDEMAND] [workers_ondemand_destroy] >> End\n"); -} - - -/* ................................................................... */ - diff --git a/src/base/workers_pool.c b/src/base/workers_pool.c deleted file mode 100644 index b911b48c3..000000000 --- a/src/base/workers_pool.c +++ /dev/null @@ -1,273 +0,0 @@ - -/* - * Copyright 2020-2025 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos - * - * 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 . - * - */ - - -/* ... Include / Inclusion ........................................... */ - - #include "workers_pool.h" - - -/* ... Auxiliar functions / Funciones auxiliares ......................................... */ - - void *worker_pool_function ( void *arg ) - { - int is_true; - worker_pool_t *w; - struct st_th th; - struct st_th *th_shadow; - - debug_info("[WORKERS_POOL] [worker_pool_function] >> Begin\n"); - - w = (worker_pool_t *)arg; - is_true = 1; - while (is_true) - { - // Dequeue operation - debug_info("[WORKERS_POOL] [worker_pool_function] dequeue\n"); - th = worker_pool_dequeue(w); - - // do function code... - debug_info("[WORKERS_POOL] [worker_pool_function] execute function\n"); - th.function(th); - - debug_info("[WORKERS_POOL] [worker_pool_function] wait4me\n"); - - th_shadow = (struct st_th *)(th.v); - if ( (NULL != th_shadow) && (TRUE == th.wait4me) ) - { - pthread_mutex_lock(&(th_shadow->m_wait)); - th_shadow->r_wait = FALSE; - pthread_cond_signal(&(th_shadow->c_wait)); - pthread_mutex_unlock(&(th_shadow->m_wait)); - } - } - - debug_info("[WORKERS_POOL] [worker_pool_function] thread exit\n"); - pthread_exit(0); - - debug_info("[WORKERS_POOL] [worker_pool_function] >> End\n"); - return NULL; - } - - -/* ... Functions / Funciones ......................................... */ - - int worker_pool_init ( worker_pool_t *w ) - { - debug_info("[WORKERS_POOL] [worker_pool_init] >> Begin\n"); - - // initialize variables... - pthread_mutex_init(&(w->m_pool), NULL); - pthread_cond_init (&(w->c_pool_no_full), NULL); - pthread_cond_init (&(w->c_poll_no_empty), NULL); - pthread_mutex_init(&(w->m_pool_end), NULL); - - // malloc threads... - debug_info("[WORKERS_POOL] [worker_pool_init] Malloc threads\n"); - - w->POOL_MAX_THREADS = POOL_OVERSUSCRIPTION * sysconf(_SC_NPROCESSORS_ONLN); - w->thid = (pthread_t *)malloc(w->POOL_MAX_THREADS * sizeof(pthread_t)); - if (NULL == w->thid) - { - perror("[WORKERS_POOL] [worker_pool_init] ERROR malloc: "); - return -1; - } - - // initialize queue variables... - w->n_operation = 0; - w->deq_pos = 0; - w->enq_pos = 0; - w->pool_end = 0; - - // starting threads... - debug_info("[WORKERS_POOL] [worker_pool_init] Starting threads\n"); - - for (int i = 0; i < w->POOL_MAX_THREADS; i++) - { - debug_info("[WORKERS_POOL] [worker_pool_init] create_thread\n"); - if (pthread_create(&(w->thid[i]), NULL, (void *(*)(void *))(worker_pool_function), (void *)w) !=0) - { - perror("[WORKERS_POOL] [worker_pool_init] ERROR: creating thread pool\n"); - return -1; - } - } - - debug_info("[WORKERS_POOL] [worker_pool_init] >> End\n"); - - return 0; - } - - void worker_pool_enqueue ( worker_pool_t *w, struct st_th *th_arg, void (*worker_function)(struct st_th) ) - { - static int th_cont = 0; - - debug_info("[WORKERS_POOL] [worker_pool_enqueue] >> Begin\n"); - - // wait no_full - debug_info("[WORKERS_POOL] [worker_pool_enqueue] lock\n"); - - pthread_mutex_lock(&(w->m_pool)); - while (w->n_operation == MAX_OPERATIONS) - { - debug_info("[WORKERS_POOL] [worker_pool_enqueue] wait c_pool_no_full\n"); - pthread_cond_wait(&(w->c_pool_no_full), &(w->m_pool)); - } - - // prepare arguments... - debug_info("[WORKERS_POOL] [worker_pool_enqueue] copy arguments\n"); - - th_arg->id = th_cont++; - th_arg->function = worker_function; - th_arg->w = w; - th_arg->v = (void *)th_arg; - - // enqueue - debug_info("[WORKERS_POOL] [worker_pool_enqueue] enqueue id = %d\n", th_arg->id); - - w->operations_buffer[w->enq_pos] = *th_arg; - w->enq_pos = (w->enq_pos + 1) % MAX_OPERATIONS; - w->n_operation++; - - // signal no_empty - debug_info("[WORKERS_POOL] [worker_pool_enqueue] signal c_poll_no_empty\n"); - pthread_cond_signal(&(w->c_poll_no_empty)); - - debug_info("[WORKERS_POOL] [worker_pool_enqueue] unlock\n"); - pthread_mutex_unlock(&(w->m_pool)); - - debug_info("[WORKERS_POOL] [worker_pool_enqueue] >> End\n"); - } - - struct st_th worker_pool_dequeue ( worker_pool_t *w ) - { - struct st_th th; - - debug_info("[WORKERS_POOL] [worker_pool_dequeue] >> Begin\n"); - - debug_info("[WORKERS_POOL] [worker_pool_dequeue] lock\n"); - pthread_mutex_lock(&(w->m_pool)); - - while (w->n_operation == 0) - { - debug_info("[WORKERS_POOL] [worker_pool_dequeue] wait c_poll_no_empty\n"); - pthread_cond_wait(&(w->c_poll_no_empty), &(w->m_pool)); - } - - // dequeue - debug_info("[WORKERS_POOL] [worker_pool_dequeue] thread id = %ld\n", pthread_self()); - debug_info("[WORKERS_POOL] [worker_pool_dequeue] dequeue\n"); - - th = w->operations_buffer[w->deq_pos]; - w->deq_pos = (w->deq_pos + 1) % MAX_OPERATIONS; - w->n_operation--; - - if ( w->pool_end == 1 || th.type_op == TH_FINALIZE ) - { - debug_info("[WORKERS_POOL] [worker_pool_dequeue] unlock end\n"); - pthread_mutex_unlock(&(w->m_pool)); - - debug_info("[WORKERS_POOL] [worker_pool_dequeue] exit\n"); - pthread_exit(0); - } - - debug_info("[WORKERS_POOL] [worker_pool_dequeue] signal c_pool_no_full\n"); - pthread_cond_signal(&(w->c_pool_no_full)); - - debug_info("[WORKERS_POOL] [worker_pool_dequeue] unlock\n"); - pthread_mutex_unlock(&(w->m_pool)); - - debug_info("[WORKERS_POOL] [worker_pool_dequeue] >> End\n"); - - return th; - } - - int worker_pool_wait ( struct st_th *th_arg ) - { - debug_info("[WORKERS_POOL] [worker_pool_wait] >> Begin\n"); - - pthread_mutex_lock(&(th_arg->m_wait)); - while (th_arg->r_wait == TRUE) { - pthread_cond_wait(&(th_arg->c_wait), &(th_arg->m_wait)); - } - - th_arg->r_wait = TRUE; - pthread_mutex_unlock(&(th_arg->m_wait)); - - debug_info("[WORKERS_POOL] [worker_pool_wait] >> End\n"); - - return 0; - } - - void worker_pool_destroy ( worker_pool_t *w ) - { - struct st_th th_arg; - - debug_info("[WORKERS_POOL] [worker_pool_destroy] >> Begin\n"); - - // update pool_end... - debug_info("[WORKERS_POOL] [worker_pool_destroy] lock m_pool_end\n"); - pthread_mutex_lock(&(w->m_pool_end)); - w->pool_end = 1; - - debug_info("[WORKERS_POOL] [worker_pool_destroy] unlock m_pool_end\n"); - pthread_mutex_unlock(&(w->m_pool_end)); - - // prepare arguments... - debug_info("[WORKERS_POOL] [worker_pool_destroy] finalize operation enqueue\n"); - memset(&th_arg, 0, sizeof(struct st_th)); - th_arg.type_op = TH_FINALIZE; - - for (int i = 0; i < w->POOL_MAX_THREADS; ++i) { - worker_pool_enqueue(w, &th_arg, NULL); - } - - debug_info("[WORKERS_POOL] [worker_pool_destroy] lock m_pool\n"); - pthread_mutex_lock(&(w->m_pool)); - - debug_info("[WORKERS_POOL] [worker_pool_destroy] broadcast\n"); - pthread_cond_broadcast(&(w->c_poll_no_empty)); - - debug_info("[WORKERS_POOL] [worker_pool_destroy] unlock m_pool\n"); - pthread_mutex_unlock(&(w->m_pool)); - - for (int i=0; i < w->POOL_MAX_THREADS; i++) - { - debug_info("[WORKERS_POOL] [worker_pool_destroy] join\n"); - pthread_join(w->thid[i],NULL); - } - - // free threads... - debug_info("[WORKERS_POOL] [worker_pool_destroy] free\n"); - free(w->thid); - w->thid = NULL; - - debug_info("[WORKERS_POOL] [worker_pool_destroy] destroy\n"); - pthread_mutex_destroy(&(w->m_pool)); - pthread_cond_destroy (&(w->c_pool_no_full)); - pthread_cond_destroy (&(w->c_poll_no_empty)); - pthread_mutex_destroy(&(w->m_pool_end)); - - debug_info("[WORKERS_POOL] [worker_pool_destroy] >> End\n"); - } - - -/* ................................................................... */ - diff --git a/src/base_cpp/CMakeLists.txt b/src/base_cpp/CMakeLists.txt new file mode 100644 index 000000000..09d9351f6 --- /dev/null +++ b/src/base_cpp/CMakeLists.txt @@ -0,0 +1,13 @@ + +file(GLOB XPN_BASE_CPP_HEADERS + "*.hpp" +) + +file(GLOB XPN_BASE_CPP_SOURCE + "*.cpp" +) + +add_library(xpn_base_cpp OBJECT ${XPN_BASE_CPP_SOURCE} ${XPN_BASE_CPP_HEADERS}) +target_include_directories(xpn_base_cpp PUBLIC + "${PROJECT_SOURCE_DIR}/src" +) \ No newline at end of file diff --git a/src/base_cpp/args.hpp b/src/base_cpp/args.hpp new file mode 100644 index 000000000..cd8af7a60 --- /dev/null +++ b/src/base_cpp/args.hpp @@ -0,0 +1,193 @@ + +/* + * Copyright 2020-2024 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos, Dario Muñoz Muñoz + * + * 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 . + * + */ + +#pragma once + +#include +#include +#include +#include +#include + +#include "debug.hpp" + +namespace XPN { + +class args { + public: + struct option { + enum class opt_type { value, flag }; + std::string sort_name; + std::string long_name; + std::string help; + opt_type type = opt_type::flag; + }; + + args(int argc, char* argv[], const std::vector