Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package zswap-cli for openSUSE:Factory checked in at 2026-10-18 19:26:16 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/zswap-cli (Old) and /work/SRC/openSUSE:Factory/.zswap-cli.new.3698736 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "zswap-cli" Sun Oct 18 19:26:16 2026 rev:7 rq:1385970 version:2.0.0 Changes: -------- --- /work/SRC/openSUSE:Factory/zswap-cli/zswap-cli.changes 2026-07-06 12:37:45.922733852 +0200 +++ /work/SRC/openSUSE:Factory/.zswap-cli.new.3698736/zswap-cli.changes 2026-10-18 19:26:58.402918939 +0200 @@ -1,0 +2,12 @@ +Sun Oct 18 10:53:48 UTC 2026 - Martin Pluskal <[email protected]> + +- Update to 2.0.0: + * Breaking: default config moved from /etc/zswap-cli/zswap-cli.conf + to /usr/share/zswap-cli/system.conf; user overrides now live in + /etc/zswap-cli/system.conf (renamed to system.conf). + * Breaking: short CLI options removed; use the long option names. + * New --system option loads ZSwap options from the installed config + file; systemd unit now uses it. + * --stats works without super-user privileges where debugfs allows. + +------------------------------------------------------------------- Old: ---- zswap-cli-1.2.0.tar.gz New: ---- zswap-cli-2.0.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ zswap-cli.spec ++++++ --- /var/tmp/diff_new_pack.0hQqG9/_old 2026-10-18 19:26:59.087947613 +0200 +++ /var/tmp/diff_new_pack.0hQqG9/_new 2026-10-18 19:26:59.088947655 +0200 @@ -2,6 +2,7 @@ # spec file for package zswap-cli # # Copyright (c) 2026 Andreas Stieger <[email protected]> +# Copyright (c) 2026 SUSE LLC and contributors # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +19,7 @@ %bcond_without systemd Name: zswap-cli -Version: 1.2.0 +Version: 2.0.0 Release: 0 Summary: Command-line tool to control the zswap kernel module options License: MIT @@ -77,13 +78,17 @@ %files %license LICENSE -%doc README.md docs/* +%doc README.md docs/configuration-files.md docs/environment-options.md +%doc docs/features.md docs/installation.md docs/maintainers.md +%doc docs/using-application.md %{_bindir}/zswap-cli %{_mandir}/man1/*.1%{?ext_man} %if %{with systemd} %dir %{_sysconfdir}/zswap-cli -%config(noreplace) %{_sysconfdir}/zswap-cli/zswap-cli.conf -%{_prefix}/lib/systemd/system/zswap-cli.service +%ghost %attr(0644,root,root) %config(noreplace) %{_sysconfdir}/zswap-cli/system.conf +%dir %{_datadir}/zswap-cli +%{_datadir}/zswap-cli/system.conf +%{_unitdir}/zswap-cli.service %endif %{_datadir}/bash-completion/completions/zswap-cli %{_datadir}/metainfo/org.easycoding.zswap-cli.metainfo.xml ++++++ zswap-cli-1.2.0.tar.gz -> zswap-cli-2.0.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/.github/workflows/fedora.yml new/zswap-cli-2.0.0/.github/workflows/fedora.yml --- old/zswap-cli-1.2.0/.github/workflows/fedora.yml 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/.github/workflows/fedora.yml 2026-09-15 08:58:51.000000000 +0200 @@ -36,6 +36,9 @@ - name: Installing core packages run: | sudo dnf -y install git-core + - name: Adjusting version control settings + run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: Fetching sources uses: actions/checkout@v7 - name: Installing ${{ matrix.compiler }} compiler packages @@ -54,6 +57,7 @@ run: | cmake -S . -B build \ -GNinja \ + -Wauthor \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_C_COMPILER=${{ matrix.cc }} \ -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \ @@ -64,6 +68,9 @@ -DBUILD_METAINFO:BOOL=ON \ -DBUILD_SHELL_COMPLETION:BOOL=ON \ -DBUILD_TESTS:BOOL=ON \ + -DCUSTOM_RELEASE_INFO:STRING="dev" \ + -DINCLUDE_COMMIT_HASH:BOOL=ON \ + -DINSTALL_CONFIG_FILE:BOOL=ON \ -DLINK_ALL_STATICALLY:BOOL=OFF \ -DLINK_BOOST_STATICALLY:BOOL=OFF \ -DLINK_ENABLE_OPTIMIZATIONS:BOOL=ON \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/.github/workflows/ubuntu.yml new/zswap-cli-2.0.0/.github/workflows/ubuntu.yml --- old/zswap-cli-1.2.0/.github/workflows/ubuntu.yml 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/.github/workflows/ubuntu.yml 2026-09-15 08:58:51.000000000 +0200 @@ -32,6 +32,9 @@ cxx: 'g++' packages: 'gcc' steps: + - name: Adjusting version control settings + run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" - name: Fetching sources uses: actions/checkout@v7 - name: Updating apt package metadata @@ -52,6 +55,7 @@ - name: Building project with CMake run: | cmake -S . -B build \ + -Wauthor \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_C_COMPILER=${{ matrix.cc }} \ -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \ @@ -62,6 +66,9 @@ -DBUILD_METAINFO:BOOL=ON \ -DBUILD_SHELL_COMPLETION:BOOL=ON \ -DBUILD_TESTS:BOOL=ON \ + -DCUSTOM_RELEASE_INFO:STRING="dev" \ + -DINCLUDE_COMMIT_HASH:BOOL=OFF \ + -DINSTALL_CONFIG_FILE:BOOL=ON \ -DLINK_ALL_STATICALLY:BOOL=OFF \ -DLINK_BOOST_STATICALLY:BOOL=OFF \ -DLINK_ENABLE_OPTIMIZATIONS:BOOL=ON \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/CMakeLists.txt new/zswap-cli-2.0.0/CMakeLists.txt --- old/zswap-cli-1.2.0/CMakeLists.txt 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/CMakeLists.txt 2026-09-15 08:58:51.000000000 +0200 @@ -11,12 +11,12 @@ cmake_minimum_required(VERSION 3.28...4.0) project(zswap-cli - VERSION 1.2.0 + VERSION 2.0.0 DESCRIPTION "Command-line tool to control the zswap kernel module options" HOMEPAGE_URL "https://github.com/xvitaly/zswap-cli" LANGUAGES CXX ) -set(RELEASE_DATE "2026-07-05") +set(RELEASE_DATE "2026-09-15") set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -32,10 +32,16 @@ option(BUILD_METAINFO "Build and install metainfo file for modern package managers." ON) option(BUILD_SHELL_COMPLETION "Build and install shell completion helper files." ON) option(BUILD_TESTS "Build various tests." OFF) +option(INCLUDE_COMMIT_HASH "Include the Git commit hash to the project version." OFF) +option(INSTALL_CONFIG_FILE "Install the application configuration file." ON) option(LINK_ALL_STATICALLY "Link the program against all libraries statically (no dependencies mode)." OFF) option(LINK_BOOST_STATICALLY "Link the program against Boost library statically (removes dependency on it)." OFF) option(LINK_ENABLE_OPTIMIZATIONS "Enable link-time optimizations if supported by current C++ compiler." ON) option(SYSTEMD_INTEGRATION "Generate and install systemd units." ON) +option(TESTS_ENABLE_NETWORK "Enable network access for the tests." OFF) + +set(CUSTOM_CONFIG_FILE_PATH "" CACHE FILEPATH "Full path to the custom configuration file to be installed instead of the default one.") +set(CUSTOM_RELEASE_INFO "" CACHE STRING "Additional release information to be added to the --version output.") # ====================================================== # ==================== Target names ==================== @@ -57,8 +63,8 @@ # ===================== File names ===================== # ====================================================== +set(CONF_FILE_NAME "system.conf") set(SCHEME_NAME "org.easycoding.${CMAKE_PROJECT_NAME}") -set(CONF_FILE_NAME "${CMAKE_PROJECT_NAME}.conf") set(UNIT_FILE_NAME "${CMAKE_PROJECT_NAME}.service") set(METAINFO_FILE_NAME "${SCHEME_NAME}.metainfo.xml") @@ -146,6 +152,19 @@ endif() # ====================================================== +# ================== Version detection ================= +# ====================================================== + +if (CUSTOM_RELEASE_INFO) + set(PRODUCT_RELEASE_EXTENDED "-${CUSTOM_RELEASE_INFO}") +endif() + +if (INCLUDE_COMMIT_HASH AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/.git") + find_package(SnapshotRelease QUIET REQUIRED) + set(PRODUCT_RELEASE_EXTENDED "${PRODUCT_RELEASE_EXTENDED} (commit ${SNAPSHOT_RELEASE_HASH})") +endif() + +# ====================================================== # ============= Tests validators detection ============= # ====================================================== @@ -160,14 +179,17 @@ set(LIBRARY_HEADERS src/lib/appconstants/appconstants.hpp src/lib/cwrappers/cwrappers.hpp + src/lib/filemanager/filemanager.hpp src/lib/ksysinfo/ksysinfo.hpp src/lib/ksysversion/ksysversion.hpp + src/lib/templates/formatters.hpp src/lib/zswapdebug/zswapdebug.hpp src/lib/zswapobject/zswapobject.hpp ) set(LIBRARY_SOURCES src/lib/cwrappers/cwrappers.cpp + src/lib/filemanager/filemanager.cpp src/lib/ksysinfo/ksysinfo.cpp src/lib/ksysversion/ksysversion.cpp src/lib/zswapdebug/zswapdebug.cpp @@ -285,10 +307,26 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${APP_NAME}.bash" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/bash-completion/completions" RENAME ${APP_NAME} COMPONENT ${ASSETS_COMP_NAME}) endif() -if (SYSTEMD_INTEGRATION) +if (INSTALL_CONFIG_FILE) + if (CUSTOM_CONFIG_FILE_PATH) + if (NOT IS_ABSOLUTE ${CUSTOM_CONFIG_FILE_PATH}) + get_filename_component(CUSTOM_CONFIG_FILE_ABSOLUTE ${CUSTOM_CONFIG_FILE_PATH} ABSOLUTE BASE_DIR ${CMAKE_CURRENT_LIST_DIR}) + set(CUSTOM_CONFIG_FILE_PATH ${CUSTOM_CONFIG_FILE_ABSOLUTE}) + unset(CUSTOM_CONFIG_FILE_ABSOLUTE) + endif() + if (NOT EXISTS ${CUSTOM_CONFIG_FILE_PATH}) + message(FATAL_ERROR "The specified in the CUSTOM_CONFIG_FILE_PATH configuration option file does not exist!") + endif() + install(FILES ${CUSTOM_CONFIG_FILE_PATH} DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${CMAKE_PROJECT_NAME}" RENAME ${CONF_FILE_NAME} COMPONENT ${ASSETS_COMP_NAME}) + else() + install(FILES "assets/config/${APP_NAME}.conf" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/${CMAKE_PROJECT_NAME}" RENAME ${CONF_FILE_NAME} COMPONENT ${ASSETS_COMP_NAME}) + endif() + install(DIRECTORY DESTINATION "${CMAKE_INSTALL_FULL_SYSCONFDIR}/${CMAKE_PROJECT_NAME}" COMPONENT ${ASSETS_COMP_NAME}) +endif() + +if (SYSTEMD_INTEGRATION AND INSTALL_CONFIG_FILE) configure_file("assets/systemd/${UNIT_FILE_NAME}.in" "${CMAKE_CURRENT_BINARY_DIR}/${UNIT_FILE_NAME}" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${UNIT_FILE_NAME}" DESTINATION "${SYSTEMD_UNITDIR}" COMPONENT ${ASSETS_COMP_NAME}) - install(FILES "assets/config/${CONF_FILE_NAME}" DESTINATION "${CMAKE_INSTALL_FULL_SYSCONFDIR}/${APP_NAME}" COMPONENT ${ASSETS_COMP_NAME}) endif() # ====================================================== diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/assets/config/zswap-cli.conf new/zswap-cli-2.0.0/assets/config/zswap-cli.conf --- old/zswap-cli-1.2.0/assets/config/zswap-cli.conf 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/assets/config/zswap-cli.conf 2026-09-15 08:58:51.000000000 +0200 @@ -18,12 +18,12 @@ # The maximum percentage of memory that the compressed pool can occupy. # Supported values: integer from 1 to 100. # Required kernel versions: any. -max_pool_percent=60 +#max_pool_percent=60 # The algorithm used to compress memory pages. # Supported values: depends on the kernel build time configuration. # Required kernel versions: any. -compressor=lzo +#compressor=lzo # The kernel's zpool type. # Supported values: depends on the kernel build time configuration. @@ -33,7 +33,7 @@ # The threshold at which ZSwap would start accepting pages again after it became full. # Supported values: integer from 1 to 100. # Required kernel versions: 5.6.0 or higher. -accept_threshold_percent=90 +#accept_threshold_percent=90 # Enable or disable accepting non same filled memory pages. # Supported values: Y, N. @@ -48,4 +48,4 @@ # Enable or disable pool shrinking based on memory pressure. # Supported values: Y, N. # Required kernel versions: 6.8.0 or higher. -shrinker_enabled=Y +#shrinker_enabled=Y diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/assets/manpage/zswap-cli.md.in new/zswap-cli-2.0.0/assets/manpage/zswap-cli.md.in --- old/zswap-cli-1.2.0/assets/manpage/zswap-cli.md.in 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/assets/manpage/zswap-cli.md.in 2026-09-15 08:58:51.000000000 +0200 @@ -45,7 +45,7 @@ Get options from the environment variables instead of the cmdline. #### \-\-stats -Get statistics and current settings of the ZSwap kernel module. +Print statistics and current settings of the ZSwap kernel module. Supported values: @@ -54,50 +54,53 @@ * **2** - print kernel module usage summary. * **3** - print kernel module debug information. +#### \-\-system +Get options from the system configuration file instead of the cmdline. + #### \-\-verbose Enable verbose mode to display additional information for debugging or informational purposes. -#### -e, \-\-enabled +#### \-\-enabled Enable or disable the ZSwap kernel module. Supported values: **Y**, **N**. -#### -s, \-\-same_filled_pages_enabled +#### \-\-same_filled_pages_enabled Enable or disable memory pages deduplication. Supported values: **Y**, **N**. -#### -p, \-\-max_pool_percent +#### \-\-max_pool_percent The maximum percentage of memory that the compressed pool can occupy. Supported values: integer from **1** to **100**. -#### -c, \-\-compressor +#### \-\-compressor The algorithm used to compress memory pages. Supported values: depends on the kernel build time configuration. -#### -z, \-\-zpool +#### \-\-zpool The kernel's zpool type. Supported values: depends on the kernel build time configuration. -#### -a, \-\-accept_threshold_percent +#### \-\-accept_threshold_percent The threshold at which ZSwap would start accepting pages again after it became full. Supported values: integer from **1** to **100**. -#### -n, \-\-non_same_filled_pages_enabled +#### \-\-non_same_filled_pages_enabled Enable or disable accepting non same filled memory pages. Supported values: **Y**, **N**. -#### -x, \-\-exclusive_loads +#### \-\-exclusive_loads Enable or disable entries invalidation when memory pages are loaded from compressed pool. Supported values: **Y**, **N**. -#### -r, \-\-shrinker_enabled +#### \-\-shrinker_enabled Enable or disable pool shrinking based on memory pressure. Supported values: **Y**, **N**. @@ -159,7 +162,23 @@ # CONFIGURATION FILES -@APP_NAME@ support of getting options from the configuration files. +This application uses a modern way of storing configuration files for the systemd unit and the `--system` command line option: + + * default read-only config **@CMAKE_INSTALL_FULL_DATAROOTDIR@/@CMAKE_PROJECT_NAME@/@CONF_FILE_NAME@**, provided by the application developers or your distribution. Should not be edited, as any changes will be overwritten with each program update. + * user high-priority config **@CMAKE_INSTALL_FULL_SYSCONFDIR@/@CMAKE_PROJECT_NAME@/@CONF_FILE_NAME@**, which can be created and edited by the user and will override all settings from the default one. Its contents will persist between application updates. + +In order to make changes to the configuration file, it need to be copied to the **@CMAKE_INSTALL_FULL_SYSCONFDIR@/@CMAKE_PROJECT_NAME@** directory first: + +``` +sudo cp -a @CMAKE_INSTALL_FULL_DATAROOTDIR@/@CMAKE_PROJECT_NAME@/@CONF_FILE_NAME@ @CMAKE_INSTALL_FULL_SYSCONFDIR@/@CMAKE_PROJECT_NAME@/@CONF_FILE_NAME@ +``` + +Now this file can be edited: +``` +sudoedit @CMAKE_INSTALL_FULL_SYSCONFDIR@/@CMAKE_PROJECT_NAME@/@CONF_FILE_NAME@ +``` + +Both configuration files have the same standard key-value syntax. ## Supported options @@ -175,7 +194,17 @@ ## Forwarding options -Create a configuration file: +### System config + +Start the application with the `--system` command-line argument: + +``` +sudo @APP_NAME@ --system +``` + +### Custom config + +Create a new **custom.conf** configuration file: ``` [zswap] @@ -193,7 +222,7 @@ Start the application with the `--config` command-line argument: ``` -sudo @APP_NAME@ --config /path/to/@CONF_FILE_NAME@ +sudo @APP_NAME@ --config /path/to/custom.conf ``` # SYSTEMD UNIT @@ -202,7 +231,7 @@ ## Changing settings -All settings are stored in the **@CMAKE_INSTALL_FULL_SYSCONFDIR@/@APP_NAME@/@CONF_FILE_NAME@** configuration file. It uses standard key-value syntax and can be edited by the user. +The default settings can be changed by editing the configuration files. More information can be found in the **CONFIGURATION FILES** chapter. ## Enabling unit diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/assets/shell-completion/zswap-cli.bash.in new/zswap-cli-2.0.0/assets/shell-completion/zswap-cli.bash.in --- old/zswap-cli-1.2.0/assets/shell-completion/zswap-cli.bash.in 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/assets/shell-completion/zswap-cli.bash.in 2026-09-15 08:58:51.000000000 +0200 @@ -10,31 +10,37 @@ _comp_initialize -- "$@" || return case "$prev" in - -a | --accept_threshold_percent | -p | --max_pool_percent) + --accept_threshold_percent | --max_pool_percent) _comp_compgen -- -W "{1..100}" return ;; - -e | --enabled | -s | --same_filled_pages_enabled | -n | --non_same_filled_pages_enabled | -x | --exclusive_loads | -r | --shrinker_enabled) - _comp_compgen -- -W "Y N" - return - ;; - -c | --compressor | -z | --zpool | --env | --version | --help | --verbose) + --compressor) + _comp_compgen -- -W "842 deflate lzo lz4 lz4hc zstd" return ;; --config) _comp_compgen_filedir "@(conf|ini)" return ;; + --enabled | --same_filled_pages_enabled | --non_same_filled_pages_enabled | --exclusive_loads | --shrinker_enabled) + _comp_compgen -- -W "Y N" + return + ;; + --env | --system | --version | --help | --verbose) + return + ;; --stats) _comp_compgen -- -W "{0..3}" return ;; + --zpool) + _comp_compgen -- -W "z3fold zbud zsmalloc" + return + ;; esac if [[ "$cur" == -* ]]; then - _comp_compgen -- -W "-a -p -e -s -n -x -r -c -z" - _comp_compgen -a -- -W "--accept_threshold_percent --max_pool_percent --enabled --same_filled_pages_enabled --non_same_filled_pages_enabled --exclusive_loads --shrinker_enabled --compressor --zpool" - _comp_compgen -a -- -W "--config --env --stats --version --help --verbose" + _comp_compgen_help [[ "${COMPREPLY-}" == *= ]] && compopt -o nospace fi } && diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/assets/systemd/zswap-cli.service.in new/zswap-cli-2.0.0/assets/systemd/zswap-cli.service.in --- old/zswap-cli-1.2.0/assets/systemd/zswap-cli.service.in 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/assets/systemd/zswap-cli.service.in 2026-09-15 08:58:51.000000000 +0200 @@ -10,7 +10,7 @@ [Service] Type=oneshot -ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/@APP_NAME@ --config @CMAKE_INSTALL_FULL_SYSCONFDIR@/@APP_NAME@/@CONF_FILE_NAME@ +ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/@APP_NAME@ --system ExecStop=@CMAKE_INSTALL_FULL_BINDIR@/@APP_NAME@ --enable N RemainAfterExit=yes ProtectSystem=strict diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/cmake/FindSnapshotRelease.cmake new/zswap-cli-2.0.0/cmake/FindSnapshotRelease.cmake --- old/zswap-cli-1.2.0/cmake/FindSnapshotRelease.cmake 1970-01-01 01:00:00.000000000 +0100 +++ new/zswap-cli-2.0.0/cmake/FindSnapshotRelease.cmake 2026-09-15 08:58:51.000000000 +0200 @@ -0,0 +1,25 @@ +# +# SPDX-FileCopyrightText: 2020-2026 EasyCoding Team and contributors +# +# SPDX-License-Identifier: MIT +# + +find_package(Git REQUIRED) + +execute_process( + COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + OUTPUT_VARIABLE _git_commit_hash + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET +) + +set(SNAPSHOT_RELEASE_HASH "${_git_commit_hash}") +unset(_git_commit_hash) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + SnapshotRelease + REQUIRED_VARS SNAPSHOT_RELEASE_HASH + REASON_FAILURE_MESSAGE "Failed to retrieve the commit hash from Git!" +) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/docs/README.md new/zswap-cli-2.0.0/docs/README.md --- old/zswap-cli-1.2.0/docs/README.md 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/docs/README.md 2026-09-15 08:58:51.000000000 +0200 @@ -7,3 +7,4 @@ * [Using application](using-application.md). * [Configuration files](configuration-files.md). * [Environment options](environment-options.md). + * [Notes for package maintainers](maintainers.md). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/docs/configuration-files.md new/zswap-cli-2.0.0/docs/configuration-files.md --- old/zswap-cli-1.2.0/docs/configuration-files.md 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/docs/configuration-files.md 2026-09-15 08:58:51.000000000 +0200 @@ -1,6 +1,22 @@ # Configuration files -This project support of getting options from the configuration files. +This application uses a modern way of storing configuration files for the systemd unit and the `--system` command line option: + + * default read-only config `/usr/share/zswap-cli/system.conf`, provided by the application developers or your distribution. Should not be edited, as any changes will be overwritten with each program update. + * user high-priority config `/etc/zswap-cli/system.conf`, which can be created and edited by the user and will override all settings from the default one. Its contents will persist between application updates. + +In order to make changes to the configuration file, it need to be copied to the `/etc/zswap-cli` directory first: + +``` +sudo cp -a /usr/share/zswap-cli/system.conf /etc/zswap-cli/system.conf +``` + +Now this file can be edited: +``` +sudoedit /etc/zswap-cli/system.conf +``` + +Both configuration files have the same standard key-value syntax. ## Supported options @@ -16,9 +32,19 @@ ## Forwarding options -Create a configuration file: +### System config +Start the application with the `--system` command-line argument: + +``` +sudo zswap-cli --system ``` + +### Custom config + +Create a new `custom.conf` configuration file: + +```ini [zswap] enabled=Y same_filled_pages_enabled=Y @@ -34,5 +60,5 @@ Start the application with the `--config` command-line argument: ``` -sudo zswap-cli --config /path/to/zswap-cli.conf +sudo zswap-cli --config /path/to/custom.conf ``` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/docs/installation.md new/zswap-cli-2.0.0/docs/installation.md --- old/zswap-cli-1.2.0/docs/installation.md 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/docs/installation.md 2026-09-15 08:58:51.000000000 +0200 @@ -25,12 +25,21 @@ | BUILD_METAINFO | Build and install metainfo file for modern package managers. | ON | | BUILD_SHELL_COMPLETION | Build and install shell completion helper files. | ON | | BUILD_TESTS | Build various tests. | OFF | +| INCLUDE_COMMIT_HASH | Include the Git commit hash to the project version. | OFF | +| INSTALL_CONFIG_FILE | Install the application configuration file. | ON | | LINK_ALL_STATICALLY | Link the program against all libraries statically (no dependencies mode). | OFF | | LINK_BOOST_STATICALLY | Link the program against Boost library statically (removes dependency on it). | OFF | | LINK_ENABLE_OPTIMIZATIONS | Enable link-time optimizations if supported by current C++ compiler. | ON | | SYSTEMD_INTEGRATION | Generate and install systemd units. | ON | | TESTS_ENABLE_NETWORK | Enable network access for the tests. | OFF | +The following build-time configuration options can be configured using `-DOPTION_NAME=VALUE`: + +| Name | Description | Type | Default | +| ------- | ------- | ------- | ------- | +| CUSTOM_CONFIG_FILE_PATH | Full path to the custom configuration file to be installed instead of the default one. | FILEPATH | EMPTY | +| CUSTOM_RELEASE_INFO | Additional release information to be added to the --version output. | STRING | EMPTY | + Any other non-default options related to external dependencies are not supported and should not be used. ## Downloading sources diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/docs/maintainers.md new/zswap-cli-2.0.0/docs/maintainers.md --- old/zswap-cli-1.2.0/docs/maintainers.md 1970-01-01 01:00:00.000000000 +0100 +++ new/zswap-cli-2.0.0/docs/maintainers.md 2026-09-15 08:58:51.000000000 +0200 @@ -0,0 +1,25 @@ +# Notes for package maintainers + +## Packaging recommendations + +Please always include a configuration file (default or custom) in your package, as it is now required for using the `--system` command-line option and the systemd unit. + +Please do not disable core features without a compelling reason, as this will degrade the user experience. + +## Custom configuration file + +Distributions can include a custom [configuration file](configuration-files.md) without the need of patching the default one. This file can be specified by using the `-DCUSTOM_CONFIG_FILE_PATH:FILEPATH=/path/to/custom.conf` [configuration option](installation.md). + +## Custom release information + +Distributions can include a custom suffix to the project version number by using the `-DCUSTOM_RELEASE_INFO:STRING="custom"` [configuration option](installation.md). The string specified there will be included in the `--version` output, separated by a hyphen. + +## Directories and files ownership + +Please remember to include in your package the `$prefix/etc/zswap-cli` directory and a virtual (does not exist by default, but can be created by the user) `$prefix/etc/zswap-cli/system.conf` file to ensure that the package contents are correctly tracked or removed by the package manager. + +## Snapshot releases + +If you are building a Git snapshot, please use the `-DINCLUDE_COMMIT_HASH:BOOL=ON` [configuration option](installation.md) to include the commit hash in the `--version` output. + +For the official release builds, this option should not be enabled. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/docs/using-application.md new/zswap-cli-2.0.0/docs/using-application.md --- old/zswap-cli-1.2.0/docs/using-application.md 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/docs/using-application.md 2026-09-15 08:58:51.000000000 +0200 @@ -18,24 +18,25 @@ * `--config` - get options from the [configuration file](configuration-files.md) instead of the cmdline. * `--env` - get options from the [environment variables](environment-options.md) instead of the cmdline. - * `--stats` - show statistics and current settings of the ZSwap kernel module. Supported values: + * `--stats` - print statistics and current settings of the ZSwap kernel module. Supported values: * `0` (default) - print everything: kernel module settings, usage summary, and debug information. * `1` - print kernel module settings. * `2` - print kernel module usage summary. * `3` - print kernel module debug information. + * `--system` - get options from the system configuration file instead of the cmdline. * `--verbose` - enable verbose mode to display additional information for debugging or informational purposes. #### Kernel module configuration options - * `-e` or `--enabled` - enable or disable the ZSwap kernel module. - * `-s` or `--same_filled_pages_enabled` - enable or disable memory pages deduplication. - * `-p` or `--max_pool_percent` - the maximum percentage of memory that the compressed pool can occupy. - * `-c` or `--compressor` - the algorithm used to compress memory pages. - * `-z` or `--zpool` - the kernel's zpool type. - * `-a` or `--accept_threshold_percent` - the threshold at which ZSwap would start accepting pages again after it became full. - * `-n` or `--non_same_filled_pages_enabled` - enable or disable accepting non same filled memory pages. - * `-x` or `--exclusive_loads` - enable or disable entries invalidation when memory pages are loaded from compressed pool. - * `-r` or `--shrinker_enabled` - enable or disable pool shrinking based on memory pressure. + * `--enabled` - enable or disable the ZSwap kernel module. + * `--same_filled_pages_enabled` - enable or disable memory pages deduplication. + * `--max_pool_percent` - the maximum percentage of memory that the compressed pool can occupy. + * `--compressor` - the algorithm used to compress memory pages. + * `--zpool` - the kernel's zpool type. + * `--accept_threshold_percent` - the threshold at which ZSwap would start accepting pages again after it became full. + * `--non_same_filled_pages_enabled` - enable or disable accepting non same filled memory pages. + * `--exclusive_loads` - enable or disable entries invalidation when memory pages are loaded from compressed pool. + * `--shrinker_enabled` - enable or disable pool shrinking based on memory pressure. ### Forwarding options @@ -60,9 +61,7 @@ ### Changing settings -All settings are stored in the `/etc/zswap-cli/zswap-cli.conf` file. It uses standard key-value syntax and can be edited by the user. - -All supported values can be found [here](configuration-files.md). +The default settings can be changed by editing the configuration files. More information can be found [here](configuration-files.md). ### Enabling unit diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/src/app/application/application.cpp new/zswap-cli-2.0.0/src/app/application/application.cpp --- old/zswap-cli-1.2.0/src/app/application/application.cpp 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/src/app/application/application.cpp 2026-09-15 08:58:51.000000000 +0200 @@ -29,8 +29,10 @@ #include "appconstants/appconstants.hpp" #include "application/application.hpp" #include "cwrappers/cwrappers.hpp" +#include "filemanager/filemanager.hpp" #include "ksysinfo/ksysinfo.hpp" #include "ksysversion/ksysversion.hpp" +#include "templates/formatters.hpp" #include "zswapdebug/zswapdebug.hpp" #include "zswapobject/zswapobject.hpp" @@ -40,18 +42,18 @@ const std::vector<std::pair<std::string_view, std::optional<unsigned long>>> Handlers { + { "Decompression failures", ZSwapDebugger -> GetDecompressFail() }, + { "Incompressible pages count", ZSwapDebugger -> GetIncompressiblePages() }, { "Pool limit hit", ZSwapDebugger -> GetPoolLimitHit() }, { "Pool total size", ZSwapDebugger -> GetPoolTotalSize() }, { "Reject allocation failures", ZSwapDebugger -> GetRejectAllocFail() }, + { "Reject compression failures", ZSwapDebugger -> GetRejectCompressFail() }, { "Reject compression poor", ZSwapDebugger -> GetRejectCompressPoor() }, { "Reject Kmemcache failures", ZSwapDebugger -> GetRejectKmemCacheFail() }, { "Reject reclaim failures", ZSwapDebugger -> GetRejectReclaimFail() }, - { "Reject compression failures", ZSwapDebugger -> GetRejectCompressFail() }, - { "Decompression failures", ZSwapDebugger -> GetDecompressFail() }, { "Same filled pages count", ZSwapDebugger -> GetSameFilledPages() }, { "Stored pages count", ZSwapDebugger -> GetStoredPages() }, { "Written back pages count", ZSwapDebugger -> GetWrittenBackPages() }, - { "Incompressible pages count", ZSwapDebugger -> GetIncompressiblePages() }, }; for (const auto& [Name, Value] : Handlers) @@ -69,15 +71,15 @@ const std::vector<std::pair<std::string_view, std::optional<std::string>>> Handlers { - { "ZSwap enabled", ZSwap -> GetZSwapEnabled() }, - { "Same filled pages enabled", ZSwap -> GetZSwapSameFilledPages() }, - { "Maximum pool percentage", ZSwap -> GetZSwapMaxPoolPercent() }, + { "Accept threshold percentage", ZSwap -> GetZSwapAcceptThresholdPercent() }, { "Compression algorithm", ZSwap -> GetZSwapCompressor() }, + { "Exclusive loads", ZSwap -> GetZSwapExclusiveLoads() }, { "Kernel's zpool type", ZSwap -> GetZSwapZpool() }, - { "Accept threshold percentage", ZSwap -> GetZSwapAcceptThresholdPercent() }, + { "Maximum pool percentage", ZSwap -> GetZSwapMaxPoolPercent() }, { "Non same filled pages enabled", ZSwap -> GetZSwapNonSameFilledPages() }, - { "Exclusive loads", ZSwap -> GetZSwapExclusiveLoads() }, + { "Same filled pages enabled", ZSwap -> GetZSwapSameFilledPages() }, { "Shrinker enabled", ZSwap -> GetZSwapShrinkerEnabled() }, + { "ZSwap enabled", ZSwap -> GetZSwapEnabled() }, }; for (const auto& [Name, Value] : Handlers) @@ -171,12 +173,13 @@ int Application::PrintVersion() const { - std::cout << std::format("{0} version: {1}\n" + std::cout << std::format("{0} version: {1}{2}\n" "Kernel API version:\n" - " build: {2}\n" - " runtime: {3}", - AppConstants::ProductNameInternal(), - AppConstants::ProductVersionInternal(), + " build: {3}\n" + " runtime: {4}", + AppConstants::ProductName(), + AppConstants::ProductVersion(), + AppConstants::ProductRelease(), SysVersion -> GetHeadersVersion(), SysVersion -> GetKernelVersion()) << std::endl; @@ -188,15 +191,15 @@ bool Result = true; const std::vector<std::pair<std::string, std::function<void(const std::string&)>>> Handlers { + { "ZSWAP_ACCEPT_THRESHOLD_PERCENT_VALUE", [this] (const std::string& Value) { ZSwap -> SetZSwapAcceptThresholdPercent(Value); } }, + { "ZSWAP_COMPRESSOR_VALUE", [this] (const std::string& Value) { ZSwap -> SetZSwapCompressor(Value); } }, { "ZSWAP_ENABLED_VALUE", [this] (const std::string& Value) { ZSwap -> SetZSwapEnabled(Value); } }, - { "ZSWAP_SAME_FILLED_PAGES_ENABLED_VALUE", [this] (const std::string& Value) { ZSwap -> SetZSwapSameFilledPages(Value); } }, + { "ZSWAP_EXCLUSIVE_LOADS_VALUE", [this] (const std::string& Value) { ZSwap -> SetZSwapExclusiveLoads(Value); } }, { "ZSWAP_MAX_POOL_PERCENT_VALUE", [this] (const std::string& Value) { ZSwap -> SetZSwapMaxPoolPercent(Value); } }, - { "ZSWAP_COMPRESSOR_VALUE", [this] (const std::string& Value) { ZSwap -> SetZSwapCompressor(Value); } }, - { "ZSWAP_ZPOOL_VALUE", [this] (const std::string& Value) { ZSwap -> SetZSwapZpool(Value); } }, - { "ZSWAP_ACCEPT_THRESHOLD_PERCENT_VALUE", [this] (const std::string& Value) { ZSwap -> SetZSwapAcceptThresholdPercent(Value); } }, { "ZSWAP_NON_SAME_FILLED_PAGES_ENABLED_VALUE", [this] (const std::string& Value) { ZSwap -> SetZSwapNonSameFilledPages(Value); } }, - { "ZSWAP_EXCLUSIVE_LOADS_VALUE", [this] (const std::string& Value) { ZSwap -> SetZSwapExclusiveLoads(Value); } }, + { "ZSWAP_SAME_FILLED_PAGES_ENABLED_VALUE", [this] (const std::string& Value) { ZSwap -> SetZSwapSameFilledPages(Value); } }, { "ZSWAP_SHRINKER_ENABLED_VALUE", [this] (const std::string& Value) { ZSwap -> SetZSwapShrinkerEnabled(Value); } }, + { "ZSWAP_ZPOOL_VALUE", [this] (const std::string& Value) { ZSwap -> SetZSwapZpool(Value); } }, }; for (const auto& [Key, Handler] : Handlers) @@ -216,22 +219,22 @@ return !Result; } -int Application::ExecuteConfig(const std::string& ConfigFile) const +int Application::ExecuteConfig(const std::filesystem::path& ConfigFile) const { ParseConfigFile(ConfigFile); bool Result = true; const std::vector<std::pair<std::string, std::function<void(const std::string&)>>> Handlers { + { "zswap.accept_threshold_percent", [this] (const std::string& Value) { ZSwap -> SetZSwapAcceptThresholdPercent(Value); } }, + { "zswap.compressor", [this] (const std::string& Value) { ZSwap -> SetZSwapCompressor(Value); } }, { "zswap.enabled", [this] (const std::string& Value) { ZSwap -> SetZSwapEnabled(Value); } }, - { "zswap.same_filled_pages_enabled", [this] (const std::string& Value) { ZSwap -> SetZSwapSameFilledPages(Value); } }, + { "zswap.exclusive_loads", [this] (const std::string& Value) { ZSwap -> SetZSwapExclusiveLoads(Value); } }, { "zswap.max_pool_percent", [this] (const std::string& Value) { ZSwap -> SetZSwapMaxPoolPercent(Value); } }, - { "zswap.compressor", [this] (const std::string& Value) { ZSwap -> SetZSwapCompressor(Value); } }, - { "zswap.zpool", [this] (const std::string& Value) { ZSwap -> SetZSwapZpool(Value); } }, - { "zswap.accept_threshold_percent", [this] (const std::string& Value) { ZSwap -> SetZSwapAcceptThresholdPercent(Value); } }, { "zswap.non_same_filled_pages_enabled", [this] (const std::string& Value) { ZSwap -> SetZSwapNonSameFilledPages(Value); } }, - { "zswap.exclusive_loads", [this] (const std::string& Value) { ZSwap -> SetZSwapExclusiveLoads(Value); } }, + { "zswap.same_filled_pages_enabled", [this] (const std::string& Value) { ZSwap -> SetZSwapSameFilledPages(Value); } }, { "zswap.shrinker_enabled", [this] (const std::string& Value) { ZSwap -> SetZSwapShrinkerEnabled(Value); } }, + { "zswap.zpool", [this] (const std::string& Value) { ZSwap -> SetZSwapZpool(Value); } }, }; for (const auto& [Key, Handler] : Handlers) @@ -255,15 +258,15 @@ bool Result = true; const std::vector<std::pair<std::string, std::function<void(const std::string&)>>> Handlers { + { "accept_threshold_percent", [this] (const std::string& Value) { ZSwap -> SetZSwapAcceptThresholdPercent(Value); } }, + { "compressor", [this] (const std::string& Value) { ZSwap -> SetZSwapCompressor(Value); } }, { "enabled", [this] (const std::string& Value) { ZSwap -> SetZSwapEnabled(Value); } }, - { "same_filled_pages_enabled", [this] (const std::string& Value) { ZSwap -> SetZSwapSameFilledPages(Value); } }, + { "exclusive_loads", [this] (const std::string& Value) { ZSwap -> SetZSwapExclusiveLoads(Value); } }, { "max_pool_percent", [this] (const std::string& Value) { ZSwap -> SetZSwapMaxPoolPercent(Value); } }, - { "compressor", [this] (const std::string& Value) { ZSwap -> SetZSwapCompressor(Value); } }, - { "zpool", [this] (const std::string& Value) { ZSwap -> SetZSwapZpool(Value); } }, - { "accept_threshold_percent", [this] (const std::string& Value) { ZSwap -> SetZSwapAcceptThresholdPercent(Value); } }, { "non_same_filled_pages_enabled", [this] (const std::string& Value) { ZSwap -> SetZSwapNonSameFilledPages(Value); } }, - { "exclusive_loads", [this] (const std::string& Value) { ZSwap -> SetZSwapExclusiveLoads(Value); } }, + { "same_filled_pages_enabled", [this] (const std::string& Value) { ZSwap -> SetZSwapSameFilledPages(Value); } }, { "shrinker_enabled", [this] (const std::string& Value) { ZSwap -> SetZSwapShrinkerEnabled(Value); } }, + { "zpool", [this] (const std::string& Value) { ZSwap -> SetZSwapZpool(Value); } }, }; for (const auto& [Key, Handler] : Handlers) @@ -282,12 +285,26 @@ return !Result; } +int Application::ExecuteSystemConfig() const +{ + for (const auto& Prefix : AppConstants::ConfigDirectoryPrefixes()) + { + const std::filesystem::path ConfigFile = Prefix / AppConstants::ProductName() / AppConstants::ConfigFileName(); + if (IsVerbose) std::cout << std::format("Checking the \"{0}\" path as a potential config file.", ConfigFile) << std::endl; + if (FileManager::CheckFileExists(ConfigFile)) + return ExecuteConfig(ConfigFile); + } + + throw std::runtime_error("System configuration files were not found."); +} + int Application::Run() const { if (CmdLine -> empty() || CmdLine -> count("help")) return PrintHelp(); if (CmdLine -> count("version")) return PrintVersion(); - CheckIfRunningBySuperUser(); if (CmdLine -> count("stats")) return PrintStats(CmdLine -> at("stats").as<int>()); + CheckIfRunningBySuperUser(); + if (CmdLine -> count("system")) return ExecuteSystemConfig(); if (CmdLine -> count("config")) return ExecuteConfig(CmdLine -> at("config").as<std::string>()); if (CmdLine -> count("env")) return ExecuteEnv(); return ExecuteCmdLine(); @@ -315,7 +332,7 @@ void Application::CheckIfModuleLoaded() const { - if (!ZSwap -> IsAvailable()) throw std::runtime_error("ZSwap kernel module is not loaded."); + if (!ZSwap -> IsAvailable()) throw std::runtime_error("ZSwap kernel module is not loaded or access to sysfs is denied."); } void Application::InitClassMembers() @@ -334,29 +351,30 @@ { boost::program_options::options_description OptionsGeneral("General options"); OptionsGeneral.add_options() - ("help,h", "Print this help message and exit.") - ("version,v", "Print version information and exit.") + ("help", "Print this help message and exit.") + ("version", "Print version information and exit.") ; boost::program_options::options_description OptionsConfiguration("Application configuration options"); OptionsConfiguration.add_options() ("config", boost::program_options::value<std::string>(), "Get options from the configuration file instead of the cmdline.") ("env", "Get options from the environment variables instead of the cmdline.") - ("stats", boost::program_options::value<int>() -> implicit_value(0), "Get statistics and current settings of ZSwap kernel module.") + ("stats", boost::program_options::value<int>() -> implicit_value(0), "Print statistics and current settings of the ZSwap kernel module.") + ("system", "Get options from the system configuration file instead of the cmdline.") ("verbose", "Enable verbose mode to display additional information for debugging or informational purposes.") ; boost::program_options::options_description OptionsZSwap("Kernel module configuration options"); OptionsZSwap.add_options() - ("enabled,e", boost::program_options::value<std::string>(), "Enable or disable the ZSwap kernel module.") - ("same_filled_pages_enabled,s", boost::program_options::value<std::string>(), "Enable or disable memory pages deduplication.") - ("max_pool_percent,p", boost::program_options::value<std::string>(), "The maximum percentage of memory that the compressed pool can occupy.") - ("compressor,c", boost::program_options::value<std::string>(), "The algorithm used to compress memory pages.") - ("zpool,z", boost::program_options::value<std::string>(), "The kernel's zpool type.") - ("accept_threshold_percent,a", boost::program_options::value<std::string>(), "The threshold at which ZSwap would start accepting pages again after it became full.") - ("non_same_filled_pages_enabled,n", boost::program_options::value<std::string>(), "Enable or disable accepting non same filled memory pages.") - ("exclusive_loads,x", boost::program_options::value<std::string>(), "Enable or disable entries invalidation when memory pages are loaded from compressed pool.") - ("shrinker_enabled,r", boost::program_options::value<std::string>(), "Enable or disable pool shrinking based on memory pressure.") + ("accept_threshold_percent", boost::program_options::value<std::string>(), "The threshold at which ZSwap would start accepting pages again after it became full.") + ("compressor", boost::program_options::value<std::string>(), "The algorithm used to compress memory pages.") + ("enabled", boost::program_options::value<std::string>(), "Enable or disable the ZSwap kernel module.") + ("exclusive_loads", boost::program_options::value<std::string>(), "Enable or disable entries invalidation when memory pages are loaded from compressed pool.") + ("max_pool_percent", boost::program_options::value<std::string>(), "The maximum percentage of memory that the compressed pool can occupy.") + ("non_same_filled_pages_enabled", boost::program_options::value<std::string>(), "Enable or disable accepting non same filled memory pages.") + ("same_filled_pages_enabled", boost::program_options::value<std::string>(), "Enable or disable memory pages deduplication.") + ("shrinker_enabled", boost::program_options::value<std::string>(), "Enable or disable pool shrinking based on memory pressure.") + ("zpool", boost::program_options::value<std::string>(), "The kernel's zpool type.") ; CmdLineOptions -> add(OptionsGeneral).add(OptionsConfiguration).add(OptionsZSwap); @@ -365,15 +383,15 @@ void Application::InitConfigOptions() const { ConfigOptions -> add_options() + ("zswap.accept_threshold_percent", boost::program_options::value<std::string>(), "The threshold at which ZSwap would start accepting pages again after it became full.") + ("zswap.compressor", boost::program_options::value<std::string>(), "The algorithm used to compress memory pages.") ("zswap.enabled", boost::program_options::value<std::string>(), "Enable or disable the ZSwap kernel module.") - ("zswap.same_filled_pages_enabled", boost::program_options::value<std::string>(), "Enable or disable memory pages deduplication.") + ("zswap.exclusive_loads", boost::program_options::value<std::string>(), "Enable or disable entries invalidation when memory pages are loaded from compressed pool.") ("zswap.max_pool_percent", boost::program_options::value<std::string>(), "The maximum percentage of memory that the compressed pool can occupy.") - ("zswap.compressor", boost::program_options::value<std::string>(), "The algorithm used to compress memory pages.") - ("zswap.zpool", boost::program_options::value<std::string>(), "The kernel's zpool type.") - ("zswap.accept_threshold_percent", boost::program_options::value<std::string>(), "The threshold at which ZSwap would start accepting pages again after it became full.") ("zswap.non_same_filled_pages_enabled", boost::program_options::value<std::string>(), "Enable or disable accepting non same filled memory pages.") - ("zswap.exclusive_loads", boost::program_options::value<std::string>(), "Enable or disable entries invalidation when memory pages are loaded from compressed pool.") + ("zswap.same_filled_pages_enabled", boost::program_options::value<std::string>(), "Enable or disable memory pages deduplication.") ("zswap.shrinker_enabled", boost::program_options::value<std::string>(), "Enable or disable pool shrinking based on memory pressure.") + ("zswap.zpool", boost::program_options::value<std::string>(), "The kernel's zpool type.") ; } @@ -383,9 +401,10 @@ CmdLine -> notify(); } -void Application::ParseConfigFile(const std::string& ConfigFile) const +void Application::ParseConfigFile(const std::filesystem::path& ConfigFile) const { - if (!std::filesystem::exists(ConfigFile)) throw std::invalid_argument("The specified configuration file does not exist!"); + if (IsVerbose) std::cout << std::format("Reading and parsing the \"{0}\" configuration file.", ConfigFile) << std::endl; + if (!FileManager::CheckFileExists(ConfigFile)) throw std::invalid_argument(std::format("The specified configuration file \"{0}\" does not exist!", ConfigFile)); std::ifstream ConfigFileFs(ConfigFile); boost::program_options::store(boost::program_options::parse_config_file(ConfigFileFs, *ConfigOptions), *Config); Config -> notify(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/src/app/application/application.hpp new/zswap-cli-2.0.0/src/app/application/application.hpp --- old/zswap-cli-1.2.0/src/app/application/application.hpp 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/src/app/application/application.hpp 2026-09-15 08:58:51.000000000 +0200 @@ -116,7 +116,7 @@ * Reads and parses the specified configuration file. * @param ConfigFile Full path to the configuration file. */ - void ParseConfigFile(const std::string&) const; + void ParseConfigFile(const std::filesystem::path&) const; /** * Sets the program additional configuration options. @@ -179,7 +179,7 @@ * if an invalid file path was specified. * @returns Exit code. */ - int ExecuteConfig(const std::string&) const; + int ExecuteConfig(const std::filesystem::path&) const; /** * Gets parameters from the command-line arguments. @@ -188,6 +188,15 @@ int ExecuteCmdLine() const; /** + * Handles the \-\-system command-line argument. Gets parameters + * from the system configuration file. + * @exception Raises an instance of the std::runtime_error exception + * if no configuration files were found. + * @returns Exit code. + */ + int ExecuteSystemConfig() const; + + /** * Prints the ZSwap kernel module debug information. */ void PrintDebugInfo() const; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/src/lib/appconstants/appconstants.cpp.in new/zswap-cli-2.0.0/src/lib/appconstants/appconstants.cpp.in --- old/zswap-cli-1.2.0/src/lib/appconstants/appconstants.cpp.in 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/src/lib/appconstants/appconstants.cpp.in 2026-09-15 08:58:51.000000000 +0200 @@ -9,16 +9,33 @@ * Contains the AppConstants namespace implementation. */ +#include <filesystem> #include <string_view> +#include <vector> #include "appconstants/appconstants.hpp" -std::string_view AppConstants::ProductNameInternal() +std::vector<std::filesystem::path> AppConstants::ConfigDirectoryPrefixes() +{ + return { "@CMAKE_INSTALL_FULL_SYSCONFDIR@", "@CMAKE_INSTALL_FULL_DATAROOTDIR@", "/etc", "/usr/share" }; +} + +std::string_view AppConstants::ConfigFileName() +{ + return "@CONF_FILE_NAME@"; +} + +std::string_view AppConstants::ProductName() { return "@CMAKE_PROJECT_NAME@"; } -std::string_view AppConstants::ProductVersionInternal() +std::string_view AppConstants::ProductVersion() { return "@CMAKE_PROJECT_VERSION@"; } + +std::string_view AppConstants::ProductRelease() +{ + return "@PRODUCT_RELEASE_EXTENDED@"; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/src/lib/appconstants/appconstants.hpp new/zswap-cli-2.0.0/src/lib/appconstants/appconstants.hpp --- old/zswap-cli-1.2.0/src/lib/appconstants/appconstants.hpp 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/src/lib/appconstants/appconstants.hpp 2026-09-15 08:58:51.000000000 +0200 @@ -12,7 +12,9 @@ * Contains the AppConstants namespace definition. */ +#include <filesystem> #include <string_view> +#include <vector> /** * Namespace for working with various constants used in project. @@ -20,14 +22,34 @@ namespace AppConstants { /** - * Returns the application internal name as a string. + * Returns the list of system configuration directory prefixes. + * @returns System configuration directory prefixes. */ - std::string_view ProductNameInternal(); + std::vector<std::filesystem::path> ConfigDirectoryPrefixes(); + + /** + * Returns the application configuration file name. + * @returns Application configuration file name. + */ + std::string_view ConfigFileName(); + + /** + * Returns the application name as a string. + * @returns Application name. + */ + std::string_view ProductName(); /** * Returns the application version number as a string. + * @returns Application version number. + */ + std::string_view ProductVersion(); + + /** + * Returns the application release as a string. + * @returns Application release. */ - std::string_view ProductVersionInternal(); + std::string_view ProductRelease(); } #endif // APPCONSTANTS_HPP diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/src/lib/cwrappers/cwrappers.cpp new/zswap-cli-2.0.0/src/lib/cwrappers/cwrappers.cpp --- old/zswap-cli-1.2.0/src/lib/cwrappers/cwrappers.cpp 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/src/lib/cwrappers/cwrappers.cpp 2026-09-15 08:58:51.000000000 +0200 @@ -9,15 +9,15 @@ * Contains the CWrappers namespace implementation. */ +#include <cstdlib> #include <string> -#include <stdlib.h> #include <unistd.h> #include "cwrappers/cwrappers.hpp" std::string CWrappers::GetEnv(const std::string& KeyName) { - const char* EnvValue = getenv(KeyName.c_str()); + const char* EnvValue = std::getenv(KeyName.c_str()); return EnvValue != nullptr ? std::string(EnvValue) : std::string(); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/src/lib/filemanager/filemanager.cpp new/zswap-cli-2.0.0/src/lib/filemanager/filemanager.cpp --- old/zswap-cli-1.2.0/src/lib/filemanager/filemanager.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/zswap-cli-2.0.0/src/lib/filemanager/filemanager.cpp 2026-09-15 08:58:51.000000000 +0200 @@ -0,0 +1,29 @@ +/** + * SPDX-FileCopyrightText: 2020-2026 EasyCoding Team and contributors + * + * SPDX-License-Identifier: MIT +*/ + +/** + * @file filemanager/filemanager.cpp + * Contains the FileManager namespace implementation. +*/ + +#include <filesystem> +#include <system_error> + +#include "filemanager/filemanager.hpp" + +bool FileManager::CheckFileExists(const std::filesystem::path& FullPath) +{ + std::error_code error; + std::filesystem::file_status status = std::filesystem::status(FullPath, error); + return !error && std::filesystem::exists(status) && std::filesystem::is_regular_file(status); +} + +bool FileManager::CheckDirectoryExists(const std::filesystem::path& FullPath) +{ + std::error_code error; + std::filesystem::file_status status = std::filesystem::status(FullPath, error); + return !error && std::filesystem::exists(status) && std::filesystem::is_directory(status); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/src/lib/filemanager/filemanager.hpp new/zswap-cli-2.0.0/src/lib/filemanager/filemanager.hpp --- old/zswap-cli-1.2.0/src/lib/filemanager/filemanager.hpp 1970-01-01 01:00:00.000000000 +0100 +++ new/zswap-cli-2.0.0/src/lib/filemanager/filemanager.hpp 2026-09-15 08:58:51.000000000 +0200 @@ -0,0 +1,39 @@ +/** + * SPDX-FileCopyrightText: 2020-2026 EasyCoding Team and contributors + * + * SPDX-License-Identifier: MIT +*/ + +#ifndef FILEMANAGER_HPP +#define FILEMANAGER_HPP + +/** + * @file filemanager/filemanager.hpp + * Contains the FileManager namespace definition. +*/ + +#include <filesystem> + +/** + * Namespace with functions for working with files and directories. +*/ +namespace FileManager +{ + /** + * Returns whether the specified file exists. + * @returns File existence check results. + * @retval true The specified file exists. + * @retval false The specified file does not exists. + */ + bool CheckFileExists(const std::filesystem::path&); + + /** + * Returns whether the specified directory exists. + * @returns Directory existence check results. + * @retval true The specified directory exists. + * @retval false The specified directory does not exists. + */ + bool CheckDirectoryExists(const std::filesystem::path&); +} + +#endif // FILEMANAGER_HPP diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/src/lib/templates/formatters.hpp new/zswap-cli-2.0.0/src/lib/templates/formatters.hpp --- old/zswap-cli-1.2.0/src/lib/templates/formatters.hpp 1970-01-01 01:00:00.000000000 +0100 +++ new/zswap-cli-2.0.0/src/lib/templates/formatters.hpp 2026-09-15 08:58:51.000000000 +0200 @@ -0,0 +1,31 @@ +/** + * SPDX-FileCopyrightText: 2020-2026 EasyCoding Team and contributors + * + * SPDX-License-Identifier: MIT +*/ + +#ifndef FORMATTERS_HPP +#define FORMATTERS_HPP + +/** + * @file templates/formatters.hpp + * Contains custom formatters for various classes. +*/ + +#include <filesystem> +#include <format> +#include <string> + +/** + * Custom formatter for the std::filesystem::path. Backported from C++26. +*/ +template <> +struct std::formatter<std::filesystem::path> : std::formatter<std::string> +{ + auto format(const std::filesystem::path& path, std::format_context& ctx) const + { + return std::formatter<std::string>::format(path.string(), ctx); + } +}; + +#endif // FORMATTERS_HPP diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/src/lib/zswapdebug/zswapdebug.cpp new/zswap-cli-2.0.0/src/lib/zswapdebug/zswapdebug.cpp --- old/zswap-cli-1.2.0/src/lib/zswapdebug/zswapdebug.cpp 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/src/lib/zswapdebug/zswapdebug.cpp 2026-09-15 08:58:51.000000000 +0200 @@ -12,11 +12,12 @@ #include <filesystem> #include <fstream> #include <optional> -#include <string> +#include <string_view> +#include "filemanager/filemanager.hpp" #include "zswapdebug/zswapdebug.hpp" -unsigned long ZSwapDebug::ReadDebugValue(const std::string& FullPath) const +unsigned long ZSwapDebug::ReadDebugValue(const std::filesystem::path& FullPath) const { unsigned long Result; std::ifstream ZSwapSysFs(FullPath); @@ -24,10 +25,10 @@ return Result; } -std::optional<unsigned long> ZSwapDebug::ReadModuleDebugValue(const std::string& Name) const +std::optional<unsigned long> ZSwapDebug::ReadModuleDebugValue(const std::string_view Name) const { - const std::string FullPath = ModuleDebugPath + Name; - if (!std::filesystem::exists(FullPath)) return std::nullopt; + const std::filesystem::path FullPath = ModuleDebugPath / Name; + if (!FileManager::CheckFileExists(FullPath)) return std::nullopt; return ReadDebugValue(FullPath); } @@ -93,5 +94,10 @@ bool ZSwapDebug::IsDebugAvailable() const { - return std::filesystem::exists(ModuleDebugPath); + return FileManager::CheckDirectoryExists(ModuleDebugPath); +} + +ZSwapDebug::ZSwapDebug() +{ + ModuleDebugPath = "/sys/kernel/debug/zswap"; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/src/lib/zswapdebug/zswapdebug.hpp new/zswap-cli-2.0.0/src/lib/zswapdebug/zswapdebug.hpp --- old/zswap-cli-1.2.0/src/lib/zswapdebug/zswapdebug.hpp 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/src/lib/zswapdebug/zswapdebug.hpp 2026-09-15 08:58:51.000000000 +0200 @@ -12,8 +12,9 @@ * Contains the ZSwapDebug class definition. */ +#include <filesystem> #include <optional> -#include <string> +#include <string_view> /** * Class for working with the ZSwap kernel module @@ -25,7 +26,7 @@ /** * Constructor of the ZSwapDebug class. */ - ZSwapDebug() = default; + ZSwapDebug(); /** * Gets the pool limit hits. @@ -77,7 +78,6 @@ /** * Gets the number of same filled pages. - * Deprecated. Removed in kernel 6.12.0. * @returns Same filled pages count. */ std::optional<unsigned long> GetSameFilledPages() const; @@ -109,7 +109,7 @@ /** * Stores the kernel module debug path. */ - const std::string ModuleDebugPath = "/sys/kernel/debug/zswap/"; + std::filesystem::path ModuleDebugPath; /** * Reads the value of the ZSwap kernel module debug variable from @@ -117,7 +117,7 @@ * @param FullPath Full path to the ZSwap kernel module debug variable. * @returns Value of the specified debug variable. */ - unsigned long ReadDebugValue(const std::string&) const; + unsigned long ReadDebugValue(const std::filesystem::path&) const; /** * Reads the debug value of the ZSwap kernel module by the @@ -125,7 +125,7 @@ * @param Name Debug value name. * @returns Value of the specified type. */ - std::optional<unsigned long> ReadModuleDebugValue(const std::string&) const; + std::optional<unsigned long> ReadModuleDebugValue(const std::string_view) const; }; #endif // ZSWAPDEBUG_HPP diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/src/lib/zswapobject/zswapobject.cpp new/zswap-cli-2.0.0/src/lib/zswapobject/zswapobject.cpp --- old/zswap-cli-1.2.0/src/lib/zswapobject/zswapobject.cpp 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/src/lib/zswapobject/zswapobject.cpp 2026-09-15 08:58:51.000000000 +0200 @@ -9,8 +9,8 @@ * Contains the ZSwapObject class implementation. */ -#include <format> #include <filesystem> +#include <format> #include <fstream> #include <iostream> #include <optional> @@ -18,29 +18,30 @@ #include <stdexcept> #include <string> +#include "filemanager/filemanager.hpp" #include "zswapobject/zswapobject.hpp" -void ZSwapObject::CheckValueBool(const std::string& Name, const std::string& Value) const +void ZSwapObject::CheckValueBool(const std::string_view Name, const std::string& Value) const { if (!std::regex_match(Value, std::regex("^[YN]$"))) throw std::invalid_argument(std::format("The requested value for the option \"{0}\" is incorrect (only Y or N are supported)!", Name)); } -void ZSwapObject::CheckValueEmpty(const std::string& Name, const std::string& Value) const +void ZSwapObject::CheckValueModuleName(const std::string_view Name, const std::string& Value) const { - if (Value.empty()) throw std::invalid_argument(std::format("The requested value for the option \"{0}\" is empty!", Name)); + if (!std::regex_match(Value, std::regex("^\\w+$"))) throw std::invalid_argument(std::format("The requested value for the option \"{0}\" is incorrect (only alphanumeric characters and underscores are supported)!", Name)); } -void ZSwapObject::CheckValueRange(const std::string& Name, const std::string& Value) const +void ZSwapObject::CheckValueRange(const std::string_view Name, const std::string& Value) const { if (!std::regex_match(Value, std::regex("^\\d{1,2}|100$"))) throw std::invalid_argument(std::format("The requested value for the option \"{0}\" is out of range [0..100]!", Name)); } -void ZSwapObject::WriteLogEntry(const std::string& Name, const std::string& NewValue, const std::string& OldValue) const +void ZSwapObject::WriteLogEntry(const std::string_view Name, const std::string& NewValue, const std::string& OldValue) const { std::cout << std::format("The option \"{0}\" has been set to a new value of \"{1}\" (old value was \"{2}\").", Name, NewValue, OldValue) << std::endl; } -std::string ZSwapObject::ReadValue(const std::string& FullPath) const +std::string ZSwapObject::ReadValue(const std::filesystem::path& FullPath) const { std::string Result; std::ifstream ZSwapSysFs(FullPath); @@ -48,23 +49,23 @@ return Result; } -void ZSwapObject::WriteValue(const std::string& FullPath, const std::string& Value) const +void ZSwapObject::WriteValue(const std::filesystem::path& FullPath, const std::string& Value) const { std::ofstream ZSwapSysFs(FullPath); ZSwapSysFs << Value; } -std::optional<std::string> ZSwapObject::ReadZSwapValue(const std::string& Name) const +std::optional<std::string> ZSwapObject::ReadZSwapValue(const std::string_view Name) const { - const std::string FullPath = ZSwapModuleParametersPath + Name; - if (!std::filesystem::exists(FullPath)) return std::nullopt; + const std::filesystem::path FullPath = ZSwapModuleParametersPath / Name; + if (!FileManager::CheckFileExists(FullPath)) return std::nullopt; return ReadValue(FullPath); } -void ZSwapObject::WriteZSwapValue(const std::string& Name, const std::string& Value) const +void ZSwapObject::WriteZSwapValue(const std::string_view Name, const std::string& Value) const { - const std::string FullPath = ZSwapModuleParametersPath + Name; - if (!std::filesystem::exists(FullPath)) throw std::runtime_error(std::format("Configuring the option \"{0}\" is not possible on the current kernel!", Name)); + const std::filesystem::path FullPath = ZSwapModuleParametersPath / Name; + if (!FileManager::CheckFileExists(FullPath)) throw std::runtime_error(std::format("Configuring the option \"{0}\" is not possible on the current kernel!", Name)); const std::string OldValue = ReadZSwapValue(Name).value_or("N/A"); WriteValue(FullPath, Value); if (ReadZSwapValue(Name) != Value) throw std::runtime_error(std::format("Failed to set the option \"{0}\" a new value \"{1}\"! Current value \"{2}\" remains unchanged.", Name, Value, OldValue)); @@ -111,7 +112,7 @@ void ZSwapObject::SetZSwapCompressor(const std::string& Value) const { - CheckValueEmpty(ZSwapCompressorName, Value); + CheckValueModuleName(ZSwapCompressorName, Value); WriteZSwapValue(ZSwapCompressorName, Value); } @@ -122,7 +123,7 @@ void ZSwapObject::SetZSwapZpool(const std::string& Value) const { - CheckValueEmpty(ZSwapZpoolName, Value); + CheckValueModuleName(ZSwapZpoolName, Value); WriteZSwapValue(ZSwapZpoolName, Value); } @@ -172,5 +173,10 @@ bool ZSwapObject::IsAvailable() const { - return std::filesystem::exists(ZSwapModuleParametersPath); + return FileManager::CheckDirectoryExists(ZSwapModuleParametersPath); +} + +ZSwapObject::ZSwapObject() +{ + ZSwapModuleParametersPath = "/sys/module/zswap/parameters"; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/zswap-cli-1.2.0/src/lib/zswapobject/zswapobject.hpp new/zswap-cli-2.0.0/src/lib/zswapobject/zswapobject.hpp --- old/zswap-cli-1.2.0/src/lib/zswapobject/zswapobject.hpp 2026-07-05 11:50:24.000000000 +0200 +++ new/zswap-cli-2.0.0/src/lib/zswapobject/zswapobject.hpp 2026-09-15 08:58:51.000000000 +0200 @@ -12,8 +12,10 @@ * Contains the ZSwapObject class definition. */ +#include <filesystem> #include <optional> #include <string> +#include <string_view> /** * Class for working with the ZSwap kernel module. @@ -24,7 +26,7 @@ /** * Constructor of the ZSwapObject class. */ - ZSwapObject() = default; + ZSwapObject(); /** * Gets the ZSwap enabled value. @@ -143,52 +145,52 @@ /** * Stores the ZSwap kernel module options path. */ - const std::string ZSwapModuleParametersPath = "/sys/module/zswap/parameters/"; + std::filesystem::path ZSwapModuleParametersPath; /** * Stores the ZSwap enabled internal option name. */ - const std::string ZSwapEnabledName = "enabled"; + static constexpr std::string_view ZSwapEnabledName = "enabled"; /** * Stores the same filled pages enabled internal option name. */ - const std::string ZSwapSameFilledPagesName = "same_filled_pages_enabled"; + static constexpr std::string_view ZSwapSameFilledPagesName = "same_filled_pages_enabled"; /** * Stores the maximum pool percentage internal option name. */ - const std::string ZSwapMaxPoolPercentName = "max_pool_percent"; + static constexpr std::string_view ZSwapMaxPoolPercentName = "max_pool_percent"; /** * Stores the compression algorithm internal option name. */ - const std::string ZSwapCompressorName = "compressor"; + static constexpr std::string_view ZSwapCompressorName = "compressor"; /** * Stores the kernel's zpool type internal option name. */ - const std::string ZSwapZpoolName = "zpool"; + static constexpr std::string_view ZSwapZpoolName = "zpool"; /** * Stores the accept threshold percentage internal option name. */ - const std::string ZSwapAcceptThresholdPercentName = "accept_threshold_percent"; + static constexpr std::string_view ZSwapAcceptThresholdPercentName = "accept_threshold_percent"; /** * Stores the non same filled pages enabled internal option name. */ - const std::string ZSwapNonSameFilledPagesName = "non_same_filled_pages_enabled"; + static constexpr std::string_view ZSwapNonSameFilledPagesName = "non_same_filled_pages_enabled"; /** * Stores the exclusive loads enabled internal option name. */ - const std::string ZSwapExclusiveLoadsName = "exclusive_loads"; + static constexpr std::string_view ZSwapExclusiveLoadsName = "exclusive_loads"; /** * Stores the shrinker enabled internal option name. */ - const std::string ZSwapShrinkerEnabledName = "shrinker_enabled"; + static constexpr std::string_view ZSwapShrinkerEnabledName = "shrinker_enabled"; /** * Checks whether the value is Y or N. @@ -197,16 +199,16 @@ * @exception Raises an instance of std::invalid_argument if the * value does not meet the criteria. */ - void CheckValueBool(const std::string&, const std::string&) const; + void CheckValueBool(const std::string_view, const std::string&) const; /** - * Checks whether the value is empty. + * Checks whether the value contains a valid kernel module name. * @param Name Option name. * @param Value Option value to check. * @exception Raises an instance of std::invalid_argument if the * value does not meet the criteria. */ - void CheckValueEmpty(const std::string&, const std::string&) const; + void CheckValueModuleName(const std::string_view, const std::string&) const; /** * Checks whether the value is within the [0..100] range. @@ -215,7 +217,7 @@ * @exception Raises an instance of std::invalid_argument if the * value does not meet the criteria. */ - void CheckValueRange(const std::string&, const std::string&) const; + void CheckValueRange(const std::string_view, const std::string&) const; /** * Prints the log entry to the standard output. @@ -223,7 +225,7 @@ * @param NewValue New option value. * @param OldValue Old option value. */ - void WriteLogEntry(const std::string&, const std::string&, const std::string&) const; + void WriteLogEntry(const std::string_view, const std::string&, const std::string&) const; /** * Reads the value of the ZSwap kernel module option from the @@ -231,7 +233,7 @@ * @param FullPath Full path to the ZSwap kernel module option. * @returns Option value. */ - std::string ReadValue(const std::string&) const; + std::string ReadValue(const std::filesystem::path&) const; /** * Writes a new value to the specified ZSwap kernel module option @@ -239,14 +241,14 @@ * @param FullPath Full path to the ZSwap kernel module option. * @param Value Option value. */ - void WriteValue(const std::string&, const std::string&) const; + void WriteValue(const std::filesystem::path&, const std::string&) const; /** * Reads the value of the specified ZSwap kernel module option. * @param Name Option name. * @returns Option value or std::nullopt if not available. */ - std::optional<std::string> ReadZSwapValue(const std::string&) const; + std::optional<std::string> ReadZSwapValue(const std::string_view) const; /** * Writes a new value to the specified ZSwap kernel module option. @@ -255,7 +257,7 @@ * @exception Raises an instance of the std::runtime_error if an * error occurs. */ - void WriteZSwapValue(const std::string&, const std::string&) const; + void WriteZSwapValue(const std::string_view, const std::string&) const; }; #endif // ZSWAPOBJECT_HPP
