├── .gitignore ├── BUG_EMAIL ├── CHANGELOG ├── COPYRIGHT ├── INSTALL ├── LGPL ├── LIB_VERSION ├── Makefile.am ├── Makefile.in ├── README ├── VERSION ├── aclocal.m4 ├── bootstrap.sh ├── config.h.in ├── configure ├── configure.ac ├── configure.common.ac ├── doc ├── Makefile.am ├── Makefile.in ├── spindle.1 └── spindle_launch_README.md ├── m4 ├── ax_tls.m4 ├── launcher.m4 ├── libtool.m4 ├── lmon.m4 ├── ltoptions.m4 ├── ltsugar.m4 ├── ltversion.m4 ├── lt~obsolete.m4 ├── lx_detect_bluegene.m4 ├── lx_find_mpi.m4 ├── pkg.m4 └── runconf.m4 ├── scripts ├── ar-lib ├── compile ├── config.guess ├── config.sub ├── depcomp ├── dtvtest │ ├── Makefile │ ├── dtvtest.c │ ├── minaudit.c │ ├── run_dtvtest.sh │ └── tlslib.c ├── install-sh ├── ltmain.sh ├── missing ├── remap.sh └── rewrite.sh ├── src ├── biter │ ├── bgq_daemon_ids.c │ ├── bgq_ids.c │ ├── biterc.c │ ├── biterc.h │ ├── biterd.c │ ├── biterd.h │ ├── client_queue.c │ ├── daemon_ids.h │ ├── demultiplex.c │ ├── demultiplex.h │ ├── ids.h │ ├── linux_daemon_ids.c │ ├── linux_ids.c │ ├── server_queue.c │ ├── sheep.c │ ├── sheep.h │ ├── shm_wrappers.c │ ├── shm_wrappers.h │ ├── shmutil.c │ └── shmutil.h ├── client │ ├── Makefile.am │ ├── Makefile.in │ ├── aclocal.m4 │ ├── auditclient │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── auditclient.c │ │ ├── auditclient.h │ │ ├── auditclient_aarch64.c │ │ ├── auditclient_common.c │ │ ├── auditclient_ppc64.c │ │ ├── auditclient_x86_64.c │ │ ├── bindgot.c │ │ ├── patch_bad_dtv.c │ │ ├── patch_linkmap.c │ │ ├── redirect.c │ │ ├── writablegot.c │ │ └── writablegot.h │ ├── beboot │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── parseloc.h │ │ └── spindle_bootstrap.c │ ├── biter │ │ ├── Makefile.am │ │ └── Makefile.in │ ├── client │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── client.c │ │ ├── client.h │ │ ├── exec_util.c │ │ ├── exec_util.h │ │ ├── intercept.c │ │ ├── intercept.h │ │ ├── intercept_exec.c │ │ ├── intercept_open.c │ │ ├── intercept_readlink.c │ │ ├── intercept_spindleapi.c │ │ ├── intercept_stat.c │ │ ├── lookup.c │ │ ├── lookup_libc.c │ │ ├── patch_interception.c │ │ ├── patch_interception.h │ │ ├── realpath.c │ │ ├── remap_exec.c │ │ ├── should_intercept.c │ │ ├── should_intercept.h │ │ ├── spindle_regex.c │ │ └── spindle_regex.h │ ├── client_comlib │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── client_api.c │ │ ├── client_api.h │ │ ├── client_api_biter.c │ │ ├── client_api_pipe.c │ │ ├── client_api_socket.c │ │ ├── client_heap.c │ │ ├── client_heap.h │ │ └── client_wrappers.c │ ├── config.h.in │ ├── configure │ ├── configure.ac │ ├── instrclient │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── intercept.c │ │ └── sym_alias.h │ ├── ldsolookup │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── print_ldso_audit.c │ │ └── print_ldso_entry.c │ ├── logging │ │ ├── Makefile.am │ │ └── Makefile.in │ ├── shm_cache │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── shmcache.c │ │ └── shmcache.h │ ├── spindle_api │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── spindle.h │ │ ├── spindle_api.c │ │ └── spindle_api_int.h │ └── subaudit │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── intercept_malloc.c │ │ ├── preloadlib.c │ │ ├── subaudit.c │ │ ├── subaudit.h │ │ └── update_pltbind.c ├── cobo │ ├── cobo.c │ ├── cobo_comm.c │ ├── cobo_comm.h │ ├── cobo_handshake.c │ ├── handshake.c │ ├── handshake.h │ └── ldcs_cobo.h ├── fe │ ├── Makefile.am │ ├── Makefile.in │ ├── aclocal.m4 │ ├── cobo │ │ ├── Makefile.am │ │ └── Makefile.in │ ├── comlib │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── cobo_fe_comm.c │ │ ├── fe_comm.h │ │ └── msocket_fe_comm.c │ ├── config.h.in │ ├── configure │ ├── configure.ac │ ├── flux │ │ ├── Makefile.am │ │ └── Makefile.in │ ├── hostbin │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ └── launch_hostbin.cc │ ├── launchmon │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ └── spindle_fe_lmon.cc │ ├── logging │ │ ├── Makefile.am │ │ └── Makefile.in │ ├── openmpi_intercept │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── ompi_intercept.c │ │ └── parse_openmpi.cc │ └── startup │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── config_mgr.cc │ │ ├── config_mgr.h │ │ ├── config_parser.cc │ │ ├── config_parser.h │ │ ├── jobtask.h │ │ ├── launch_flux.cc │ │ ├── launch_lsf.cc │ │ ├── launch_slurm.cc │ │ ├── launcher.cc │ │ ├── launcher.h │ │ ├── parse_launcher.cc │ │ ├── parse_launcher.h │ │ ├── parse_launcher_args.cc │ │ ├── parse_preload.cc │ │ ├── parse_preload.h │ │ ├── parseargs.cc │ │ ├── spindle_fe.cc │ │ ├── spindle_fe_main.cc │ │ ├── spindle_fe_serial.cc │ │ ├── spindle_session.cc │ │ └── spindle_session.h ├── flux │ ├── Makefile.am │ ├── Makefile.in │ ├── flux-spindle.c │ ├── fluxmgr.c │ ├── fluxmgr.h │ ├── main.cc │ ├── procmgr.c │ ├── procmgr.h │ ├── sessionmgr.c │ ├── sessionmgr.h │ ├── spindle_rc │ ├── spindlebemgr.c │ ├── spindlefemgr.c │ └── spindlemgr.h ├── include │ ├── ldcs_api.h │ ├── ldcs_api_pipe.h │ ├── ldcs_api_socket.h │ └── spindle_launch.h ├── logging │ ├── spindle_debug.h │ ├── spindle_logc.c │ ├── spindle_logc.h │ └── spindle_logd.cc ├── server │ ├── Makefile.am │ ├── Makefile.in │ ├── aclocal.m4 │ ├── auditserver │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── cleanup_proc.cc │ │ ├── cleanup_proc.h │ │ ├── force_exit.c │ │ ├── force_exit.h │ │ ├── ldcs_audit_server_client_cb.c │ │ ├── ldcs_audit_server_filemngt.c │ │ ├── ldcs_audit_server_filemngt.h │ │ ├── ldcs_audit_server_handlers.c │ │ ├── ldcs_audit_server_handlers.h │ │ ├── ldcs_audit_server_md.h │ │ ├── ldcs_audit_server_md_cobo.c │ │ ├── ldcs_audit_server_md_msocket.c │ │ ├── ldcs_audit_server_md_msocket.h │ │ ├── ldcs_audit_server_md_msocket_topo.c │ │ ├── ldcs_audit_server_md_msocket_topo.h │ │ ├── ldcs_audit_server_md_msocket_util.c │ │ ├── ldcs_audit_server_md_msocket_util.h │ │ ├── ldcs_audit_server_md_none.c │ │ ├── ldcs_audit_server_numa.c │ │ ├── ldcs_audit_server_numa.h │ │ ├── ldcs_audit_server_process.c │ │ ├── ldcs_audit_server_process.h │ │ ├── ldcs_audit_server_requestors.c │ │ ├── ldcs_audit_server_requestors.h │ │ ├── ldcs_audit_server_server_cb.c │ │ ├── ldcs_elf_read.c │ │ ├── ldcs_elf_read.h │ │ ├── msgbundle.c │ │ ├── msgbundle.h │ │ ├── parse_mounts.cc │ │ ├── parse_mounts.h │ │ └── translate_maps.c │ ├── biter │ │ ├── Makefile.am │ │ └── Makefile.in │ ├── cache │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── global_name.c │ │ ├── global_name.h │ │ ├── ldcs_cache.cc │ │ ├── ldcs_cache.h │ │ ├── ldcs_cache_file_op.c │ │ ├── stat_cache.cc │ │ └── stat_cache.h │ ├── cobo │ │ ├── Makefile.am │ │ └── Makefile.in │ ├── comlib │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── ldcs_api_biter.c │ │ ├── ldcs_api_listen.c │ │ ├── ldcs_api_listen.h │ │ ├── ldcs_api_pipe.c │ │ ├── ldcs_api_pipe_notify.c │ │ ├── ldcs_api_pipe_notify.h │ │ ├── ldcs_api_socket.c │ │ ├── ldcs_api_socket.h │ │ ├── ldcs_api_util.c │ │ └── ldcs_api_wrapper.c │ ├── config.h.in │ ├── configure │ ├── configure.ac │ ├── launchmon │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ └── spindle_be_lmon.cc │ ├── logging │ │ ├── Makefile.am │ │ └── Makefile.in │ └── startup │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── hookexec.c │ │ ├── spindle_be.cc │ │ ├── spindle_be_hostbin.cc │ │ ├── spindle_be_main.cc │ │ ├── spindle_be_mpilaunch.cc │ │ └── spindle_be_serial.cc ├── slurm_plugin │ ├── Makefile.am │ ├── Makefile.in │ ├── encode_decode.c │ ├── plugin_utils.c │ ├── plugin_utils.h │ └── slurm_plugin.c └── utils │ ├── ccwarns.h │ ├── exitnote.c │ ├── exitnote.h │ ├── fileutil.c │ ├── fileutil.h │ ├── getcpu.c │ ├── handle_vararg.h │ ├── keyfile.c │ ├── keyfile.h │ ├── parse_plt.h │ ├── parseloc.c │ ├── pathfn.c │ ├── pathfn.h │ ├── rshlaunch.c │ ├── rshlaunch.h │ └── spindle_mkdir.c └── testsuite ├── Makefile.am ├── Makefile.in ├── funcdict.c ├── hello.py ├── libcxxexceptA.cc ├── libcxxexceptB.cc ├── libdepA.c ├── libdepB.c ├── libdepC.c ├── libgenerator.c ├── local.c ├── originlib.c ├── origintarget.c ├── preload_file_list_template ├── registerlib.c ├── retzero.c ├── runTests_template ├── run_driver_flux ├── run_driver_lrun ├── run_driver_openmpi ├── run_driver_serial ├── run_driver_slurm ├── run_driver_template ├── run_driver_unknown ├── spindle_deactivated_template.sh ├── spindle_exec_test.c ├── spindle_rc ├── symbind_fileops.c ├── symbind_test.c ├── symbindlib.c ├── symbindlib_g.c ├── test_driver.c └── testoutput.c /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | /autom4te.cache 3 | /src/server/autom4te.cache 4 | /src/client/autom4te.cache 5 | /src/fe/autom4te.cache 6 | 7 | tags 8 | 9 | #Need if someone does an in-source configure/build 10 | Makefile 11 | config.h 12 | config.log 13 | config.status 14 | libtool 15 | stamp-h1 16 | .deps 17 | .libs 18 | *.o 19 | *.lo 20 | *.la 21 | *.so 22 | spindle_bootstrap 23 | spindle 24 | spindle_logd 25 | spindled_logd 26 | libstdc++.a 27 | spindle_be 28 | libtest*.c 29 | libgenerator 30 | runTests 31 | test_driver 32 | test_driver_libs 33 | run_driver 34 | run_driver_rm 35 | preload_file_list 36 | build 37 | -------------------------------------------------------------------------------- /BUG_EMAIL: -------------------------------------------------------------------------------- 1 | legendre1@llnl.gov 2 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | Spindle 0.13 2 | ----------- 3 | - Fix handling of ORIGIN when it appears in .so libraries. 4 | - Can now wrap IBM's jsrun (and the LLNL alias lrun) with spindle. 5 | - New SLURM plugin for launching spindle with "srun --spindle ..." 6 | - New spindle launch mode that starts up daemons via an rsh/ssh tree 7 | - New interfaces in spindle_launch for easier RM integration. 8 | - Numerous bug smaller fixes 9 | 10 | Spindle 0.12 11 | ----------- 12 | - Fixes for handling libraries with aliases, such as the same library loaded twice under two different symlink paths 13 | - Fixes for working with older glibc's. 14 | - Support for building Spindle with clang 15 | - Fix network performance issues seen on IBM systems 16 | - Fix bug causing incorrect device in some stat calls 17 | - Move spindle testsuite to Python 3 18 | 19 | Spindle 0.11 20 | ------------ 21 | - ppc64le support 22 | - Spindle sessions feature, allowing running of multiple jobs under the same spindle session 23 | - Pure slurm-based launcher mode that does not require LaunchMON 24 | - Fixes around stat and execve error return values in errno when running with Spindle 25 | - Remap is now default, which makes debuggers operating on Spindle jobs happier 26 | - Resurrected subaudit support, which is needed to work-around ld.so bugs on ppc64le 27 | - Dropped BG/Q support 28 | 29 | Spindle 0.10 30 | ----------- 31 | - New API for integrating Spindle with job-launchers 32 | - Integration of BGQ branch into mainline 33 | - Support for RHEL7 34 | - Bug fixes 35 | 36 | Spindle 0.9 37 | ----------- 38 | - Support for OpenMPI's ORTE-based launching 39 | - Support for the flux resource manager 40 | - Improve support for co-existing with debuggers 41 | - Reorganize source tree to separate FE/BE/CLIENT builds 42 | - Support for building different spindle components with different compilers 43 | - Add security models for authentication TCP/IP connections 44 | - New hostbin-based startup for when LaunchMON doesn't work 45 | - New spindle man page 46 | - Fix a crash when dealing with size 0 libraries 47 | - Fix a race-condition hang on startup 48 | 49 | Spindle 0.8 50 | ----------- 51 | - New Spindle API allows for manually requesting Spindle semantics of open and stat calls 52 | - Support for running serial processes under Spindle with the --no-mpi option 53 | - Support for Spindle interception of stat and lstat calls. 54 | - Improved Python support, supported by --python-prefixes option 55 | - Bug fixes, many focused around following processes through fork/exec 56 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | Spindle is co-developed by Lawrence Livermore National Security and 2 | Juelich Supercomputing Center. The following copyrights apply: 3 | 4 | Copyright (c) 2020, Lawrence Livermore National Security, LLC. Produced at 5 | the Lawrence Livermore National Laboratory. Written by Matthew LeGendre 6 | 'legendre1 at llnl dot gov'. CODE-636292. All rights reserved. 7 | 8 | Copyright (c) 2020, Juelich Supercomputing Center. Written by Wolfgang Frings 9 | 'W.Frings at fz-juelich dot de'. All rights reserved. 10 | 11 | 12 | This program is free software; you can redistribute it and/or modify it under 13 | the terms of the GNU Lesser General Public License (as published by the Free Software 14 | Foundation) version 2.1 dated February 1999. This program is distributed in 15 | the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 16 | IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 17 | the terms and conditions of the GNU Lesser General Public License for more details. 18 | You should have received a copy of the GNU Lesser General Public License along 19 | with this program; if not, write to the Free Software Foundation, Inc., 59 20 | Temple Place, Suite 330, Boston, MA 02111-1307 USA. 21 | 22 | 23 | -------------------------------------------------------------------------------- /LIB_VERSION: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #Return library version in the libtool current:revision:age format. 4 | 5 | #From http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html: 6 | 7 | # 1. Start with version information of .0:0:0. for each libtool 8 | # library. 9 | # 2. Update the version information only immediately before a public 10 | # release of your software. More frequent updates are unnecessary, and 11 | # only guarantee that the current interface number gets larger faster. 12 | # 3. If the library source code has changed at all since the last 13 | # update, then increment revision (.c:r:a. becomes .c:r+1:a.). 14 | # 4. If any interfaces have been added, removed, or changed since the 15 | # last update, increment current, and set revision to 0. 16 | # 5. If any interfaces have been added since the last public release, 17 | # then increment age. 18 | # 6. If any interfaces have been removed or changed since the last 19 | # public release, then set age to 0. 20 | 21 | # History: 22 | # Spindle 0.9 - libspindlefe.so 0.0.0, libspindlebe.so 0.0.0, libspindle.so 0.0.0 23 | # Spindle 0.10 - libspindlefe.so 1.0.1, libspindlebe.so 1.0.1, libspindle.so 0.1.0 24 | # Spindle 0.11 - libspindlefe.so 2.0.0, libspindlebe.so 2.0.0, libspindle.so 0.1.0 25 | # Spindle 0.12 - libspindlefe.so 2.1.0, libspindlebe.so 2.1.0, libspindle.so 0.1.0 26 | # Spindle 0.13 - libspindlefe.so 3.0.1, libspindlebe.so 3.0.1, libspindle.so 0.1.0, libspindleslurm.so 0.0.0 27 | # Spindle 0.14 - libspindlefe.so 3.0.1, libspindlebe.so 3.0.1, libspindle.so 0.1.0, libspindleslurm.so 0.0.0, libspindleflux 0.0.0 28 | 29 | if test "x$1" == "xspindlefe"; then 30 | echo 3:0:1 31 | fi 32 | if test "x$1" == "xspindlebe"; then 33 | echo 3:0:1 34 | fi 35 | if test "x$1" == "xlibspindle"; then 36 | echo 0:1:0 37 | fi 38 | if test "x$1" == "xspindleslurm"; then 39 | echo 0:0:0 40 | fi 41 | if test "x$1" == "xspindleflux"; then 42 | echo 0:0:0 43 | fi 44 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = src/client src/server src/fe doc 2 | if BLD_SLURMPLUGIN 3 | SUBDIRS += src/slurm_plugin 4 | endif 5 | if BLD_FLUXPLUGIN 6 | SUBDIRS += src/flux 7 | endif 8 | if BLD_TESTSUITE 9 | SUBDIRS += testsuite 10 | endif 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | ============================================================================= 2 | == SPINDLE: Scalable Parallel Input Network for Dynamic Load Environments == 3 | ============================================================================= 4 | Authors: SPINDLE: Matthew LeGendre (legendre1 at llnl dot gov) 5 | W.Frings 6 | COBO: Adam Moody 7 | 8 | Version: 0.13 (Aug 2020) 9 | 10 | Summary: 11 | =========== 12 | 13 | Spindle is a tool for improving the performance of dynamic library 14 | and python loading in HPC enviornments. 15 | 16 | Documentation: 17 | ============ 18 | https://computing.llnl.gov/projects/spindle/software 19 | 20 | Overview: 21 | ============ 22 | 23 | Using dynamically-linked libraries is common in most computational 24 | environments, but they can cause serious problem when used on large 25 | clusters and supercomputers. Shared libraries are frequently stored 26 | on shared file systems, such as NFS. When thousands of processes 27 | simultaneously start and attempt to search for and load libraries, it 28 | resembles a denial-of-service attack against the shared file system. 29 | This "attack" doesn't just slow down the application, but impacts 30 | every user on the system. We encountered cases where it took over ten 31 | hours for a dynamically-linked MPI application running on 16K 32 | processes to reach main. 33 | 34 | Spindle presents a novel solution to this problem. It transparently 35 | runs alongside your distributed application and takes over its library 36 | loading mechanism. When processes start to load a new library, 37 | Spindle intercepts the operation, designates one process to read the 38 | file from the shared file system, then distributes the library's 39 | contents to every process with a scalable broadcast operation. 40 | 41 | Spindle is very scalable. On a cluster at LLNL the Pynamic benchmark 42 | (which measures library loading performance) was unable to scale much 43 | past 100 nodes. Even at that small scale it was causing significant 44 | performance problems that were impacting everyone on the cluster. 45 | When running Pynamic under Spindle, we were able to scale up to the 46 | max job size at 1,280 nodes without showing any signs of file-system 47 | stress or library-related slowdowns. 48 | 49 | Unlike competing solutions, Spindle does not require any special 50 | hardware, and libraries do not have to be staged into any special 51 | locations. Applications can work out-of-the-box do not need any 52 | special compile or link flags. Spindle is completely userspace and 53 | does not require kernel patches or root privileges. 54 | 55 | Spindle can trigger scalable loading of dlopened libraries, dependent 56 | library, executables, python modules and specified application data 57 | files. 58 | 59 | 60 | Compilation: 61 | ============ 62 | 63 | Please see INSTALL file in the Spindle source tree. 64 | 65 | Usage: 66 | ====== 67 | 68 | Put 'spindle' before your job launch command. E.g: 69 | 70 | spindle mpirun -n 128 mpi_hello_world 71 | 72 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.13 2 | -------------------------------------------------------------------------------- /bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo Bootstrap in spindle 4 | rm -rf autom4te.cache/ 5 | aclocal 6 | autoheader 7 | autoconf 8 | automake --add-missing 9 | automake 10 | 11 | echo Bootstrap in client 12 | cd src/client 13 | rm -rf autom4te.cache/ 14 | aclocal 15 | autoheader 16 | autoconf 17 | automake --add-missing 18 | automake 19 | cd ../.. 20 | 21 | echo Bootstrap in server 22 | cd src/server 23 | rm -rf autom4te.cache/ 24 | aclocal 25 | autoheader 26 | autoconf 27 | automake --add-missing 28 | automake 29 | cd ../.. 30 | 31 | echo Bootstrap in fe 32 | cd src/fe 33 | rm -rf autom4te.cache/ 34 | aclocal 35 | autoheader 36 | autoconf 37 | automake --add-missing 38 | automake 39 | cd ../.. 40 | 41 | automake 42 | touch configure 43 | 44 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | man1_MANS = spindle.1 2 | -------------------------------------------------------------------------------- /m4/launcher.m4: -------------------------------------------------------------------------------- 1 | #MPI Implementations Support 2 | 3 | AC_ARG_ENABLE(slurm, 4 | [AS_HELP_STRING([--enable-slurm],[Enable support for the SLURM job launcher])], 5 | [ENABLE_SLURM="true",EXPLICIT_RM="true"]) 6 | 7 | AC_ARG_ENABLE(openmpi, 8 | [AS_HELP_STRING([--enable-openmpi],[Enable support for the OpenMPI job launcher])], 9 | [ENABLE_OPENMPI="true",EXPLICIT_RM="true"]) 10 | 11 | AC_ARG_ENABLE(wreck, 12 | [AS_HELP_STRING([--enable-wreck],[Enable support for the Wreck job launcher])], 13 | [ENABLE_WRECK="true",EXPLICIT_RM="true"]) 14 | 15 | AC_ARG_ENABLE(lrun, 16 | [AS_HELP_STRING([--enable-lrun],[Enable support for LLNL's lrun job launcher])], 17 | [ENABLE_LRUN="true",EXPLICIT_RM="true"]) 18 | 19 | AC_ARG_ENABLE(jsrun, 20 | [AS_HELP_STRING([--enable-jsrun],[Enable support for IBM's jsrun job launcher])], 21 | [ENABLE_JSRUN="true",EXPLICIT_RM="true"]) 22 | 23 | if test "x$TESTRM" != "xunknown"; then 24 | EXPLICIT_RM="true" 25 | fi 26 | 27 | if test "x$EXPLICIT_RM" != "xtrue"; then 28 | ENABLE_SLURM="true" 29 | ENABLE_OPENMPI="true" 30 | ENABLE_WRECK="true" 31 | ENABLE_LRUN="true" 32 | ENABLE_JSRUN="true" 33 | fi 34 | 35 | if test "x$TESTRM" == "xslurm"; then 36 | ENABLE_SLURM="true" 37 | fi 38 | if test "x$TESTRM" == "xflux"; then 39 | ENABLE_WRECK="true" 40 | fi 41 | if test "x$TESTRM" == "xlrun"; then 42 | ENABLE_LRUN="true" 43 | fi 44 | if test "x$TESTRM" == "xjsrun"; then 45 | ENABLE_JSRUN="true" 46 | fi 47 | 48 | if test "x$ENABLE_LRUN" == "xtrue"; then 49 | ENABLE_JSRUN="true" 50 | fi 51 | 52 | if test "x$ENABLE_SLURM" == "xtrue"; then 53 | AC_DEFINE([ENABLE_SRUN_LAUNCHER],[1],[Enable support for srun]) 54 | fi 55 | if test "x$ENABLE_OPENMPI" == "xtrue"; then 56 | AC_DEFINE([ENABLE_OPENMPI_LAUNCHER],[1],[Enable support for openmpi]) 57 | fi 58 | if test "x$ENABLE_WRECK" == "xtrue"; then 59 | AC_DEFINE([ENABLE_WRECKRUN_LAUNCHER],[1],[Enable support for wreckrun]) 60 | fi 61 | if test "x$ENABLE_LRUN" == "xtrue"; then 62 | AC_DEFINE([ENABLE_LRUN_LAUNCHER],[1],[Enable support for lrun]) 63 | fi 64 | if test "x$ENABLE_JSRUN" == "xtrue"; then 65 | AC_DEFINE([ENABLE_JSRUN_LAUNCHER],[1],[Enable support for jsrun]) 66 | fi 67 | 68 | -------------------------------------------------------------------------------- /m4/ltversion.m4: -------------------------------------------------------------------------------- 1 | # ltversion.m4 -- version numbers -*- Autoconf -*- 2 | # 3 | # Copyright (C) 2004 Free Software Foundation, Inc. 4 | # Written by Scott James Remnant, 2004 5 | # 6 | # This file is free software; the Free Software Foundation gives 7 | # unlimited permission to copy and/or distribute it, with or without 8 | # modifications, as long as this notice is preserved. 9 | 10 | # @configure_input@ 11 | 12 | # serial 3337 ltversion.m4 13 | # This file is part of GNU Libtool 14 | 15 | m4_define([LT_PACKAGE_VERSION], [2.4.2]) 16 | m4_define([LT_PACKAGE_REVISION], [1.3337]) 17 | 18 | AC_DEFUN([LTVERSION_VERSION], 19 | [macro_version='2.4.2' 20 | macro_revision='1.3337' 21 | _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) 22 | _LT_DECL(, macro_revision, 0) 23 | ]) 24 | -------------------------------------------------------------------------------- /scripts/dtvtest/Makefile: -------------------------------------------------------------------------------- 1 | DEP_NUMS = 01 02 03 04 05 06 07 08 09 10 11 12 13 2 | DLOPEN_NUMS = 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 3 | 4 | DEP_LIBS = $(DEP_NUMS:%=libdeptls%.so) 5 | DEP_LINKS = $(DEP_NUMS:%=-ldeptls%) 6 | 7 | DLOPEN_LIBS = $(DLOPEN_NUMS:%=libdlopentls%.so) 8 | 9 | .PHONY: default $(DEP_NUMS) $(DLOPEN_NUMS) clean run 10 | 11 | default: dtvtest 12 | 13 | clean: 14 | rm -f $(DEP_LIBS) $(DLOPEN_LIBS) libminaudit.so dtvtest 15 | 16 | libdeptls%.so: $(SRCDIR)/tlslib.c 17 | gcc -shared -fPIC -o $@ -DINSTANCE=$(shell echo $@ | cut -c 10-11) -DLIBTYPE=dep $(SRCDIR)/tlslib.c 18 | 19 | libdlopentls%.so: $(SRCDIR)/tlslib.c 20 | gcc -shared -fPIC -o $@ -DINSTANCE=$(shell echo $@ | cut -c 13-14) -DLIBTYPE=dlopen $(SRCDIR)/tlslib.c 21 | 22 | libminaudit.so: $(SRCDIR)/minaudit.c 23 | gcc -shared -fPIC -o $@ $< 24 | 25 | dtvtest: $(SRCDIR)/dtvtest.c $(DEP_LIBS) 26 | gcc -o $@ $(SRCDIR)/dtvtest.c -ldl -lpthread -g -Wl,-rpath,`pwd` -L`pwd` $(DEP_LINKS) 27 | 28 | run: dtvtest libminaudit.so $(DLOPEN_LIBS) 29 | echo LD_AUDIT=./libminaudit.so ./dtvtest $(DLOPEN_NUMS) 30 | LD_AUDIT=./libminaudit.so ./dtvtest $(DLOPEN_NUMS) 31 | echo $? 32 | -------------------------------------------------------------------------------- /scripts/dtvtest/dtvtest.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | void onsig(int sig) 10 | { 11 | exit(-1); 12 | } 13 | 14 | typedef void (*set_f)(int); 15 | typedef int (*get_f)(void); 16 | int openlib(char *num) 17 | { 18 | char name[32]; 19 | void *result; 20 | set_f s; 21 | 22 | snprintf(name, 32, "./libdlopentls%s.so", num); 23 | result = dlopen(name, RTLD_NOW); 24 | if (!result) { 25 | fprintf(stderr, "Test error opening %s: %s\n", name, dlerror()); 26 | return -1; 27 | } 28 | 29 | snprintf(name, 32, "dlopen_set_%s", num); 30 | s = (set_f) dlsym(result, name); 31 | if (!s) { 32 | fprintf(stderr, "Test error looking up name %s\n", name); 33 | return -1; 34 | } 35 | s(4); 36 | return 0; 37 | } 38 | 39 | int main(int argc, char *argv[]) 40 | { 41 | int result; 42 | signal(SIGABRT, onsig); 43 | signal(SIGSEGV, onsig); 44 | signal(SIGTERM, onsig); 45 | 46 | if (argc == 1) { 47 | fprintf(stderr, "Test error: Expected to be run with list of numbers to dlopen\n"); 48 | return -1; 49 | } 50 | for (int i = 1; i < argc; i++) { 51 | result = openlib(argv[i]); 52 | if (result == -1) { 53 | return -1; 54 | } 55 | } 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /scripts/dtvtest/minaudit.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | #include 3 | 4 | unsigned int la_version(unsigned int version) 5 | { 6 | return LAV_CURRENT; 7 | } 8 | -------------------------------------------------------------------------------- /scripts/dtvtest/run_dtvtest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DTVSRCDIR=$1 4 | DTVBUILDDIR=$2 5 | CC=$3 6 | CFLAGS=$4 7 | 8 | mkdir -p $DTVBUILDDIR 9 | make -s -C $DTVBUILDDIR -f $DTVSRCDIR/Makefile SRCDIR=$DTVSRCDIR CC=$CC "CFLAGS=$CFLAGS" dtvtest 10 | if [ $? != 0 ] ; then 11 | exit 0 12 | fi 13 | make -s -C $DTVBUILDDIR -f $DTVSRCDIR/Makefile SRCDIR=$DTVSRCDIR CC=$CC "CFLAGS=$CFLAG" run > /dev/null 2>&1 14 | exit $? 15 | 16 | -------------------------------------------------------------------------------- /scripts/dtvtest/tlslib.c: -------------------------------------------------------------------------------- 1 | #if !defined(INSTANCE) 2 | #error INSTANCE not defined 3 | #endif 4 | 5 | #if !defined(LIBTYPE) 6 | #error LIBTYPE not defined 7 | #endif 8 | 9 | #define CAT2(X, T, I) T ## _ ## X ## _ ## I 10 | #define CAT(X, T, I) CAT2(X, T, I) 11 | #define NS(X) CAT(X, LIBTYPE, INSTANCE) 12 | 13 | __thread int NS(tlsvar); 14 | int NS(set)(int val) 15 | { 16 | NS(tlsvar) = val; 17 | } 18 | 19 | int NS(get)() 20 | { 21 | return NS(tlsvar); 22 | } 23 | -------------------------------------------------------------------------------- /scripts/remap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | WORKINGDIR=$1 4 | SRCDIR=$2 5 | CCLINE=$3 6 | UNIQ=$4 7 | 8 | cat < 19 | 20 | void get_relocated_file(int ldcs_id, char *orig_exec, int dso, char **reloc_exec, int *errcode, int *direxists) 21 | { 22 | *reloc_exec = strdup(WORKINGDIR "/remap2" UNIQ); 23 | *errcode = 0; 24 | if (direxists) *direxists = 1; 25 | } 26 | 27 | #include "src/client/client/remap_exec.c" 28 | 29 | int dowork() 30 | { 31 | char buffer[4097]; 32 | memset(buffer, 0, 4096); 33 | remap_executable(0); 34 | if (readlink("/proc/self/exe", buffer, 4096) == -1) 35 | return -1; 36 | if (strstr(buffer, "remap2")) 37 | return -1; 38 | return 0; 39 | } 40 | EOF 41 | 42 | cat < /dev/null 53 | RETVAL=$? 54 | #rm -f $WORKINGDIR/remap$UNIQ $WORKINGDIR/remap2$UNIQ $WORKINGDIR/libremap$UNIQ.so 55 | exit $RETVAL 56 | -------------------------------------------------------------------------------- /scripts/rewrite.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SRCDIR=$1 4 | WORKINGDIR=$2 5 | CCLINE=$3 6 | 7 | $CCLINE $SRCDIR/client/client/patch_interception.c -o $WORKINGDIR/patch_test -ldl -DCONFIG_TEST 8 | RETVAL=$? 9 | if [[ "x$RETVAL" != "x0" ]]; then 10 | exit -1 11 | fi 12 | LDSO=`ldd $WORKINGDIR/patch_test |& grep ld-linux | awk '{print $1}'` 13 | $WORKINGDIR/patch_test `nm $LDSO | grep __xstat | awk '{print $1}' | sort | uniq` `nm $LDSO | grep __lxstat | awk '{print $1}' | sort | uniq` `nm $LDSO | grep rtld_errno | awk '{print $1}' | sort | uniq` 14 | RETVAL=$? 15 | rm -f $WORKINDIR/patch_test 16 | exit $RETVAL 17 | -------------------------------------------------------------------------------- /src/biter/bgq_ids.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include 18 | #include 19 | #include "spi/include/kernel/location.h" 20 | #include "spi/include/kernel/process.h" 21 | #include "ids.h" 22 | #include "spindle_debug.h" 23 | 24 | #define MEMORY_BARRIER __sync_synchronize() 25 | 26 | extern int take_queue_lock(void *session); 27 | extern int release_queue_lock(void *session); 28 | 29 | int biterc_get_job_id() 30 | { 31 | int result = (int) Kernel_GetJobID(); 32 | if (result == INT_MIN) 33 | result = INT_MAX; 34 | else if (result < 0) 35 | result *= -1; 36 | return result; 37 | } 38 | 39 | unsigned int biterc_get_rank(int session_id) 40 | { 41 | return Kernel_GetRank(); 42 | } 43 | -------------------------------------------------------------------------------- /src/biter/biterc.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(BITERC_H_) 18 | #define BITERC_H_ 19 | 20 | #if defined(__cplusplus) 21 | extern "C" { 22 | #endif 23 | 24 | extern int biterc_newsession(const char *tmpdir, size_t shm_size); 25 | extern int biterc_read(int biter_session, void *buf, size_t size); 26 | extern int biterc_write(int biter_session, void *buf, size_t size); 27 | extern int biterc_get_id(int biter_session); 28 | extern unsigned int biterc_get_rank(int session_id); 29 | extern int biterc_is_client_fd(int biter_session, int fd); 30 | extern const char *biterc_lasterror_str(); 31 | 32 | #if defined(__cplusplus) 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/biter/biterd.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(BITERD_H_) 18 | #define BITERD_H_ 19 | 20 | #if defined(__cplusplus) 21 | extern "C" { 22 | #endif 23 | 24 | #include 25 | 26 | extern int biterd_newsession(const char *tmpdir, int session_id); 27 | extern int biterd_num_clients(int session_id); 28 | 29 | extern int biterd_fill_in_read_set(int session_id, fd_set *readset, int *max_fd); 30 | extern int biterd_has_data_avail(int session_id, fd_set *readset); 31 | extern int biterd_get_fd(int session_id); 32 | extern int biterd_get_aux_fd(); 33 | extern int biterd_find_client_w_data(int session_id); 34 | extern int biterd_get_session_proc_w_aux_data(int *session, int *proc); 35 | extern int biterd_init_comms(const char *tmpdir); 36 | 37 | extern int biterd_get_rank(int compute_node_id, int client_id); 38 | 39 | extern int biterd_write(int session_id, int client_id, const void *buf, size_t count); 40 | extern int biterd_read(int session_id, int client_id, void *buf, size_t count); 41 | 42 | extern int biterd_clean(int session_id); 43 | extern const char *biterd_lasterror_str(); 44 | 45 | extern int biterd_num_compute_nodes(); 46 | 47 | #if defined(__cplusplus) 48 | } 49 | #endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/biter/daemon_ids.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(DAEMON_IDS_H_) 18 | #define DAEMON_IDS_H_ 19 | 20 | #include 21 | 22 | extern int biterd_num_compute_nodes(); 23 | extern int biterd_ranks_in_cn(int cn_id); 24 | extern int biterd_unique_num_for_cn(int cn_id); 25 | extern int biterd_get_rank(int compute_node_id, int client_id); 26 | extern int biterd_register_rank(int session_id, uint32_t client_id, uint32_t rank); 27 | extern int biterd_init_comms(const char *tmpdir); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/biter/demultiplex.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(_MSGREAD_H_) 18 | #define _MSGREAD_H_ 19 | 20 | #include 21 | #include 22 | 23 | typedef struct msg_header_t { 24 | uint32_t msg_size; 25 | uint32_t msg_target; 26 | } msg_header_t; 27 | 28 | extern int test_pipe_lock(void *session); 29 | extern int take_pipe_lock(void *session); 30 | extern int release_pipe_lock(void *session); 31 | extern void set_last_error(const char *errstr); 32 | extern int take_queue_lock(void *session); 33 | extern int release_queue_lock(void *session); 34 | extern int take_write_lock(void *session); 35 | extern int release_write_lock(void *session); 36 | 37 | extern void set_polled_data(void *session, msg_header_t msg); 38 | extern void get_polled_data(void *session, msg_header_t *msg); 39 | extern void clear_polled_data(void *session); 40 | extern int has_polled_data(void *session); 41 | 42 | extern void set_heap_blocked(void *session); 43 | extern void set_heap_unblocked(void *session); 44 | extern int is_heap_blocked(void *session); 45 | 46 | extern void get_message(int for_proc, void **msg_data, size_t *msg_size, size_t *bytes_read, void *session); 47 | extern int has_message(int for_proc, void *session); 48 | extern void rm_message(int for_proc, void *session); 49 | extern int enqueue_message(int for_proc, void *msg_data, size_t msg_size, void *header_space, void *session); 50 | extern int get_message_space(size_t msg_size, unsigned char **msg_space, void **header_space, void *session); 51 | extern void update_bytes_read(int for_proc, size_t newval, void *session); 52 | 53 | int demultiplex_read(void *session, int fd, int myid, void *buf, size_t size); 54 | int demultiplex_write(void *session, int fd, int id, const void *buf, size_t size); 55 | int demultiplex_poll(void *session, int fd, int *id); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/biter/ids.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(IDS_H_) 18 | #define IDS_H_ 19 | 20 | int biterc_get_job_id(); 21 | unsigned int biterc_get_rank(); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/biter/linux_daemon_ids.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include 18 | #include 19 | #include "daemon_ids.h" 20 | 21 | int biterd_num_compute_nodes() 22 | { 23 | return 1; 24 | } 25 | 26 | int biterd_ranks_in_cn(int cn_id) 27 | { 28 | char *proc_s = getenv("PROCS"); 29 | if (proc_s) 30 | return atoi(proc_s); 31 | 32 | assert(0); 33 | } 34 | 35 | int biterd_unique_num_for_cn(int cn_id) 36 | { 37 | return 0; 38 | } 39 | 40 | int biterd_get_rank(int compute_node_id, int client_id) 41 | { 42 | return client_id; 43 | } 44 | 45 | int biterd_register_rank(int session_id, uint32_t client_id, uint32_t rank) 46 | { 47 | return 0; 48 | } 49 | 50 | int biterd_init_comms(const char *tmpdir) 51 | { 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /src/biter/linux_ids.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "ids.h" 18 | #include 19 | 20 | extern int get_id(int session_id); 21 | 22 | int biterc_get_job_id() 23 | { 24 | return 0; 25 | } 26 | 27 | unsigned int biterc_get_rank(int session_id) 28 | { 29 | return get_id(session_id); 30 | } 31 | -------------------------------------------------------------------------------- /src/biter/shm_wrappers.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(BITER_SHM_H_) 18 | #define BITER_SHM_H_ 19 | 20 | /** 21 | * We try to keep the client library only dependant on glibc (because 22 | * anything it depends on must be loaded via traditional file system 23 | * access). Unfortunately, the shm_open and shm_unlink functions 24 | * come from librt.so. So we've got our own implementations. 25 | **/ 26 | #include 27 | #include 28 | #include 29 | 30 | int shm_open_wrapper(const char *name, int oflag, mode_t mode); 31 | int shm_unlink_wrapper(const char *name); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/biter/shmutil.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(SHMUTIL_H_) 18 | #define SHMUTIL_H_ 19 | 20 | #include "sheep.h" 21 | #include "spindle_launch.h" 22 | 23 | typedef struct { 24 | volatile unsigned long *lock; 25 | volatile unsigned long *held_by; 26 | int ref_count; 27 | } lock_t; 28 | 29 | typedef struct { 30 | volatile int cur_id; 31 | unsigned long locks[2]; 32 | } base_header_t; 33 | 34 | #include "demultiplex.h" 35 | typedef struct { 36 | volatile int ready; 37 | int num_procs; 38 | sheep_ptr_t msg_table_ptr; 39 | msg_header_t polled_data; 40 | int has_polled_data; 41 | int heap_blocked; 42 | int max_rank; 43 | int num_ranks; 44 | int read_file; 45 | int num_started; 46 | unsigned long locks[6]; 47 | } biter_header_t; 48 | 49 | typedef struct { 50 | unsigned long locks[2]; 51 | sheep_ptr_t hash; 52 | sheep_ptr_t lru_head; 53 | sheep_ptr_t lru_end; 54 | size_t heap_used; 55 | } shmcache_header_t; 56 | 57 | typedef struct { 58 | base_header_t base; 59 | biter_header_t biter; 60 | shmcache_header_t shmcache; 61 | } header_t; 62 | 63 | typedef struct { 64 | void *mem; 65 | char *filename; 66 | header_t *shared_header; 67 | size_t size; 68 | lock_t mem_lock; 69 | int fd; 70 | int leader; 71 | int id; 72 | } shminfo_t; 73 | 74 | #define MEMORY_BARRIER __sync_synchronize() 75 | 76 | int take_lock(lock_t *lock); 77 | int test_lock(lock_t *lock); 78 | int release_lock(lock_t *lock); 79 | 80 | int init_shm(const char *tmpdir, size_t shm_size, number_t unique_number, shminfo_t **shminfo); 81 | int init_heap_lock(shminfo_t *shminfo); 82 | int init_heap(shminfo_t *shminfo); 83 | int setup_ids(shminfo_t *shminfo); 84 | 85 | int take_heap_lock(shminfo_t *shminfo); 86 | int release_heap_lock(shminfo_t *shminfo); 87 | 88 | void update_shm_id(); 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /src/client/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = logging biter shm_cache client_comlib client auditclient subaudit beboot spindle_api ldsolookup 2 | -------------------------------------------------------------------------------- /src/client/auditclient/Makefile.am: -------------------------------------------------------------------------------- 1 | pkglib_LTLIBRARIES = 2 | 3 | if SOCKETS 4 | pkglib_LTLIBRARIES += libspindle_audit_socket.la 5 | endif 6 | if PIPES 7 | pkglib_LTLIBRARIES += libspindle_audit_pipe.la 8 | endif 9 | if BITER 10 | pkglib_LTLIBRARIES += libspindle_audit_biter.la 11 | endif 12 | 13 | AM_CFLAGS = -fvisibility=hidden 14 | 15 | AM_CPPFLAGS = -I$(top_srcdir)/../logging -I$(top_srcdir)/../include -I$(top_srcdir)/client -I$(top_srcdir)/client_comlib 16 | 17 | BASE_SRCS = auditclient.c auditclient_common.c patch_linkmap.c redirect.c bindgot.c writablegot.c patch_bad_dtv.c 18 | if X86_64_BLD 19 | ARCH_SRCS = auditclient_x86_64.c 20 | endif 21 | if PPC64_BLD 22 | ARCH_SRCS = auditclient_ppc64.c 23 | endif 24 | if PPC64LE_BLD 25 | ARCH_SRCS = auditclient_ppc64.c 26 | endif 27 | if AARCH64_BLD 28 | ARCH_SRCS = auditclient_aarch64.c 29 | endif 30 | 31 | AUDITLIB = $(top_builddir)/client/libspindle_audit.la 32 | 33 | libspindle_audit_socket_la_SOURCES = $(BASE_SRCS) $(ARCH_SRCS) 34 | libspindle_audit_socket_la_LIBADD = $(top_builddir)/client/libspindlec_socket.la $(AUDITLIB) 35 | libspindle_audit_socket_la_LDFLAGS = -shared -avoid-version -Wl,-rpath,$(GLIBC_BE_DIR) 36 | 37 | libspindle_audit_pipe_la_SOURCES = $(BASE_SRCS) $(ARCH_SRCS) 38 | libspindle_audit_pipe_la_LIBADD = $(top_builddir)/client/libspindlec_pipe.la $(AUDITLIB) 39 | libspindle_audit_pipe_la_LDFLAGS = -shared -avoid-version -Wl,-rpath,$(GLIBC_BE_DIR) 40 | 41 | libspindle_audit_biter_la_SOURCES = $(BASE_SRCS) $(ARCH_SRCS) 42 | libspindle_audit_biter_la_LIBADD = $(top_builddir)/client/libspindlec_biter.la $(AUDITLIB) 43 | libspindle_audit_biter_la_LDFLAGS = -shared -avoid-version -Wl,-rpath,$(GLIBC_BE_DIR) 44 | -------------------------------------------------------------------------------- /src/client/auditclient/auditclient.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | /* rtld-audit interface functions. Other rtld-audit functions may be found 18 | in platform files like auditclient_x86_64.c */ 19 | 20 | 21 | #include "client.h" 22 | #include "auditclient.h" 23 | #include "ldcs_api.h" 24 | #include 25 | #include 26 | #include 27 | 28 | extern void restore_pathpatch(); 29 | 30 | unsigned int spindle_la_version(unsigned int version) 31 | { 32 | patchDTV_init(); 33 | return 1; 34 | } 35 | 36 | void spindle_la_activity (uintptr_t *cookie, unsigned int flag) 37 | { 38 | debug_printf3("la_activity(): cookie = %p; flag = %s\n", cookie, 39 | (flag == LA_ACT_CONSISTENT) ? "LA_ACT_CONSISTENT" : 40 | (flag == LA_ACT_ADD) ? "LA_ACT_ADD" : 41 | (flag == LA_ACT_DELETE) ? "LA_ACT_DELETE" : 42 | "???"); 43 | restore_pathpatch(); 44 | if (flag == LA_ACT_CONSISTENT) { 45 | patchDTV_check(); 46 | lookup_libc_symbols(); 47 | updateDataBindingQueue(0); 48 | } 49 | return; 50 | } 51 | 52 | unsigned int spindle_la_objopen(struct link_map *map, Lmid_t lmid, uintptr_t *cookie) 53 | { 54 | char buffer[4096]; 55 | char *exe_name, *exe_name2; 56 | 57 | restore_pathpatch(); 58 | patch_on_linkactivity(map); 59 | memset(buffer, 0, sizeof(buffer)); 60 | readlink("/proc/self/exe", buffer, sizeof(buffer)); 61 | exe_name = strrchr(buffer, '/'); 62 | if (exe_name) 63 | exe_name++; 64 | else 65 | exe_name = buffer; 66 | if (strstr(exe_name, "spindlens")) { 67 | exe_name2 = strrchr(exe_name, '-'); 68 | if (exe_name2) 69 | exe_name = exe_name2 + 1; 70 | } 71 | return LA_FLG_BINDTO | LA_FLG_BINDFROM; 72 | } 73 | 74 | unsigned int spindle_la_objclose(uintptr_t *cookie) 75 | { 76 | return 0; 77 | } 78 | -------------------------------------------------------------------------------- /src/client/auditclient/auditclient.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(AUDITCLIENT_H_) 18 | #define AUDITCLIENT_H_ 19 | 20 | #define _GNU_SOURCE 21 | 22 | #include 23 | #include 24 | #include "client.h" 25 | 26 | struct link_map *get_linkmap_from_cookie(uintptr_t *cookie); 27 | void patch_on_linkactivity(struct link_map *lmap); 28 | ElfX_Addr client_call_binding(const char *symname, ElfX_Addr symvalue); 29 | struct link_map *get_linkmap_from_cookie(uintptr_t *cookie); 30 | 31 | Elf64_Addr doPermanentBinding_idx(struct link_map *map, 32 | unsigned long plt_reloc_idx, 33 | Elf64_Addr target, 34 | const char *symname); 35 | Elf64_Addr doPermanentBinding_noidx(uintptr_t *refcook, uintptr_t *defcook, 36 | Elf64_Addr target, const char *symname, 37 | void *stack_begin, void *stack_end); 38 | int do_global_bindings(struct link_map *map); 39 | void patchDTV_init(); 40 | void patchDTV_check(); 41 | void addToDataBindingQueue(struct link_map *map, 42 | Elf64_Addr target, 43 | Elf64_Addr *got_entry); 44 | void updateDataBindingQueue(int flush); 45 | 46 | #define AUDIT_EXPORT __attribute__((__visibility__("default"))) 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/client/auditclient/auditclient_aarch64.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef _GNU_SOURCE 18 | #define _GNU_SOURCE 19 | #endif 20 | 21 | #include 22 | #include "client.h" 23 | #include "auditclient.h" 24 | #include "spindle_debug.h" 25 | 26 | Elf64_Addr la_aarch64_gnu_pltenter(Elf64_Sym *sym, unsigned int ndx, 27 | uintptr_t *refcook, 28 | uintptr_t *defcook, 29 | La_aarch64_regs *regs, 30 | unsigned int *flags, 31 | const char *symname, 32 | long int *framesizep) AUDIT_EXPORT; 33 | 34 | Elf64_Addr la_aarch64_gnu_pltenter (Elf64_Sym *sym, unsigned int ndx, 35 | uintptr_t *refcook, 36 | uintptr_t *defcook, 37 | La_aarch64_regs *regs, 38 | unsigned int *flags, 39 | const char *symname, 40 | long int *framesizep) 41 | { 42 | Elf64_Addr target; 43 | void *sp; 44 | 45 | __asm__("mov %0, sp\n" : "=r" (sp)); 46 | 47 | target = client_call_binding(symname, sym->st_value); 48 | return doPermanentBinding_noidx(refcook, defcook, target, symname, 49 | sp, (void *) regs); 50 | } 51 | -------------------------------------------------------------------------------- /src/client/auditclient/auditclient_ppc64.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef _GNU_SOURCE 18 | #define _GNU_SOURCE 19 | #endif 20 | 21 | #include 22 | #include "client.h" 23 | #include "auditclient.h" 24 | #include "spindle_debug.h" 25 | 26 | #if _CALL_ELF != 2 27 | // v1 ABI 28 | #define SPINDLE_PLTENTER la_ppc64_gnu_pltenter 29 | #define SPINDLE_PPC_REGS La_ppc64_regs 30 | 31 | struct ppc64_funcptr_t { 32 | Elf64_Addr fptr; 33 | Elf64_Addr toc; 34 | }; 35 | #else 36 | // v2 ABI 37 | #define SPINDLE_PLTENTER la_ppc64v2_gnu_pltenter 38 | #define SPINDLE_PPC_REGS La_ppc64v2_regs 39 | #endif 40 | 41 | Elf64_Addr SPINDLE_PLTENTER(Elf64_Sym *sym, unsigned int ndx, 42 | uintptr_t *refcook, uintptr_t *defcook, 43 | SPINDLE_PPC_REGS *regs, unsigned int *flags, 44 | const char *symname, long int *framesizep) AUDIT_EXPORT; 45 | 46 | Elf64_Addr SPINDLE_PLTENTER(Elf64_Sym *sym, 47 | unsigned int ndx, 48 | uintptr_t *refcook, 49 | uintptr_t *defcook, 50 | SPINDLE_PPC_REGS *regs, 51 | unsigned int *flags, 52 | const char *symname, 53 | long int *framesizep) 54 | { 55 | Elf64_Addr target; 56 | void *sp; 57 | 58 | __asm__("or %0, %%r1, %%r1\n" : "=r" (sp)); 59 | 60 | target = client_call_binding(symname, sym->st_value); 61 | return doPermanentBinding_noidx(refcook, defcook, target, symname, 62 | sp, (void *) regs); 63 | } 64 | -------------------------------------------------------------------------------- /src/client/auditclient/patch_linkmap.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | 18 | #define _GNU_SOURCE 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "client.h" 26 | #include "auditclient.h" 27 | #include "client_heap.h" 28 | #include "client_api.h" 29 | #include "spindle_launch.h" 30 | 31 | static char *last_rewritten_name = NULL; 32 | static char *last_orig_name = NULL; 33 | static char *ldso_path = NULL; 34 | 35 | void patch_on_load_success(const char *rewritten_name, const char *orig_name, const char *ldso_path_name) 36 | { 37 | if (last_orig_name) 38 | spindle_free(last_orig_name); 39 | if (ldso_path) 40 | spindle_free(ldso_path); 41 | 42 | last_rewritten_name = (char *) rewritten_name; 43 | last_orig_name = spindle_strdup(orig_name); 44 | ldso_path = spindle_strdup(ldso_path_name); 45 | debug_printf2("Setting up patching of link map %s -> %s for origpath %s\n", rewritten_name, orig_name, ldso_path_name); 46 | } 47 | 48 | void patch_on_linkactivity(struct link_map *lmap) 49 | { 50 | size_t len; 51 | char *oname; 52 | 53 | if (!last_rewritten_name || !last_orig_name) 54 | return; 55 | 56 | if (lmap->l_name == last_rewritten_name || 57 | lmap->l_name == ldso_path || 58 | strcmp(lmap->l_name, last_rewritten_name) == 0 || 59 | strcmp(lmap->l_name, ldso_path) == 0) 60 | { 61 | debug_printf3("Replacing name %s with name %s\n", lmap->l_name, last_orig_name); 62 | if (strlen(lmap->l_name) >= strlen(last_orig_name)) { 63 | strcpy(lmap->l_name, last_orig_name); 64 | } 65 | else { 66 | malloc_sig_t app_malloc = get_libc_malloc(); 67 | if (app_malloc) { 68 | len = strlen(last_orig_name) + 2; 69 | oname = (char *) app_malloc(len); 70 | if (oname) { 71 | strncpy(oname, last_orig_name, len); 72 | lmap->l_name = oname; 73 | } 74 | } 75 | } 76 | } 77 | else { 78 | debug_printf3("Did not replace name %s with name %s\n", lmap->l_name ? : "NULL", last_orig_name ? : "NULL"); 79 | } 80 | spindle_free(last_orig_name); 81 | last_rewritten_name = NULL; 82 | last_orig_name = NULL; 83 | } 84 | -------------------------------------------------------------------------------- /src/client/auditclient/redirect.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "intercept.h" 18 | #include "client.h" 19 | #include "spindle_debug.h" 20 | 21 | #include 22 | #include 23 | 24 | ElfX_Addr client_call_binding(const char *symname, ElfX_Addr symvalue) 25 | { 26 | struct spindle_binding_t *binding; 27 | 28 | if (run_tests && strcmp(symname, "spindle_test_log_msg") == 0) 29 | return (Elf64_Addr) int_spindle_test_log_msg; 30 | if (!app_errno_location && strcmp(symname, ERRNO_NAME) == 0) { 31 | app_errno_location = (errno_location_t) symvalue; 32 | return symvalue; 33 | } 34 | 35 | binding = lookup_in_binding_hash(symname); 36 | if (!binding) 37 | return symvalue; 38 | 39 | if (*binding->libc_func == NULL) 40 | *binding->libc_func = (void *) symvalue; 41 | 42 | if (binding->spindle_func) 43 | return (ElfX_Addr) binding->spindle_func; 44 | else 45 | return symvalue; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /src/client/auditclient/writablegot.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(WRITABLEGOT_H_) 18 | #define WRITABLEGOT_H_ 19 | 20 | #ifndef _GNU_SOURCE 21 | #define _GNU_SOURCE 22 | #endif 23 | 24 | #include 25 | 26 | int add_wgot_library(struct link_map *map); 27 | int rm_wgot_library(struct link_map *map); 28 | int make_got_writable(void *got_entry, struct link_map *map); 29 | void mark_newlibs_as_need_writable_got(); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/client/beboot/Makefile.am: -------------------------------------------------------------------------------- 1 | pkglibexec_PROGRAMS = spindle_bootstrap 2 | 3 | spindle_bootstrap_LDFLAGS = $(AM_LDFLAGS) $(STATICFLAG) 4 | spindle_bootstrap_CPPFLAGS = $(AM_CPPFLAGS) -DLIBEXECDIR=\"$(pkglibexecdir)\" -DPROGLIBDIR=\"$(pkglibdir)\" -I$(top_srcdir)/../include -I$(top_srcdir)/../logging -I$(top_srcdir)/client_comlib -I$(top_srcdir)/client -I$(top_srcdir)/shm_cache -I$(top_srcdir)/../utils 5 | spindle_bootstrap_LDADD = $(top_builddir)/logging/libspindleclogc.la $(top_builddir)/shm_cache/libshmcache.la 6 | spindle_bootstrap_SOURCES = spindle_bootstrap.c $(top_srcdir)/../utils/parseloc.c $(top_srcdir)/../utils/spindle_mkdir.c $(top_srcdir)/../utils/getcpu.c $(top_srcdir)/client/exec_util.c $(top_srcdir)/client/lookup.c $(top_srcdir)/../utils/fileutil.c 7 | 8 | if PIPES 9 | spindle_bootstrap_LDADD += $(top_builddir)/client_comlib/libclient_pipe.la 10 | endif 11 | if BITER 12 | spindle_bootstrap_LDADD += $(top_builddir)/client_comlib/libclient_biter.la $(top_builddir)/biter/libbiterc.la 13 | endif 14 | -------------------------------------------------------------------------------- /src/client/beboot/parseloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(PARSELOC_H_) 18 | #define PARSELOC_H_ 19 | 20 | #if defined(__cplusplus) 21 | extern "C" { 22 | #endif 23 | 24 | #include "spindle_launch.h" 25 | 26 | char *parse_location(char *loc, number_t number); 27 | 28 | #if defined(__cplusplus) 29 | } 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/client/biter/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libbiterc.la libsheep.la 2 | 3 | libbiterc_la_SOURCES = $(top_srcdir)/../biter/biterc.c $(top_srcdir)/../biter/client_queue.c $(top_srcdir)/../biter/demultiplex.c 4 | libbiterc_la_CFLAGS = -DCLIENT 5 | libbiterc_la_LIBADD = libsheep.la 6 | 7 | libsheep_la_SOURCES = $(top_srcdir)/../biter/sheep.c $(top_srcdir)/../biter/shmutil.c $(top_srcdir)/../biter/shm_wrappers.c 8 | 9 | AM_CPPFLAGS = -I$(top_srcdir)/../biter -I$(top_srcdir)/../logging -I$(top_srcdir)/../include 10 | AM_CFLAGS = -fvisibility=hidden 11 | 12 | if BGQ_BLD 13 | AM_CPPFLAGS += -I/bgsys/drivers/ppcfloor/comm/lib/gnu -I/bgsys/drivers/ppcfloor -I/bgsys/drivers/ppcfloor/comm/sys/include -I/bgsys/drivers/ppcfloor/spi/include -I/bgsys/drivers/ppcfloor/spi/include/kernel/cnk 14 | libbiterc_la_SOURCES += $(top_srcdir)/../biter/bgq_ids.c 15 | endif 16 | if LINUX_BLD 17 | libbiterc_la_SOURCES += $(top_srcdir)/../biter/linux_ids.c 18 | endif 19 | -------------------------------------------------------------------------------- /src/client/client/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libspindle_audit.la 2 | #noinst_LTLIBRARIES += libspindle_instr.la 3 | 4 | if SOCKETS 5 | noinst_LTLIBRARIES += libspindlec_socket.la 6 | endif 7 | if PIPES 8 | noinst_LTLIBRARIES += libspindlec_pipe.la 9 | endif 10 | if BITER 11 | noinst_LTLIBRARIES += libspindlec_biter.la 12 | endif 13 | 14 | AM_CFLAGS = -fvisibility=hidden 15 | 16 | AM_CPPFLAGS = -I$(top_srcdir)/../logging -I$(top_srcdir)/client_comlib -I$(top_srcdir)/../include -I$(top_srcdir)/shm_cache -I$(top_srcdir)/subaudit -I$(top_srcdir)/../utils 17 | 18 | INTERCEPT_SRCS = intercept_open.c intercept_exec.c intercept_stat.c intercept_readlink.c intercept_spindleapi.c intercept.c spindle_regex.c patch_interception.c realpath.c $(top_srcdir)/../utils/fileutil.c 19 | 20 | BASE_SRCS = client.c lookup.c should_intercept.c exec_util.c remap_exec.c lookup_libc.c $(top_srcdir)/../utils/parseloc.c $(top_srcdir)/../utils/getcpu.c 21 | 22 | libspindlec_socket_la_SOURCES = $(BASE_SRCS) 23 | libspindlec_socket_la_LIBADD = $(top_builddir)/client_comlib/libclient_socket.la $(top_builddir)/logging/libspindleclogc.la $(top_builddir)/shm_cache/libshmcache.la 24 | 25 | libspindlec_pipe_la_SOURCES = $(BASE_SRCS) 26 | libspindlec_pipe_la_LIBADD = $(top_builddir)/client_comlib/libclient_pipe.la $(top_builddir)/logging/libspindleclogc.la $(top_builddir)/shm_cache/libshmcache.la 27 | 28 | libspindlec_biter_la_SOURCES = $(BASE_SRCS) 29 | libspindlec_biter_la_LIBADD = $(top_builddir)/client_comlib/libclient_biter.la $(top_builddir)/logging/libspindleclogc.la $(top_builddir)/shm_cache/libshmcache.la 30 | 31 | libspindle_audit_la_SOURCES = $(INTERCEPT_SRCS) 32 | libspindle_audit_la_CPPFLAGS = -DAUDIT_LIB -I$(top_srcdir)/auditclient $(AM_CPPFLAGS) 33 | 34 | #libspindle_instr_la_SOURCES = $(INTERCEPT_SRCS) 35 | #libspindle_instr_la_CPPFLAGS = -DINSTR_LIB -I$(top_srcdir)/instrclient $(AM_CPPFLAGS) 36 | -------------------------------------------------------------------------------- /src/client/client/exec_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(EXEC_UTIL_H_) 18 | #define EXEC_UTIL_H_ 19 | 20 | #define SCRIPT_ERR -1 21 | #define SCRIPT_ENOENT -2 22 | #define SCRIPT_NOTSCRIPT -3 23 | 24 | int adjust_if_script(const char *orig_path, char *reloc_path, char **argv, char **interp_path, char ***new_argv); 25 | int exec_pathsearch(int ldcsid, const char *orig_exec, char **new_exec, int *errcode); 26 | int isExecExcluded(const char *fname); 27 | int get_dirlists(char ***prefixes, char ***eexecs); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/client/client/patch_interception.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(PATCH_INTERCEPTION_H_) 18 | #define PATCH_INTERCEPTION_H_ 19 | 20 | int install_ldso_patch(unsigned long ldso_offset, void *patch_to); 21 | int *calc_ldso_errno(unsigned long errno_offset); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/client/client/should_intercept.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(SHOULD_INTERCEPT_H_) 18 | #define SHOULD_INTERCEPT_H_ 19 | 20 | /** 21 | * These functions are the control our policy on whether we relocate operations 22 | * through spindle, or let them happen normally 23 | **/ 24 | 25 | #define ORIG_CALL 0 26 | #define REDIRECT 1 27 | #define EXCL_OPEN 2 28 | #define ERR_CALL 3 29 | 30 | int open_filter(const char *fname, int flags); 31 | int fopen_filter(const char *fname, const char *flags); 32 | int exec_filter(const char *fname); 33 | int stat_filter(const char *fname); 34 | int fd_filter(int fd); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/client/client/spindle_regex.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include 18 | #include 19 | #include "spindle_regex.h" 20 | #include "client_heap.h" 21 | #include "spindle_debug.h" 22 | 23 | static int is_regex(const char *regex_str) 24 | { 25 | int i = 0; 26 | for (i = 0; regex_str[i] != '\0'; i++) { 27 | char c = regex_str[i]; 28 | if (c == '*' || c == '[' || c == '+' || c == '^' || c == '$' || c == '?') 29 | return 1; 30 | } 31 | return 0; 32 | } 33 | 34 | #define STR(X) STR2(X) 35 | #define STR2(X) #X 36 | 37 | #define STRCASE(X) case X: return STR(X) 38 | const char *regex_error_str(int errcode) { 39 | switch (errcode) { 40 | STRCASE(REG_BADPAT); 41 | STRCASE(REG_BADRPT); 42 | STRCASE(REG_ECOLLATE); 43 | STRCASE(REG_ECTYPE); 44 | STRCASE(REG_EESCAPE); 45 | STRCASE(REG_ESUBREG); 46 | STRCASE(REG_EBRACK); 47 | STRCASE(REG_EPAREN); 48 | STRCASE(REG_EBRACE); 49 | STRCASE(REG_ERANGE); 50 | STRCASE(REG_ESPACE); 51 | default: return "[UNKNOWN ERROR CODE]"; 52 | } 53 | } 54 | 55 | spindle_regex_t parse_spindle_regex_str(const char *regex_str) 56 | { 57 | regex_t *compiled_regex = NULL; 58 | int result; 59 | 60 | if (!is_regex(regex_str)) { 61 | return NULL; 62 | } 63 | 64 | compiled_regex = (regex_t *) spindle_malloc(sizeof(regex_t)); 65 | result = regcomp(compiled_regex, regex_str, REG_NOSUB); 66 | if (result != 0) { 67 | err_printf("Failed to parse regular expression. Error is %s (%d)\n", regex_error_str(result), result); 68 | return NULL; 69 | } 70 | 71 | debug_printf2("Compiled regex from %s\n", regex_str); 72 | return (spindle_regex_t) compiled_regex; 73 | } 74 | 75 | int matches_spindle_regex(spindle_regex_t regex, const char *str) 76 | { 77 | int result; 78 | regex_t *compiled_regex = (regex_t *) regex; 79 | 80 | result = regexec(compiled_regex, str, 0, NULL, 0); 81 | return (result == 0) ? 1 : 0; 82 | } 83 | -------------------------------------------------------------------------------- /src/client/client/spindle_regex.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(__SPINDLE_REGEX_H_) 18 | #define __SPINDLE_REGEX_H_ 19 | 20 | typedef void* spindle_regex_t; 21 | 22 | spindle_regex_t parse_spindle_regex_str(const char *regex_str); 23 | int matches_spindle_regex(spindle_regex_t regex, const char *str); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/client/client_comlib/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = 2 | 3 | AM_CPPFLAGS = -I$(top_srcdir)/../logging -I$(top_srcdir)/../include 4 | 5 | BASE_SRCS = client_api.c client_heap.c client_wrappers.c 6 | 7 | AM_CFLAGS = -fvisibility=hidden 8 | 9 | noinst_LTLIBRARIES += libclient_pipe.la 10 | libclient_pipe_la_CPPFLAGS = $(AM_CPPFLAGS) -DCOMM=pipe 11 | libclient_pipe_la_SOURCES = client_api_pipe.c $(BASE_SRCS) 12 | 13 | noinst_LTLIBRARIES += libclient_socket.la 14 | libclient_socket_la_CPPFLAGS = $(AM_CPPFLAGS) -DCOMM=socket 15 | libclient_socket_la_SOURCES = client_api_socket.c $(BASE_SRCS) 16 | 17 | noinst_LTLIBRARIES += libclient_biter.la 18 | libclient_biter_la_CPPFLAGS = $(AM_CPPFLAGS) -DCOMM=biter -I$(top_srcdir)/../biter 19 | libclient_biter_la_LIBADD = $(top_builddir)/biter/libbiterc.la 20 | libclient_biter_la_SOURCES = client_api_biter.c $(BASE_SRCS) 21 | -------------------------------------------------------------------------------- /src/client/client_comlib/client_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(CLIENT_API_H_) 18 | #define CLIENT_API_H_ 19 | 20 | #include "ldcs_api.h" 21 | #include "spindle_launch.h" 22 | #include 23 | #include 24 | #include 25 | 26 | /** 27 | * Communication functions for sending messages to the server 28 | **/ 29 | int send_file_query(int fd, char* path, int dso, char **newpath, int *errcode); 30 | int send_dir_cwd(int fd, char *cwd); 31 | int send_cwd(int fd); 32 | int send_pid(int fd); 33 | int send_cpu(int fd, int cpu); 34 | int send_location(int fd, char *location); 35 | int send_rankinfo_query(int fd, int *mylrank, int *mylsize, int *mymdrank, int *mymdsize); 36 | int send_end(int fd); 37 | int send_existance_test(int fd, char *path, int *exists); 38 | #define STAT_SELF 1 39 | int send_stat_request(int fd, char *path, int islstat, char *result); 40 | int send_ldso_info_request(int fd, const char *ldso_path, char *result_path); 41 | int send_orig_path_request(int fd, const char *path, char *newpath); 42 | int send_dirlists_request(int fd, char **local_result, char **exece_result, char **to_free); 43 | int send_procmaps_query(int fd, int pid, char *result); 44 | int send_pickone_query(int fd, char *key, int *result); 45 | 46 | int get_python_prefix(int fd, char **prefix); 47 | 48 | /* client */ 49 | int client_open_connection(char* location, number_t number); 50 | int client_close_connection(int connid); 51 | int client_register_connection(char *connection_str); 52 | char *client_get_connection_string(int fd); 53 | int client_send_msg(int connid, ldcs_message_t * msg); 54 | int client_recv_msg_static(int fd, ldcs_message_t *msg, ldcs_read_block_t block); 55 | int client_recv_msg_dynamic(int fd, ldcs_message_t *msg, ldcs_read_block_t block); 56 | int is_client_fd(int connfd, int fd); 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/client/client_comlib/client_heap.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "client_heap.h" 18 | #include "ldcs_api.h" 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | struct lock_t heap_lock; 26 | 27 | static pid_t gettid() 28 | { 29 | return syscall(SYS_gettid); 30 | } 31 | 32 | int lock(struct lock_t *l) 33 | { 34 | pid_t me = gettid(); 35 | for (;;) { 36 | long result = __sync_lock_test_and_set(&l->lock, 1); 37 | if (result == 0) { 38 | /* Obtained lock */ 39 | l->held_by = me; 40 | return 0; 41 | } 42 | if (l->held_by == me) { 43 | /* Re-entering lock, likely via a signal. We're not re-enterant, 44 | and we have to abort this operation. */ 45 | err_printf("Failing to take lock because I already hold it. Canceling operation\n"); 46 | return -1; 47 | } 48 | sched_yield(); 49 | } 50 | } 51 | 52 | void unlock(struct lock_t *l) 53 | { 54 | l->held_by = 0; 55 | __sync_lock_release(&l->lock); 56 | } 57 | 58 | void *spindle_malloc(size_t size) 59 | { 60 | void *result; 61 | HEAP_LOCK; 62 | result = malloc(size); 63 | HEAP_UNLOCK; 64 | return result; 65 | } 66 | 67 | void spindle_free(void *mem) 68 | { 69 | HEAP_LOCK; 70 | free(mem); 71 | HEAP_UNLOCK; 72 | } 73 | 74 | char *spindle_strdup(const char *str) 75 | { 76 | char *result; 77 | HEAP_LOCK; 78 | result = strdup(str); 79 | HEAP_UNLOCK; 80 | return result; 81 | } 82 | 83 | void *spindle_realloc(void *orig, size_t size) 84 | { 85 | void *result; 86 | HEAP_LOCK; 87 | result = realloc(orig, size); 88 | HEAP_UNLOCK; 89 | return result; 90 | } 91 | -------------------------------------------------------------------------------- /src/client/client_comlib/client_heap.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(CLIENT_HEAP_H_) 18 | #define CLIENT_HEAP_H_ 19 | 20 | #include 21 | 22 | /** 23 | * We have to use explicity locks around the malloc/free family of functions. 24 | * Normally glibc malloc/free implement thread safety if linked with libpthreads. 25 | * Our libc runs in its own lmid namespace and doesn't know whether libpthread is 26 | * loaded, so we don't get a thread safe heap even if the app is multithreaded. 27 | **/ 28 | struct lock_t { 29 | volatile long lock; 30 | volatile pid_t held_by; 31 | }; 32 | 33 | int lock(struct lock_t *l); 34 | void unlock(struct lock_t *l); 35 | 36 | extern struct lock_t heap_lock; 37 | #define HEAP_LOCK do { if (lock(&heap_lock) == -1) assert(0); } while (0) 38 | #define HEAP_UNLOCK unlock(&heap_lock) 39 | 40 | /* These functions automatically lock the heap_lock */ 41 | void *spindle_malloc(size_t size); 42 | void spindle_free(void *mem); 43 | char *spindle_strdup(const char *str); 44 | void *spindle_realloc(void *orig, size_t size); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/client/client_comlib/client_wrappers.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "ldcs_api.h" 18 | #include "config.h" 19 | #include "spindle_launch.h" 20 | 21 | #if !defined(COMM) 22 | #if defined(COMM_PIPES) 23 | #define COMM pipe 24 | #elif defined(COMM_SOCKETS) 25 | #define COMM socket 26 | #elif defined(COMM_BITER) 27 | #define COMM biter 28 | #elif defined(COMM_SHMEM) 29 | #define COMM shmem 30 | #else 31 | #error Unknown communication type 32 | #endif 33 | #endif 34 | 35 | #define RENAME3(X, Y) X ## _ ## Y 36 | #define RENAME2(X, Y) RENAME3(X, Y) 37 | #define RENAME(X) RENAME2(X, COMM) 38 | 39 | extern int RENAME(client_open_connection) (char* location, number_t number); 40 | extern int RENAME(client_close_connection) (int connid); 41 | extern int RENAME(client_register_connection) (char *connection_str); 42 | extern char *RENAME(client_get_connection_string) (int fd); 43 | extern int RENAME(client_send_msg) (int connid, ldcs_message_t * msg); 44 | extern int RENAME(client_recv_msg_static) (int fd, ldcs_message_t *msg, ldcs_read_block_t block); 45 | extern int RENAME(client_recv_msg_dynamic) (int fd, ldcs_message_t *msg, ldcs_read_block_t block); 46 | 47 | int client_open_connection(char* location, number_t number) 48 | { 49 | return RENAME(client_open_connection) (location, number); 50 | } 51 | 52 | int client_close_connection(int connid) 53 | { 54 | return RENAME(client_close_connection) (connid); 55 | } 56 | 57 | int client_register_connection(char *connection_str) 58 | { 59 | return RENAME(client_register_connection) (connection_str); 60 | } 61 | 62 | char *client_get_connection_string(int fd) 63 | { 64 | return RENAME(client_get_connection_string) (fd); 65 | } 66 | 67 | int client_send_msg(int connid, ldcs_message_t * msg) 68 | { 69 | return RENAME(client_send_msg) (connid, msg); 70 | } 71 | 72 | int client_recv_msg_static(int fd, ldcs_message_t *msg, ldcs_read_block_t block) 73 | { 74 | return RENAME(client_recv_msg_static) (fd, msg, block); 75 | } 76 | 77 | int client_recv_msg_dynamic(int fd, ldcs_message_t *msg, ldcs_read_block_t block) 78 | { 79 | return RENAME(client_recv_msg_dynamic) (fd, msg, block); 80 | } 81 | 82 | -------------------------------------------------------------------------------- /src/client/configure.ac: -------------------------------------------------------------------------------- 1 | AC_INIT([spindle], m4_esyscmd([tr -d '\n' < ../../VERSION]), m4_esyscmd([tr -d '\n' < ../../BUG_EMAIL])) 2 | AC_CONFIG_MACRO_DIR([../../m4]) 3 | AC_CONFIG_AUX_DIR([../../scripts]) 4 | AC_CANONICAL_TARGET 5 | AM_INIT_AUTOMAKE([foreign subdir-objects]) 6 | AM_SILENT_RULES([yes]) 7 | AC_CONFIG_HEADERS([config.h]) 8 | AM_PROG_AR 9 | AC_PROG_CC 10 | AM_PROG_CC_C_O 11 | AC_CONFIG_FILES([logging/Makefile biter/Makefile shm_cache/Makefile client_comlib/Makefile client/Makefile auditclient/Makefile subaudit/Makefile beboot/Makefile spindle_api/Makefile ldsolookup/Makefile Makefile]) 12 | AC_PROG_LN_S 13 | LT_INIT 14 | SPINDLE_BUILD_ROOT=`pwd`/../.. 15 | SPINDLE_SOURCE_ROOT=`realpath ${srcdir}/../..` 16 | 17 | #Include common ops 18 | m4_include([../../m4/lx_detect_bluegene.m4]) 19 | m4_include([../../configure.common.ac]) 20 | 21 | CHECK_MMAP([cl]) 22 | 23 | AC_SUBST([LIBSPINDLE_LIB_VERSION],[`$srcdir/../../LIB_VERSION libspindle`]) 24 | AC_SUBST([GLIBC_BE_DIR]) 25 | AC_OUTPUT 26 | 27 | -------------------------------------------------------------------------------- /src/client/instrclient/Makefile.am: -------------------------------------------------------------------------------- 1 | pkglibexec_LTLIBRARIES = 2 | 3 | if SOCKETS 4 | pkglibexec_LTLIBRARIES += libspindle_instr_socket.la 5 | endif 6 | if PIPES 7 | pkglibexec_LTLIBRARIES += libspindle_instr_pipe.la 8 | endif 9 | if BITER 10 | pkglibexec_LTLIBRARIES += libspindle_instr_biter.la 11 | endif 12 | 13 | AM_CPPFLAGS = -I$(top_srcdir)/../logging -I$(top_srcdir)/../include -I$(top_srcdir)/client -I$(top_srcdir)/client_comlib 14 | 15 | BASE_SRCS = intercept.c 16 | 17 | INSTRLIB = $(top_builddir)/client/libspindle_instr.la 18 | 19 | AM_CFLAGS = -fvisibility=hidden 20 | 21 | libspindle_instr_socket_la_SOURCES = $(BASE_SRCS) 22 | libspindle_instr_socket_la_LIBADD = $(top_builddir)/client/libspindlec_socket.la $(INSTRLIB) 23 | libspindle_instr_socket_la_LDFLAGS = -shared -avoid-version 24 | 25 | libspindle_instr_pipe_la_SOURCES = $(BASE_SRCS) 26 | libspindle_instr_pipe_la_LIBADD = $(top_builddir)/client/libspindlec_pipe.la $(INSTRLIB) 27 | libspindle_instr_pipe_la_LDFLAGS = -shared -avoid-version 28 | 29 | libspindle_instr_biter_la_SOURCES = $(BASE_SRCS) 30 | libspindle_instr_biter_la_LIBADD = $(top_builddir)/client/libspindlec_biter.la $(INSTRLIB) 31 | libspindle_instr_biter_la_LDFLAGS = -shared -avoid-version 32 | -------------------------------------------------------------------------------- /src/client/instrclient/intercept.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include "client.h" 22 | #include "intercept.h" 23 | 24 | 25 | struct libc_binding_t { 26 | const char *name; 27 | void **fptr; 28 | }; 29 | 30 | static struct libc_binding_t bindings[] = { 31 | { "stat", (void **) &orig_stat }, 32 | { "lstat", (void **) &orig_lstat }, 33 | { "__xstat", (void **) &orig_xstat }, 34 | { "__lxstat", (void **) &orig_lxstat }, 35 | { "__xstat64", (void **) &orig_xstat64 }, 36 | { "__lxstat64", (void **) &orig_lxstat64 }, 37 | { "fstat", (void **) &orig_fstat }, 38 | { "__fxstat", (void **) &orig_fxstat }, 39 | { "__fxstat64", (void **) &orig_fxstat64 }, 40 | { "execv", (void **) &orig_execv }, 41 | { "execve", (void **) &orig_execve }, 42 | { "execvp", (void **) &orig_execvp }, 43 | { "fork", (void **) &orig_fork }, 44 | { "open", (void **) &orig_open }, 45 | { "open64", (void **) &orig_open64 }, 46 | { "fopen", (void **) &orig_fopen }, 47 | { "fopen64", (void **) &orig_fopen64 }, 48 | { "close", (void **) &orig_close }, 49 | { NULL, NULL } 50 | }; 51 | 52 | static struct link_map *find_libc() 53 | { 54 | struct link_map *map; 55 | for (map = _r_debug.r_map; map != NULL; map = map->l_next) { 56 | if (!map->l_name) 57 | continue; 58 | if (strcmp(map->l_name, "libc") == 0) 59 | return map; 60 | } 61 | return NULL; 62 | } 63 | 64 | void setup_orig_bindings() 65 | { 66 | (void) bindings; 67 | (void) find_libc; 68 | } 69 | -------------------------------------------------------------------------------- /src/client/ldsolookup/Makefile.am: -------------------------------------------------------------------------------- 1 | pkglibexec_PROGRAMS = print_ldso_entry 2 | pkglib_LTLIBRARIES = libprint_ldso_audit.la 3 | 4 | print_ldso_entry_SOURCES = print_ldso_entry.c 5 | libprint_ldso_audit_la_SOURCES = print_ldso_audit.c 6 | 7 | print_ldso_entry_CPPFLAGS = -DLIBEXECDIR=\"$(pkglibexecdir)\" 8 | 9 | libprint_ldso_audit_la_LDFLAGS = -shared -avoid-version 10 | 11 | if BGQ_BLD 12 | print_ldso_entry_LDFLAGS = -dynamic 13 | endif 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/client/ldsolookup/print_ldso_audit.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | unsigned int la_version(unsigned int version) 4 | { 5 | return version; 6 | } 7 | -------------------------------------------------------------------------------- /src/client/ldsolookup/print_ldso_entry.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #if !defined(LIBEXECDIR) 8 | #error LIBEXECDIR must be defined 9 | #endif 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | ElfW(Dyn) *dyn; 14 | ElfW(Addr) *pltgot = NULL; 15 | char path[4097]; 16 | 17 | for (dyn = _DYNAMIC; dyn->d_tag != DT_NULL; dyn++) { 18 | if (dyn->d_tag == DT_PLTGOT) { 19 | pltgot = (ElfW(Addr) *) dyn->d_un.d_ptr; 20 | break; 21 | } 22 | } 23 | if (!pltgot) 24 | return -1; 25 | 26 | printf("%lu\n", pltgot[2] - _r_debug.r_ldbase); 27 | 28 | if (getenv("LD_AUDIT")) 29 | return 0; 30 | 31 | snprintf(path, sizeof(path), "%s/%s", LIBEXECDIR, "libprint_ldso_audit.so"); 32 | path[sizeof(path)-1] = '\0'; 33 | setenv("LD_AUDIT", path, 1); 34 | 35 | execv(argv[1], argv+1); 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /src/client/logging/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libspindleclogc.la 2 | 3 | AM_CFLAGS = -fvisibility=hidden 4 | 5 | libspindleclogc_la_SOURCES = $(top_srcdir)/../logging/spindle_logc.c $(top_srcdir)/../utils/spindle_mkdir.c 6 | libspindleclogc_la_CPPFLAGS = -I$(top_srcdir)/../logging -I$(top_srcdir)/../include -DSPINDLECLIENT 7 | libspindleclogc_la_CFLAGS = -DLIBEXEC=\"${pkglibexecdir}\" -DDAEMON_NAME=\"spindled_logd\" $(AM_CFLAGS) 8 | -------------------------------------------------------------------------------- /src/client/shm_cache/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libshmcache.la 2 | 3 | AM_CFLAGS = -fvisibility=hidden 4 | 5 | libshmcache_la_SOURCES = shmcache.c 6 | if BITER 7 | else 8 | libshmcache_la_LIBADD = $(top_builddir)/biter/libsheep.la 9 | endif 10 | AM_CPPFLAGS = -I$(top_srcdir)/../biter -I$(top_srcdir)/shm_cache -I$(top_srcdir)/../logging -I$(top_srcdir)/client_comlib -I$(top_srcdir)/../include 11 | 12 | -------------------------------------------------------------------------------- /src/client/shm_cache/shmcache.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(SHMCACHE_H_) 18 | #define SHMCACHE_H_ 19 | 20 | #include 21 | #include "spindle_launch.h" 22 | 23 | int shmcache_lookup_or_add(const char *libname, char **result); 24 | int shmcache_add(const char *libname, const char *mapped_name); 25 | int shmcache_update(const char *libname, const char *mapped_name); 26 | int shmcache_init(const char *tmpdir, number_t unique_number, size_t shm_size, size_t hlimit); 27 | int shmcache_waitfor_update(const char *libname, char **result); 28 | int shmcache_lookup(const char *libname, char **result); 29 | void shmcache_take_lock(); 30 | void shmcache_release_lock(); 31 | 32 | extern char *in_progress; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/client/spindle_api/Makefile.am: -------------------------------------------------------------------------------- 1 | lib_LTLIBRARIES = libspindle.la 2 | include_HEADERS = spindle.h 3 | 4 | AM_CFLAGS = -fvisibility=hidden 5 | 6 | AM_CPPFLAGS = -I$(top_builddir) -DSPINDLE_INTERNAL_BUILD 7 | libspindle_la_LDFLAGS = -shared -version-info $(LIBSPINDLE_LIB_VERSION) 8 | libspindle_la_SOURCES = spindle_api.c 9 | -------------------------------------------------------------------------------- /src/client/spindle_api/spindle.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(SPINDLE_H_) 18 | #define SPINDLE_H_ 19 | 20 | #if defined(__cplusplus) 21 | extern "C" { 22 | #endif 23 | 24 | #if defined(SPINDLE_INTERNAL_BUILD) 25 | #define SPINDLE_EXPORT __attribute__((__visibility__("default"))) 26 | #else 27 | #define SPINDLE_EXPORT 28 | #endif 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | int spindle_is_present() SPINDLE_EXPORT; 36 | 37 | /** 38 | * These calls will perform IO operations through Spindle, if present, 39 | * and forward on to regular IO calls if Spindle is not present. 40 | * The open calls will only forward to Spindle if opening read-only. 41 | **/ 42 | int spindle_open(const char *pathname, int flags, ...) SPINDLE_EXPORT; 43 | int spindle_stat(const char *path, struct stat *buf) SPINDLE_EXPORT; 44 | int spindle_lstat(const char *path, struct stat *buf) SPINDLE_EXPORT; 45 | FILE *spindle_fopen(const char *path, const char *mode) SPINDLE_EXPORT; 46 | 47 | /** 48 | * If spindle is enabled through this API, then all open and stat calls 49 | * will automatically be routed through Spindle. 50 | * 51 | * enable_spindle and disable_spindle are counting calls that must be matched. 52 | * Thus if enable_spindle is called twice, disable_spindle must be called twice 53 | * to disable Spindle interception. is_spindle_enabled returns the current count. 54 | * 55 | * Spindle enabling/disabling counts are tracked per-thread (if Spindle was built 56 | * with TLS support). 57 | **/ 58 | void enable_spindle() SPINDLE_EXPORT; 59 | void disable_spindle() SPINDLE_EXPORT; 60 | int is_spindle_enabled() SPINDLE_EXPORT; 61 | 62 | /** 63 | * is_spindle_present returns true if the application was started under Spindle 64 | **/ 65 | int is_spindle_present() SPINDLE_EXPORT; 66 | 67 | #if defined(__cplusplus) 68 | } 69 | #endif 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /src/client/spindle_api/spindle_api.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "spindle.h" 18 | #include "spindle_api_int.h" 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | /** 28 | * These are the functions that get called if Spindle isn't present. 29 | * If Spindle is present, then the functions in intercept_spindleapi.c 30 | * will be called instead of these. 31 | **/ 32 | int spindle_open(const char *pathname, int flags, ...) 33 | { 34 | va_list argp; 35 | mode_t mode = (mode_t) 0; 36 | 37 | va_start(argp, flags); 38 | if (flags & O_CREAT) 39 | mode = va_arg(argp, mode_t); 40 | va_end(argp); 41 | return open(pathname, flags, mode); 42 | } 43 | 44 | int spindle_stat(const char *path, struct stat *buf) 45 | { 46 | return stat(path, buf); 47 | } 48 | 49 | int spindle_lstat(const char *path, struct stat *buf) 50 | { 51 | return lstat(path, buf); 52 | } 53 | 54 | FILE *spindle_fopen(const char *path, const char *mode) 55 | { 56 | return fopen(path, mode); 57 | } 58 | 59 | void spindle_enable() 60 | { 61 | } 62 | 63 | void spindle_disable() 64 | { 65 | } 66 | 67 | int spindle_is_enabled() 68 | { 69 | return 0; 70 | } 71 | 72 | int spindle_is_present() 73 | { 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /src/client/spindle_api/spindle_api_int.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(SPINDLE_API_INT_H_) 18 | #define SPINDLE_API_INT_H_ 19 | 20 | void spindle_enable_int(int index); 21 | void spindle_disable_int(int index); 22 | int spindle_is_enabled_int(int index); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/client/subaudit/Makefile.am: -------------------------------------------------------------------------------- 1 | pkglib_LTLIBRARIES = libspindleint.la 2 | 3 | if SOCKETS 4 | pkglib_LTLIBRARIES += libspindle_subaudit_socket.la 5 | endif 6 | if PIPES 7 | pkglib_LTLIBRARIES += libspindle_subaudit_pipe.la 8 | endif 9 | if BITER 10 | pkglib_LTLIBRARIES += libspindle_subaudit_biter.la 11 | endif 12 | 13 | AM_CFLAGS = -fvisibility=hidden 14 | 15 | AM_CPPFLAGS = -I$(top_srcdir)/../logging -I$(top_srcdir)/../include -I$(top_srcdir)/client -I$(top_srcdir)/client_comlib -I$(top_srcdir)/auditclient -I$(top_srcdir)/../utils 16 | 17 | BASE_SRCS = subaudit.c intercept_malloc.c update_pltbind.c ../auditclient/auditclient_common.c ../auditclient/patch_linkmap.c 18 | 19 | AUDITLIB = $(top_builddir)/client/libspindle_audit.la 20 | 21 | libspindleint_la_SOURCES = preloadlib.c 22 | libspindleint_la_LDFLAGS = -shared -avoid-version 23 | 24 | libspindle_subaudit_socket_la_SOURCES = $(BASE_SRCS) 25 | libspindle_subaudit_socket_la_LIBADD = $(top_builddir)/client/libspindlec_socket.la $(AUDITLIB) 26 | libspindle_subaudit_socket_la_LDFLAGS = -shared -avoid-version 27 | 28 | libspindle_subaudit_pipe_la_SOURCES = $(BASE_SRCS) 29 | libspindle_subaudit_pipe_la_LIBADD = $(top_builddir)/client/libspindlec_pipe.la $(AUDITLIB) 30 | libspindle_subaudit_pipe_la_LDFLAGS = -shared -avoid-version 31 | 32 | libspindle_subaudit_biter_la_SOURCES = $(BASE_SRCS) 33 | libspindle_subaudit_biter_la_LIBADD = $(top_builddir)/client/libspindlec_biter.la $(AUDITLIB) 34 | libspindle_subaudit_biter_la_LDFLAGS = -shared -avoid-version 35 | -------------------------------------------------------------------------------- /src/client/subaudit/intercept_malloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | 18 | /** 19 | * When ld.so has LD_AUDIT set it will do huge calloc operations of size 20 | * LDSO_EXTRA_CALLOC_SZ * DT_PLTRELSZ for each library. Because we redirect 21 | * ld.so's binding operation to not use the audit version, these are unnecessary 22 | * calloc's that aren't used. But they can chew up memory (300MB per process on 23 | * Pynamic). 24 | * 25 | * We thus overwrite ld.so's calloc() function by writing our own over ld.so's GOT 26 | * table. Our calloc watches for allocations of the appropriate sizes and drops 27 | * them on the ground. 28 | **/ 29 | 30 | #define _GNU_SOURCE 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include "spindle_debug.h" 39 | #include "subaudit.h" 40 | #include "parse_plt.h" 41 | #include "config.h" 42 | #include "client_heap.h" 43 | #include "client.h" 44 | 45 | struct link_map *get_ldso() 46 | { 47 | static struct link_map *result = 0; 48 | if (result) 49 | return result; 50 | 51 | char *interp_name = find_interp_name(); 52 | for (result = _r_debug.r_map; result != NULL; result = result->l_next) { 53 | if (result->l_name && (interp_name == result->l_name || strcmp(result->l_name, interp_name) == 0)) { 54 | return result; 55 | } 56 | } 57 | for (result = _r_debug.r_map; result != NULL; result = result->l_next) { 58 | if (result->l_name && strstr(result->l_name, "/ld")) 59 | return result; 60 | } 61 | return NULL; 62 | } 63 | -------------------------------------------------------------------------------- /src/client/subaudit/subaudit.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #define _GNU_SOURCE 18 | #include 19 | #include 20 | #include 21 | 22 | #include "spindle_debug.h" 23 | #include "subaudit.h" 24 | #include "client.h" 25 | #include "intercept.h" 26 | #include "auditclient.h" 27 | 28 | unsigned int spindle_la_version(unsigned int version) 29 | { 30 | int result; 31 | int binding_offset = 0; 32 | 33 | result = get_ldso_metadata_bindingoffset(&binding_offset); 34 | if (result == -1) { 35 | err_printf("Unable to lookup binding offset\n"); 36 | return -1; 37 | } 38 | debug_printf3("Updating subaudit bindings with offset %d\n", binding_offset); 39 | init_plt_binding_func(binding_offset); 40 | 41 | return 1; 42 | } 43 | 44 | static void bind_to_libc() 45 | { 46 | static int bound_libc_symbols = 0; 47 | int result; 48 | if (!bound_libc_symbols) { 49 | result = lookup_libc_symbols(); 50 | if (result == 0) { 51 | bound_libc_symbols = 1; 52 | } 53 | } 54 | } 55 | 56 | void spindle_la_activity(uintptr_t *cookie, unsigned int flag) 57 | { 58 | bind_to_libc(); 59 | update_plt_bindings(); 60 | } 61 | 62 | unsigned int spindle_la_objopen(struct link_map *map, Lmid_t lmid, uintptr_t *cookie) 63 | { 64 | bind_to_libc(); 65 | add_library_to_plt_update_list(map); 66 | return 0; 67 | } 68 | 69 | unsigned int spindle_la_objclose(uintptr_t *cookie) 70 | { 71 | struct link_map *map = get_linkmap_from_cookie(cookie); 72 | remove_library_from_plt_update_list(map); 73 | return 0; 74 | } 75 | 76 | int protect_range(void *address, unsigned long size, int prot) 77 | { 78 | unsigned long start_page, end_page; 79 | static unsigned long pagesize; 80 | 81 | if (!pagesize) 82 | pagesize = getpagesize(); 83 | 84 | start_page = ((unsigned long) address) & ~(pagesize-1); 85 | 86 | end_page = (((unsigned long) address) + size); 87 | if (end_page | (pagesize-1)) { 88 | end_page &= ~(pagesize-1); 89 | end_page += pagesize; 90 | } 91 | 92 | return mprotect((void *) start_page, end_page - start_page, prot); 93 | } 94 | -------------------------------------------------------------------------------- /src/client/subaudit/subaudit.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(SUBAUDIT_H_) 18 | #define SUBAUDIT_H_ 19 | 20 | int protect_range(void *address, unsigned long size, int prot); 21 | void init_plt_binding_func(signed int binding_offset_); 22 | void add_library_to_plt_update_list(struct link_map *lmap); 23 | void remove_library_from_plt_update_list(struct link_map *lmap); 24 | int update_plt_bindings(); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/cobo/cobo_comm.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef _COBO_COMM_H 18 | #define _COBO_COMM_H 19 | 20 | #define COBO_SUCCESS (0) 21 | 22 | #include "ldcs_api.h" 23 | 24 | int ldcs_cobo_read_fd(int fd, void* buf, int size); 25 | int ldcs_cobo_write_fd(int fd, void* buf, int size); 26 | int ll_write(int fd, void *buf, size_t count); 27 | int ll_read(int fd, void *buf, size_t count); 28 | int write_msg(int fd, ldcs_message_t *msg); 29 | 30 | #endif /* _COBO_COMM_H */ 31 | -------------------------------------------------------------------------------- /src/cobo/cobo_handshake.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "handshake.h" 18 | #include "ldcs_cobo.h" 19 | #include "spindle_debug.h" 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | int initialize_handshake_security(handshake_protocol_t *protocol) 26 | { 27 | if (spindle_debug_prints > 2) 28 | spindle_handshake_enable_debug_prints(spindle_debug_output_f); 29 | 30 | assert(spindle_handshake_is_security_type_enabled(protocol->mechanism)); 31 | cobo_set_handshake(protocol); 32 | spindle_handshake_enable_read_timeout(10); 33 | 34 | return 0; 35 | } 36 | 37 | void handle_security_error(const char *msg) 38 | { 39 | char *prefix = "Spindle security error: "; 40 | char *newstr; 41 | size_t msg_size; 42 | 43 | msg_size = strlen(prefix) + strlen(msg) + 1; 44 | newstr = malloc(msg_size); 45 | assert(newstr); 46 | 47 | snprintf(newstr, msg_size, "%s%s", prefix, msg); 48 | 49 | openlog("spindle", LOG_CONS, LOG_USER); 50 | syslog(LOG_AUTHPRIV | LOG_ERR, "%s", newstr); 51 | closelog(); 52 | } 53 | -------------------------------------------------------------------------------- /src/cobo/handshake.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include 18 | #include 19 | 20 | #if !defined(handshake_h_) 21 | #define handshake_h_ 22 | 23 | #if defined(__cplusplus) 24 | extern "C" { 25 | #endif 26 | 27 | /* Error returns from handshake session */ 28 | 29 | #define HSHAKE_SUCCESS 0 30 | #define HSHAKE_INTERNAL_ERROR -1 31 | #define HSHAKE_DROP_CONNECTION -2 32 | #define HSHAKE_CONNECTION_REFUSED -3 33 | #define HSHAKE_ABORT -4 34 | 35 | typedef enum { 36 | hs_none, //No security validation in handshake 37 | hs_munge, //Use munge 38 | hs_key_in_file, //Use gcrypt with key from file 39 | hs_explicit_key //Use gcrypt with provided key 40 | } handshake_security_t; 41 | 42 | typedef struct { 43 | handshake_security_t mechanism; 44 | union { 45 | struct { 46 | int unused; 47 | //No data needed for none 48 | } none; 49 | struct { 50 | int unused; 51 | //No data needed for munge 52 | } munge; 53 | struct { 54 | char *key_filepath; 55 | int key_length_bytes; 56 | } key_in_file; 57 | struct { 58 | unsigned char *key; 59 | int key_length_bytes; 60 | } explicit_key; 61 | } data; 62 | } handshake_protocol_t; 63 | 64 | int spindle_handshake_server(int sockfd, handshake_protocol_t *hdata, uint64_t session_id); 65 | int spindle_handshake_client(int sockfd, handshake_protocol_t *hdata, uint64_t session_id); 66 | int spindle_handshake_is_security_type_enabled(handshake_security_t sectype); 67 | char *spindle_handshake_last_error_str(); 68 | 69 | void spindle_handshake_enable_read_timeout(int timeout_sec); 70 | void spindle_handshake_enable_debug_prints(FILE *debug_output); 71 | 72 | #if defined(__cplusplus) 73 | } 74 | #endif 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /src/fe/Makefile.am: -------------------------------------------------------------------------------- 1 | if LMON 2 | BUILD_LMON=launchmon 3 | endif 4 | if BLD_FLUXPLUGIN 5 | BUILD_FLUX=flux 6 | endif 7 | 8 | SUBDIRS = logging cobo comlib openmpi_intercept $(BUILD_LMON) $(BUILD_FLUX) hostbin startup 9 | 10 | -------------------------------------------------------------------------------- /src/fe/cobo/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libldcs_cobo.la 2 | libldcs_cobo_la_SOURCES = $(top_srcdir)/../cobo/cobo.c $(top_srcdir)/../cobo/handshake.c $(top_srcdir)/../cobo/cobo_comm.c $(top_srcdir)/../cobo/cobo_handshake.c 3 | AM_CPPFLAGS = -I$(top_srcdir)/../logging -I$(top_srcdir)/../cobo -I$(top_srcdir)/../include $(MUNGE_CFLAGS) $(GCRYPT_CFLAGS) 4 | -------------------------------------------------------------------------------- /src/fe/comlib/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libfe_cobo.la 2 | #noinst_LTLIBRARIES = libfe_msocket.la 3 | AM_CPPFLAGS = -I$(top_srcdir)/../logging -I$(top_srcdir)/../include -I$(top_srcdir)/../cobo 4 | libfe_cobo_la_SOURCES = cobo_fe_comm.c 5 | #libfe_msocket_la_SOURCES = msocket_fe_comm.c 6 | -------------------------------------------------------------------------------- /src/fe/comlib/fe_comm.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(FE_COMM_H_) 18 | #define FE_COMM_H_ 19 | 20 | #if defined(__cplusplus) 21 | extern "C" { 22 | #endif 23 | 24 | #include "ldcs_api.h" 25 | #include "spindle_launch.h" 26 | 27 | int ldcs_audit_server_fe_md_open(char **hostlist, int numhosts, unsigned int port, unsigned int num_ports, 28 | unique_id_t unique_id, void **data); 29 | int ldcs_audit_server_fe_md_close(void *data); 30 | int ldcs_audit_server_fe_md_waitfor_close(); 31 | int ldcs_audit_server_fe_md_waitfor_alive(int timeout_seconds); 32 | int ldcs_audit_server_fe_broadcast(ldcs_message_t *msg, void *data); 33 | 34 | #if defined(__cplusplus) 35 | } 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/fe/configure.ac: -------------------------------------------------------------------------------- 1 | AC_INIT([spindle], m4_esyscmd([tr -d '\n' < ../../VERSION]), m4_esyscmd([tr -d '\n' < ../../BUG_EMAIL])) 2 | AC_CONFIG_MACRO_DIR([../../m4]) 3 | AC_CONFIG_AUX_DIR([../../scripts]) 4 | AC_CANONICAL_TARGET 5 | AM_INIT_AUTOMAKE([foreign subdir-objects]) 6 | AM_SILENT_RULES([yes]) 7 | AM_PROG_AR 8 | AC_CONFIG_HEADERS([config.h]) 9 | AC_PROG_CC 10 | AM_PROG_CC_C_O 11 | AC_PROG_CXX 12 | AC_CONFIG_FILES([logging/Makefile cobo/Makefile comlib/Makefile openmpi_intercept/Makefile launchmon/Makefile flux/Makefile startup/Makefile hostbin/Makefile Makefile]) 13 | AC_PROG_LN_S 14 | LT_INIT 15 | 16 | SPINDLE_BUILD_ROOT=`pwd`/../.. 17 | SPINDLE_SOURCE_ROOT=`realpath ${srcdir}/../..` 18 | 19 | #Include common ops 20 | m4_include([../../m4/lx_detect_bluegene.m4]) 21 | m4_include([../../configure.common.ac]) 22 | CHOOSE_SEC 23 | CHOOSE_DEF_AUDIT 24 | 25 | #Include LaunchMON 26 | m4_include([../../m4/lmon.m4]) 27 | #Include RM Selection 28 | m4_include([../../m4/launcher.m4]) 29 | 30 | CPPFLAGS="$CPPFLAGS -DSPINDLEFE" 31 | CFLAGS="$CFLAGS -fvisibility=hidden" 32 | CXXFLAGS="$CXXFLAGS -fvisibility=hidden" 33 | 34 | AC_SUBST([SPINDLEFE_LIB_VERSION],[`$srcdir/../../LIB_VERSION spindlefe`]) 35 | 36 | if test "x$CLEANUP_PROC" == "xtrue"; then 37 | AC_DEFINE([DEFAULT_CLEANUP_PROC],[1],[Default to using a dedicated process to clean data files]) 38 | fi 39 | 40 | AC_OUTPUT 41 | AC_SUBST(PKGSYSCONF_DIR) 42 | -------------------------------------------------------------------------------- /src/fe/flux/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libfluxsessionfe.la 2 | 3 | libfluxsessionfe_la_SOURCES = $(top_srcdir)/../flux/fluxmgr.c $(top_srcdir)/../flux/spindlefemgr.c 4 | libfluxsessionfe_la_CPPFLAGS = -I$(top_srcdir)/../include -I$(top_srcdir)/../flux $(FLUX_CORE_CFLAGS) $(FLUX_HOSTLIST_CFLAGS) 5 | libfluxsessionfe_la_LDFLAGS = $(fluxplugin_ldflags) -Wl,--allow-multiple-definition 6 | libfluxsessionfe_la_LIBADD = $(FLUX_CORE_LIBS) $(FLUX_HOSTLIST_LIBS) 7 | 8 | -------------------------------------------------------------------------------- /src/fe/hostbin/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libhostbin.la 2 | 3 | libhostbin_la_SOURCES = launch_hostbin.cc 4 | libhostbin_la_CPPFLAGS = -I$(top_srcdir)/../logging -I$(top_srcdir)/../include -DLIBEXEC=\"${pkglibexecdir}\" 5 | -------------------------------------------------------------------------------- /src/fe/launchmon/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libfelmon.la 2 | 3 | libfelmon_la_SOURCES = spindle_fe_lmon.cc 4 | libfelmon_la_CPPFLAGS = $(LAUNCHMON_INC) -I$(top_srcdir)/../logging -I$(top_srcdir)/../include -DBINDIR=\"$(pkglibexecdir)\" -DLIBEXECDIR=\"$(pkglibexecdir)\" 5 | libfelmon_la_LIBADD = $(LAUNCHMON_LIB) $(LAUNCHMON_RMCOMM) -lmonfeapi 6 | 7 | -------------------------------------------------------------------------------- /src/fe/logging/Makefile.am: -------------------------------------------------------------------------------- 1 | pkglibexec_PROGRAMS = spindlef_logd 2 | noinst_LTLIBRARIES = libspindleflogc.la 3 | 4 | spindlef_logd_SOURCES = $(top_srcdir)/../logging/spindle_logd.cc 5 | spindlef_logd_CPPFLAGS = -I$(top_srcdir)/../logging 6 | spindlef_logd_LDADD = -lpthread 7 | 8 | libspindleflogc_la_SOURCES = $(top_srcdir)/../logging/spindle_logc.c $(top_srcdir)/../utils/spindle_mkdir.c 9 | libspindleflogc_la_CPPFLAGS = -I$(top_srcdir)/../logging -I$(top_srcdir)/../utils -I$(top_srcdir)/../include 10 | libspindleflogc_la_CFLAGS = -DLIBEXEC=\"${pkglibexecdir}\" -DDAEMON_NAME=\"spindlef_logd\" 11 | -------------------------------------------------------------------------------- /src/fe/openmpi_intercept/Makefile.am: -------------------------------------------------------------------------------- 1 | pkglib_LTLIBRARIES = libompiintercept.la 2 | noinst_LTLIBRARIES = libparseompi.la 3 | 4 | libompiintercept_la_SOURCES = ompi_intercept.c 5 | libompiintercept_la_LDFLAGS = -shared -avoid-version 6 | 7 | libparseompi_la_SOURCES = parse_openmpi.cc 8 | 9 | AM_CPPFLAGS = -I$(top_srcdir)/../include -I$(top_srcdir)/../logging -I$(top_srcdir)/startup 10 | libparseompi_la_CPPFLAGS = $(AM_CPPFLAGS) -DLIBEXECDIR=\"$(pkglibexecdir)\" -DPROGLIBDIR=\"$(pkglibdir)\" 11 | -------------------------------------------------------------------------------- /src/fe/startup/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = spindle 2 | lib_LTLIBRARIES = libspindlefe.la 3 | noinst_LTLIBRARIES = libspindlefe_static.la 4 | 5 | include_HEADERS = $(top_srcdir)/../include/spindle_launch.h 6 | 7 | AM_CPPFLAGS = -I$(top_srcdir)/../logging 8 | 9 | CORE_SOURCES = spindle_fe.cc parseargs.cc config_parser.cc config_mgr.cc parse_preload.cc $(top_srcdir)/../utils/pathfn.c $(top_srcdir)/../utils/keyfile.c $(top_srcdir)/../utils/parseloc.c $(top_srcdir)/../utils/rshlaunch.c 10 | CORE_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/../include -I$(top_srcdir)/comlib -I$(top_srcdir)/../server/cache -I$(top_srcdir)/../server/comlib -I$(top_srcdir)/../utils -I$(top_srcdir)/../cobo -DBINDIR=\"$(pkglibexecdir)\" -DLIBEXECDIR=\"$(pkglibexecdir)\" -DPROGLIBDIR=\"$(pkglibdir)\" -DPKGSYSCONFDIR=\"$(PKGSYSCONF_DIR)\" 11 | CORE_LDADD = $(top_builddir)/logging/libspindleflogc.la -lpthread 12 | if COBO 13 | CORE_LDADD += $(top_builddir)/comlib/libfe_cobo.la $(top_builddir)/cobo/libldcs_cobo.la 14 | endif 15 | if MSOCKET 16 | CORE_LDADD += $(top_builddir)/comlib/libfe_msocket.la 17 | endif 18 | CORE_LDADD += $(MUNGE_DYN_LIB) $(GCRYPT_LIBS) 19 | 20 | libspindlefe_la_CPPFLAGS = $(CORE_CPPFLAGS) -DSPINDLEFELIB 21 | libspindlefe_la_SOURCES = $(CORE_SOURCES) 22 | libspindlefe_la_LIBADD = $(CORE_LDADD) 23 | libspindlefe_la_LDFLAGS = -version-info $(SPINDLEFE_LIB_VERSION) 24 | 25 | libspindlefe_static_la_CPPFLAGS = $(libspindlefe_la_CPPFLAGS) 26 | libspindlefe_static_la_SOURCES = $(libspindlefe_la_SOURCES) 27 | libspindlefe_static_la_LIBADD = $(libspindlefe_la_LIBADD) 28 | 29 | 30 | spindle_CPPFLAGS = $(CORE_CPPFLAGS) -DSPINDLEEXE 31 | spindle_SOURCES = spindle_fe_main.cc spindle_fe_serial.cc parse_launcher.cc parse_launcher_args.cc launcher.cc spindle_session.cc launch_slurm.cc launch_lsf.cc $(CORE_SOURCES) 32 | 33 | spindle_LDADD = $(CORE_LDADD) $(top_builddir)/openmpi_intercept/libparseompi.la $(top_builddir)/hostbin/libhostbin.la 34 | 35 | if BLD_FLUXPLUGIN 36 | spindle_LDADD += $(FLUX_CORE_LIBS) $(FLUX_HOSTLIST_LIBS) $(top_builddir)/flux/libfluxsessionfe.la 37 | spindle_LDFLAGS = $(fluxplugin-ldflags) -Wl,--allow-multiple-definition 38 | spindle_CPPFLAGS += -I$(top_srcdir)/../flux 39 | spindle_SOURCES += launch_flux.cc 40 | endif 41 | 42 | if LMON 43 | spindle_LDADD += $(top_builddir)/launchmon/libfelmon.la 44 | endif 45 | 46 | -------------------------------------------------------------------------------- /src/fe/startup/config_parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(CONFIG_PARSER_H_) 18 | #define CONFIG_PARSER_H_ 19 | 20 | #include 21 | #include "config_mgr.h" 22 | 23 | class ConfigFile 24 | { 25 | private: 26 | std::string filename; 27 | 28 | bool open_error; 29 | bool parse_error; 30 | std::string err_string; 31 | ConfigMap configmap; 32 | 33 | void parse(); 34 | bool parseLine(std::string line, int lineno); 35 | public: 36 | ConfigFile(std::string filename_); 37 | ~ConfigFile(); 38 | 39 | bool parseError() const; 40 | bool openError() const; 41 | std::string errorString() const; 42 | 43 | const ConfigMap& getConfigMap() const; 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/fe/startup/parse_preload.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(PARSE_PRELOAD_H_) 18 | #define PARSE_PRELOAD_H_ 19 | 20 | #include 21 | #include "ldcs_api.h" 22 | 23 | void cleanPreloadMsg(ldcs_message_t *msg); 24 | ldcs_message_t *parsePreloadFile(std::string filename); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/fe/startup/spindle_session.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(SPINDLE_SESSION_H_) 18 | #define SPINDLE_SESSION_H_ 19 | 20 | #include "spindle_launch.h" 21 | #include "launcher.h" 22 | #include "config_mgr.h" 23 | 24 | int init_session(spindle_args_t *args, const ConfigMap &config, Launcher *launcher); 25 | int get_session_runcmds(app_id_t &appid, int &app_argc, char** &app_argv, bool &session_complete); 26 | int get_session_fd(); 27 | int return_session_cmd(app_id_t appid, int app_argc, char **app_argv); 28 | void signal_init_done(); 29 | void mark_session_job_done(app_id_t appid, int rc); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/flux/Makefile.am: -------------------------------------------------------------------------------- 1 | libver=`$(top_srcdir)/LIB_VERSION spindleflux` 2 | 3 | pkglibexec_PROGRAMS = spindle_flux_session 4 | lib_LTLIBRARIES = libspindleflux.la 5 | noinst_LTLIBRARIES = libfluxsession.la 6 | 7 | rcdir = $(PKGSYSCONF_DIR) 8 | rc_DATA = spindle.rc 9 | 10 | libspindleflux_la_SOURCES = \ 11 | flux-spindle.c 12 | 13 | libspindleflux_la_CPPFLAGS = \ 14 | -I$(top_srcdir)/src/include \ 15 | $(FLUX_CORE_CFLAGS) \ 16 | $(FLUX_HOSTLIST_CFLAGS) 17 | 18 | libspindleflux_la_LIBADD = \ 19 | $(top_builddir)/src/server/startup/libspindlebe_static.la \ 20 | $(top_builddir)/src/fe/startup/libspindlefe_static.la \ 21 | $(FLUX_CORE_LIBS) \ 22 | $(FLUX_HOSTLIST_LIBS) \ 23 | libfluxsession.la 24 | 25 | libspindleflux_la_LDFLAGS = \ 26 | $(fluxplugin_ldflags) \ 27 | -Wl,--allow-multiple-definition \ 28 | -version-info $(libver) \ 29 | -module 30 | 31 | spindle_flux_session_SOURCES = main.cc $(top_srcdir)/src/utils/spindle_mkdir.c $(top_srcdir)/src/utils/parseloc.c 32 | spindle_flux_session_CPPFLAGS = -I$(top_srcdir)/src/flux -I$(top_srcdir)/src/logging -I$(top_srcdir)/src/include 33 | spindle_flux_session_LDADD = libfluxsession.la 34 | 35 | libfluxsession_la_SOURCES = sessionmgr.c fluxmgr.c procmgr.c spindlefemgr.c spindlebemgr.c 36 | libfluxsession_la_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/flux $(FLUX_CORE_CFLAGS) $(FLUX_HOSTLIST_CFLAGS) 37 | libfluxsession_la_LDFLAGS = $(fluxplugin_ldflags) -Wl,--allow-multiple-definition 38 | libfluxsession_la_LIBADD = \ 39 | $(top_builddir)/src/server/startup/libspindlebe_static.la \ 40 | $(top_builddir)/src/fe/startup/libspindlefe_static.la \ 41 | $(FLUX_CORE_LIBS) \ 42 | $(FLUX_HOSTLIST_LIBS) 43 | 44 | spindle.rc: $(srcdir)/spindle_rc $(top_builddir)/Makefile 45 | @rm -f ./spindle.rc 46 | $(AM_V_GEN)$(SED) -e s,SPINDLE_LIB,$(libdir),g < $(srcdir)/spindle_rc > $(top_builddir)/src/flux/spindle.rc 47 | 48 | mostlyclean-local: 49 | rm -f ./spindle.rc 50 | -------------------------------------------------------------------------------- /src/flux/fluxmgr.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(FLUXMGR_H_) 18 | #define FLUXMGR_H_ 19 | 20 | #if defined(__cplusplus) 21 | extern "C" { 22 | #endif 23 | 24 | #include 25 | 26 | int fluxmgr_init(); 27 | void fluxmgr_close(); 28 | int fluxmgr_is_headnode(); 29 | int fluxmgr_add_to_kvs(const char *daemon_args, const char *bootstrap_args, const char *default_session); 30 | int fluxmgr_get_from_kvs(char **daemon_args, int timeout_seconds); 31 | int fluxmgr_get_default_session(char **default_session); 32 | int fluxmgr_get_bootstrap(flux_t *fhandle, char **bootstrap_args); 33 | int fluxmgr_rm_from_kvs(); 34 | int fluxmgr_is_active(); 35 | int fluxmgr_waitfor(int timeout); 36 | char **fluxmgr_get_hostlist(); 37 | void fluxmgr_free_hostlist(char **hostlist); 38 | 39 | #if defined(__cplusplus) 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/flux/main.cc: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | 18 | //This file is c++ just to fool the automake linker to use c++ linkage 19 | 20 | extern "C" { 21 | #include "sessionmgr.h" 22 | } 23 | #include 24 | #include 25 | 26 | int main(int argc, char *argv[]) 27 | { 28 | const char *session_dir = get_session_dir(); 29 | if (argc >= 2 && strcmp(argv[1], "start") == 0) { 30 | char **new_argv = strip_start_from_argv(argc, argv); 31 | return spindle_session_start(argc - 1, new_argv, session_dir); 32 | } 33 | else if (argc >= 2 && strcmp(argv[1], "stop") == 0) { 34 | return spindle_session_stop(session_dir); 35 | } 36 | 37 | fprintf(stderr, "Usage: %s {start|stop} [SPINDLE OPTIONS]\n", argc ? argv[0] : "[NULL]"); 38 | return -1; 39 | } 40 | -------------------------------------------------------------------------------- /src/flux/procmgr.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(PROCMGR_H_) 18 | #define PROCMGR_H_ 19 | 20 | #if defined(__cplusplus) 21 | extern "C" { 22 | #endif 23 | 24 | typedef int service_cb_t(int argc, char *argv[]); 25 | 26 | int start_service(const char *name, service_cb_t cb, const char *session_dir, int argc, char *argv[]); 27 | int stop_service(const char *name, const char *session_dir); 28 | int clean_service(); 29 | int is_active_service(const char *name, const char *session_dir); 30 | 31 | int init_readymsg(); 32 | int ping_readymsg(int had_error); 33 | int waitfor_readymsg(int timeout_seconds, int *had_error, int *had_timeout); 34 | void clean_readymsg(); 35 | 36 | #if defined(__cplusplus) 37 | } 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/flux/sessionmgr.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(SESSIONMGR_H_) 18 | #define SESSIONMGR_H_ 19 | 20 | #if defined(__cplusplus) 21 | extern "C" { 22 | #endif 23 | 24 | int spindle_session_start(int argc, char **argv, const char *session_dir); 25 | int spindle_session_stop(const char *session_dir); 26 | char **strip_start_from_argv(int argc, char **argv); 27 | const char *get_session_dir(); 28 | 29 | #if defined(__cplusplus) 30 | } 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/flux/spindle_rc: -------------------------------------------------------------------------------- 1 | plugin.load { file="SPINDLE_LIB/libspindleflux.so" } 2 | -------------------------------------------------------------------------------- /src/flux/spindlemgr.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(SPINDLEMGR_H_) 18 | #define SPINDLEMGR_H_ 19 | 20 | #include "spindle_launch.h" 21 | 22 | #if defined(__cplusplus) 23 | extern "C" { 24 | #endif 25 | 26 | int run_fe(int argc, char **argv); 27 | int run_be(int argc, char **argv); 28 | int setup_args_on_fe(spindle_args_t *params, int is_default_session); 29 | 30 | #if defined(__cplusplus) 31 | } 32 | #endif 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /src/include/ldcs_api_pipe.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef LDCS_API_PIPE_H 18 | #define LDCS_API_PIPE_H 19 | 20 | #include "ldcs_api.h" 21 | #include "spindle_launch.h" 22 | 23 | int ldcs_open_connection_pipe(char* location, number_t number); 24 | int ldcs_close_connection_pipe(int fd); 25 | int ldcs_create_server_pipe(char* location, number_t number); 26 | int ldcs_open_server_connection_pipe(int fd); 27 | int ldcs_open_server_connections_pipe(int fd, int nc, int *more_avail); 28 | int ldcs_close_server_connection_pipe(int fd); 29 | int ldcs_get_fd_pipe(int id); 30 | int ldcs_destroy_server_pipe(int fd); 31 | int ldcs_send_msg_pipe(int fd, ldcs_message_t * msg); 32 | ldcs_message_t * ldcs_recv_msg_pipe(int fd, ldcs_read_block_t block ); 33 | int ldcs_recv_msg_static_pipe(int fd, ldcs_message_t *msg, ldcs_read_block_t block); 34 | char *ldcs_get_connection_string_pipe(int fd); 35 | int ldcs_register_connection_pipe(char *connection_str); 36 | 37 | /* internal */ 38 | int _ldcs_write_pipe(int fd, const void *data, int bytes ); 39 | int _ldcs_read_pipe(int fd, void *data, int bytes, ldcs_read_block_t block ); 40 | 41 | typedef enum { 42 | LDCS_PIPE_FD_TYPE_SERVER, 43 | LDCS_PIPE_FD_TYPE_CONN 44 | } fd_list_entry_type_t; 45 | 46 | struct fdlist_entry_t 47 | { 48 | int inuse; 49 | fd_list_entry_type_t type; 50 | 51 | /* server part */ 52 | int notify_fd; 53 | int conn_list_size; 54 | int conn_list_used; 55 | int *conn_list; 56 | char *path; 57 | 58 | /* connection part */ 59 | int in_fd; 60 | char *in_fn; 61 | int out_fd; 62 | char *out_fn; 63 | int serverfd; 64 | }; 65 | 66 | #endif 67 | 68 | -------------------------------------------------------------------------------- /src/include/ldcs_api_socket.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef LDCS_API_SOCKET_H 18 | #define LDCS_API_SOCKET_H 19 | 20 | typedef enum { 21 | LDCS_SOCKET_FD_TYPE_SERVER, 22 | LDCS_SOCKET_FD_TYPE_CONN, 23 | LDCS_SOCKET_FD_TYPE_UNKNOWN 24 | } fd_list_entry_type_t; 25 | 26 | struct fdlist_entry_t 27 | { 28 | int inuse; 29 | fd_list_entry_type_t type; 30 | 31 | /* server part */ 32 | int server_fd; 33 | int conn_list_size; 34 | int conn_list_used; 35 | int *conn_list; 36 | 37 | /* connection part */ 38 | int fd; 39 | int serverid; 40 | }; 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /src/logging/spindle_debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(SPINDLE_DEBUG_H_) 18 | #define SPINDLE_DEBUG_H_ 19 | 20 | #include 21 | #include 22 | 23 | #define LOGD_DEBUG 24 | 25 | #if defined(LOGD_DEBUG) 26 | #define LDCSDEBUG 1 27 | #if defined(__cplusplus) 28 | extern "C" { 29 | #endif 30 | #include "spindle_logc.h" 31 | #if defined(__cplusplus) 32 | } 33 | #endif 34 | #elif defined(DEBUG) 35 | #define LDCSDEBUG 1 36 | #define debug_printf(format, ...) \ 37 | do { \ 38 | fprintf(stderr, "[%s:%u@%d] - " format, __FILE__, __LINE__, getpid(), ## __VA_ARGS__); \ 39 | } while (0) 40 | #elif defined(SIONDEBUG) 41 | #define LDCSDEBUG 1 42 | #include "sion_debug.h" 43 | #define debug_printf(format, ...) \ 44 | do { \ 45 | sion_dprintfp(32, __FILE__, getpid(), "[L%04u, %12.2f] - " format, __LINE__,_sion_get_time(), ## __VA_ARGS__); \ 46 | } while (0) 47 | #else 48 | #define debug_printf(format, ...) 49 | #endif 50 | 51 | #if defined(LOGD_DEBUG) 52 | #define LOGGING_INIT(S) init_spindle_debugging(S, 0) 53 | #define LOGGING_INIT_PREEXEC(S) init_spindle_debugging(S, 1) 54 | #define LOGGING_FINI fini_spindle_debugging() 55 | #else 56 | #define LOGGING_INIT(S) 57 | #define LOGGING_INIT_PREEXEC(S) 58 | #define LOGGING_FINI 59 | #define debug_printf2(S, ...) debug_printf(S, ## __VA_ARGS__) 60 | #define debug_printf3(S, ...) debug_printf(S, ## __VA_ARGS__) 61 | 62 | #define bare_printf(S, ...) debug_printf(S, ## __VA_ARGS__) 63 | #define bare_printf2(S, ...) debug_printf(S, ## __VA_ARGS__) 64 | #define bare_printf3(S, ...) debug_printf(S, ## __VA_ARGS__) 65 | 66 | #define err_printf(S, ...) debug_printf(S, ## __VA_ARGS__) 67 | #endif 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /src/server/Makefile.am: -------------------------------------------------------------------------------- 1 | if LMON 2 | BUILD_LMON=launchmon 3 | endif 4 | 5 | SUBDIRS = logging biter cache cobo comlib auditserver $(BUILD_LMON) startup 6 | -------------------------------------------------------------------------------- /src/server/auditserver/Makefile.am: -------------------------------------------------------------------------------- 1 | #noinst_LTLIBRARIES = libaudit_server_msocket.la libaudit_server_cobo.la libserverbase.la 2 | noinst_LTLIBRARIES = libaudit_server_cobo.la libserverbase.la 3 | 4 | AM_CPPFLAGS = -I$(top_srcdir)/comlib -I$(top_srcdir)/cache -I$(top_srcdir)/../cobo -I$(top_srcdir)/../logging -I$(top_srcdir)/../include -I$(top_srcdir)/../utils -DLIBEXECDIR=\"$(pkglibexecdir)\" 5 | LDADD = $(top_builddir)/cache/libldcs_cache.la -lrt 6 | #AM_LDFLAGS = -all-static 7 | 8 | libserverbase_la_SOURCES = ldcs_audit_server_client_cb.c ldcs_audit_server_server_cb.c ldcs_audit_server_process.c ldcs_audit_server_filemngt.c ldcs_audit_server_handlers.c ldcs_elf_read.c ldcs_audit_server_requestors.c ldcs_audit_server_numa.c msgbundle.c parse_mounts.cc cleanup_proc.cc translate_maps.c force_exit.c $(top_srcdir)/../utils/fileutil.c 9 | libserverbase_la_LIBADD = -lpthread 10 | 11 | #libaudit_server_msocket_la_SOURCES = ldcs_audit_server_md_msocket.c ldcs_audit_server_md_msocket_util.c ldcs_audit_server_md_msocket_topo.c 12 | libaudit_server_cobo_la_SOURCES = ldcs_audit_server_md_cobo.c 13 | 14 | LCD = $(top_builddir)/comlib 15 | COD = $(top_builddir)/cobo/ 16 | #libaudit_server_msocket_la_LIBADD = $(LDADD) libserverbase.la 17 | libaudit_server_cobo_la_LIBADD = $(LDADD) libserverbase.la $(COD)/libldcs_cobo.la 18 | -------------------------------------------------------------------------------- /src/server/auditserver/cleanup_proc.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if defined(__cplusplus) 18 | extern "C" { 19 | #endif 20 | 21 | void init_cleanup_proc(const char *location_dir); 22 | void track_mkdir(const char *dir); 23 | int lookup_prev_mkdir(const char *dir); 24 | void cleanup_created_dirs(const char *location_dir); 25 | 26 | #if defined(__cplusplus) 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /src/server/auditserver/force_exit.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(FORCE_EXIT_H_) 18 | #define FORCE_EXIT_H_ 19 | 20 | #if defined(__cplusplus) 21 | extern "C" { 22 | #endif 23 | 24 | int getForceExitFd(); 25 | int forceExitCB(int fd, int serverid, void *data); 26 | 27 | #if defined(__cplusplus) 28 | } 29 | #endif 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/server/auditserver/ldcs_audit_server_handlers.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef LDCS_AUDIT_SERVER_STATELOOP_H 18 | #define LDCS_AUDIT_SERVER_STATELOOP_H 19 | 20 | #include "ldcs_audit_server_process.h" 21 | #include "ldcs_audit_server_md.h" 22 | 23 | int handle_server_message(ldcs_process_data_t *procdata, node_peer_t peer, ldcs_message_t *msg); 24 | int handle_server_error(ldcs_process_data_t *procdata, node_peer_t peer); 25 | int handle_client_message(ldcs_process_data_t *procdata, int nc, ldcs_message_t *msg); 26 | int handle_client_start(ldcs_process_data_t *procdata, int nc); 27 | int handle_client_end(ldcs_process_data_t *procdata, int nc); 28 | int exit_note_cb(int infd, int serverid, void *data); 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/server/auditserver/ldcs_audit_server_md_msocket_topo.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef LDCS_AUDIT_SERVER_MD_MSOCKET_TOPO_H 18 | #define LDCS_AUDIT_SERVER_MD_MSOCKET_TOPO_H 19 | 20 | #include "ldcs_audit_server_md_msocket.h" 21 | 22 | struct ldcs_msocket_bootstrap_struct 23 | { 24 | int size; 25 | int allocsize; 26 | int* fromlist; 27 | int* tolist; 28 | char** tohostlist; 29 | int* toportlist; 30 | }; 31 | typedef struct ldcs_msocket_bootstrap_struct ldcs_msocket_bootstrap_t; 32 | 33 | 34 | int ldcs_audit_server_md_msocket_init_topo_bootstrap(ldcs_msocket_data_t *ldcs_msocket_data); 35 | int ldcs_audit_server_md_msocket_run_topo_bootstrap(ldcs_msocket_data_t *ldcs_msocket_data, char *serbootinfo, int serbootlen); 36 | int _ldcs_audit_server_md_msocket_run_topo_bootstrap(ldcs_msocket_data_t *ldcs_msocket_data, ldcs_msocket_bootstrap_t *bootstrap); 37 | 38 | int compute_connections(int size, int **connlist, int *connlistsize, int *max_connections); 39 | int compute_binom_tree(int size, int **connlist, int *connlistsize, int *max_connections); 40 | 41 | int ldcs_audit_server_md_msocket_route_msg(ldcs_msocket_data_t *ldcs_msocket_data, ldcs_message_t *msg); 42 | int ldcs_audit_server_md_msocket_route_msg_binom_tree(ldcs_msocket_data_t *ldcs_msocket_data, ldcs_message_t *msg); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/server/auditserver/ldcs_audit_server_md_msocket_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef LDCS_AUDIT_SERVER_MD_MSOCKET_UTIL_H 18 | #define LDCS_AUDIT_SERVER_MD_MSOCKET_UTIL_H 19 | 20 | #include "ldcs_audit_server_md_msocket.h" 21 | #include "ldcs_audit_server_md_msocket_topo.h" 22 | 23 | int ldcs_audit_server_md_msocket_create_server(char * location, int *portlist, int num_ports, int *portused); 24 | 25 | int ldcs_audit_server_md_msocket_serialize_hostlist(char **hostlist, int numhosts, char **rdata, int *rsize); 26 | char* ldcs_audit_server_md_msocket_expand_hostname(char *rdata, int rsize, int rank); 27 | 28 | 29 | ldcs_msocket_bootstrap_t *ldcs_audit_server_md_msocket_new_bootstrap(int max_connections); 30 | int ldcs_audit_server_md_msocket_free_bootstrap(ldcs_msocket_bootstrap_t *bootstrap); 31 | int ldcs_audit_server_md_msocket_dump_bootstrap(ldcs_msocket_bootstrap_t *bootstrap); 32 | int ldcs_audit_server_md_msocket_serialize_bootstrap(ldcs_msocket_bootstrap_t *bootstrap, char **rdata, int *rsize); 33 | int ldcs_audit_server_md_msocket_deserialize_bootstrap(char *data, int datasize, ldcs_msocket_bootstrap_t **rbootstrap); 34 | 35 | int ldcs_audit_server_md_msocket_get_free_connection_table_entry (ldcs_msocket_data_t *ldcs_msocket_data); 36 | 37 | int ldcs_audit_server_md_msocket_connect(char *hostname, int *portlist, int num_ports); 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/server/auditserver/ldcs_audit_server_md_none.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include "ldcs_api.h" 25 | #include "ldcs_api_listen.h" 26 | #include "ldcs_audit_server_process.h" 27 | #include "ldcs_audit_server_md.h" 28 | 29 | int ldcs_audit_server_md_init ( ldcs_process_data_t *data ) { 30 | int rc=0; 31 | 32 | return(rc); 33 | } 34 | 35 | int ldcs_audit_server_md_register_fd ( ldcs_process_data_t *data ) { 36 | int rc=0; 37 | 38 | return(rc); 39 | } 40 | 41 | int ldcs_audit_server_md_unregister_fd ( ldcs_process_data_t *data ) { 42 | int rc=0; 43 | 44 | return(rc); 45 | } 46 | 47 | int ldcs_audit_server_md_destroy ( ldcs_process_data_t *data ) { 48 | int rc=0; 49 | 50 | return(rc); 51 | } 52 | 53 | int ldcs_audit_server_md_is_responsible ( ldcs_process_data_t *data, char *msg ) { 54 | int rc=0; 55 | 56 | return(rc); 57 | } 58 | 59 | int ldcs_audit_server_md_forward_query(ldcs_process_data_t *ldcs_process_data, ldcs_message_t* msg) { 60 | int rc=0; 61 | 62 | return(rc); 63 | } 64 | 65 | 66 | int ldcs_audit_server_fe_md_open ( char **hostlist, int numhosts, unsigned int port, void **data ) { 67 | int rc=0; 68 | 69 | return(rc); 70 | } 71 | 72 | int ldcs_audit_server_fe_md_preload ( char *filename, void *data ) { 73 | int rc=0; 74 | 75 | return(rc); 76 | } 77 | 78 | int ldcs_audit_server_fe_md_close ( void *data ) { 79 | int rc=0; 80 | 81 | return(rc); 82 | } 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /src/server/auditserver/ldcs_audit_server_numa.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined LDCS_AUDIT_SERVER_NUMA_H_ 18 | #define LDCS_AUDIT_SERVER_NUMA_H_ 19 | 20 | #include "ldcs_audit_server_process.h" 21 | 22 | int numa_should_replicate(ldcs_process_data_t *procdata, char *filename); 23 | int numa_num_nodes(); 24 | int numa_node_for_core(int core); 25 | int numa_assign_memory_to_node(void *memory, size_t memory_size, int node); 26 | void *numa_alloc_temporary_memory(size_t size); 27 | void numa_free_temporary_memory(void *alloc, size_t size); 28 | void numa_update_local_filename(char *localfilename, int node); 29 | 30 | #endif 31 | 32 | -------------------------------------------------------------------------------- /src/server/auditserver/ldcs_audit_server_requestors.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(LDCS_AUDIT_SERVER_REQUESTORS_H_) 18 | #define LDCS_AUDIT_SERVER_REQUESTORS_H_ 19 | 20 | #include "ldcs_audit_server_md.h" 21 | #include "ldcs_audit_server_process.h" 22 | 23 | requestor_list_t new_requestor_list(); 24 | int been_requested(requestor_list_t list, char *file); 25 | void add_requestor(requestor_list_t list, char *file, node_peer_t peer); 26 | void clear_requestor(requestor_list_t list, char *file); 27 | int get_requestors(requestor_list_t list, char *file, node_peer_t **requestor_list, int *requestor_list_size); 28 | int get_requestors2(requestor_list_t list, requestor_list_t list2, char *file, node_peer_t **requestor_list, int *requestor_list_size); 29 | int peer_requested(requestor_list_t list, char *file, node_peer_t peer); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/server/auditserver/ldcs_elf_read.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(LDCS_ELF_READ_H_) 18 | #define LDCS_ELF_READ_H_ 19 | 20 | #include 21 | int read_file_and_strip(FILE *f, void *data, size_t *size, int strip, int mod_ro_got, int *was_elf); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/server/auditserver/msgbundle.h: -------------------------------------------------------------------------------- 1 | #if !defined(MSGBUNDLE_H_) 2 | #define MSGBUNDLE_H_ 3 | 4 | #include "ldcs_audit_server_process.h" 5 | #include "ldcs_audit_server_md.h" 6 | #include "ldcs_api.h" 7 | 8 | void msgbundle_init(ldcs_process_data_t *procdata); 9 | void msgbundle_done(ldcs_process_data_t *procdata); 10 | void msgbundle_force_flush(ldcs_process_data_t *procdata); 11 | 12 | int spindle_send_noncontig(ldcs_process_data_t *procdata, ldcs_message_t *msg, node_peer_t node, 13 | void *secondary_data, size_t secondary_size); 14 | int spindle_broadcast_noncontig(ldcs_process_data_t *procdata, ldcs_message_t *msg, 15 | void *secondary_data, size_t secondary_size); 16 | 17 | int spindle_send(ldcs_process_data_t *procdata, ldcs_message_t *msg, node_peer_t node); 18 | int spindle_broadcast(ldcs_process_data_t *procdata, ldcs_message_t *msg); 19 | 20 | int spindle_forward_query(ldcs_process_data_t *procdata, ldcs_message_t *msg); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/server/auditserver/parse_mounts.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(PARSE_MOUNTS_H_) 18 | #define PARSE_MOUNTS_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #if defined __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | int mount_to_dev(const char *mount_str, dev_t *device); 29 | int dev_to_mount(dev_t device, const char **mount_str); 30 | 31 | #if defined __cplusplus 32 | } 33 | #endif 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /src/server/biter/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libbiterd.la 2 | 3 | AM_CFLAGS = -fvisibility=hidden 4 | 5 | libbiterd_la_SOURCES = $(top_srcdir)/../biter/biterd.c $(top_srcdir)/../biter/server_queue.c $(top_srcdir)/../biter/demultiplex.c 6 | libbiterd_la_CFLAGS = -DSERVER 7 | AM_CPPFLAGS = -I$(top_srcdir)/../biter -I$(top_srcdir)/../logging -I$(top_srcdir)/../include 8 | 9 | if BGQ_BLD 10 | libbiterd_la_SOURCES += $(top_srcdir)/../biter/bgq_daemon_ids.c 11 | endif 12 | if LINUX_BLD 13 | libbiterd_la_SOURCES += $(top_srcdir)/../biter/linux_daemon_ids.c 14 | endif 15 | 16 | -------------------------------------------------------------------------------- /src/server/cache/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libldcs_cache.la 2 | libldcs_cache_la_SOURCES = ldcs_cache.cc ldcs_cache_file_op.c stat_cache.cc global_name.c $(top_srcdir)/../utils/pathfn.c 3 | AM_CPPFLAGS = -I$(top_srcdir)/comlib -I$(top_srcdir)/../logging -I$(top_srcdir)/auditserver -I$(top_srcdir)/../include -I$(top_srcdir)/../utils 4 | -------------------------------------------------------------------------------- /src/server/cache/global_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(GLOBAL_NAME_H) 18 | #define GLOBAL_NAME_H 19 | 20 | #if defined(__cplusplus) 21 | extern "C" { 22 | #endif 23 | 24 | int init_global_name(); 25 | 26 | int init_global_name_list(void); 27 | void grow_global_name_list(void); 28 | void add_global_name(char* pathname, char* localpath); 29 | char* lookup_global_name(char* localpath); 30 | 31 | #if defined(__cplusplus) 32 | } 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/server/cache/ldcs_cache_file_op.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include "ldcs_cache.h" 23 | 24 | -------------------------------------------------------------------------------- /src/server/cache/stat_cache.cc: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "spindle_debug.h" 22 | #include "stat_cache.h" 23 | 24 | static std::map stat_table; 25 | static std::map lstat_table; 26 | static std::map ldso_table; 27 | 28 | int init_stat_cache() 29 | { 30 | return 0; 31 | } 32 | 33 | void add_stat_cache(char *pathname, char *data, metadata_t stattype) 34 | { 35 | if (stattype == metadata_loader) 36 | debug_printf3("Adding ldso cache entry %s = %s\n", pathname, data ? data : "NULL"); 37 | else 38 | debug_printf3("Adding %sstat cache entry %s = %s\n", 39 | (stattype == metadata_lstat) ? "l" : "", 40 | pathname, data ? data : "NULL"); 41 | 42 | std::string pathname_key = pathname; 43 | std::map *table = nullptr; 44 | switch (stattype) { 45 | case metadata_none: assert(0); break; 46 | case metadata_stat: table = &stat_table; break; 47 | case metadata_lstat: table = &lstat_table; break; 48 | case metadata_loader: table = &ldso_table; break; 49 | } 50 | 51 | table->insert(std::make_pair(pathname_key, data)); 52 | } 53 | 54 | int lookup_stat_cache(char *pathname, char **data, metadata_t stattype) 55 | { 56 | std::string pathname_key = pathname; 57 | 58 | std::map *table = nullptr; 59 | switch (stattype) { 60 | case metadata_none: assert(0); break; 61 | case metadata_stat: table = &stat_table; break; 62 | case metadata_lstat: table = &lstat_table; break; 63 | case metadata_loader: table = &ldso_table; break; 64 | } 65 | 66 | std::map::iterator i = table->find(pathname_key); 67 | if (i == table->end()) { 68 | debug_printf3("Looked up metadata cache entry %s, not cached\n", pathname); 69 | *data = NULL; 70 | return -1; 71 | } 72 | 73 | *data = i->second; 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /src/server/cache/stat_cache.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(STAT_CACHE_H_) 18 | #define STAT_CACHE_H_ 19 | 20 | #if defined(__cplusplus) 21 | extern "C" { 22 | #endif 23 | 24 | typedef enum { 25 | metadata_none, 26 | metadata_stat, 27 | metadata_lstat, 28 | metadata_loader 29 | } metadata_t; 30 | 31 | /* data can be NULL if file doesn't exist */ 32 | int init_stat_cache(); 33 | void add_stat_cache(char *pathname, char *data, metadata_t stattype); 34 | int lookup_stat_cache(char *pathname, char **data, metadata_t stattype); 35 | 36 | #if defined(__cplusplus) 37 | } 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/server/cobo/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libldcs_cobo.la 2 | libldcs_cobo_la_SOURCES = $(top_srcdir)/../cobo/cobo.c $(top_srcdir)/../cobo/handshake.c $(top_srcdir)/../cobo/cobo_comm.c $(top_srcdir)/../cobo/cobo_handshake.c 3 | AM_CPPFLAGS = -I$(top_srcdir)/../logging -I$(top_srcdir)/../cobo -I$(top_srcdir)/../include $(MUNGE_CFLAGS) $(GCRYPT_CFLAGS) 4 | 5 | -------------------------------------------------------------------------------- /src/server/comlib/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = 2 | 3 | AM_CPPFLAGS = -I$(top_srcdir)/../logging -I$(top_srcdir)/../include -I$(top_srcdir)/auditserver -I$(top_srcdir)/cache 4 | 5 | BASE_SRCS = ldcs_api_util.c ldcs_api_listen.c ldcs_api_wrapper.c 6 | 7 | noinst_LTLIBRARIES += libserver_pipe.la 8 | libserver_pipe_la_CPPFLAGS = $(AM_CPPFLAGS) -Dcomm=pipe 9 | libserver_pipe_la_SOURCES = ldcs_api_pipe.c ldcs_api_pipe_notify.c $(BASE_SRCS) 10 | 11 | noinst_LTLIBRARIES += libserver_socket.la 12 | libserver_socket_la_CPPFLAGS = $(AM_CPPFLAGS) -Dcomm=socket 13 | libserver_socket_la_SOURCES = ldcs_api_socket.c $(BASE_SRCS) 14 | 15 | noinst_LTLIBRARIES += libserver_biter.la 16 | libserver_biter_la_CPPFLAGS = $(AM_CPPFLAGS) -Dcomm=biter -I$(top_srcdir)/../biter 17 | libserver_biter_la_SOURCES = ldcs_api_biter.c $(BASE_SRCS) 18 | 19 | if SHMEM 20 | noinst_LTLIBRARIES += libserver_shmem.la 21 | libserver_shmem_la_CPPFLAGS = $(AM_CPPFLAGS) -Dcomm=shmem 22 | libserver_shmem_la_SOURCES = ldcs_api_shmem.c $(BASE_SRCS) 23 | endif 24 | -------------------------------------------------------------------------------- /src/server/comlib/ldcs_api_listen.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef LDCS_API_LISTEN_H 18 | #define LDCS_API_LISTEN_H 19 | 20 | int ldcs_listen_register_fd( int fd, 21 | int id, 22 | int _ldcs_server_CB ( int fd, int id, void *data ), 23 | void * data); 24 | 25 | int ldcs_listen_register_exit_loop_cb( int cb_func ( int num_fds, void *data ), 26 | void * data); 27 | 28 | int ldcs_listen_unregister_fd( int fd ); 29 | 30 | int ldcs_listen_signal_end_listen_loop( ); 31 | 32 | int ldcs_listen(); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/server/comlib/ldcs_api_pipe_notify.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef LDCS_API_PIPE_NOTIFY_H 18 | #define LDCS_API_PIPE_NOTIFY_H 19 | 20 | int ldcs_notify_init(char *path); 21 | int ldcs_notify_destroy(int fd); 22 | int ldcs_notify_get_fd(int fd); 23 | char *ldcs_notify_get_next_file(int nfd); 24 | int ldcs_notify_more_avail(int fd); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/server/comlib/ldcs_api_socket.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #ifndef LDCS_API_SOCKET_H 18 | #define LDCS_API_SOCKET_H 19 | 20 | typedef enum { 21 | LDCS_SOCKET_FD_TYPE_SERVER, 22 | LDCS_SOCKET_FD_TYPE_CONN, 23 | LDCS_SOCKET_FD_TYPE_UNKNOWN 24 | } fd_list_entry_type_t; 25 | 26 | struct fdlist_entry_t 27 | { 28 | int inuse; 29 | fd_list_entry_type_t type; 30 | 31 | /* server part */ 32 | int server_fd; 33 | int conn_list_size; 34 | int conn_list_used; 35 | int *conn_list; 36 | 37 | /* connection part */ 38 | int fd; 39 | int serverid; 40 | }; 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /src/server/launchmon/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libbelmon.la 2 | 3 | libbelmon_la_SOURCES = spindle_be_lmon.cc 4 | libbelmon_la_CPPFLAGS = $(LAUNCHMON_INC) -I$(top_srcdir)/../logging -I$(top_srcdir)/../include 5 | -------------------------------------------------------------------------------- /src/server/logging/Makefile.am: -------------------------------------------------------------------------------- 1 | pkglibexec_PROGRAMS = spindled_logd 2 | noinst_LTLIBRARIES = libspindledlogc.la 3 | 4 | spindled_logd_SOURCES = $(top_srcdir)/../logging/spindle_logd.cc 5 | spindled_logd_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/../logging 6 | spindled_logd_LDADD = -lpthread 7 | 8 | libspindledlogc_la_SOURCES = $(top_srcdir)/../logging/spindle_logc.c 9 | libspindledlogc_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/../logging -I$(top_srcdir)/../include 10 | libspindledlogc_la_CFLAGS = -DLIBEXEC=\"${pkglibexecdir}\" -DDAEMON_NAME=\"spindled_logd\" 11 | 12 | -------------------------------------------------------------------------------- /src/server/startup/Makefile.am: -------------------------------------------------------------------------------- 1 | pkglibexec_PROGRAMS = spindle_be 2 | lib_LTLIBRARIES = libspindlebe.la 3 | noinst_LTLIBRARIES = libspindlebe_static.la 4 | 5 | AM_CPPFLAGS = -I$(top_srcdir)/../logging 6 | 7 | CORE_SOURCES = spindle_be.cc hookexec.c $(top_srcdir)/../utils/parseloc.c $(top_srcdir)/../utils/keyfile.c $(top_srcdir)/../utils/spindle_mkdir.c $(top_srcdir)/../utils/exitnote.c 8 | CORE_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/comlib -I$(top_srcdir)/cache -I$(top_srcdir)/auditserver -I$(top_srcdir)/../client/beboot -I$(top_srcdir)/../include -I$(top_srcdir)/../utils -I$(top_srcdir)/../cobo -DTRACK_MKDIR -DLOOKUP_PREV_MKDIR -DLIBEXECDIR=\"$(pkglibexecdir)\" 9 | CORE_LDADD = $(top_builddir)/logging/libspindledlogc.la -ldl 10 | if COBO 11 | CORE_LDADD += $(top_builddir)/auditserver/libaudit_server_cobo.la 12 | endif 13 | if MSOCKET 14 | CORE_LDADD += $(top_builddir)/auditserver/libaudit_server_msocket.la 15 | endif 16 | if SOCKETS 17 | CORE_LDADD += $(top_builddir)/comlib/libserver_socket.la 18 | endif 19 | if PIPES 20 | CORE_LDADD += $(top_builddir)/comlib/libserver_pipe.la 21 | endif 22 | if BITER 23 | CORE_LDADD += $(top_builddir)/comlib/libserver_biter.la $(top_builddir)/biter/libbiterd.la 24 | endif 25 | if USE_NUMA 26 | CORE_LDADD += -lnuma 27 | endif 28 | CORE_LDADD += $(GCRYPT_LIBS) 29 | 30 | libspindlebe_la_CPPFLAGS = $(CORE_CPPFLAGS) -DSPINDLEBELIB 31 | libspindlebe_la_SOURCES = $(CORE_SOURCES) 32 | libspindlebe_la_LIBADD = $(CORE_LDADD) $(MUNGE_DYN_LIB) 33 | libspindlebe_la_LDFLAGS = -version-info $(SPINDLEBE_LIB_VERSION) 34 | 35 | libspindlebe_static_la_CPPFLAGS = $(libspindlebe_la_CPPFLAGS) 36 | libspindlebe_static_la_SOURCES = $(libspindlebe_la_SOURCES) 37 | libspindlebe_static_la_LIBADD = $(libspindlebe_la_LIBADD) 38 | 39 | spindle_be_LDFLAGS = -static 40 | spindle_be_CPPFLAGS = $(CORE_CPPFLAGS) 41 | spindle_be_SOURCES = spindle_be_main.cc spindle_be_serial.cc spindle_be_hostbin.cc spindle_be_mpilaunch.cc $(top_srcdir)/../utils/rshlaunch.c $(CORE_SOURCES) 42 | spindle_be_LDADD = $(CORE_LDADD) $(MUNGE_LIBS) 43 | 44 | if LINK_LIBSTDCXX_STATIC 45 | spindle_be_LDFLAGS += $(STATIC_LIBGCC_OPT) -L. 46 | CLEANFILES = ./libstdc++.a 47 | ./libstdc++.a: 48 | $(AM_V_GEN)$(LN_S) $(STATIC_LIBSTDCXX) $@ 49 | BUILT_SOURCES=./libstdc++.a 50 | endif 51 | 52 | if LMON 53 | if LMON_DYNAMIC 54 | spindle_be_LDADD += $(top_builddir)/launchmon/libbelmon.la $(LAUNCHMON_LIB) $(LAUNCHMON_RMCOMM) -lmonbeapi -lgcrypt -lpthread 55 | else 56 | spindle_be_LDADD += $(top_builddir)/launchmon/libbelmon.la $(LAUNCHMON_STATIC_LIBS) 57 | endif 58 | endif 59 | -------------------------------------------------------------------------------- /src/server/startup/spindle_be_hostbin.cc: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "spindle_launch.h" 18 | #include "spindle_debug.h" 19 | 20 | int startHostbinBE(unsigned int port, unsigned int num_ports, unique_id_t unique_id, int security_type) 21 | { 22 | return spindleRunBE(port, num_ports, unique_id, security_type, NULL); 23 | } 24 | -------------------------------------------------------------------------------- /src/server/startup/spindle_be_mpilaunch.cc: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "spindle_launch.h" 18 | #include "spindle_debug.h" 19 | 20 | int startMPILaunchBE(unsigned int port, unsigned int num_ports, unique_id_t unique_id, int security_type) 21 | { 22 | return spindleRunBE(port, num_ports, unique_id, security_type, NULL); 23 | } 24 | -------------------------------------------------------------------------------- /src/server/startup/spindle_be_serial.cc: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "spindle_launch.h" 18 | #include "spindle_debug.h" 19 | #include 20 | 21 | int startSerialBE(int /*argc*/, char * /*argv*/[], int security_type) 22 | { 23 | char *port_s, *num_ports_s, *unique_id_s; 24 | unsigned port, num_ports; 25 | unique_id_t unique_id; 26 | 27 | port_s = getenv("SPINDLE_SERIAL_PORT"); 28 | if (!port_s) { 29 | err_printf("SPINDLE_SERIAL_PORT wasn't set\n"); 30 | return -1; 31 | } 32 | num_ports_s = getenv("SPINDLE_SERIAL_NUMPORTS"); 33 | if (!num_ports_s) { 34 | err_printf("SPINDLE_SERIAL_NUMPORTS wasn't set\n"); 35 | return -1; 36 | } 37 | unique_id_s = getenv("SPINDLE_SERIAL_SHARED"); 38 | if (!unique_id_s) { 39 | err_printf("SPINDLE_SERIAL_SHARED wasn't set\n"); 40 | return -1; 41 | } 42 | port = atoi(port_s); 43 | unique_id = strtoul(unique_id_s, NULL, 10); 44 | num_ports = atoi(num_ports_s); 45 | 46 | return spindleRunBE(port, num_ports, unique_id, security_type, NULL); 47 | } 48 | -------------------------------------------------------------------------------- /src/slurm_plugin/Makefile.am: -------------------------------------------------------------------------------- 1 | lib_LTLIBRARIES = libspindleslurm.la 2 | 3 | libver=`$(top_srcdir)/LIB_VERSION spindleslurm` 4 | 5 | libspindleslurm_la_SOURCES = encode_decode.c plugin_utils.c slurm_plugin.c $(top_srcdir)/src/utils/spindle_mkdir.c $(top_srcdir)/src/utils/parseloc.c 6 | libspindleslurm_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/src/include -I$(top_srcdir)/src/logging -DUSE_PLUGIN_DEBUG -DDEBUG -DCUSTOM_GETENV -DCUSTOM_GETENV_FREE -DSCONTROL_BIN="$(SCONTROL_ABSPATH)" -DSPINDLE_DO_EXPORT 7 | libspindleslurm_la_LDFLAGS = $(AM_LDFLAGS) -ldl -version-info $(libver) 8 | libspindleslurm_la_LIBADD = $(top_builddir)/src/server/startup/libspindlebe.la $(top_builddir)/src/fe/startup/libspindlefe.la 9 | libspindleslurm_la_CFLAGS = $(CFLAGS) -fvisibility=hidden 10 | libspindleslurm_la_CXXFLAGS = $(CXXFLAGS) -fvisibility=hidden 11 | -------------------------------------------------------------------------------- /src/utils/ccwarns.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(GCCWARNS_H_) 18 | #define GCCWARNS_H_ 19 | 20 | #if defined(__GNUC__) 21 | 22 | #define DOPRAGMA(X) _Pragma(#X) 23 | 24 | #define GCC_DISABLE_WARNING(WARN) \ 25 | _Pragma("GCC diagnostic push") \ 26 | DOPRAGMA(GCC diagnostic ignored WARN) 27 | 28 | #define GCC_ENABLE_WARNING \ 29 | _Pragma("GCC diagnostic pop") 30 | 31 | #if __GNUC__ >= 7 32 | #define GCC7_DISABLE_WARNING(WARN) GCC_DISABLE_WARNING(WARN) 33 | #define GCC7_ENABLE_WARNING GCC_ENABLE_WARNING 34 | #else 35 | #define GCC7_DISABLE_WARNING(WARN) 36 | #define GCC7_ENABLE_WARNING 37 | #endif 38 | 39 | #if __GNUC__ >= 8 40 | #define GCC8_DISABLE_WARNING(WARN) GCC_DISABLE_WARNING(WARN) 41 | #define GCC8_ENABLE_WARNING GCC_ENABLE_WARNING 42 | #else 43 | #define GCC8_DISABLE_WARNING(WARN) 44 | #define GCC8_ENABLE_WARNING 45 | #endif 46 | 47 | #if __GNUC__ >= 9 48 | #define GCC9_DISABLE_WARNING(WARN) GCC_DISABLE_WARNING(WARN) 49 | #define GCC9_ENABLE_WARNING GCC_ENABLE_WARNING 50 | #else 51 | #define GCC9_DISABLE_WARNING(WARN) 52 | #define GCC9_ENABLE_WARNING 53 | #endif 54 | 55 | #else 56 | 57 | #define GCC_DISABLE_WARNING(X) 58 | #define GCC_ENABLE_WARNING 59 | 60 | #endif 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /src/utils/exitnote.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(EXITNOTE_H_) 18 | #define EXITNOTE_H_ 19 | 20 | #if defined(__cplusplus) 21 | extern "C" { 22 | #endif 23 | 24 | int createExitNote(const char *location); 25 | int pingExitNote(const char *location); 26 | int handleExitNote(int sockfd, const char *location); 27 | 28 | #if defined(__cplusplus) 29 | } 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/utils/fileutil.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MECHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(FILEUTIL_H_) 18 | #define FILEUTIL_H_ 19 | 20 | int read_n_bytes(char *localname, int fd, void *buffer, size_t size); 21 | int read_buffer(char *localname, char *buffer, int size); 22 | int write_buffer(char *localname, char *buffer, size_t size); 23 | int write_n_bytes(char *localname, int fd, void *buffer, size_t size); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/utils/getcpu.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #define _GNU_SOURCE 18 | #include 19 | 20 | int get_cur_cpu() 21 | { 22 | return sched_getcpu(); 23 | } 24 | -------------------------------------------------------------------------------- /src/utils/keyfile.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(KEYFILE_H_) 18 | #define KEYFILE_H_ 19 | 20 | #include 21 | 22 | #if defined(__cplusplus) 23 | extern "C" { 24 | #endif 25 | 26 | void create_key(unsigned char *buffer, int key_size_bytes); 27 | void get_keyfile_path(char *pathname, int pathname_len, uint64_t unique_id); 28 | void create_keyfile(uint64_t unique_id); 29 | void clean_keyfile(uint64_t unique_id); 30 | 31 | #if defined(__cplusplus) 32 | } 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/utils/pathfn.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(PATHFN_H_) 18 | #define PATHFN_H_ 19 | 20 | #include 21 | 22 | #if defined(__cplusplus) 23 | extern "C" { 24 | #endif 25 | 26 | int parseFilenameNoAlloc(const char *name, char *file, char *dir, int result_size); 27 | int addCWDToDir(pid_t pid, char *dir, int result_size); 28 | int reducePath(char *dir); 29 | char *concatStrings(const char *str1, int str1_len, const char *str2, int str2_len); 30 | 31 | #if defined(__cplusplus) 32 | } 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/utils/rshlaunch.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #if !defined(RSHLAUNCH_H_) 18 | #define RSHLAUNCH_H_ 19 | 20 | #include "spindle_launch.h" 21 | 22 | #if defined(__cplusplus) 23 | extern "C" { 24 | #endif 25 | 26 | void init_rsh_launch_fe(spindle_args_t *args); 27 | int collect_rsh_pid_fe(); 28 | void init_rsh_launch_be(int argc, char **argv); 29 | char *get_rsh_launcher(); 30 | pid_t get_fe_rsh_pid(); 31 | void clear_fe_rsh_pid(); 32 | 33 | #if defined(__cplusplus) 34 | } 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /testsuite/funcdict.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include 18 | #include 19 | 20 | typedef int (*func_t)(void); 21 | typedef void (*cb_func_t)(func_t, func_t, char *); 22 | 23 | struct func_table_t { 24 | func_t calc_function; 25 | func_t tls_function; 26 | char *name; 27 | }; 28 | 29 | cb_func_t cb = NULL; 30 | #define MAX_LIBRARIES 1024 31 | struct func_table_t func_table[MAX_LIBRARIES]; 32 | int cur_library = 0; 33 | 34 | void setup_func_callback(cb_func_t c) 35 | { 36 | int i; 37 | cb = c; 38 | 39 | for (i = 0; i 18 | 19 | extern "C" { 20 | int cxxexceptA_calc(); 21 | } 22 | extern int cxxexception_B(); 23 | static int value; 24 | void catch_exception() 25 | { 26 | try { 27 | cxxexception_B(); 28 | } 29 | catch (int e) { 30 | value = e; 31 | } 32 | } 33 | 34 | int cxxexceptA_calc() 35 | { 36 | catch_exception(); 37 | assert(value == 42); 38 | return value; 39 | } 40 | -------------------------------------------------------------------------------- /testsuite/libcxxexceptB.cc: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | int cxxexception_B() 18 | { 19 | throw 42; 20 | } 21 | -------------------------------------------------------------------------------- /testsuite/libdepA.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | extern int depB_calc(); 18 | 19 | int depA_calc() 20 | { 21 | return depB_calc() + 2; 22 | } 23 | -------------------------------------------------------------------------------- /testsuite/libdepB.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | extern int depC_calc(); 18 | 19 | int depB_calc() 20 | { 21 | return depC_calc() + 1; 22 | } 23 | -------------------------------------------------------------------------------- /testsuite/libdepC.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | int depC_calc() 18 | { 19 | return 4; 20 | } 21 | -------------------------------------------------------------------------------- /testsuite/libgenerator.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | void writeFile(FILE *f, char *prefix, int size) 23 | { 24 | int i; 25 | fprintf(f, "__thread int tlsvar_%d = -1;\n", size); 26 | fprintf(f, "static void on_load() __attribute__((constructor));\n"); 27 | fprintf(f, "static void on_load() { tlsvar_%d = %d; }\n", size, size); 28 | fprintf(f, "int get_tlsvar_%s() { return tlsvar_%d; }\n", prefix, size); 29 | fprintf(f, "#if defined(FUNC_NAME)\n"); 30 | fprintf(f, "int %s_cache[%d];\n", prefix, size+1); 31 | fprintf(f, "volatile int always_zero = 0;\n"); 32 | fprintf(f, "volatile int vals[16];\n"); 33 | fprintf(f, "#define SPACE_FILLER \\\n"); 34 | fprintf(f, " if (always_zero) { \\\n"); 35 | for (i = 0; i < 16; i++) 36 | fprintf(f, " vals[%d]++;\\\n", i); 37 | fprintf(f, "}\n"); 38 | fprintf(f, "int %s_fib0(volatile int *v) { return 0; }\n", prefix); 39 | fprintf(f, "int %s_fib1(volatile int *v) { return 1; }\n", prefix); 40 | for (i = 2; i <= size; i++) { 41 | fprintf(f, "int %s_fib%d(volatile int *v) { SPACE_FILLER ; if (!%s_cache[%d]) %s_cache[%d] = %s_fib%d(v) + %s_fib%d(v); return %s_cache[%d]; }\n", 42 | prefix, i, /* function sig */ 43 | prefix, i, /* if statement */ 44 | prefix, i, /* assignment lvalue */ 45 | prefix, i-1, prefix, i-2, /* assignment rvalue */ 46 | prefix, i); /* return */ 47 | } 48 | fprintf(f, "int %s_calc() { int count = 0; return %s_fib%d(&count); }\n", prefix, prefix, size); 49 | fprintf(f, "#endif\n"); 50 | fclose(f); 51 | }; 52 | 53 | int main(int argc, char *argv[]) 54 | { 55 | char *prefix; 56 | FILE *f; 57 | int size; 58 | 59 | if (argc != 4) { 60 | fprintf(stderr, "Argument error\n"); 61 | return -1; 62 | } 63 | 64 | f = fopen(argv[1], "w"); 65 | if (!f) { 66 | fprintf(stderr, "Failed to open %s: %s\n", argv[2], strerror(errno)); 67 | return -1; 68 | } 69 | size = atoi(argv[2]); 70 | prefix = argv[3]; 71 | 72 | writeFile(f, prefix, size); 73 | return 0; 74 | } 75 | -------------------------------------------------------------------------------- /testsuite/local.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | char placeholder[256] = 7 | "SPINDLE_PLACEHOLDERxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; 8 | 9 | int check_hostname() 10 | { 11 | char hostname[256]; 12 | memset(hostname, 0, sizeof(hostname)); 13 | gethostname(hostname, sizeof(hostname)); 14 | hostname[sizeof(hostname)-1] = '\0'; 15 | 16 | if (strcmp(placeholder, hostname) != 0) { 17 | fprintf(stderr, "ERROR: Problem during liblocal test, placeholder name did not match hostname: %s != %s\n", 18 | placeholder, hostname); 19 | return 0; 20 | } 21 | return 1; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /testsuite/originlib.c: -------------------------------------------------------------------------------- 1 | extern int origin_target(); 2 | 3 | int origin_calc() 4 | { 5 | return origin_target(); 6 | } 7 | -------------------------------------------------------------------------------- /testsuite/origintarget.c: -------------------------------------------------------------------------------- 1 | int origin_target() 2 | { 3 | return 2; 4 | } 5 | 6 | 7 | -------------------------------------------------------------------------------- /testsuite/preload_file_list_template: -------------------------------------------------------------------------------- 1 | TEST_RUN_DIR/libcxxexceptA.so 2 | TEST_RUN_DIR/libcxxexceptB.so 3 | TEST_RUN_DIR/libdepA.so 4 | TEST_RUN_DIR/libdepB.so 5 | TEST_RUN_DIR/libdepC.so 6 | TEST_RUN_DIR/libtest10.so 7 | TEST_RUN_DIR/libtest100.so 8 | TEST_RUN_DIR/libtest1000.so 9 | TEST_RUN_DIR/libtest10000.so 10 | TEST_RUN_DIR/libtest2000.so 11 | TEST_RUN_DIR/libtest4000.so 12 | TEST_RUN_DIR/libtest50.so 13 | TEST_RUN_DIR/libtest500.so 14 | TEST_RUN_DIR/libtest6000.so 15 | TEST_RUN_DIR/libtest8000.so 16 | TEST_RUN_DIR/test_driver 17 | TEST_RUN_DIR/test_driver_libs 18 | -------------------------------------------------------------------------------- /testsuite/retzero.c: -------------------------------------------------------------------------------- 1 | int main(int argc, char *argv[]) 2 | { 3 | return 0; 4 | } 5 | -------------------------------------------------------------------------------- /testsuite/run_driver_flux: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x$SPINDLE_TEST_ARGS" = "x" ] ; then 4 | PROCS="-N `flux resource info | tr ',' '\n' | grep Nodes | awk '{print $1}'` --tasks-per-node 16" 5 | else 6 | PROCS=$SPINDLE_TEST_ARGS 7 | fi 8 | 9 | FLUX_SPINDLE_OPTS="spindle" 10 | if [ "x$SPINDLE_OPTS" = "x--preload=preload_file_list" ] ; then 11 | FLUX_SPINDLE_OPTS="spindle.preload=preload_file_list" 12 | fi 13 | if [ "x$SPINDLE_OPTS" = "x--push" ] ; then 14 | FLUX_SPINDLE_OPTS="spindle.push" 15 | fi 16 | if [ "x$SPINDLE_OPTS" = "x--pull" ] ; then 17 | FLUX_SPINDLE_OPTS="spindle.pull" 18 | fi 19 | if [ "x$SPINDLE_OPTS" = "x--numa" ] ; then 20 | FLUX_SPINDLE_OPTS="spindle.numa" 21 | fi 22 | if [ "x$SPINDLE_OPTS" = "--run-in-session $SESSION_ID" ] ; then 23 | #Currently nothing to do 24 | /bin/true 25 | fi 26 | if [ "x$SPINDLE_LD_PRELOAD" != "x" ] ; then 27 | export FLUX_LD_PRELOAD="--env=LD_PRELOAD=$SPINDLE_LD_PRELOAD" 28 | else 29 | export FLUX_LD_PRELOAD="" 30 | fi 31 | 32 | exec flux run $FLUX_LD_PRELOAD -o userrc=spindle.rc -o spindle.level=high -o $FLUX_SPINDLE_OPTS $PROCS $* 33 | 34 | -------------------------------------------------------------------------------- /testsuite/run_driver_lrun: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x$SPINDLE_TEST_ARGS" == "x" ] ; then 4 | PROC_ARG="-T 4" 5 | else 6 | PROC_ARGS="-n $SPINDLE_TEST_ARGS" 7 | fi 8 | 9 | $SPINDLE $SPINDLE_OPTS lrun $PROC_ARG $* 10 | -------------------------------------------------------------------------------- /testsuite/run_driver_openmpi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PROCS=$SPINDLE_TEST_ARGS 4 | export PROCS 5 | $SPINDLE $SPINDLE_OPTS mpiexec -np $PROCS $* 6 | -------------------------------------------------------------------------------- /testsuite/run_driver_serial: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ "x$SPINDLE_LD_PRELOAD" != "x" ] ; then 4 | $SPINDLE $SPINDLE_FLAGS $SPINDLE_OPTS --launcher=serial bash -c "LD_PRELOAD=$SPINDLE_LD_PRELOAD $*" 5 | else 6 | $SPINDLE $SPINDLE_FLAGS $SPINDLE_OPTS --launcher=serial $* 7 | fi 8 | -------------------------------------------------------------------------------- /testsuite/run_driver_slurm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ x$SLURM_CPUS_ON_NODE = x ] ; then 4 | export SLURM_CPUS_ON_NODE=1 5 | fi 6 | 7 | if [ x$SPINDLE_TEST_ARGS = x ] ; then 8 | ((PROCS=$SLURM_NNODES*$SLURM_CPUS_ON_NODE)) 9 | else 10 | PROCS=$SPINDLE_TEST_ARGS 11 | fi 12 | export PROCS 13 | 14 | if [ "x$SPINDLE_BGQ_LD_PRELOAD" == "xtrue" ] ; then 15 | PRELOAD_ARGS="--runjob-opts=--envs LD_PRELOAD=$LIBRARY_LIST" 16 | elif [ "x$SPINDLE_LD_PRELOAD" != "x" ] ; then 17 | export LD_PRELOAD=$SPINDLE_LD_PRELOAD 18 | PRELOAD_ARGS="--export=ALL" 19 | fi 20 | 21 | exec $SPINDLE $SPINDLE_FLAGS $SPINDLE_OPTS srun "$PRELOAD_ARGS" -n $PROCS $* 22 | -------------------------------------------------------------------------------- /testsuite/run_driver_template: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd TEST_RUN_DIR 4 | if [ "x$LD_LIBRARY_PATH" != "x" ] ; then 5 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd` 6 | else 7 | export LD_LIBRARY_PATH=`pwd` 8 | fi 9 | export SPINDLE_TEST=1 10 | export SPINDLE=SPINDLE_EXEC 11 | export PATH=$PATH:. 12 | 13 | if [ $1 == --start-session ] ; then 14 | export SPINDLEID=`$SPINDLE --start-session --level=high` 15 | if [ x$SPINDLEID == x ]; then 16 | echo ANONYMOUS_SESSION 17 | else 18 | echo $SPINDLEID 19 | fi 20 | exit 0 21 | fi 22 | if [ $1 == --end-session ] ; then 23 | if [ x$2 == xANONYMOUS_SESSION ] ; then 24 | $SPINDLE --end-session 25 | else 26 | $SPINDLE $1=$2 27 | fi 28 | exit 0 29 | fi 30 | 31 | echo Running: ./run_driver $* $SPINDLE_LAUNCH_MODE 32 | 33 | if [ $1 == --serial ] ; then 34 | exec SPINDLE_EXEC --level=high --launcher=serial $2 35 | fi 36 | 37 | export LIBRARY_LIST="`pwd`/libcxxexceptA.so:`pwd`/libtest100.so:`pwd`/libtest2000.so:`pwd`/libtest500.so:`pwd`/libtest1000.so:`pwd`/libtest4000.so:`pwd`/libtest6000.so:`pwd`/libdepA.so:`pwd`/libtest10.so:`pwd`/libtest11.so:`pwd`/libtest12.so:`pwd`/libtest13.so:`pwd`/libtest14.so:`pwd`/libtest15.so:`pwd`/libtest16.so:`pwd`/libtest17.so:`pwd`/libtest18.so:`pwd`/libtest19.so:`pwd`/libtest20.so:`pwd`/libtest10000.so:`pwd`/libtest50.so:`pwd`/libtest8000.so:`pwd`/origin_dir/liboriginlib.so" 38 | 39 | 40 | if [ $1 == --dependency ] ; then 41 | export TEST_EXEC=./test_driver_libs 42 | elif [ $1 == --dlreopen ] ; then 43 | export TEST_EXEC=./test_driver_libs 44 | else 45 | export TEST_EXEC=./test_driver 46 | fi 47 | 48 | if [ $2 == --preload ] ; then 49 | export SPINDLE_OPTS="--preload=preload_file_list" 50 | fi 51 | if [ $2 == --push ] ; then 52 | export SPINDLE_OPTS="--push" 53 | fi 54 | if [ $2 == --pull ] ; then 55 | export SPINDLE_OPTS="--pull" 56 | fi 57 | if [ $2 == --numa ] ; then 58 | export SPINDLE_OPTS="--numa" 59 | fi 60 | 61 | if [ $2 == --session ] ; then 62 | if [ x$SESSION_ID == x ] ; then 63 | export SESSION_ID=`$SPINDLE --start-session` 64 | export STARTED_SPINDLE_SESSION=true 65 | fi 66 | export SPINDLE_OPTS="--run-in-session $SESSION_ID" 67 | fi 68 | 69 | export SPINDLE_BLUEGENE="BLUEGENE_TEST" 70 | if test "x$SPINDLE_BLUEGENE" == "xfalse"; then 71 | if [ $1 == --ldpreload ] ; then 72 | export SPINDLE_LD_PRELOAD="$LIBRARY_LIST" 73 | fi 74 | export SPINDLE_BGQ_LD_PRELOAD="false" 75 | else 76 | export SPINDLE_BGQ_LD_PRELOAD="true" 77 | fi 78 | 79 | export SPINDLE_FLAGS="--level=high" 80 | 81 | ./run_driver_rm $TEST_EXEC $* 82 | RESULT=$? 83 | 84 | if [ x$STARTED_SPINDLE_SESSION == xtrue ]; then 85 | $SPINDLE --end-session $SESSION_ID 86 | fi 87 | 88 | exit $RESULT 89 | 90 | -------------------------------------------------------------------------------- /testsuite/run_driver_unknown: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo Error. Spindle was not configured with support for a testing resource manager. 4 | echo Create a run_driver_RM file in spindle/testsuite/, where RM is a name for 5 | echo your resource manager. Then re-run configure with the option --with-testrm=RM. 6 | echo 7 | echo The run_driver_RM file should be a simple script that launches an MPI job in 8 | echo under Spindle in your environment. The arguments to your mpi job are passed 9 | echo on the run_driver_RM command line, and any arguments passed to runTests are 10 | echo forwarded on in the SPINDLE_TEST_ARGS environment variable. The \$SPINDLE 11 | echo environment variable will contain the path to the spindle executable. 12 | echo A basic example that uses mpirun is: 13 | echo 14 | echo \#!/bin/sh 15 | echo \$SPINDLE /usr/bin/mpirun \$\* 16 | echo 17 | exit 18 | 19 | -------------------------------------------------------------------------------- /testsuite/spindle_deactivated_template.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [[ "x$1" != "xspindletest" ]]; then 3 | echo Failed. Parameter not passed 4 | exit -1 5 | fi 6 | if [[ "x$SPINDLE_EXEC_TEST" != "xcorrect" ]]; then 7 | echo Failed. Environment not passed 8 | exit -1 9 | fi 10 | exec grep -q spindlens- /proc/self/maps 11 | -------------------------------------------------------------------------------- /testsuite/spindle_rc: -------------------------------------------------------------------------------- 1 | plugin.load { file="SPINDLE_LIB/libspindleflux.so" } 2 | -------------------------------------------------------------------------------- /testsuite/symbind_fileops.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | static int do_file_ops() 25 | { 26 | char buffer[4096]; 27 | struct stat buf; 28 | int fd; 29 | int result; 30 | pid_t pid = getpid(); 31 | 32 | fd = open("/proc/self/maps", O_RDONLY); 33 | if (fd == -1) { 34 | perror("Could not open"); 35 | return -1; 36 | } 37 | result = fstat(fd, &buf); 38 | if (result == -1) { 39 | perror("Could not fstat"); 40 | return -1; 41 | } 42 | 43 | result = read(fd, buffer, 8); 44 | if (result == -1) { 45 | perror("Could not read"); 46 | return -1; 47 | } 48 | 49 | close(fd); 50 | 51 | result = stat("/proc/self/status", &buf); 52 | if (result == -1) { 53 | perror("Could not stat"); 54 | return -1; 55 | } 56 | 57 | result = lstat("/proc/self/exe", &buf); 58 | if (result == -1) { 59 | perror("Could not lstat"); 60 | return -1; 61 | } 62 | 63 | memset(buffer, 0, sizeof(buffer)); 64 | result = readlink("/proc/self/exe", buffer, sizeof(buffer)); 65 | if (result == -1) { 66 | perror("Could not readlink"); 67 | return -1; 68 | } 69 | 70 | if (pid == 0) { 71 | fprintf(stderr, "Unexpected pid is 0\n"); 72 | return -1; 73 | } 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /testsuite/symbindlib.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include "symbind_fileops.c" 18 | 19 | #if defined(AUTORUN) 20 | #define CAT2(X, Y) X ## Y 21 | #define CAT(X, Y) CAT2(X, Y) 22 | #define FNAME CAT(dowork, AUTORUN) 23 | int FNAME() __attribute__((constructor)); 24 | #else 25 | #define FNAME dowork 26 | #endif 27 | 28 | int FNAME() 29 | { 30 | return do_file_ops(); 31 | } 32 | -------------------------------------------------------------------------------- /testsuite/symbindlib_g.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | static pid_t (*getpid_fptr)(); 25 | static int (*open_fptr)(const char *, int flags, ...); 26 | static ssize_t (*read_fptr)(int fd, void *buffer, size_t len); 27 | static int (*close_fptr)(int fd); 28 | static void* (*memset_fptr)(void *s, int c, size_t n); 29 | static ssize_t (*readlink_fptr)(const char *path, char *buf, size_t size); 30 | static void (*perror_fptr)(const char *s); 31 | static int (*fprintf_fptr)(FILE *stream, const char *format, ...); 32 | 33 | static int do_file_ops() 34 | { 35 | char buffer[4096]; 36 | int fd; 37 | int result; 38 | pid_t pid = getpid_fptr(); 39 | 40 | fd = open_fptr("/proc/self/maps", O_RDONLY); 41 | if (fd == -1) { 42 | perror_fptr("Could not open"); 43 | return -1; 44 | } 45 | result = read_fptr(fd, buffer, 8); 46 | if (result == -1) { 47 | perror_fptr("Could not read"); 48 | return -1; 49 | } 50 | 51 | close_fptr(fd); 52 | 53 | memset_fptr(buffer, 0, sizeof(buffer)); 54 | result = readlink_fptr("/proc/self/exe", buffer, sizeof(buffer)); 55 | if (result == -1) { 56 | perror_fptr("Could not readlink"); 57 | return -1; 58 | } 59 | 60 | if (pid == 0) { 61 | fprintf_fptr(stderr, "Unexpected pid is 0\n"); 62 | return -1; 63 | } 64 | return 0; 65 | } 66 | 67 | static void dowork() __attribute__((constructor)); 68 | static void dowork() 69 | { 70 | getpid_fptr = getpid; 71 | open_fptr = open; 72 | read_fptr = read; 73 | close_fptr = close; 74 | memset_fptr = memset; 75 | readlink_fptr = readlink; 76 | perror_fptr = perror; 77 | fprintf_fptr = fprintf; 78 | 79 | do_file_ops(); 80 | } 81 | -------------------------------------------------------------------------------- /testsuite/testoutput.c: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of Spindle. For copyright information see the COPYRIGHT 3 | file in the top level directory, or at 4 | https://github.com/hpc/Spindle/blob/master/COPYRIGHT 5 | 6 | This program is free software; you can redistribute it and/or modify it under 7 | the terms of the GNU Lesser General Public License (as published by the Free Software 8 | Foundation) version 2.1 dated February 1999. This program is distributed in the 9 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even the IMPLIED 10 | WARRANTY OF MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms 11 | and conditions of the GNU Lesser General Public License for more details. You should 12 | have received a copy of the GNU Lesser General Public License along with this 13 | program; if not, write to the Free Software Foundation, Inc., 59 Temple 14 | Place, Suite 330, Boston, MA 02111-1307 USA 15 | */ 16 | 17 | #include 18 | 19 | #if defined(__cplusplus) 20 | extern "C" { 21 | #endif 22 | void spindle_test_log_msg(char *s); 23 | #if defined(__cplusplus) 24 | } 25 | #endif 26 | 27 | void spindle_test_log_msg(char *s) 28 | { 29 | fprintf(stderr, "%s", s); 30 | } 31 | 32 | --------------------------------------------------------------------------------