### Install BLKSNAP Project Components Source: https://github.com/veeam/blksnap/blob/master/README.md This command installs the compiled BLKSNAP components to the system's standard directories. While this method works, it is generally recommended to use pre-built packages (e.g., Debian or RPM packages) for better system management and easier uninstallation. ```bash sudo make install ``` -------------------------------- ### Install Kernel Build Prerequisites (Debian/Ubuntu) Source: https://github.com/veeam/blksnap/blob/master/doc/README-upstream-kernel.md Installs necessary packages for building the Linux kernel on Debian and derivative systems, including development tools and libraries. ```bash sudo apt install wget build-essential bison flex libncurses-dev libssl-dev libelf-dev dwarves ``` -------------------------------- ### Install BLKSNAP Build Dependencies (RHEL/CentOS/Fedora) Source: https://github.com/veeam/blksnap/blob/master/README.md This command installs the necessary development packages for building BLKSNAP components on RPM-based systems. It includes `g++` for C++ compilation, `cmake` for build system generation, `libuuid-devel` for UUID library, `boost-static` for static Boost libraries, `libstdc++-static` for static C++ standard library, and `openssl-static` for static OpenSSL libraries. ```bash sudo yum install g++ cmake libuuid-devel boost-static libstdc++-static openssl-static ``` -------------------------------- ### Install BLKSNAP Build Dependencies (Debian/Ubuntu) Source: https://github.com/veeam/blksnap/blob/master/README.md This command installs the required development packages for building BLKSNAP components on Debian-based systems. It includes `g++` for C++ compilation, `cmake` for build system generation, `uuid-dev` for UUID library, `libboost-program-options-dev` and `libboost-filesystem-dev` for Boost libraries, and `libssl-dev` for OpenSSL development files. ```bash sudo apt install g++ cmake uuid-dev libboost-program-options-dev libboost-filesystem-dev libssl-dev ``` -------------------------------- ### Build blksnap Deb Packages Source: https://github.com/veeam/blksnap/blob/master/README.md This snippet provides the necessary commands to install build dependencies and then execute the blksnap package build script. It assumes a Debian/Ubuntu-based system and requires a 'VERSION' variable to be set for the build script. ```bash sudo apt install g++ cmake uuid-dev libboost-program-options-dev libboost-filesystem-dev libssl-dev debhelper cd ./pkg/deb ./build-blksnap.sh ${VERSION} ``` -------------------------------- ### Uninstall BLKSNAP Project Components Source: https://github.com/veeam/blksnap/blob/master/README.md This command removes the BLKSNAP components that were previously installed using `sudo make install`. It should be used when direct installation was performed and the components need to be uninstalled from the system. ```bash sudo make uninstall ``` -------------------------------- ### Configure and Build blksnap Static Library with CMake Source: https://github.com/veeam/blksnap/blob/master/lib/blksnap/CMakeLists.txt This CMake script sets up the build environment for the `blksnap` static library. It specifies CMake version requirements, project name, C++ standard (C++14), compiler flags for static linking, and locates necessary external libraries like Boost filesystem and libuuid. It then defines the source files, creates a static library, sets its output name, and specifies include and installation directories for the library and its headers. ```CMake cmake_minimum_required(VERSION 3.5) project(blksnap-dev) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc -pthread") set(Boost_USE_STATIC_LIBS ON) FIND_PACKAGE( Boost COMPONENTS filesystem REQUIRED) FIND_LIBRARY(LIBUUID_LIBRARY libuuid.so REQUIRED) if (NOT LIBUUID_LIBRARY) message(FATAL_ERROR "libuuid not found. please install uuid-dev or libuuid-devel package.") endif () set(SOURCE_FILES OpenFileHolder.cpp Snapshot.cpp Tracker.cpp Cbt.cpp Service.cpp Session.cpp ) add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES}) set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "blksnap") target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../include) install(TARGETS ${PROJECT_NAME} DESTINATION /usr/lib) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../include/blksnap DESTINATION /usr/include/blksnap FILES_MATCHING PATTERN "*.h") ``` -------------------------------- ### Install Kernel Debian Image Package Source: https://github.com/veeam/blksnap/blob/master/doc/README-upstream-kernel.md Installs the generated Linux kernel image Debian package using dpkg. The placeholder values for version and architecture must be replaced with the actual package details. ```bash sudo dpkg -i linux-image-_.deb ``` -------------------------------- ### Configure blksnap-tools Project with CMake Source: https://github.com/veeam/blksnap/blob/master/tools/blksnap/CMakeLists.txt This CMake script sets up the blksnap-tools project. It specifies CMake version requirements, C++ standard, compiler flags for static linking, finds and links necessary libraries (Boost and libuuid), defines an executable, and sets its installation path. ```CMake cmake_minimum_required(VERSION 3.5) project(blksnap-tools) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc") set(Boost_USE_STATIC_LIBS ON) FIND_PACKAGE( Boost COMPONENTS program_options filesystem REQUIRED) FIND_LIBRARY(LIBUUID_LIBRARY libuuid.so REQUIRED) if (NOT LIBUUID_LIBRARY) message(FATAL_ERROR "libuuid not found. please install uuid-dev or libuuid-devel package.") endif () add_executable(${PROJECT_NAME} main.cpp) set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "blksnap") set(TOOLS_LIBS ${LIBUUID_LIBRARY} blksnap-dev Boost::filesystem Boost::program_options) target_link_libraries(${PROJECT_NAME} PRIVATE ${TOOLS_LIBS}) target_include_directories(${PROJECT_NAME} PRIVATE ./) install(TARGETS ${PROJECT_NAME} DESTINATION /usr/sbin) ``` -------------------------------- ### Build Kernel Debian Packages Source: https://github.com/veeam/blksnap/blob/master/doc/README-upstream-kernel.md Compiles the kernel and creates Debian packages (.deb files) for easy installation and removal on Debian-based systems. ```bash make deb-pkg ``` -------------------------------- ### APIDOC: blksnap Console Tool Usage Source: https://github.com/veeam/blksnap/blob/master/doc/blksnap.md Documents the blksnap command-line tool, providing access to detailed built-in help for commands and general usage. Users can get a list of commands or specific command descriptions. ```Bash blksnap --help blksnap --help ``` -------------------------------- ### CMake Build Configuration for blksnap-tests Project Source: https://github.com/veeam/blksnap/blob/master/tests/cpp/CMakeLists.txt This CMakeLists.txt file configures the build system for the `blksnap-tests` project. It specifies the C++ standard (C++14), sets compiler flags for static linking, and manages external dependencies such as Boost, libuuid, and OpenSSL. The configuration defines and links multiple test executables, including `test_corrupt`, `test_cbt`, `test_boundary`, and `test_performance`, ensuring they are linked with necessary libraries and include directories. Finally, it sets up installation rules for the compiled tests and related scripts. ```CMake # SPDX-License-Identifier: GPL-2.0+ cmake_minimum_required(VERSION 3.5) project(blksnap-tests) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc -pthread") set(Boost_USE_STATIC_LIBS ON) FIND_PACKAGE( Boost COMPONENTS program_options filesystem REQUIRED) FIND_LIBRARY(LIBUUID_LIBRARY libuuid.so REQUIRED) if (NOT LIBUUID_LIBRARY) message(FATAL_ERROR "libuuid not found. please install uuid-dev or libuuid-devel package.") endif () set(OPENSSL_USE_STATIC_LIBS TRUE) find_package(OpenSSL REQUIRED) if (NOT OPENSSL_LIBRARIES) message(FATAL_ERROR "openssl not found. please install libssl-dev package.") endif () add_subdirectory(helpers) set(TESTS_LIBS blksnap-dev Helpers::Lib Boost::program_options Boost::filesystem ${LIBUUID_LIBRARY}) set(TEST_CORRUPT test_corrupt) add_executable(${TEST_CORRUPT} TestSector.cpp corrupt.cpp) target_link_libraries(${TEST_CORRUPT} PRIVATE ${TESTS_LIBS}) target_include_directories(${TEST_CORRUPT} PRIVATE ./) set(TEST_CBT test_cbt) add_executable(${TEST_CBT} cbt.cpp) target_link_libraries(${TEST_CBT} PRIVATE ${TESTS_LIBS}) target_include_directories(${TEST_CBT} PRIVATE ./) set(TEST_BOUNDARY test_boundary) add_executable(${TEST_BOUNDARY} TestSector.cpp boundary.cpp) target_link_libraries(${TEST_BOUNDARY} PRIVATE ${TESTS_LIBS}) target_include_directories(${TEST_BOUNDARY} PRIVATE ./) set(TEST_PERFORMANCE test_performance) add_executable(${TEST_PERFORMANCE} performance.cpp) target_link_libraries(${TEST_PERFORMANCE} PRIVATE ${TESTS_LIBS}) target_include_directories(${TEST_PERFORMANCE} PRIVATE ./) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../ DESTINATION /opt/blksnap/tests USE_SOURCE_PERMISSIONS PATTERN "*.sh" PATTERN "cpp" EXCLUDE ) install(TARGETS ${TEST_CORRUPT} ${TEST_CBT} ${TEST_DIFF_STORAGE} ${TEST_BOUNDARY} ${TEST_PERFORMANCE} DESTINATION /opt/blksnap/tests ) ``` -------------------------------- ### APIDOC: blksnap::ICbt Class Definition Source: https://github.com/veeam/blksnap/blob/master/doc/blksnap.md Documents the blksnap::ICbt class, which provides access to the block device change tracker data. It includes methods for creating an interaction object, retrieving change tracker information, reading change tables, and getting snapshot image names. ```APIDOC class blksnap::ICbt Description: Allows accessing the data of the change tracker. Methods: static Create(): Creates an object to interact with the block device change tracker. GetCbtInfo(): Provides information about the current state of the change tracker for a block device. GetCbtData(): Allow reading the table of changes. GetImage(): Provide the name of the block device for the snapshot image. GetError(): Allows checking the snapshot status of a block device. ``` -------------------------------- ### Build BLKSNAP Project Components Source: https://github.com/veeam/blksnap/blob/master/README.md These commands compile the BLKSNAP library, tools, and tests using CMake and Make. The `cmake .` command configures the build system based on the `CMakeLists.txt` in the current directory, and `make` then compiles the source code according to the generated build files. ```bash cmake . make ``` -------------------------------- ### Run All BLKSNAP Usage Tests Source: https://github.com/veeam/blksnap/blob/master/README.md This snippet provides commands to execute all BLKSNAP usage tests. It demonstrates how to change the working directory to the tests directory and run the `all.sh` script, with an option to log the output to a file. This requires `sudo` privileges and assumes the tests are located at `/opt/blksnap/tests`. ```bash # change working directory to the tests one, for example for debian package is /opt/blksnap/tests cd /opt/blksnap/tests # execute all tests script sudo ./all.sh # or for logging the output to a file sudo ./all.sh 2>&1 | tee -a /tmp/blksnap_test_$(date -u '+%Y-%m-%d_%H-%M-%S').log ``` -------------------------------- ### Configure blksnap Project with CMake Source: https://github.com/veeam/blksnap/blob/master/CMakeLists.txt This CMake script sets up the build environment for the 'blksnap' project. It specifies C++14 as the standard, includes subdirectories for libraries, tools, and tests, and conditionally adds an 'uninstall' target if a `cmake_uninstall.cmake.in` file exists. ```CMake cmake_minimum_required(VERSION 3.5) project(blksnap) set(CMAKE_CXX_STANDARD 14) add_subdirectory(${CMAKE_SOURCE_DIR}/lib/blksnap) add_subdirectory(${CMAKE_SOURCE_DIR}/tools/blksnap) add_subdirectory(${CMAKE_SOURCE_DIR}/tests/cpp) if(EXISTS ${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in) configure_file(${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake @ONLY ) add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") endif() ``` -------------------------------- ### Configure Kernel Options (Menu-driven) Source: https://github.com/veeam/blksnap/blob/master/doc/README-upstream-kernel.md Launches a menu-driven interface to manually configure kernel options, specifically used here to enable blksnap under "Device drivers" -> "Block devices". ```bash make menuconfig ``` -------------------------------- ### Configure CMake Project for C++ Helper Library Source: https://github.com/veeam/blksnap/blob/master/tests/cpp/helpers/CMakeLists.txt This snippet sets up a CMake project, defines source files for a C++ helper library, and creates both a static library and an alias for it. It requires CMake version 3.5 or higher to ensure compatibility with modern CMake features. ```CMake # SPDX-License-Identifier: GPL-2.0+ cmake_minimum_required(VERSION 3.5) project(helpers) set(SOURCE_FILES Log.cpp BlockDevice.cpp RandomHelper.cpp ) add_library(${PROJECT_NAME} ${SOURCE_FILES}) add_library(Helpers::Lib ALIAS ${PROJECT_NAME}) ``` -------------------------------- ### Copy Current Kernel Configuration Source: https://github.com/veeam/blksnap/blob/master/doc/README-upstream-kernel.md Copies the currently running kernel's configuration file to the kernel source directory as .config, serving as a base for the new build. ```bash cp /boot/config-`uname -r` .config ``` -------------------------------- ### blksnap::CSnapshot C++ Class API Source: https://github.com/veeam/blksnap/blob/master/doc/blksnap.md A C++ wrapper for the blksnap module's snapshot management interface, implementing various ioctl calls for snapshot creation, collection, taking, destruction, and event waiting. It provides both static methods for module-wide operations and instance methods for specific snapshot management. ```APIDOC class blksnap::CSnapshot: Description: Thin C++ wrapper for the blksnap module management interface (ioctl: IOCTL_BLKSNAP_VERSION, IOCTL_BLKSNAP_SNAPSHOT_CREATE, IOCTL_BLKSNAP_SNAPSHOT_COLLECT, IOCTL_BLKSNAP_SNAPSHOT_TAKE, IOCTL_BLKSNAP_SNAPSHOT_DESTROY, IOCTL_BLKSNAP_SNAPSHOT_WAIT_EVENT) Static Methods: Collect(): Allows getting a list of UUIDs of all snapshots of the blksnap module Version(): Get the module version Create(): Creates an instance of blksnap::CSnapshot class; module creates a snapshot to which devices can be added Open(uuid): Creates an instance of blksnap::CSnapshot class for an existing snapshot by its UUID Methods: Take(): Take snapshot Destroy(): Destroy snapshot WaitEvent(): Allows receiving events about changes in the state of snapshot Id(): Requests a snapshot UUID ``` -------------------------------- ### blksnap Kernel Module ioctl Interface Source: https://github.com/veeam/blksnap/blob/master/doc/blksnap.md Details the ioctl commands for interacting with the blksnap kernel module, including attaching/detaching filters and sending control commands. It also mentions the /dev/blksnap-control file for snapshot management. ```APIDOC ioctl Commands: BLKFILTER_ATTACH: Attach filter to a block device BLKFILTER_DETACH: Detach filter BLKFILTER_CTL: Send control commands to the filter Control File: /dev/blksnap-control: Used for transmitting snapshot management commands to the module ``` -------------------------------- ### SPDX License Identifiers for Source File Headers Source: https://github.com/veeam/blksnap/blob/master/CONTRIBUTING.md Specifies the required SPDX License Identifiers to be included in the header comments of source files, categorized by their intended use: kernel modules, tools/tests, and libraries/includes. ```Plaintext SPDX-License-Identifier: GPL-2.0-only ``` ```Plaintext SPDX-License-Identifier: GPL-2.0-or-later ``` ```Plaintext SPDX-License-Identifier: LGPL-3.0-or-later ``` -------------------------------- ### Update Kernel Configuration (Interactive) Source: https://github.com/veeam/blksnap/blob/master/doc/README-upstream-kernel.md Updates the kernel configuration to the latest version, interactively prompting the user for new options and allowing manual enabling of features like blksnap. ```bash make oldconfig ``` -------------------------------- ### APIDOC: blksnap::Version Function Definition Source: https://github.com/veeam/blksnap/blob/master/doc/blksnap.md Documents the blksnap::Version function, which allows retrieving the version of the kernel module. ```APIDOC function blksnap::Version() Description: Allows getting the version of the kernel module. ``` -------------------------------- ### blksnap::CTracker C++ Class API Source: https://github.com/veeam/blksnap/blob/master/doc/blksnap.md A C++ wrapper for the kernel's block device filter ioctl interface, simplifying operations like attaching/detaching filters and managing change tracking. It provides methods to query CBT status, read CBT maps, mark dirty blocks, and manage snapshots. ```APIDOC class blksnap::CTracker: Description: Thin C++ wrapper for the block device filter interface (ioctl: BLKFILTER_ATTACH, BLKFILTER_DETACH, BLKFILTER_CTL) Methods: Attach(): Attaches the 'blksnap' block layer filter Detach(): Detaches the filter CbtInfo(): Provides the status of the change tracker for the block device ReadCbtMap(): Reads the block device change tracker table MarkDirtyBlock(): Sets the 'dirty blocks' of the change tracker SnapshotAdd(): Adds a block device to the snapshot SnapshotInfo(): Allows getting the snapshot status of a block device ``` -------------------------------- ### Update Kernel Configuration (Default) Source: https://github.com/veeam/blksnap/blob/master/doc/README-upstream-kernel.md Automatically sets default values for all new kernel configuration options, providing a quicker way to update the .config file. ```bash make olddefconfig ``` -------------------------------- ### APIDOC: blksnap::ISession Class Definition Source: https://github.com/veeam/blksnap/blob/master/doc/blksnap.md Documents the blksnap::ISession class, responsible for creating and managing snapshot sessions. It includes a worker thread for status checks and error retrieval, with the destructor handling snapshot destruction. ```APIDOC class blksnap::ISession Description: Creates a snapshot session. Methods: static Create(): Creates an instance of the class that creates, takes and holds the snapshot. GetError(): Allows reading a message from the snapshot status queue. ``` -------------------------------- ### APIDOC: blksnap::SRange Struct Definition Source: https://github.com/veeam/blksnap/blob/master/doc/blksnap.md Documents the blksnap::SRange struct, which describes an area of a block device. It combines the offset from the beginning of the block device and the size of the area in the form of the number of sectors. ```APIDOC struct blksnap::SRange Description: Describes the area of the block device, combines the offset from the beginning of the block device and the size of the area in the form of the number of sectors. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.