Commit f009209a authored by Bernd Lietzow's avatar Bernd Lietzow 🐨

update to release 7.1.4

parent 0db578d4
# all variables used by package builds must be exported.
export BEEGFS_DEBUG
export BEEGFS_OPENTK_IBVERBS
export USER_CXXFLAGS
export USER_LDFLAGS
......
......@@ -59,6 +59,9 @@ You also have the choice between
the openssl, nss, or gnutls version of `libcurl-dev`. Choose the one you prefer.
## Building Packages
### For development systems
BeeGFS comes with a Makefile capable of building packages for the system on which it is executed.
These include all services, the client module and utilities.
......@@ -91,6 +94,20 @@ You may specify any other non-existent directory instead.
Note, however, that having `PACKAGE_DIR` on a NFS or similar network share may slow down
the build process significantly.
### For production systems, or from source snapshots
By default the packaging system generates version numbers suitable only for development
packages. Packages intended for installation on production systems must be built differently.
All instructions to build development packages (as given above) apply, but additionally the
package version must be explicitly set. This is done by passing `BEEGFS_VERSION=<version>`
in the make command line, e.g.
```
$ make package-deb PACKAGE_DIR=packages DEBUILD_OPTS="-j<n>" BEEGFS_VERSION=7.1.4-local1
```
Setting the version explicitly is required to generate packages that can be easily upgraded
with the system package manager.
## Building without packaging
To build the complete project without generating any packages,
......
......@@ -386,6 +386,18 @@ install -D client_module/build/dist/sbin/beegfs-setup-client \
install -D client_module/build/dist/etc/beegfs-client-mount-hook.example \
${RPM_BUILD_ROOT}/etc/beegfs/beegfs-client-mount-hook.example
##########
########## client-dkms
##########
cp client_module/build/dist/etc/*.conf ${RPM_BUILD_ROOT}/etc/beegfs/
mkdir -p ${RPM_BUILD_ROOT}/usr/src/beegfs-%{VER}
cp -r client_module/build ${RPM_BUILD_ROOT}/usr/src/beegfs-%{VER}
cp -r client_module/source ${RPM_BUILD_ROOT}/usr/src/beegfs-%{VER}
sed -e 's/__VERSION__/%{VER}/g' -e 's/__NAME__/beegfs/g' -e 's/__MODNAME__/beegfs/g' \
< client_module/dkms.conf.in \
> ${RPM_BUILD_ROOT}/usr/src/beegfs-%{VER}/dkms.conf
##########
########## client-devel
##########
......@@ -591,12 +603,34 @@ This package contains the BeeGFS mon server binaries.
%config(noreplace) /etc/default/beegfs-mon
/etc/init.d/beegfs-mon
/opt/beegfs/sbin/beegfs-mon
/opt/beegfs/scripts/grafana/
/usr/lib/systemd/system/beegfs-mon.service
/usr/lib/systemd/system/beegfs-mon@.service
%package mon-grafana
Summary: BeeGFS mon dashboards for Grafana
Group: Software/Other
BuildArch: noarch
%description mon-grafana
This package contains the BeeGFS mon dashboards to display monitoring data in Grafana.
The default dashboard setup requires both Grafana, and InfluxDB.
%post mon-grafana
%post_package beegfs-mon-grafana
%preun mon-grafana
%preun_package beegfs-mon-grafana
%files mon-grafana
%defattr(-,root,root)
/opt/beegfs/scripts/grafana/
%package admon
Summary: BeeGFS administration and monitoring daemon
......@@ -710,10 +744,11 @@ License: GPL v2
Group: Software/Other
BuildArch: noarch
requires: make, gcc, gcc-c++
conflicts: beegfs-client-dkms
%description client
This package contains binary objects of the closed source part of BeeGFS and
open source code to allow to build the client kernel module.
This package contains scripts, config and source files to build and
start beegfs-client.
%post client
%post_package beegfs-client
......@@ -741,6 +776,33 @@ touch /var/lib/beegfs/client/force-auto-build
%package client-dkms
Summary: BeeGFS client kernel module (DKMS version)
License: GPL v2
Group: Software/Other
BuildArch: noarch
requires: make, dkms
conflicts: beegfs-client
provides: beegfs-client
%description client-dkms
This package contains scripts, config and source files to build and
start beegfs-client. It uses DKMS to build the kernel module.
%post client-dkms
dkms install beegfs/%{VER}
%preun client-dkms
dkms remove beegfs/%{VER} --all
%files client-dkms
%defattr(-,root,root)
%config(noreplace) /etc/beegfs/beegfs-client.conf
/usr/src/beegfs-%{VER}
%package client-compat
Summary: BeeGFS client compat module, allows to run two different client versions.
......
......@@ -11,6 +11,7 @@ BEEOND_END_FILE_LIST="${BEEOND_FILENAME_PREFIX}files_end"
BEEOND_END_UPDATED_FILE_LIST="${BEEOND_FILENAME_PREFIX}files_end_updated"
BEEOND_START_DIR_LIST="${BEEOND_FILENAME_PREFIX}dirs_start"
BEEOND_END_DIR_LIST="${BEEOND_FILENAME_PREFIX}dirs_end"
BEEOND_END_UPDATED_DIR_LIST="${BEEOND_FILENAME_PREFIX}dirs_end_updated"
BEEOND_SESSION_FILE="${BEEOND_FILENAME_PREFIX}session"
BEEOND_BATCH_SIZE=20
......@@ -76,7 +77,7 @@ beeond_generate_file_list()
beeond_print_info \
"Generating file list ${LISTFILE}. Timestamp reference: ${REFERENCE_FILE}..."
find . ! -path ./${BEEOND_FILENAME_PREFIX}\* -type f -or -type l \
find . ! -path ./${BEEOND_FILENAME_PREFIX}\* \( -type f -or -type l \) \
\( -cnewer "${REFERENCE_FILE}" -or -newer "${REFERENCE_FILE}" \) \
-exec bash -c 'printf "%q\n" "$0"' {} \; \
| grep -v ^\\$ | sort > "${LISTFILE}"
......@@ -91,13 +92,29 @@ beeond_generate_directory_list()
{
local LOCAL_PATH="${1}"
local LISTFILE="${2}"
beeond_print_info "Generating directory list file ${LISTFILE}..."
local REFERENCE_FILE="${3}"
pushd "${LOCAL_PATH}"
find . ! -path . -type d \
-exec bash -c 'printf "%q\n" "$0"' {} \; \
| grep -v ^\\$ | sort > "${LISTFILE}"
if [ "${REFERENCE_FILE}" = "" ]
then # No reference file - just generate the full list (e.g. on startup).
beeond_print_info "Generating directory list ${LISTFILE}..."
find . ! -path . -type d \
-exec bash -c 'printf "%q\n" "$0"' {} \; \
| grep -v ^\\$ | sort > "${LISTFILE}"
else # Reference file given: Compare timestamps.
beeond_print_info \
"Generating directory list ${LISTFILE}. Timestamp reference: ${REFERENCE_FILE}..."
find . ! -path . -type d \
\( -cnewer "${REFERENCE_FILE}" -or -newer "${REFERENCE_FILE}" \) \
-exec bash -c 'printf "%q\n" "$0"' {} \; \
| grep -v ^\\$ | sort > "${LISTFILE}"
fi
popd
}
......@@ -274,20 +291,23 @@ beeond_copy_updated_files()
done; \
"
# Copy files into moved directories. (When a directory is renamed, the files in it don't have
# their timestamp updated. Therefore, we need to check all the new directories again).
# Copy files into updated directories. (When a directory is renamed or files
# are moved to a directory, the files in it don't have their timestamp
# updated. Therefore, we need to check all the updated directories again).
beeond_print_info "Copying back changed files (moved dirs):"
beeond_print_info "Copying back changed files (updated dirs):"
comm -13 "${LOCAL_PATH}/${BEEOND_START_DIR_LIST}" "${LOCAL_PATH}/${BEEOND_END_DIR_LIST}" | \
cut -b3- | \
${PARALLEL} -S "${NODE_LIST}" -j"${CONCURRENCY}" --pipe --recend "\n" \
-N${BEEOND_BATCH_SIZE} --controlmaster --will-cite \
" \
while read FILE; do \
cp -uv \"${LOCAL_PATH}/\${FILE}\" \"\`dirname \"${GLOBAL_PATH}/\${FILE}\"\`\"; \
done; \
"
pushd "${LOCAL_PATH}"
< "${LOCAL_PATH}/${BEEOND_END_UPDATED_DIR_LIST}" \
xargs -I{} find {} -maxdepth 1 \( -type f -or -type l \) | \
${PARALLEL} -S "${NODE_LIST}" -j"${CONCURRENCY}" --pipe --recend "\n" \
-N${BEEOND_BATCH_SIZE} --controlmaster --will-cite \
" \
while read FILE; do \
cp -uv \"${LOCAL_PATH}/\${FILE}\" \"\`dirname \"${GLOBAL_PATH}/\${FILE}\"\`\"; \
done; \
"
popd
}
# Stage in process: Copy all files from the global store to the local store.
......@@ -346,9 +366,11 @@ beeond_stage_out()
beeond_generate_file_list "${LOCAL_PATH}" "${LOCAL_PATH}/${BEEOND_END_FILE_LIST}"
beeond_generate_file_list "${LOCAL_PATH}" "${LOCAL_PATH}/${BEEOND_END_UPDATED_FILE_LIST}" \
${BEEOND_START_FILE_LIST}
"${BEEOND_START_FILE_LIST}"
beeond_generate_directory_list "${LOCAL_PATH}" "${LOCAL_PATH}/${BEEOND_END_DIR_LIST}"
beeond_generate_directory_list "${LOCAL_PATH}" "${LOCAL_PATH}/${BEEOND_END_UPDATED_DIR_LIST}" \
"${BEEOND_START_DIR_LIST}"
beeond_remove_removed_files "${GLOBAL_PATH}" "${LOCAL_PATH}" "${NODE_LIST}" "${CONCURRENCY}"
......
......@@ -11,8 +11,6 @@ $(eval \
&& echo "-D$(strip $1)"))
endef
ifeq ($(BEEGFS_OPENTK_IBVERBS),1)
ifneq ($(OFED_INCLUDE_PATH),)
OFED_DETECTION_PATH := $(OFED_INCLUDE_PATH)
else
......@@ -60,8 +58,6 @@ KERNEL_FEATURE_DETECTION += $(shell \
${OFED_DETECTION_PATH}/rdma/ib_verbs.h \
&& echo "-DOFED_UNSAFE_GLOBAL_RKEY")
endif # BEEGFS_OPENTK_IBVERBS
# Find out whether the kernel has a scsi/fc_compat.h file, which defines
# vlan_dev_vlan_id.
# Note: We need this, because some kernels (e.g. RHEL 5.9's 2.6.18) forgot this
......
......@@ -96,10 +96,7 @@ BEEGFS_CFLAGS += $(BEEGFS_CFLAGS_DEBUG)
endif
# OFED
ifeq ($(BEEGFS_OPENTK_IBVERBS),1)
BEEGFS_CFLAGS += -DBEEGFS_OPENTK_IBVERBS
endif
-include /etc/beegfs/beegfs-client-build.mk
ifneq ($(OFED_INCLUDE_PATH),)
BEEGFS_CFLAGS += -I$(OFED_INCLUDE_PATH)
......@@ -228,8 +225,6 @@ help:
@echo ' Set a different module and file system name.'
@echo ' '
@echo 'Infiniband (RDMA) arguments (optional):'
@echo ' BEEGFS_OPENTK_IBVERBS=1:'
@echo ' Defining this enables ibverbs support.'
@echo ' OFED_INCLUDE_PATH=<path>:'
@echo ' Path to OpenFabrics Enterpise Distribution kernel include directory, e.g.'
@echo ' "/usr/src/openib/include". (If not defined, the standard kernel headers'
......
......@@ -88,10 +88,6 @@ BEEGFS_CFLAGS += '-DBEEGFS_VERSION=\"$(BEEGFS_VERSION)\"'
endif
# OFED
ifeq ($(BEEGFS_OPENTK_IBVERBS),1)
BEEGFS_CFLAGS += -DBEEGFS_OPENTK_IBVERBS
endif
ifneq ($(OFED_INCLUDE_PATH),)
BEEGFS_CFLAGS += -I$(OFED_INCLUDE_PATH)
......@@ -180,8 +176,6 @@ help:
@echo ' Set a different module and file system name.'
@echo ' '
@echo 'Infiniband (RDMA) arguments (optional):'
@echo ' BEEGFS_OPENTK_IBVERBS=1:'
@echo ' Defining this enables ibverbs support.'
@echo ' OFED_INCLUDE_PATH=<path>:'
@echo ' Path to OpenFabrics Enterpise Distribution kernel include directory, e.g.'
@echo ' "/usr/src/openib/include". (If not defined, the standard kernel headers'
......
......@@ -21,10 +21,6 @@
# RDMA Support Notes
# ==================
# If you want to build BeeGFS with RDMA support based on ibverbs for InfiniBand,
# RDMA over converged Ethernet (RoCE) or Omni-Path, add
# "BEEGFS_OPENTK_IBVERBS=1" to the "buildArgs" below.
#
# If you installed InfiniBand kernel modules from OpenFabrics OFED, then also
# define the correspsonding header include path by adding
# "OFED_INCLUDE_PATH=<path>" to the "buildArgs", where <path> usually is
......@@ -44,10 +40,10 @@
# here.
#
# Example1:
# buildArgs=-j8 BEEGFS_OPENTK_IBVERBS=1
# buildArgs=-j8
#
# Example2 (see "RDMA Support Notes" above):
# buildArgs=-j8 BEEGFS_OPENTK_IBVERBS=1 OFED_INCLUDE_PATH=/usr/src/openib/include
# buildArgs=-j8 OFED_INCLUDE_PATH=/usr/src/openib/include
#
# Default:
# buildArgs=-j8
......
PACKAGE_NAME="__NAME__"
PACKAGE_VERSION="__VERSION__"
BUILT_MODULE_NAME[0]="__MODNAME__"
BUILT_MODULE_LOCATION[0]="build/"
DEST_MODULE_LOCATION[0]="/kernel/fs/beegfs/"
MAKE[0]="make -C build module 'KDIR=$kernel_source_dir' TARGET=__MODNAME__ BEEGFS_VERSION=__VERSION__"
CLEAN="make -C build clean"
AUTOINSTALL="yes"
\ No newline at end of file
......@@ -60,6 +60,16 @@ static size_t Config_fs_read(struct file *file, char *buf, size_t size, loff_t *
return readRes;
}
static bool assignKeyIfNotZero(const char* key, const char* strVal, int* const intVal) {
const int tempVal = StringTk_strToInt(strVal);
if (tempVal <= 0 || intVal == NULL) {
return false;
}
*intVal = tempVal;
return true;
}
/**
* @param mountConfig will be copied (not owned by this object)
*/
......@@ -302,16 +312,28 @@ bool _Config_applyConfigMap(Config* this, bool enableException)
this->connPortShift = StringTk_strToInt(valueStr);
else
if(!strcmp(keyStr, "connClientPortUDP") )
this->connClientPortUDP = StringTk_strToInt(valueStr);
{
if (!assignKeyIfNotZero(keyStr, valueStr, &this->connClientPortUDP))
goto bad_config_elem;
}
else
if(!strcmp(keyStr, "connMgmtdPortUDP") )
this->connMgmtdPortUDP = StringTk_strToInt(valueStr);
{
if (!assignKeyIfNotZero(keyStr, valueStr, &this->connMgmtdPortUDP))
goto bad_config_elem;
}
else
if(!strcmp(keyStr, "connHelperdPortTCP") )
this->connHelperdPortTCP = StringTk_strToInt(valueStr);
{
if (!assignKeyIfNotZero(keyStr, valueStr, &this->connHelperdPortTCP))
goto bad_config_elem;
}
else
if(!strcmp(keyStr, "connMgmtdPortTCP") )
this->connMgmtdPortTCP = StringTk_strToInt(valueStr);
{
if (!assignKeyIfNotZero(keyStr, valueStr, &this->connMgmtdPortTCP))
goto bad_config_elem;
}
else
if(!strcmp(keyStr, "connUseRDMA") )
this->connUseRDMA = StringTk_strToBool(valueStr);
......
......@@ -74,7 +74,11 @@ void _RDMASocket_uninit(Socket* this)
bool RDMASocket_rdmaDevicesExist(void)
{
return IBVSocket_rdmaDevicesExist();
#if defined(CONFIG_INFINIBAND) || defined(CONFIG_INFINIBAND_MODULE)
return true;
#else
return false;
#endif
}
bool _RDMASocket_connectByIP(Socket* this, struct in_addr* ipaddress, unsigned short port)
......
#ifdef BEEGFS_OPENTK_IBVERBS
#if defined(CONFIG_INFINIBAND) || defined(CONFIG_INFINIBAND_MODULE)
#include "IBVBuffer.h"
#include "IBVSocket.h"
......
#ifndef IBVBuffer_h_aMQFNfzrjbEHDOcv216fi
#define IBVBuffer_h_aMQFNfzrjbEHDOcv216fi
#ifdef BEEGFS_OPENTK_IBVERBS
#if defined(CONFIG_INFINIBAND) || defined(CONFIG_INFINIBAND_MODULE)
#include <rdma/ib_verbs.h>
#include <rdma/rdma_cm.h>
......
#ifdef BEEGFS_OPENTK_IBVERBS
#include "IBVSocket.h"
#if defined(CONFIG_INFINIBAND) || defined(CONFIG_INFINIBAND_MODULE)
#ifdef KERNEL_HAS_SCSI_FC_COMPAT
#include <scsi/fc_compat.h> // some kernels (e.g. rhel 5.9) forgot this in their rdma headers
#endif // KERNEL_HAS_SCSI_FC_COMPAT
#include "IBVSocket.h"
#include <common/toolkit/TimeTk.h>
#include <linux/in.h>
......@@ -1859,4 +1860,4 @@ const char* __IBVSocket_wcStatusStr(int wcStatusCode)
}
}
#endif // BEEGFS_OPENTK_IBVERBS
#endif
......@@ -71,7 +71,12 @@ struct IBVCommConfig
};
#ifdef BEEGFS_OPENTK_IBVERBS
#if defined(CONFIG_INFINIBAND) || defined(CONFIG_INFINIBAND_MODULE)
#include <rdma/ib_verbs.h>
#include <rdma/rdma_cm.h>
#include <rdma/ib_cm.h>
#include "IBVBuffer.h"
enum IBVSocketConnState;
......@@ -215,7 +220,7 @@ struct IBVSocket
};
#else // BEEGFS_OPENTK_IBVERBS not defined in this case
#else
struct IBVSocket
......@@ -225,6 +230,6 @@ struct IBVSocket
};
#endif // BEEGFS_OPENTK_IBVERBS
#endif
#endif /*OPENTK_IBVSOCKET_H_*/
#ifndef BEEGFS_OPENTK_IBVERBS
#include "IBVSocket.h"
#if !defined(CONFIG_INFINIBAND) && !defined(CONFIG_INFINIBAND_MODULE)
bool IBVSocket_init(IBVSocket* _this)
{
......@@ -85,5 +84,5 @@ void IBVSocket_setTypeOfService(IBVSocket* _this, int typeOfService)
}
#endif // BEEGFS_OPENTK_IBVERBS
#endif
......@@ -97,3 +97,4 @@ module_exit(exit_fhgfs_client)
MODULE_LICENSE(BEEGFS_LICENSE);
MODULE_DESCRIPTION("BeeGFS parallel file system client (http://www.beegfs.com)");
MODULE_AUTHOR("Fraunhofer ITWM, CC-HPC");
MODULE_ALIAS("fs-" BEEGFS_MODULE_NAME_STR);
SHELL = /bin/bash
EXE = beegfs-client-tests
BEEGFS_VERSION_PATH ?= ../../beegfs-version
BEEGFS_COMMON_PATH ?= ../../common/
BEEGFS_THIRDPARTY_PATH ?= ../../thirdparty/
BEEGFS_AUTO_CXX11_SCRIPT_PATH ?= $(BEEGFS_COMMON_PATH)/build/check-cxx-for-c++11.sh
CPPUNIT_INC_PATH ?= $(BEEGFS_THIRDPARTY_PATH)/source/cppunit_install/usr/local/include
CXX ?= g++
CXXFLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 \
-I../source -I$(CPPUNIT_INC_PATH) \
-pthread -Wall -fmessage-length=0 -fno-strict-aliasing \
-Wunused-variable -Woverloaded-virtual -Wextra -Wno-unused-parameter \
-ggdb3 $(USER_CXXFLAGS)
CXXFLAGS_RELEASE = -O3 -Wuninitialized
CXXFLAGS_DEBUG = -O0 -ggdb3
THIRTPARTY_LIBS = $(BEEGFS_THIRDPARTY_PATH)/build/libcppunit.a
LDFLAGS = -L$(BEEGFS_COMMON_PATH)/build \
-L$(BEEGFS_THIRDPARTY_PATH)/build -pthread -rdynamic -lrt \
$(THIRTPARTY_LIBS) -rdynamic -ldl $(USER_LDFLAGS)
LDFLAGS_RELASE = -O3
LDFLAGS_DEBUG = -O0
SOURCES = $(shell find ../source -name '*.cpp')
OBJECTS = $(SOURCES:.cpp=.o)
CLEANUP_OBJECTS = $(shell find ../source -name '*.o')
DEPENDENCY_FILES = $(shell find ../source -name '*.d')
ifeq ($(BEEGFS_DEBUG),)
CXXFLAGS += $(CXXFLAGS_RELEASE)
LDFLAGS += $(LDFLAGS_RELASE)
else
CXXFLAGS += $(CXXFLAGS_DEBUG)
LDFLAGS += $(LDFLAGS_DEBUG)
endif
# beegfs version
# "override", because we don't want BEEGFS_VERSION(_CODE) from the environment.
# VER and RELEASE_STR are the variables that can be set by the environment.
override BEEGFS_VERSION := $(shell bash -c \
"VER=$(VER) RELEASE_STR=$(RELEASE_STR) $(BEEGFS_VERSION_PATH) --print_version")
override BEEGFS_VERSION_CODE := $(shell bash -c \
"VER=$(VER) RELEASE_STR=$(RELEASE_STR) $(BEEGFS_VERSION_PATH) --print_version_code")
CXXFLAGS += -DBEEGFS_VERSION=\"$(BEEGFS_VERSION)\" -DBEEGFS_VERSION_CODE=$(BEEGFS_VERSION_CODE)
# automatic selection of c++11 if compiler is g++ with version >=4.8
AUTO_CXX11 ?= $(shell $(BEEGFS_AUTO_CXX11_SCRIPT_PATH) $(CXX) )
ifeq ($(AUTO_CXX11),1)
CXXFLAGS += -std=c++11
endif
all: test_version $(SOURCES) $(EXE)
test_version:
@# just call the beegfs-version script to check whether it returns an error. the script output is
@# used in other places of this makefile and we want to make sure that we don't mess up version
@# tags in the binary with script errors.
@echo "beegfs version check..."
@$(BEEGFS_VERSION_PATH) --verbose
$(EXE): $(OBJECTS)
$(CXX) -o $(EXE) $(OBJECTS) $(LDFLAGS)
.cpp.o:
$(CXX) $(CXXFLAGS) -c $(@:.o=.cpp) -E -MMD -MF$(@:.o=.d) -MT$(@) -o/dev/null
$(DISTCC) $(CXX) $(CXXFLAGS) -o$(@) -c $(@:.o=.cpp)
clean:
rm -rf $(CLEANUP_OBJECTS) $(DEPENDENCY_FILES) $(EXE) $(EXE)-unstripped
help:
@echo 'Optional Arguments:'
@echo ' CXX=<compiler>:'
@echo ' Specifies a c++ compiler.'
@echo ' DISTCC=distcc:'
@echo ' Enables the usage of distcc.'
# Include dependency files
ifneq ($(DEPENDENCY_FILES),)
include $(DEPENDENCY_FILES)
endif
#include "Config.h"
#include <getopt.h>
#include <iostream>
#include <string>
std::string Config::dir1;
std::string Config::dir2;
bool Config::useVectorFunctions;
enum { F_DIR_1, F_DIR_2, F_USE_VECTORS, FLAG_COUNT };
static int requiredOptions[] = {
F_DIR_2, F_DIR_2
};
static struct option options[] = {
{ "dir1", required_argument, nullptr, F_DIR_1 },
{ "dir2", required_argument, nullptr, F_DIR_2 },
{ "vectors", no_argument, nullptr, F_USE_VECTORS },
{ nullptr, 0, nullptr, 0 },
};
static const char* flagNameFor(int flag)
{
for(auto& opt : options)
{
if(opt.val == flag)
return opt.name;
}
return "(unknown flag)";
}
bool Config::parse(int argc, char* argv[])
{
bool flagsSeen[FLAG_COUNT] = {};
bool fail = false;
while(true)
{
int flag;
flag = getopt_long(argc, argv, "", options, nullptr);
if(flag == -1)
break;
if(flagsSeen[flag])
{
std::cout << "error: duplicate value " << flagNameFor(flag) << "\n";
fail = true;
}
flagsSeen[flag] = true;
switch(flag)
{
case F_DIR_1:
dir1 = optarg;
break;
case F_DIR_2:
dir2 = optarg;
break;
case F_USE_VECTORS:
useVectorFunctions = true;
break;
}
}
for(int required : requiredOptions)
{
if(!flagsSeen[required])
{
std::cout << "error: required --" << flagNameFor(required) << " missing\n";
fail = true;
}
}
return !fail;
}
#ifndef source_Config_h_jEVyxglaXM5kTfYzNu0Hu
#define source_Config_h_jEVyxglaXM5kTfYzNu0Hu
#include <string>
class Config {
private:
Config() = delete;
static std::string dir1;
static std::string dir2;
static bool useVectorFunctions;
public:
static bool parse(int argc, char* argv[]);
static const std::string& getDir1() { return dir1; }
static const std::string& getDir2() { return dir2; }
static bool getUseVectorFunctions() { return useVectorFunctions; }
};
#endif
#include "FaultInject.h"
#include <fstream>
#include <iostream>
static const std::string& getDebugFSMount()
{
static std::string debugFSMount;
if(!debugFSMount.empty() )
return debugFSMount;
std::ifstream mounts("/proc/mounts");
if(!mounts)
throw std::runtime_error("could not open /proc/mounts to locate debugfs");
while(mounts && !mounts.eof() )
{
std::string device, mount, fsType;
std::getline(mounts, device, ' ');
std::getline(mounts, mount, ' ');
std::getline(mounts, fsType, ' ');
if(fsType == "debugfs")
{
debugFSMount = mount;
return debugFSMount;
}
std::getline(mounts, mount);
}
throw std::runtime_error("could not locate debugfs, not mounted?");
}
static void writeFileAt(const SafeFD& dir, const std::string& file, const std::string& data)
{
auto fd = SafeFD::openAt(dir, file, O_WRONLY);
auto writeRes = ::write(fd.raw(), data.c_str(), data.size() );
if(writeRes != (int) data.size() )
throw std::runtime_error("could not write " + file);
}
InjectFault::InjectFault(const char* type, bool quiet)
: faultDir(SafeFD::open(getDebugFSMount() + "/beegfs/fault/" + type, O_DIRECTORY) )
{
writeFileAt(this->faultDir, "interval", "1");