salvage: require bundled static yyjson
Some checks failed
Source release / source-package (push) Failing after 11m41s
Some checks failed
Source release / source-package (push) Failing after 11m41s
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -7,9 +7,6 @@
|
||||
[submodule "smart"]
|
||||
path = smart
|
||||
url = git@gitea.disconnected-by-peer.at:mars_nwe/mars-smart.git
|
||||
[submodule "nweadmin"]
|
||||
path = admin
|
||||
url = git@gitea.disconnected-by-peer.at:mars_nwe/mars-nweadmin.git
|
||||
[submodule "admin"]
|
||||
path = admin
|
||||
url = git@gitea.disconnected-by-peer.at:mars_nwe/mars-nweadmin.git
|
||||
|
||||
@@ -193,24 +193,39 @@ endif()
|
||||
|
||||
set(MARS_NWE_YYJSON_SOURCE_DIR
|
||||
"${CMAKE_SOURCE_DIR}/third_party/yyjson"
|
||||
CACHE PATH "Path to the vendored yyjson source tree")
|
||||
CACHE PATH "Path to the bundled yyjson source tree")
|
||||
|
||||
set(MARS_NWE_HAVE_YYJSON 0)
|
||||
if(EXISTS "${MARS_NWE_YYJSON_SOURCE_DIR}/CMakeLists.txt")
|
||||
set(YYJSON_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(YYJSON_BUILD_FUZZER OFF CACHE BOOL "" FORCE)
|
||||
set(YYJSON_BUILD_MISC OFF CACHE BOOL "" FORCE)
|
||||
add_subdirectory("${MARS_NWE_YYJSON_SOURCE_DIR}"
|
||||
"${CMAKE_BINARY_DIR}/third_party/yyjson"
|
||||
EXCLUDE_FROM_ALL)
|
||||
set(MARS_NWE_HAVE_YYJSON 1)
|
||||
if(NOT EXISTS "${MARS_NWE_YYJSON_SOURCE_DIR}/CMakeLists.txt")
|
||||
message(FATAL_ERROR
|
||||
"Bundled yyjson is required. Run: git submodule update --init --recursive third_party/yyjson")
|
||||
endif()
|
||||
|
||||
if(MARS_NWE_HAVE_YYJSON)
|
||||
message(STATUS "Salvage JSON backend: yyjson")
|
||||
else()
|
||||
message(STATUS "Salvage JSON backend: disabled (third_party/yyjson not found)")
|
||||
endif()
|
||||
set(YYJSON_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
set(YYJSON_BUILD_FUZZER OFF CACHE BOOL "" FORCE)
|
||||
set(YYJSON_BUILD_MISC OFF CACHE BOOL "" FORCE)
|
||||
set(YYJSON_BUILD_DOC OFF CACHE BOOL "" FORCE)
|
||||
set(YYJSON_ENABLE_COVERAGE OFF CACHE BOOL "" FORCE)
|
||||
set(YYJSON_ENABLE_VALGRIND OFF CACHE BOOL "" FORCE)
|
||||
set(YYJSON_ENABLE_FASTMATH OFF CACHE BOOL "" FORCE)
|
||||
set(YYJSON_FORCE_32_BIT OFF CACHE BOOL "" FORCE)
|
||||
set(YYJSON_INSTALL OFF CACHE BOOL "" FORCE)
|
||||
set(YYJSON_SANITIZER "" CACHE STRING "" FORCE)
|
||||
set(YYJSON_DISABLE_READER OFF CACHE BOOL "" FORCE)
|
||||
set(YYJSON_DISABLE_WRITER OFF CACHE BOOL "" FORCE)
|
||||
set(YYJSON_DISABLE_INCR_READER ON CACHE BOOL "" FORCE)
|
||||
set(YYJSON_DISABLE_UTILS ON CACHE BOOL "" FORCE)
|
||||
set(YYJSON_DISABLE_FAST_FP_CONV ON CACHE BOOL "" FORCE)
|
||||
set(YYJSON_DISABLE_NON_STANDARD ON CACHE BOOL "" FORCE)
|
||||
set(YYJSON_DISABLE_UTF8_VALIDATION OFF CACHE BOOL "" FORCE)
|
||||
|
||||
set(MARS_NWE_SAVED_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
add_subdirectory("${MARS_NWE_YYJSON_SOURCE_DIR}"
|
||||
"${CMAKE_BINARY_DIR}/third_party/yyjson"
|
||||
EXCLUDE_FROM_ALL)
|
||||
set(BUILD_SHARED_LIBS ${MARS_NWE_SAVED_BUILD_SHARED_LIBS})
|
||||
|
||||
message(STATUS "Salvage JSON backend: bundled static yyjson")
|
||||
|
||||
# we want to use systemd, if possible
|
||||
set(SYSTEMD_SERVICES_INSTALL_DIR "" CACHE PATH "Directory for systemd service files")
|
||||
|
||||
@@ -76,11 +76,7 @@ add_executable(ftrustee ftrustee.c tools.c nwfname.c unxfile.c nwvolume.c nwattr
|
||||
##############
|
||||
|
||||
target_link_libraries(nwserv ${CRYPT_LIBRARIES} )
|
||||
target_link_libraries(nwconn ${CRYPT_LIBRARIES} ${XATTR_LIBRARIES} )
|
||||
if(MARS_NWE_HAVE_YYJSON)
|
||||
target_compile_definitions(nwconn PRIVATE MARS_NWE_HAVE_YYJSON)
|
||||
target_link_libraries(nwconn yyjson)
|
||||
endif()
|
||||
target_link_libraries(nwconn ${CRYPT_LIBRARIES} ${XATTR_LIBRARIES} yyjson )
|
||||
target_link_libraries(ncpserv ${CRYPT_LIBRARIES} )
|
||||
target_link_libraries(nwclient ${CRYPT_LIBRARIES} )
|
||||
target_link_libraries(nwbind ${CRYPT_LIBRARIES} ${GDBM_LIBRARIES} )
|
||||
|
||||
@@ -13,10 +13,8 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#ifdef MARS_NWE_HAVE_YYJSON
|
||||
#include <stdint.h>
|
||||
#include <yyjson.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -364,7 +362,6 @@ int nwsalvage_build_metadata_path(char *out, size_t out_len,
|
||||
config->metadata_repository, relative_path, ".json"));
|
||||
}
|
||||
|
||||
#ifdef MARS_NWE_HAVE_YYJSON
|
||||
static int make_dir_if_missing(const char *path)
|
||||
{
|
||||
struct stat st;
|
||||
@@ -426,28 +423,7 @@ static int make_parent_dirs(const char *path)
|
||||
|
||||
return(make_dir_if_missing(tmp));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef MARS_NWE_HAVE_YYJSON
|
||||
int nwsalvage_write_metadata(const char *metadata_path,
|
||||
const struct nwsalvage_deleted_entry *entry)
|
||||
{
|
||||
(void)metadata_path;
|
||||
(void)entry;
|
||||
errno = ENOSYS;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
int nwsalvage_read_metadata(const char *metadata_path,
|
||||
struct nwsalvage_metadata_entry *entry)
|
||||
{
|
||||
(void)metadata_path;
|
||||
if (entry)
|
||||
memset(entry, 0, sizeof(*entry));
|
||||
errno = ENOSYS;
|
||||
return(-1);
|
||||
}
|
||||
#else
|
||||
static const char *metadata_source(const struct nwsalvage_deleted_entry *entry)
|
||||
{
|
||||
return(entry->source && *entry->source ? entry->source : "mars_nwe");
|
||||
@@ -1008,9 +984,7 @@ int nwsalvage_read_metadata(const char *metadata_path,
|
||||
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MARS_NWE_HAVE_YYJSON
|
||||
static int nwsalvage_move_deleted_file(const char *live_path,
|
||||
const char *recycle_path,
|
||||
const char *metadata_path,
|
||||
@@ -1065,7 +1039,6 @@ static int nwsalvage_move_deleted_file(const char *live_path,
|
||||
errno = saved_errno;
|
||||
return(-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int nwsalvage_ini_get(int entry, char *str, size_t strsize, void *data)
|
||||
{
|
||||
@@ -1301,12 +1274,6 @@ static void nwsalvage_fill_trustees(int volume, const char *unixname,
|
||||
int nwsalvage_capture_node_delete(int volume, const char *unixname,
|
||||
const struct stat *stb)
|
||||
{
|
||||
#ifndef MARS_NWE_HAVE_YYJSON
|
||||
(void)volume;
|
||||
(void)unixname;
|
||||
(void)stb;
|
||||
return(1);
|
||||
#else
|
||||
struct nwsalvage_config config;
|
||||
struct nwsalvage_deleted_entry entry;
|
||||
char volume_root[NWSALVAGE_PATH_MAX];
|
||||
@@ -1412,5 +1379,4 @@ int nwsalvage_capture_node_delete(int volume, const char *unixname,
|
||||
return(-1);
|
||||
|
||||
return(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -81,10 +81,7 @@ target_include_directories(salvage_config_smoke PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
if(MARS_NWE_HAVE_YYJSON)
|
||||
target_compile_definitions(salvage_config_smoke PRIVATE MARS_NWE_HAVE_YYJSON)
|
||||
target_link_libraries(salvage_config_smoke yyjson)
|
||||
endif()
|
||||
target_link_libraries(salvage_config_smoke yyjson)
|
||||
|
||||
add_custom_target(run_salvage_config_smoke ALL
|
||||
COMMAND $<TARGET_FILE:salvage_config_smoke>
|
||||
|
||||
@@ -4,11 +4,9 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef MARS_NWE_HAVE_YYJSON
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
struct fake_ini {
|
||||
@@ -35,7 +33,6 @@ static int fake_ini_getter(int entry, char *str, size_t strsize, void *data)
|
||||
}
|
||||
|
||||
|
||||
#ifdef MARS_NWE_HAVE_YYJSON
|
||||
static int file_contains(const char *path, const char *needle)
|
||||
{
|
||||
FILE *fp = fopen(path, "r");
|
||||
@@ -60,8 +57,6 @@ static void remove_test_tree(const char *root)
|
||||
system(cmd);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static int expect_true(int condition, const char *message)
|
||||
{
|
||||
if (!condition) {
|
||||
@@ -75,9 +70,7 @@ int main(void)
|
||||
{
|
||||
struct nwsalvage_config config;
|
||||
char path[NWSALVAGE_PATH_MAX];
|
||||
#ifdef MARS_NWE_HAVE_YYJSON
|
||||
char root[NWSALVAGE_PATH_MAX];
|
||||
#endif
|
||||
struct fake_ini ini;
|
||||
int failures = 0;
|
||||
|
||||
@@ -200,7 +193,6 @@ int main(void)
|
||||
"path builder rejects too-small buffers");
|
||||
|
||||
|
||||
#ifdef MARS_NWE_HAVE_YYJSON
|
||||
snprintf(root, sizeof(root), "/tmp/mars_nwe_salvage_smoke_%ld",
|
||||
(long)getpid());
|
||||
remove_test_tree(root);
|
||||
@@ -355,29 +347,6 @@ int main(void)
|
||||
"metadata reader returns second trustee rights");
|
||||
}
|
||||
remove_test_tree(root);
|
||||
#else
|
||||
{
|
||||
struct nwsalvage_deleted_entry deleted_entry;
|
||||
|
||||
memset(&deleted_entry, 0, sizeof(deleted_entry));
|
||||
deleted_entry.volume_name = "SYS";
|
||||
deleted_entry.deleted_by = "SUPERVISOR";
|
||||
deleted_entry.deleted_at = 1780215322;
|
||||
deleted_entry.original_path = "SYS:PUBLIC/PMDFLTS.INI";
|
||||
deleted_entry.original_parent_entry_id = 4;
|
||||
deleted_entry.original_name = "PMDFLTS.INI";
|
||||
deleted_entry.recycle_relative_path = ".recycle/SUPERVISOR/PUBLIC/PMDFLTS.INI";
|
||||
deleted_entry.salvage_relative_path = ".salvage/SUPERVISOR/PUBLIC/PMDFLTS.INI.json";
|
||||
deleted_entry.atime = 1700000000;
|
||||
deleted_entry.mtime = 1700000000;
|
||||
deleted_entry.ctime = 1700000000;
|
||||
failures += expect_true(nwsalvage_write_metadata(
|
||||
"/tmp/mars_nwe_salvage_disabled.json",
|
||||
&deleted_entry) < 0 && errno == ENOSYS,
|
||||
"metadata writer reports ENOSYS without yyjson");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (failures)
|
||||
return(1);
|
||||
|
||||
15
third_party/README.md
vendored
15
third_party/README.md
vendored
@@ -2,16 +2,17 @@
|
||||
|
||||
## yyjson
|
||||
|
||||
The salvage metadata backend uses yyjson for JSON read/write support when the
|
||||
vendored source tree is available at `third_party/yyjson`.
|
||||
The salvage metadata backend uses the bundled yyjson submodule for JSON
|
||||
read/write support. The submodule is required and is linked statically into the
|
||||
mars-nwe server targets that use salvage metadata.
|
||||
|
||||
Recommended setup:
|
||||
Setup:
|
||||
|
||||
```sh
|
||||
git submodule add -b master https://github.com/ibireme/yyjson.git third_party/yyjson
|
||||
git submodule update --init --recursive third_party/yyjson
|
||||
```
|
||||
|
||||
CMake auto-detects `third_party/yyjson/CMakeLists.txt`. When the submodule is
|
||||
missing, mars_nwe still builds, but the salvage JSON entry read/write helpers
|
||||
return `ENOSYS` and the yyjson-backed smoke assertions are skipped.
|
||||
CMake expects `third_party/yyjson/CMakeLists.txt` to exist. Reader and writer
|
||||
support stay enabled; yyjson tests, fuzzer, misc tools, docs, install targets,
|
||||
JSON5/non-standard support, utilities and incremental reader support are disabled
|
||||
for the mars-nwe build.
|
||||
|
||||
Reference in New Issue
Block a user