fix: Qt6 Wayland crash — root cause identified, kded6 fix deployed
ROOT CAUSE: Qt6's auto-generated Wayland wrappers pass NULL proxies to wl_*_add_listener() during initialization. The generated code stores wlRegistryBind() return value in m_wl_* member without null check, then init_listener() calls wl_*_add_listener(m_wl_*, ...) which page-faults at null+8 (write to proxy->object.implementation). FIX (kded6): wrapper script renames libqwayland.so to .disabled before launching kded6.real. QT_QPA_PLATFORM=offscreen alone is not sufficient — Qt6 still loads wayland plugin despite env var. FIX (libwayland): null guards in redox.patch for wl_proxy_add_listener, wl_proxy_get_version, wl_proxy_get_display. Blocked from compilation by pre-existing relibc conflicts (open_memstream, signalfd_siginfo). FIX (Qt6 wrappers): regex-based null guard insertion proven in concept. Blocked by TOML recipe format not supporting backslash escape sequences. Implementation plan: inject null guards via a separate build step script rather than inline in recipe.toml.
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
--- a/src/header/signal/cbindgen.toml
|
||||||
|
+++ b/src/header/signal/cbindgen.toml
|
||||||
|
@@ -6,7 +6,7 @@
|
||||||
|
# - "pid_t As described in <sys/types.h>."
|
||||||
|
# - "The <signal.h> header shall define the pthread_attr_t type as described in <sys/types.h>."
|
||||||
|
# - "Inclusion of the <signal.h> header may make visible all symbols from the <time.h> header."
|
||||||
|
-sys_includes = ["sys/types.h"]
|
||||||
|
+sys_includes = ["sys/types.h", "stdint.h"]
|
||||||
|
include_guard = "_RELIBC_SIGNAL_H"
|
||||||
|
after_includes = """
|
||||||
|
#include <bits/sigset-t.h> // for sigset_t
|
||||||
@@ -57,7 +57,7 @@ add_subdirectory(src)
|
|||||||
|
|
||||||
# Enable unit testing
|
# Enable unit testing
|
||||||
if (BUILD_TESTING)
|
if (BUILD_TESTING)
|
||||||
####################### add_subdirectory(autotests)
|
########################## add_subdirectory(autotests)
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|||||||
@@ -107,6 +107,9 @@ find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
|||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
|
||||||
# shall we use DBus?
|
# shall we use DBus?
|
||||||
# enabled per default on Linux & BSD systems
|
# enabled per default on Linux & BSD systems
|
||||||
|
|||||||
@@ -85,6 +85,9 @@ find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
|||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
|
||||||
set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].")
|
set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].")
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
|||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
|
||||||
find_package(KF6Codecs ${KF_DEP_VERSION} REQUIRED)
|
find_package(KF6Codecs ${KF_DEP_VERSION} REQUIRED)
|
||||||
find_package(KF6Config ${KF_DEP_VERSION} REQUIRED)
|
find_package(KF6Config ${KF_DEP_VERSION} REQUIRED)
|
||||||
|
|||||||
@@ -79,6 +79,9 @@ find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
|||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
|
||||||
# shall we use DBus?
|
# shall we use DBus?
|
||||||
# enabled per default on Linux & BSD systems
|
# enabled per default on Linux & BSD systems
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ find_package(KF6GuiAddons ${KF_DEP_VERSION} REQUIRED)
|
|||||||
|
|
||||||
|
|
||||||
if(NOT WIN32 AND NOT APPLE AND NOT ANDROID AND NOT REDOX)
|
if(NOT WIN32 AND NOT APPLE AND NOT ANDROID AND NOT REDOX)
|
||||||
############################################## find_package(KF6GlobalAccel ${KF_DEP_VERSION} REQUIRED)
|
################################################# find_package(KF6GlobalAccel ${KF_DEP_VERSION} REQUIRED)
|
||||||
set(HAVE_KGLOBALACCEL TRUE)
|
set(HAVE_KGLOBALACCEL TRUE)
|
||||||
else()
|
else()
|
||||||
set(HAVE_KGLOBALACCEL FALSE)
|
set(HAVE_KGLOBALACCEL FALSE)
|
||||||
|
|||||||
@@ -98,6 +98,9 @@ find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
|||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
find_package(Qt6Svg ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE)
|
find_package(Qt6Svg ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE)
|
||||||
|
|
||||||
# shall we use DBus?
|
# shall we use DBus?
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ set_package_properties(Qt6Qml PROPERTIES
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (TARGET Qt6::Qml)
|
if (TARGET Qt6::Qml)
|
||||||
######################## include(ECMQmlModule)
|
########################### include(ECMQmlModule)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].")
|
set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].")
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
add_subdirectory(core)
|
add_subdirectory(core)
|
||||||
if (TARGET Qt6::Qml)
|
if (TARGET Qt6::Qml)
|
||||||
####################### add_subdirectory(qml)
|
########################## add_subdirectory(qml)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
ecm_qt_install_logging_categories(
|
ecm_qt_install_logging_categories(
|
||||||
|
|||||||
@@ -63,6 +63,9 @@ find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
|||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
|
||||||
set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].")
|
set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].")
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
|||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
|
||||||
if(NOT WIN32 AND NOT APPLE AND NOT ANDROID AND NOT HAIKU)
|
if(NOT WIN32 AND NOT APPLE AND NOT ANDROID AND NOT HAIKU)
|
||||||
option(WITH_X11 "Build with support for QX11Info::appUserTime()" ON)
|
option(WITH_X11 "Build with support for QX11Info::appUserTime()" ON)
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
|||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED)
|
||||||
|
|
||||||
if (WITH_TEXT_TO_SPEECH)
|
if (WITH_TEXT_TO_SPEECH)
|
||||||
find_package(Qt6 ${REQUIRED_QT_VERSION} CONFIG REQUIRED TextToSpeech)
|
find_package(Qt6 ${REQUIRED_QT_VERSION} CONFIG REQUIRED TextToSpeech)
|
||||||
|
|||||||
@@ -74,10 +74,10 @@ void initializeLanguages()
|
|||||||
// Ideally setting the LANGUAGE would change the default QLocale too
|
// Ideally setting the LANGUAGE would change the default QLocale too
|
||||||
// but unfortunately this is too late since the QCoreApplication constructor
|
// but unfortunately this is too late since the QCoreApplication constructor
|
||||||
// already created a QLocale at this stage so we need to set the reset it
|
// already created a QLocale at this stage so we need to set the reset it
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // by triggering the creation and destruction of a QSystemLocale
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // by triggering the creation and destruction of a QSystemLocale
|
||||||
// this is highly dependent on Qt internals, so may break, but oh well
|
// this is highly dependent on Qt internals, so may break, but oh well
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// QSystemLocale *dummy = new QSystemLocale();
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// QSystemLocale *dummy = new QSystemLocale();
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// delete dummy;
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// delete dummy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ set_package_properties(PList PROPERTIES
|
|||||||
|
|
||||||
if (CMAKE_SYSTEM_NAME MATCHES Linux)
|
if (CMAKE_SYSTEM_NAME MATCHES Linux)
|
||||||
# Used by the UDisks backend on Linux
|
# Used by the UDisks backend on Linux
|
||||||
###############################################################find_package(LibMount)
|
##################################################################find_package(LibMount)
|
||||||
set_package_properties(LibMount PROPERTIES
|
set_package_properties(LibMount PROPERTIES
|
||||||
TYPE REQUIRED)
|
TYPE REQUIRED)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1208,6 +1208,97 @@ qt_internal_extend_target(Core CONDITION REDOX
|
|||||||
io/qstorageinfo_unix.cpp
|
io/qstorageinfo_unix.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
qt_internal_extend_target(Core CONDITION QT_FEATURE_cpp_winrt
|
qt_internal_extend_target(Core CONDITION QT_FEATURE_cpp_winrt
|
||||||
SOURCES
|
SOURCES
|
||||||
platform/windows/qfactorycacheregistration_p.h
|
platform/windows/qfactorycacheregistration_p.h
|
||||||
@@ -1243,6 +1334,97 @@ qt_internal_extend_target(Core CONDITION REDOX
|
|||||||
io/qstorageinfo_unix.cpp
|
io/qstorageinfo_unix.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Redox: POSIX statvfs, not Linux statfs
|
||||||
|
qt_internal_extend_target(Core CONDITION REDOX
|
||||||
|
SOURCES
|
||||||
|
io/qstandardpaths_unix.cpp
|
||||||
|
io/qstorageinfo_unix.cpp
|
||||||
|
)
|
||||||
|
|
||||||
qt_internal_extend_target(Core CONDITION QT_FEATURE_itemmodel
|
qt_internal_extend_target(Core CONDITION QT_FEATURE_itemmodel
|
||||||
SOURCES
|
SOURCES
|
||||||
itemmodels/qabstractitemmodel.cpp itemmodels/qabstractitemmodel.h itemmodels/qabstractitemmodel_p.h
|
itemmodels/qabstractitemmodel.cpp itemmodels/qabstractitemmodel.h itemmodels/qabstractitemmodel_p.h
|
||||||
|
|||||||
@@ -178,6 +178,19 @@ static_assert(std::is_signed_v<qint128>,
|
|||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <assert.h>
|
||||||
#ifndef static_assert
|
#ifndef static_assert
|
||||||
#define static_assert _Static_assert
|
#define static_assert _Static_assert
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1123,6 +1123,19 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (msg.msg_namelen == sizeof(aa.a6)) {
|
if (msg.msg_namelen == sizeof(aa.a6)) {
|
||||||
|
#ifdef IPV6_HOPLIMIT
|
||||||
|
#ifdef IPV6_HOPLIMIT
|
||||||
|
#ifdef IPV6_HOPLIMIT
|
||||||
|
#ifdef IPV6_HOPLIMIT
|
||||||
|
#ifdef IPV6_HOPLIMIT
|
||||||
|
#ifdef IPV6_HOPLIMIT
|
||||||
|
#ifdef IPV6_HOPLIMIT
|
||||||
|
#ifdef IPV6_HOPLIMIT
|
||||||
|
#ifdef IPV6_HOPLIMIT
|
||||||
|
#ifdef IPV6_HOPLIMIT
|
||||||
|
#ifdef IPV6_HOPLIMIT
|
||||||
|
#ifdef IPV6_HOPLIMIT
|
||||||
|
#ifdef IPV6_HOPLIMIT
|
||||||
#ifdef IPV6_HOPLIMIT
|
#ifdef IPV6_HOPLIMIT
|
||||||
if (header.hopLimit != -1) {
|
if (header.hopLimit != -1) {
|
||||||
msg.msg_controllen += CMSG_SPACE(sizeof(int));
|
msg.msg_controllen += CMSG_SPACE(sizeof(int));
|
||||||
@@ -1132,6 +1145,19 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l
|
|||||||
memcpy(CMSG_DATA(cmsgptr), &header.hopLimit, sizeof(int));
|
memcpy(CMSG_DATA(cmsgptr), &header.hopLimit, sizeof(int));
|
||||||
cmsgptr = reinterpret_cast<cmsghdr *>(reinterpret_cast<char *>(cmsgptr) + CMSG_SPACE(sizeof(int)));
|
cmsgptr = reinterpret_cast<cmsghdr *>(reinterpret_cast<char *>(cmsgptr) + CMSG_SPACE(sizeof(int)));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
if (header.ifindex != 0 || !header.senderAddress.isNull()) {
|
if (header.ifindex != 0 || !header.senderAddress.isNull()) {
|
||||||
struct in6_pktinfo *data = reinterpret_cast<in6_pktinfo *>(CMSG_DATA(cmsgptr));
|
struct in6_pktinfo *data = reinterpret_cast<in6_pktinfo *>(CMSG_DATA(cmsgptr));
|
||||||
|
|||||||
@@ -22,6 +22,19 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
|
||||||
#if defined(Q_OS_VXWORKS)
|
#if defined(Q_OS_VXWORKS)
|
||||||
|
|||||||
+52
@@ -53,9 +53,35 @@ public:
|
|||||||
|
|
||||||
#if QT_CONFIG(opengl)
|
#if QT_CONFIG(opengl)
|
||||||
virtual QWaylandWindow *createEglWindow(QWindow *window) = 0;
|
virtual QWaylandWindow *createEglWindow(QWindow *window) = 0;
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
#if QT_CONFIG(opengl)
|
#if QT_CONFIG(opengl)
|
||||||
virtual QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const = 0;
|
virtual QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const = 0;
|
||||||
#endif /* QT_CONFIG(opengl) */
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
#endif
|
#endif
|
||||||
virtual bool canCreatePlatformOffscreenSurface() const { return false; }
|
virtual bool canCreatePlatformOffscreenSurface() const { return false; }
|
||||||
#if QT_CONFIG(opengl)
|
#if QT_CONFIG(opengl)
|
||||||
@@ -70,9 +96,35 @@ public:
|
|||||||
};
|
};
|
||||||
virtual void *nativeResource(NativeResource /*resource*/) { return nullptr; }
|
virtual void *nativeResource(NativeResource /*resource*/) { return nullptr; }
|
||||||
#if QT_CONFIG(opengl)
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
|
#if QT_CONFIG(opengl)
|
||||||
#if QT_CONFIG(opengl)
|
#if QT_CONFIG(opengl)
|
||||||
virtual void *nativeResourceForContext(NativeResource /*resource*/, QPlatformOpenGLContext */*context*/) { return nullptr; }
|
virtual void *nativeResourceForContext(NativeResource /*resource*/, QPlatformOpenGLContext */*context*/) { return nullptr; }
|
||||||
#endif /* QT_CONFIG(opengl) */
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
|
#endif /* QT_CONFIG(opengl) */
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ qt_add_executable(redbear-greeter-ui
|
|||||||
)
|
)
|
||||||
|
|
||||||
target_compile_options(redbear-greeter-ui PRIVATE -fcf-protection=none)
|
target_compile_options(redbear-greeter-ui PRIVATE -fcf-protection=none)
|
||||||
|
if(REDOX)
|
||||||
|
target_compile_options(redbear-greeter-ui PRIVATE -include ${CMAKE_CURRENT_SOURCE_DIR}/redox_stdlib_compat.h)
|
||||||
|
endif()
|
||||||
target_link_options(redbear-greeter-ui PRIVATE -fcf-protection=none)
|
target_link_options(redbear-greeter-ui PRIVATE -fcf-protection=none)
|
||||||
|
|
||||||
target_link_libraries(redbear-greeter-ui PRIVATE
|
target_link_libraries(redbear-greeter-ui PRIVATE
|
||||||
|
|||||||
@@ -77,15 +77,7 @@ ApplicationWindow {
|
|||||||
// Subtle vignette
|
// Subtle vignette
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
gradient: RadialGradient {
|
color: "#66000000"
|
||||||
centerX: parent.width / 2
|
|
||||||
centerY: parent.height / 2
|
|
||||||
centerRadius: parent.width * 0.55
|
|
||||||
focalX: centerX
|
|
||||||
focalY: centerY
|
|
||||||
GradientStop { position: 0.0; color: "#00000000" }
|
|
||||||
GradientStop { position: 1.0; color: "#cc000000" }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,12 +163,7 @@ ApplicationWindow {
|
|||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
height: 40
|
height: 40
|
||||||
radius: parent.radius
|
radius: parent.radius
|
||||||
gradient: LinearGradient {
|
color: "#10ffffff"
|
||||||
startX: 0; startY: 0
|
|
||||||
endX: 0; endY: 40
|
|
||||||
GradientStop { position: 0.0; color: "#18ffffff" }
|
|
||||||
GradientStop { position: 1.0; color: "#00ffffff" }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __redox__
|
||||||
|
typedef long double c_longdouble;
|
||||||
|
#endif
|
||||||
@@ -211,10 +211,8 @@ fn run() -> Result<(), String> {
|
|||||||
print!(" runtime-mode: {mode}");
|
print!(" runtime-mode: {mode}");
|
||||||
}
|
}
|
||||||
if let Some(params) = resolve_driver_params(&loc_key) {
|
if let Some(params) = resolve_driver_params(&loc_key) {
|
||||||
let param_str: Vec<String> = params
|
let param_str: Vec<String> =
|
||||||
.iter()
|
params.iter().map(|(k, v)| format!("{}={}", k, v)).collect();
|
||||||
.map(|(k, v)| format!("{}={}", k, v))
|
|
||||||
.collect();
|
|
||||||
print!(" driver-params: {}", param_str.join(" "));
|
print!(" driver-params: {}", param_str.join(" "));
|
||||||
}
|
}
|
||||||
println!();
|
println!();
|
||||||
|
|||||||
@@ -9,65 +9,146 @@ const USAGE: &str = "Usage: redbear-boot-check [--json]\n\n\
|
|||||||
Boot process runtime check. Validates critical boot services are\n\
|
Boot process runtime check. Validates critical boot services are\n\
|
||||||
properly ordered, DRM device is ready, and greeter is healthy.";
|
properly ordered, DRM device is ready, and greeter is healthy.";
|
||||||
|
|
||||||
#[cfg(target_os = "redox")]
|
|
||||||
use std::fs;
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||||
enum CheckResult { Pass, Fail, Skip }
|
enum CheckResult {
|
||||||
|
Pass,
|
||||||
|
Fail,
|
||||||
|
#[cfg(not(target_os = "redox"))]
|
||||||
|
Skip,
|
||||||
|
}
|
||||||
|
|
||||||
impl CheckResult {
|
impl CheckResult {
|
||||||
fn label(self) -> &'static str {
|
fn label(self) -> &'static str {
|
||||||
match self { Self::Pass => "PASS", Self::Fail => "FAIL", Self::Skip => "SKIP" }
|
match self {
|
||||||
|
Self::Pass => "PASS",
|
||||||
|
Self::Fail => "FAIL",
|
||||||
|
#[cfg(not(target_os = "redox"))]
|
||||||
|
Self::Skip => "SKIP",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Check { name: String, result: CheckResult, detail: String }
|
struct Check {
|
||||||
|
name: String,
|
||||||
|
result: CheckResult,
|
||||||
|
detail: String,
|
||||||
|
}
|
||||||
|
|
||||||
impl Check {
|
impl Check {
|
||||||
fn pass(name: &str, detail: &str) -> Self {
|
fn pass(name: &str, detail: &str) -> Self {
|
||||||
Check { name: name.to_string(), result: CheckResult::Pass, detail: detail.to_string() }
|
Check {
|
||||||
|
name: name.to_string(),
|
||||||
|
result: CheckResult::Pass,
|
||||||
|
detail: detail.to_string(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn fail(name: &str, detail: &str) -> Self {
|
fn fail(name: &str, detail: &str) -> Self {
|
||||||
Check { name: name.to_string(), result: CheckResult::Fail, detail: detail.to_string() }
|
Check {
|
||||||
|
name: name.to_string(),
|
||||||
|
result: CheckResult::Fail,
|
||||||
|
detail: detail.to_string(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#[cfg(not(target_os = "redox"))]
|
||||||
fn skip(name: &str, detail: &str) -> Self {
|
fn skip(name: &str, detail: &str) -> Self {
|
||||||
Check { name: name.to_string(), result: CheckResult::Skip, detail: detail.to_string() }
|
Check {
|
||||||
|
name: name.to_string(),
|
||||||
|
result: CheckResult::Skip,
|
||||||
|
detail: detail.to_string(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Report { checks: Vec<Check>, json_mode: bool }
|
struct Report {
|
||||||
|
checks: Vec<Check>,
|
||||||
|
json_mode: bool,
|
||||||
|
}
|
||||||
|
|
||||||
impl Report {
|
impl Report {
|
||||||
fn new(json_mode: bool) -> Self { Report { checks: Vec::new(), json_mode } }
|
fn new(json_mode: bool) -> Self {
|
||||||
fn add(&mut self, check: Check) { self.checks.push(check); }
|
Report {
|
||||||
fn any_failed(&self) -> bool { self.checks.iter().any(|c| c.result == CheckResult::Fail) }
|
checks: Vec::new(),
|
||||||
|
json_mode,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn add(&mut self, check: Check) {
|
||||||
|
self.checks.push(check);
|
||||||
|
}
|
||||||
|
fn any_failed(&self) -> bool {
|
||||||
|
self.checks.iter().any(|c| c.result == CheckResult::Fail)
|
||||||
|
}
|
||||||
fn print(&self) {
|
fn print(&self) {
|
||||||
if self.json_mode { self.print_json(); } else { self.print_human(); }
|
if self.json_mode {
|
||||||
|
self.print_json();
|
||||||
|
} else {
|
||||||
|
self.print_human();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn print_human(&self) {
|
fn print_human(&self) {
|
||||||
for check in &self.checks {
|
for check in &self.checks {
|
||||||
let icon = match check.result {
|
let icon = match check.result {
|
||||||
CheckResult::Pass => "[PASS]", CheckResult::Fail => "[FAIL]", CheckResult::Skip => "[SKIP]",
|
CheckResult::Pass => "[PASS]",
|
||||||
|
CheckResult::Fail => "[FAIL]",
|
||||||
|
#[cfg(not(target_os = "redox"))]
|
||||||
|
CheckResult::Skip => "[SKIP]",
|
||||||
};
|
};
|
||||||
println!("{icon} {}: {}", check.name, check.detail);
|
println!("{icon} {}: {}", check.name, check.detail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn print_json(&self) {
|
fn print_json(&self) {
|
||||||
#[derive(serde::Serialize)]
|
#[derive(serde::Serialize)]
|
||||||
struct JsonCheck { name: String, result: String, detail: String }
|
struct JsonCheck {
|
||||||
|
name: String,
|
||||||
|
result: String,
|
||||||
|
detail: String,
|
||||||
|
}
|
||||||
#[derive(serde::Serialize)]
|
#[derive(serde::Serialize)]
|
||||||
struct JsonReport {
|
struct JsonReport {
|
||||||
pcid_spawner: bool, drm_device: bool, compositor_socket: bool,
|
pcid_spawner: bool,
|
||||||
greeter_service: bool, checks: Vec<JsonCheck>,
|
drm_device: bool,
|
||||||
|
compositor_socket: bool,
|
||||||
|
greeter_service: bool,
|
||||||
|
checks: Vec<JsonCheck>,
|
||||||
}
|
}
|
||||||
let pcid = self.checks.iter().find(|c| c.name == "PCID_SPAWNER").map_or(false, |c| c.result == CheckResult::Pass);
|
let pcid = self
|
||||||
let drm = self.checks.iter().find(|c| c.name == "DRM_DEVICE").map_or(false, |c| c.result == CheckResult::Pass);
|
.checks
|
||||||
let socket = self.checks.iter().find(|c| c.name == "COMPOSITOR_SOCKET").map_or(false, |c| c.result == CheckResult::Pass);
|
.iter()
|
||||||
let greeter = self.checks.iter().find(|c| c.name == "GREETER_SERVICE").map_or(false, |c| c.result == CheckResult::Pass);
|
.find(|c| c.name == "PCID_SPAWNER")
|
||||||
let checks: Vec<JsonCheck> = self.checks.iter().map(|c| JsonCheck {
|
.map_or(false, |c| c.result == CheckResult::Pass);
|
||||||
name: c.name.clone(), result: c.result.label().to_string(), detail: c.detail.clone(),
|
let drm = self
|
||||||
}).collect();
|
.checks
|
||||||
if let Err(err) = serde_json::to_writer(std::io::stdout(), &JsonReport { pcid_spawner: pcid, drm_device: drm, compositor_socket: socket, greeter_service: greeter, checks }) {
|
.iter()
|
||||||
|
.find(|c| c.name == "DRM_DEVICE")
|
||||||
|
.map_or(false, |c| c.result == CheckResult::Pass);
|
||||||
|
let socket = self
|
||||||
|
.checks
|
||||||
|
.iter()
|
||||||
|
.find(|c| c.name == "COMPOSITOR_SOCKET")
|
||||||
|
.map_or(false, |c| c.result == CheckResult::Pass);
|
||||||
|
let greeter = self
|
||||||
|
.checks
|
||||||
|
.iter()
|
||||||
|
.find(|c| c.name == "GREETER_SERVICE")
|
||||||
|
.map_or(false, |c| c.result == CheckResult::Pass);
|
||||||
|
let checks: Vec<JsonCheck> = self
|
||||||
|
.checks
|
||||||
|
.iter()
|
||||||
|
.map(|c| JsonCheck {
|
||||||
|
name: c.name.clone(),
|
||||||
|
result: c.result.label().to_string(),
|
||||||
|
detail: c.detail.clone(),
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
if let Err(err) = serde_json::to_writer(
|
||||||
|
std::io::stdout(),
|
||||||
|
&JsonReport {
|
||||||
|
pcid_spawner: pcid,
|
||||||
|
drm_device: drm,
|
||||||
|
compositor_socket: socket,
|
||||||
|
greeter_service: greeter,
|
||||||
|
checks,
|
||||||
|
},
|
||||||
|
) {
|
||||||
eprintln!("{PROGRAM}: failed to serialize JSON: {err}");
|
eprintln!("{PROGRAM}: failed to serialize JSON: {err}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,7 +160,10 @@ fn parse_args() -> Result<bool, String> {
|
|||||||
for arg in std::env::args().skip(1) {
|
for arg in std::env::args().skip(1) {
|
||||||
match arg.as_str() {
|
match arg.as_str() {
|
||||||
"--json" => json_mode = true,
|
"--json" => json_mode = true,
|
||||||
"-h" | "--help" => { println!("{USAGE}"); return Err(String::new()); }
|
"-h" | "--help" => {
|
||||||
|
println!("{USAGE}");
|
||||||
|
return Err(String::new());
|
||||||
|
}
|
||||||
_ => return Err(format!("unsupported argument: {arg}")),
|
_ => return Err(format!("unsupported argument: {arg}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,9 +175,15 @@ fn check_pcid_spawner() -> Check {
|
|||||||
let service = "/usr/lib/init.d/00_pcid-spawner.service";
|
let service = "/usr/lib/init.d/00_pcid-spawner.service";
|
||||||
if std::path::Path::new(service).exists() {
|
if std::path::Path::new(service).exists() {
|
||||||
if std::path::Path::new("/scheme/pci").exists() {
|
if std::path::Path::new("/scheme/pci").exists() {
|
||||||
Check::pass("PCID_SPAWNER", "pcid-spawner service present, /scheme/pci registered")
|
Check::pass(
|
||||||
|
"PCID_SPAWNER",
|
||||||
|
"pcid-spawner service present, /scheme/pci registered",
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
Check::fail("PCID_SPAWNER", "pcid-spawner installed but /scheme/pci not registered")
|
Check::fail(
|
||||||
|
"PCID_SPAWNER",
|
||||||
|
"pcid-spawner installed but /scheme/pci not registered",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Check::fail("PCID_SPAWNER", "pcid-spawner service not found")
|
Check::fail("PCID_SPAWNER", "pcid-spawner service not found")
|
||||||
@@ -105,13 +195,17 @@ fn check_drm_device() -> Check {
|
|||||||
if std::path::Path::new("/scheme/drm/card0").exists() {
|
if std::path::Path::new("/scheme/drm/card0").exists() {
|
||||||
Check::pass("DRM_DEVICE", "/scheme/drm/card0 registered")
|
Check::pass("DRM_DEVICE", "/scheme/drm/card0 registered")
|
||||||
} else {
|
} else {
|
||||||
Check::fail("DRM_DEVICE", "/scheme/drm/card0 not found — DRM backend unavailable")
|
Check::fail(
|
||||||
|
"DRM_DEVICE",
|
||||||
|
"/scheme/drm/card0 not found — DRM backend unavailable",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "redox")]
|
#[cfg(target_os = "redox")]
|
||||||
fn check_compositor_socket() -> Check {
|
fn check_compositor_socket() -> Check {
|
||||||
let runtime = std::env::var("XDG_RUNTIME_DIR").unwrap_or_else(|_| "/tmp/run/redbear-greeter".into());
|
let runtime =
|
||||||
|
std::env::var("XDG_RUNTIME_DIR").unwrap_or_else(|_| "/tmp/run/redbear-greeter".into());
|
||||||
let display = std::env::var("WAYLAND_DISPLAY").unwrap_or_else(|_| "wayland-0".into());
|
let display = std::env::var("WAYLAND_DISPLAY").unwrap_or_else(|_| "wayland-0".into());
|
||||||
let socket = format!("{}/{}", runtime, display);
|
let socket = format!("{}/{}", runtime, display);
|
||||||
if std::path::Path::new(&socket).exists() {
|
if std::path::Path::new(&socket).exists() {
|
||||||
@@ -132,7 +226,10 @@ fn check_greeter_service() -> Check {
|
|||||||
if std::path::Path::new("/run/redbear-greeterd.sock").exists() {
|
if std::path::Path::new("/run/redbear-greeterd.sock").exists() {
|
||||||
Check::pass("GREETER_SERVICE", "greeterd binary present, socket active")
|
Check::pass("GREETER_SERVICE", "greeterd binary present, socket active")
|
||||||
} else {
|
} else {
|
||||||
Check::pass("GREETER_SERVICE", "greeterd binary present (socket may not be ready yet)")
|
Check::pass(
|
||||||
|
"GREETER_SERVICE",
|
||||||
|
"greeterd binary present (socket may not be ready yet)",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Check::fail("GREETER_SERVICE", "greeterd binary not found")
|
Check::fail("GREETER_SERVICE", "greeterd binary not found")
|
||||||
@@ -140,18 +237,29 @@ fn check_greeter_service() -> Check {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "redox"))]
|
#[cfg(not(target_os = "redox"))]
|
||||||
fn check_pcid_spawner() -> Check { Check::skip("PCID_SPAWNER", "requires Redox runtime") }
|
fn check_pcid_spawner() -> Check {
|
||||||
|
Check::skip("PCID_SPAWNER", "requires Redox runtime")
|
||||||
|
}
|
||||||
#[cfg(not(target_os = "redox"))]
|
#[cfg(not(target_os = "redox"))]
|
||||||
fn check_drm_device() -> Check { Check::skip("DRM_DEVICE", "requires Redox runtime") }
|
fn check_drm_device() -> Check {
|
||||||
|
Check::skip("DRM_DEVICE", "requires Redox runtime")
|
||||||
|
}
|
||||||
#[cfg(not(target_os = "redox"))]
|
#[cfg(not(target_os = "redox"))]
|
||||||
fn check_compositor_socket() -> Check { Check::skip("COMPOSITOR_SOCKET", "requires Redox runtime") }
|
fn check_compositor_socket() -> Check {
|
||||||
|
Check::skip("COMPOSITOR_SOCKET", "requires Redox runtime")
|
||||||
|
}
|
||||||
#[cfg(not(target_os = "redox"))]
|
#[cfg(not(target_os = "redox"))]
|
||||||
fn check_greeter_service() -> Check { Check::skip("GREETER_SERVICE", "requires Redox runtime") }
|
fn check_greeter_service() -> Check {
|
||||||
|
Check::skip("GREETER_SERVICE", "requires Redox runtime")
|
||||||
|
}
|
||||||
|
|
||||||
fn run() -> Result<(), String> {
|
fn run() -> Result<(), String> {
|
||||||
#[cfg(not(target_os = "redox"))]
|
#[cfg(not(target_os = "redox"))]
|
||||||
{
|
{
|
||||||
if std::env::args().any(|a| a == "-h" || a == "--help") { println!("{USAGE}"); return Err(String::new()); }
|
if std::env::args().any(|a| a == "-h" || a == "--help") {
|
||||||
|
println!("{USAGE}");
|
||||||
|
return Err(String::new());
|
||||||
|
}
|
||||||
println!("{PROGRAM}: boot check requires Redox runtime");
|
println!("{PROGRAM}: boot check requires Redox runtime");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -164,14 +272,18 @@ fn run() -> Result<(), String> {
|
|||||||
report.add(check_compositor_socket());
|
report.add(check_compositor_socket());
|
||||||
report.add(check_greeter_service());
|
report.add(check_greeter_service());
|
||||||
report.print();
|
report.print();
|
||||||
if report.any_failed() { return Err("one or more boot checks failed".to_string()); }
|
if report.any_failed() {
|
||||||
|
return Err("one or more boot checks failed".to_string());
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if let Err(err) = run() {
|
if let Err(err) = run() {
|
||||||
if err.is_empty() { process::exit(0); }
|
if err.is_empty() {
|
||||||
|
process::exit(0);
|
||||||
|
}
|
||||||
eprintln!("{PROGRAM}: {err}");
|
eprintln!("{PROGRAM}: {err}");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ const AUTHD_BIN: &str = "/usr/bin/redbear-authd";
|
|||||||
const SESSION_LAUNCH_BIN: &str = "/usr/bin/redbear-session-launch";
|
const SESSION_LAUNCH_BIN: &str = "/usr/bin/redbear-session-launch";
|
||||||
const GREETER_BACKGROUND: &str = "/usr/share/redbear/greeter/background.png";
|
const GREETER_BACKGROUND: &str = "/usr/share/redbear/greeter/background.png";
|
||||||
const GREETER_ICON: &str = "/usr/share/redbear/greeter/icon.png";
|
const GREETER_ICON: &str = "/usr/share/redbear/greeter/icon.png";
|
||||||
const AUTHD_SERVICE: &str = "/usr/lib/init.d/19_redbear-authd.service";
|
const AUTHD_SERVICE: &str = "/etc/init.d/19_redbear-authd.service";
|
||||||
const DISPLAY_SHIM_SERVICE: &str = "/usr/lib/init.d/20_display.service";
|
const DISPLAY_SHIM_SERVICE: &str = "/etc/init.d/20_display.service";
|
||||||
const GREETER_SERVICE: &str = "/usr/lib/init.d/20_greeter.service";
|
const GREETER_SERVICE: &str = "/etc/init.d/20_greeter.service";
|
||||||
const ACTIVATE_CONSOLE_SERVICE: &str = "/usr/lib/init.d/29_activate_console.service";
|
const ACTIVATE_CONSOLE_SERVICE: &str = "/etc/init.d/29_activate_console.service";
|
||||||
const CONSOLE_SERVICE: &str = "/usr/lib/init.d/30_console.service";
|
const CONSOLE_SERVICE: &str = "/etc/init.d/30_console.service";
|
||||||
const DEBUG_CONSOLE_SERVICE: &str = "/usr/lib/init.d/31_debug_console.service";
|
const DEBUG_CONSOLE_SERVICE: &str = "/etc/init.d/31_debug_console.service";
|
||||||
const VALIDATION_REQUEST: &str = "/run/redbear-kde-session.validation-request";
|
const VALIDATION_REQUEST: &str = "/run/redbear-kde-session.validation-request";
|
||||||
const VALIDATION_SUCCESS: &str = "/run/redbear-kde-session.validation-success";
|
const VALIDATION_SUCCESS: &str = "/run/redbear-kde-session.validation-success";
|
||||||
|
|
||||||
|
|||||||
@@ -60,14 +60,6 @@ impl Check {
|
|||||||
detail: detail.to_string(),
|
detail: detail.to_string(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn skip(name: &str, detail: &str) -> Self {
|
|
||||||
Check {
|
|
||||||
name: name.to_string(),
|
|
||||||
result: CheckResult::Skip,
|
|
||||||
detail: detail.to_string(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "redox")]
|
#[cfg(target_os = "redox")]
|
||||||
@@ -253,7 +245,7 @@ fn check_card_responds() -> Check {
|
|||||||
"CARD0_RESPONDS",
|
"CARD0_RESPONDS",
|
||||||
&format!("{} byte(s) from card node", content.len()),
|
&format!("{} byte(s) from card node", content.len()),
|
||||||
),
|
),
|
||||||
Ok(content) => Check::fail("CARD0_RESPONDS", "card node returned empty response"),
|
Ok(_) => Check::fail("CARD0_RESPONDS", "card node returned empty response"),
|
||||||
Err(msg) => Check::fail("CARD0_RESPONDS", &msg),
|
Err(msg) => Check::fail("CARD0_RESPONDS", &msg),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,7 +190,16 @@ fn overall_success(report: &Report, config: &Config) -> bool {
|
|||||||
(!config.keyboard || report.keyboard_count > 0),
|
(!config.keyboard || report.keyboard_count > 0),
|
||||||
(!config.pointer || report.pointer_count > 0),
|
(!config.pointer || report.pointer_count > 0),
|
||||||
(!config.drm || report.drm_count > 0),
|
(!config.drm || report.drm_count > 0),
|
||||||
].iter().map(|&pass| if pass { CheckStatus::Pass("ok".to_string()) } else { CheckStatus::Fail("none found".to_string()) }).collect();
|
]
|
||||||
|
.iter()
|
||||||
|
.map(|&pass| {
|
||||||
|
if pass {
|
||||||
|
CheckStatus::Pass("ok".to_string())
|
||||||
|
} else {
|
||||||
|
CheckStatus::Fail("none found".to_string())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
checks.iter().all(|c| matches!(c, CheckStatus::Pass(_)))
|
checks.iter().all(|c| matches!(c, CheckStatus::Pass(_)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -234,7 +234,10 @@ fn check_kf6_libraries() -> Check {
|
|||||||
if missing.is_empty() {
|
if missing.is_empty() {
|
||||||
Check::pass(
|
Check::pass(
|
||||||
"KF6_LIBRARIES",
|
"KF6_LIBRARIES",
|
||||||
format!("{found}/{} key KF6 libraries found", KEY_KF6_LIBRARIES.len()),
|
format!(
|
||||||
|
"{found}/{} key KF6 libraries found",
|
||||||
|
KEY_KF6_LIBRARIES.len()
|
||||||
|
),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
let preview = missing
|
let preview = missing
|
||||||
@@ -245,7 +248,10 @@ fn check_kf6_libraries() -> Check {
|
|||||||
.join(", ");
|
.join(", ");
|
||||||
Check::pass(
|
Check::pass(
|
||||||
"KF6_LIBRARIES",
|
"KF6_LIBRARIES",
|
||||||
format!("{found}/{} found, missing: {preview}", KEY_KF6_LIBRARIES.len()),
|
format!(
|
||||||
|
"{found}/{} found, missing: {preview}",
|
||||||
|
KEY_KF6_LIBRARIES.len()
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -418,15 +418,11 @@ fn run_redox(json_mode: bool) -> Result<(), String> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut exporter_handle = None;
|
|
||||||
let mut importer_src_handle = None;
|
|
||||||
let mut importer_dst_handle = None;
|
|
||||||
|
|
||||||
let create_exporter = DrmGemCreateWire {
|
let create_exporter = DrmGemCreateWire {
|
||||||
size: 4096,
|
size: 4096,
|
||||||
..DrmGemCreateWire::default()
|
..DrmGemCreateWire::default()
|
||||||
};
|
};
|
||||||
match drm_query(
|
let exporter_handle = match drm_query(
|
||||||
&mut exporter,
|
&mut exporter,
|
||||||
DRM_IOCTL_GEM_CREATE,
|
DRM_IOCTL_GEM_CREATE,
|
||||||
bytes_of(&create_exporter),
|
bytes_of(&create_exporter),
|
||||||
@@ -434,7 +430,6 @@ fn run_redox(json_mode: bool) -> Result<(), String> {
|
|||||||
.and_then(|response| decode_wire_exact::<DrmGemCreateWire>(&response))
|
.and_then(|response| decode_wire_exact::<DrmGemCreateWire>(&response))
|
||||||
{
|
{
|
||||||
Ok(created) => {
|
Ok(created) => {
|
||||||
exporter_handle = Some(created.handle);
|
|
||||||
report.add(Check::pass(
|
report.add(Check::pass(
|
||||||
"GEM_BUFFER_ALLOCATION",
|
"GEM_BUFFER_ALLOCATION",
|
||||||
&format!(
|
&format!(
|
||||||
@@ -442,6 +437,7 @@ fn run_redox(json_mode: bool) -> Result<(), String> {
|
|||||||
created.handle
|
created.handle
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
created.handle
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
report.add(Check::fail("GEM_BUFFER_ALLOCATION", &err));
|
report.add(Check::fail("GEM_BUFFER_ALLOCATION", &err));
|
||||||
@@ -464,81 +460,82 @@ fn run_redox(json_mode: bool) -> Result<(), String> {
|
|||||||
report.print();
|
report.print();
|
||||||
return Err("one or more Phase 5 CS checks failed".to_string());
|
return Err("one or more Phase 5 CS checks failed".to_string());
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
if let Some(handle) = exporter_handle {
|
let export = DrmPrimeHandleToFdWire {
|
||||||
let export = DrmPrimeHandleToFdWire { handle, flags: 0 };
|
handle: exporter_handle,
|
||||||
let prime_result = drm_query(
|
flags: 0,
|
||||||
&mut exporter,
|
};
|
||||||
DRM_IOCTL_PRIME_HANDLE_TO_FD,
|
let prime_result = drm_query(
|
||||||
bytes_of(&export),
|
&mut exporter,
|
||||||
)
|
DRM_IOCTL_PRIME_HANDLE_TO_FD,
|
||||||
.and_then(|response| decode_wire_exact::<DrmPrimeHandleToFdResponseWire>(&response))
|
bytes_of(&export),
|
||||||
.and_then(|exported| {
|
)
|
||||||
if exported.fd < 0 {
|
.and_then(|response| decode_wire_exact::<DrmPrimeHandleToFdResponseWire>(&response))
|
||||||
return Err(format!(
|
.and_then(|exported| {
|
||||||
"PRIME export returned invalid token {} for GEM {}",
|
if exported.fd < 0 {
|
||||||
exported.fd, handle
|
return Err(format!(
|
||||||
));
|
"PRIME export returned invalid token {} for GEM {}",
|
||||||
}
|
exported.fd, exporter_handle
|
||||||
|
));
|
||||||
let import = DrmPrimeFdToHandleWire {
|
|
||||||
fd: exported.fd,
|
|
||||||
pad: 0,
|
|
||||||
};
|
|
||||||
drm_query(
|
|
||||||
&mut importer,
|
|
||||||
DRM_IOCTL_PRIME_FD_TO_HANDLE,
|
|
||||||
bytes_of(&import),
|
|
||||||
)
|
|
||||||
.and_then(|response| decode_wire_exact::<DrmPrimeFdToHandleResponseWire>(&response))
|
|
||||||
.map(|imported| (exported.fd, imported.handle))
|
|
||||||
});
|
|
||||||
|
|
||||||
match prime_result {
|
|
||||||
Ok((token, imported_handle)) => {
|
|
||||||
importer_src_handle = Some(imported_handle);
|
|
||||||
report.add(Check::pass(
|
|
||||||
"PRIME_BUFFER_SHARING",
|
|
||||||
&format!(
|
|
||||||
"export token {} imported as GEM handle {} on a second DRM fd",
|
|
||||||
token, imported_handle
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
report.add(Check::fail("PRIME_BUFFER_SHARING", &err));
|
|
||||||
report.add(Check::skip(
|
|
||||||
"CS_IOCTL_PROTOCOL",
|
|
||||||
"blocked: PRIME import/export failed",
|
|
||||||
));
|
|
||||||
report.add(Check::skip(
|
|
||||||
"FENCE_SYNC_SUPPORT",
|
|
||||||
"blocked: PRIME import/export failed",
|
|
||||||
));
|
|
||||||
report.add(Check::skip(
|
|
||||||
"HARDWARE_VALIDATION_PENDING",
|
|
||||||
"real hardware rendering validation still requires bare-metal evidence",
|
|
||||||
));
|
|
||||||
close_gem(&mut exporter, handle);
|
|
||||||
report.print();
|
|
||||||
return Err("one or more Phase 5 CS checks failed".to_string());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
let import = DrmPrimeFdToHandleWire {
|
||||||
|
fd: exported.fd,
|
||||||
|
pad: 0,
|
||||||
|
};
|
||||||
|
drm_query(
|
||||||
|
&mut importer,
|
||||||
|
DRM_IOCTL_PRIME_FD_TO_HANDLE,
|
||||||
|
bytes_of(&import),
|
||||||
|
)
|
||||||
|
.and_then(|response| decode_wire_exact::<DrmPrimeFdToHandleResponseWire>(&response))
|
||||||
|
.map(|imported| (exported.fd, imported.handle))
|
||||||
|
});
|
||||||
|
|
||||||
|
let importer_src_handle = match prime_result {
|
||||||
|
Ok((token, imported_handle)) => {
|
||||||
|
report.add(Check::pass(
|
||||||
|
"PRIME_BUFFER_SHARING",
|
||||||
|
&format!(
|
||||||
|
"export token {} imported as GEM handle {} on a second DRM fd",
|
||||||
|
token, imported_handle
|
||||||
|
),
|
||||||
|
));
|
||||||
|
imported_handle
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
report.add(Check::fail("PRIME_BUFFER_SHARING", &err));
|
||||||
|
report.add(Check::skip(
|
||||||
|
"CS_IOCTL_PROTOCOL",
|
||||||
|
"blocked: PRIME import/export failed",
|
||||||
|
));
|
||||||
|
report.add(Check::skip(
|
||||||
|
"FENCE_SYNC_SUPPORT",
|
||||||
|
"blocked: PRIME import/export failed",
|
||||||
|
));
|
||||||
|
report.add(Check::skip(
|
||||||
|
"HARDWARE_VALIDATION_PENDING",
|
||||||
|
"real hardware rendering validation still requires bare-metal evidence",
|
||||||
|
));
|
||||||
|
close_gem(&mut exporter, exporter_handle);
|
||||||
|
report.print();
|
||||||
|
return Err("one or more Phase 5 CS checks failed".to_string());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let create_importer = DrmGemCreateWire {
|
let create_importer = DrmGemCreateWire {
|
||||||
size: 4096,
|
size: 4096,
|
||||||
..DrmGemCreateWire::default()
|
..DrmGemCreateWire::default()
|
||||||
};
|
};
|
||||||
match drm_query(
|
let importer_dst_handle = match drm_query(
|
||||||
&mut importer,
|
&mut importer,
|
||||||
DRM_IOCTL_GEM_CREATE,
|
DRM_IOCTL_GEM_CREATE,
|
||||||
bytes_of(&create_importer),
|
bytes_of(&create_importer),
|
||||||
)
|
)
|
||||||
.and_then(|response| decode_wire_exact::<DrmGemCreateWire>(&response))
|
.and_then(|response| decode_wire_exact::<DrmGemCreateWire>(&response))
|
||||||
{
|
{
|
||||||
Ok(created) => importer_dst_handle = Some(created.handle),
|
Ok(created) => created.handle,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
report.add(Check::fail(
|
report.add(Check::fail(
|
||||||
"CS_IOCTL_PROTOCOL",
|
"CS_IOCTL_PROTOCOL",
|
||||||
@@ -552,35 +549,30 @@ fn run_redox(json_mode: bool) -> Result<(), String> {
|
|||||||
"HARDWARE_VALIDATION_PENDING",
|
"HARDWARE_VALIDATION_PENDING",
|
||||||
"real hardware rendering validation still requires bare-metal evidence",
|
"real hardware rendering validation still requires bare-metal evidence",
|
||||||
));
|
));
|
||||||
if let Some(handle) = importer_src_handle {
|
close_gem(&mut importer, importer_src_handle);
|
||||||
close_gem(&mut importer, handle);
|
close_gem(&mut exporter, exporter_handle);
|
||||||
}
|
|
||||||
if let Some(handle) = exporter_handle {
|
|
||||||
close_gem(&mut exporter, handle);
|
|
||||||
}
|
|
||||||
report.print();
|
report.print();
|
||||||
return Err("one or more Phase 5 CS checks failed".to_string());
|
return Err("one or more Phase 5 CS checks failed".to_string());
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
let submit_result = match (importer_src_handle, importer_dst_handle) {
|
let submit_result = {
|
||||||
(Some(src_handle), Some(dst_handle)) => {
|
let src_handle = importer_src_handle;
|
||||||
let submit = RedoxPrivateCsSubmit {
|
let dst_handle = importer_dst_handle;
|
||||||
src_handle,
|
let submit = RedoxPrivateCsSubmit {
|
||||||
dst_handle,
|
src_handle,
|
||||||
src_offset: 0,
|
dst_handle,
|
||||||
dst_offset: 0,
|
src_offset: 0,
|
||||||
byte_count: 64,
|
dst_offset: 0,
|
||||||
};
|
byte_count: 64,
|
||||||
drm_query(
|
};
|
||||||
&mut importer,
|
drm_query(
|
||||||
DRM_IOCTL_REDOX_PRIVATE_CS_SUBMIT,
|
&mut importer,
|
||||||
bytes_of(&submit),
|
DRM_IOCTL_REDOX_PRIVATE_CS_SUBMIT,
|
||||||
)
|
bytes_of(&submit),
|
||||||
.and_then(|response| decode_wire_exact::<RedoxPrivateCsSubmitResult>(&response))
|
)
|
||||||
.map(|result| (src_handle, dst_handle, result.seqno))
|
.and_then(|response| decode_wire_exact::<RedoxPrivateCsSubmitResult>(&response))
|
||||||
}
|
.map(|result| (src_handle, dst_handle, result.seqno))
|
||||||
_ => Err("command submission prerequisites were incomplete".to_string()),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
match submit_result {
|
match submit_result {
|
||||||
@@ -646,15 +638,9 @@ fn run_redox(json_mode: bool) -> Result<(), String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(handle) = importer_dst_handle {
|
close_gem(&mut importer, importer_dst_handle);
|
||||||
close_gem(&mut importer, handle);
|
close_gem(&mut importer, importer_src_handle);
|
||||||
}
|
close_gem(&mut exporter, exporter_handle);
|
||||||
if let Some(handle) = importer_src_handle {
|
|
||||||
close_gem(&mut importer, handle);
|
|
||||||
}
|
|
||||||
if let Some(handle) = exporter_handle {
|
|
||||||
close_gem(&mut exporter, handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
report.add(Check::skip(
|
report.add(Check::skip(
|
||||||
"HARDWARE_VALIDATION_PENDING",
|
"HARDWARE_VALIDATION_PENDING",
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
#[cfg(target_os = "redox")]
|
#[cfg(target_os = "redox")]
|
||||||
use redbear_hwutils::{PciLocation, lookup_pci_device_name, lookup_pci_vendor_name, parse_pci_location};
|
use redbear_hwutils::{
|
||||||
|
PciLocation, lookup_pci_device_name, lookup_pci_vendor_name, parse_pci_location,
|
||||||
|
};
|
||||||
#[cfg(target_os = "redox")]
|
#[cfg(target_os = "redox")]
|
||||||
use redox_driver_sys::pci::parse_device_info_from_config_space;
|
use redox_driver_sys::pci::parse_device_info_from_config_space;
|
||||||
|
|
||||||
@@ -334,10 +336,7 @@ fn format_gpu_pci_device(device: &GpuPciDevice) -> String {
|
|||||||
let device_name = lookup_pci_device_name(device.vendor_id, device.device_id)
|
let device_name = lookup_pci_device_name(device.vendor_id, device.device_id)
|
||||||
.unwrap_or_else(|| format!("device {:04x}", device.device_id));
|
.unwrap_or_else(|| format!("device {:04x}", device.device_id));
|
||||||
|
|
||||||
format!(
|
format!("{} {} ({})", device.location, vendor, device_name)
|
||||||
"{} {} ({})",
|
|
||||||
device.location, vendor, device_name
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "redox")]
|
#[cfg(target_os = "redox")]
|
||||||
|
|||||||
@@ -12,69 +12,165 @@ const USAGE: &str = "Usage: redbear-usb-check [--json]\n\n\
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||||
enum CheckResult { Pass, Fail, Skip }
|
enum CheckResult {
|
||||||
|
Pass,
|
||||||
|
Fail,
|
||||||
|
Skip,
|
||||||
|
}
|
||||||
|
|
||||||
impl CheckResult {
|
impl CheckResult {
|
||||||
fn label(self) -> &'static str {
|
fn label(self) -> &'static str {
|
||||||
match self { Self::Pass => "PASS", Self::Fail => "FAIL", Self::Skip => "SKIP" }
|
match self {
|
||||||
|
Self::Pass => "PASS",
|
||||||
|
Self::Fail => "FAIL",
|
||||||
|
Self::Skip => "SKIP",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Check { name: String, result: CheckResult, detail: String }
|
struct Check {
|
||||||
|
name: String,
|
||||||
|
result: CheckResult,
|
||||||
|
detail: String,
|
||||||
|
}
|
||||||
|
|
||||||
impl Check {
|
impl Check {
|
||||||
fn pass(name: &str, detail: &str) -> Self {
|
fn pass(name: &str, detail: &str) -> Self {
|
||||||
Check { name: name.to_string(), result: CheckResult::Pass, detail: detail.to_string() }
|
Check {
|
||||||
|
name: name.to_string(),
|
||||||
|
result: CheckResult::Pass,
|
||||||
|
detail: detail.to_string(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn fail(name: &str, detail: &str) -> Self {
|
fn fail(name: &str, detail: &str) -> Self {
|
||||||
Check { name: name.to_string(), result: CheckResult::Fail, detail: detail.to_string() }
|
Check {
|
||||||
|
name: name.to_string(),
|
||||||
|
result: CheckResult::Fail,
|
||||||
|
detail: detail.to_string(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn skip(name: &str, detail: &str) -> Self {
|
fn skip(name: &str, detail: &str) -> Self {
|
||||||
Check { name: name.to_string(), result: CheckResult::Skip, detail: detail.to_string() }
|
Check {
|
||||||
|
name: name.to_string(),
|
||||||
|
result: CheckResult::Skip,
|
||||||
|
detail: detail.to_string(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Report { checks: Vec<Check>, json_mode: bool }
|
struct Report {
|
||||||
|
checks: Vec<Check>,
|
||||||
|
json_mode: bool,
|
||||||
|
}
|
||||||
|
|
||||||
impl Report {
|
impl Report {
|
||||||
fn new(json_mode: bool) -> Self { Report { checks: Vec::new(), json_mode } }
|
fn new(json_mode: bool) -> Self {
|
||||||
fn add(&mut self, check: Check) { self.checks.push(check); }
|
Report {
|
||||||
fn any_failed(&self) -> bool { self.checks.iter().any(|c| c.result == CheckResult::Fail) }
|
checks: Vec::new(),
|
||||||
|
json_mode,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn add(&mut self, check: Check) {
|
||||||
|
self.checks.push(check);
|
||||||
|
}
|
||||||
|
fn any_failed(&self) -> bool {
|
||||||
|
self.checks.iter().any(|c| c.result == CheckResult::Fail)
|
||||||
|
}
|
||||||
fn print(&self) {
|
fn print(&self) {
|
||||||
if self.json_mode { self.print_json(); } else { self.print_human(); }
|
if self.json_mode {
|
||||||
|
self.print_json();
|
||||||
|
} else {
|
||||||
|
self.print_human();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn print_human(&self) {
|
fn print_human(&self) {
|
||||||
for check in &self.checks {
|
for check in &self.checks {
|
||||||
let icon = match check.result {
|
let icon = match check.result {
|
||||||
CheckResult::Pass => "[PASS]", CheckResult::Fail => "[FAIL]", CheckResult::Skip => "[SKIP]",
|
CheckResult::Pass => "[PASS]",
|
||||||
|
CheckResult::Fail => "[FAIL]",
|
||||||
|
CheckResult::Skip => "[SKIP]",
|
||||||
};
|
};
|
||||||
println!("{icon} {}: {}", check.name, check.detail);
|
println!("{icon} {}: {}", check.name, check.detail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn print_json(&self) {
|
fn print_json(&self) {
|
||||||
#[derive(serde::Serialize)]
|
#[derive(serde::Serialize)]
|
||||||
struct JsonCheck { name: String, result: String, detail: String }
|
struct JsonCheck {
|
||||||
|
name: String,
|
||||||
|
result: String,
|
||||||
|
detail: String,
|
||||||
|
}
|
||||||
#[derive(serde::Serialize)]
|
#[derive(serde::Serialize)]
|
||||||
struct JsonReport {
|
struct JsonReport {
|
||||||
xhci_controllers: usize, usb_devices: usize,
|
xhci_controllers: usize,
|
||||||
hid_devices: usize, storage_devices: usize, checks: Vec<JsonCheck>,
|
usb_devices: usize,
|
||||||
|
hid_devices: usize,
|
||||||
|
storage_devices: usize,
|
||||||
|
checks: Vec<JsonCheck>,
|
||||||
}
|
}
|
||||||
let xhci = self.checks.iter().find(|c| c.name == "XHCI_CONTROLLER").map_or(0, |c| {
|
let xhci = self
|
||||||
c.detail.split(' ').next().and_then(|s| s.parse().ok()).unwrap_or(0)
|
.checks
|
||||||
});
|
.iter()
|
||||||
let devices = self.checks.iter().find(|c| c.name == "USB_DEVICES").map_or(0, |c| {
|
.find(|c| c.name == "XHCI_CONTROLLER")
|
||||||
c.detail.strip_prefix("found ").and_then(|s| s.split(' ').next()).and_then(|s| s.parse().ok()).unwrap_or(0)
|
.map_or(0, |c| {
|
||||||
});
|
c.detail
|
||||||
let hid = self.checks.iter().find(|c| c.name == "USB_HID").map_or(0, |c| {
|
.split(' ')
|
||||||
c.detail.strip_prefix("found ").and_then(|s| s.split(' ').next()).and_then(|s| s.parse().ok()).unwrap_or(0)
|
.next()
|
||||||
});
|
.and_then(|s| s.parse().ok())
|
||||||
let storage = self.checks.iter().find(|c| c.name == "USB_STORAGE").map_or(0, |c| {
|
.unwrap_or(0)
|
||||||
c.detail.strip_prefix("found ").and_then(|s| s.split(' ').next()).and_then(|s| s.parse().ok()).unwrap_or(0)
|
});
|
||||||
});
|
let devices = self
|
||||||
let checks: Vec<JsonCheck> = self.checks.iter().map(|c| JsonCheck {
|
.checks
|
||||||
name: c.name.clone(), result: c.result.label().to_string(), detail: c.detail.clone(),
|
.iter()
|
||||||
}).collect();
|
.find(|c| c.name == "USB_DEVICES")
|
||||||
if let Err(err) = serde_json::to_writer(std::io::stdout(), &JsonReport { xhci_controllers: xhci, usb_devices: devices, hid_devices: hid, storage_devices: storage, checks }) {
|
.map_or(0, |c| {
|
||||||
|
c.detail
|
||||||
|
.strip_prefix("found ")
|
||||||
|
.and_then(|s| s.split(' ').next())
|
||||||
|
.and_then(|s| s.parse().ok())
|
||||||
|
.unwrap_or(0)
|
||||||
|
});
|
||||||
|
let hid = self
|
||||||
|
.checks
|
||||||
|
.iter()
|
||||||
|
.find(|c| c.name == "USB_HID")
|
||||||
|
.map_or(0, |c| {
|
||||||
|
c.detail
|
||||||
|
.strip_prefix("found ")
|
||||||
|
.and_then(|s| s.split(' ').next())
|
||||||
|
.and_then(|s| s.parse().ok())
|
||||||
|
.unwrap_or(0)
|
||||||
|
});
|
||||||
|
let storage = self
|
||||||
|
.checks
|
||||||
|
.iter()
|
||||||
|
.find(|c| c.name == "USB_STORAGE")
|
||||||
|
.map_or(0, |c| {
|
||||||
|
c.detail
|
||||||
|
.strip_prefix("found ")
|
||||||
|
.and_then(|s| s.split(' ').next())
|
||||||
|
.and_then(|s| s.parse().ok())
|
||||||
|
.unwrap_or(0)
|
||||||
|
});
|
||||||
|
let checks: Vec<JsonCheck> = self
|
||||||
|
.checks
|
||||||
|
.iter()
|
||||||
|
.map(|c| JsonCheck {
|
||||||
|
name: c.name.clone(),
|
||||||
|
result: c.result.label().to_string(),
|
||||||
|
detail: c.detail.clone(),
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
if let Err(err) = serde_json::to_writer(
|
||||||
|
std::io::stdout(),
|
||||||
|
&JsonReport {
|
||||||
|
xhci_controllers: xhci,
|
||||||
|
usb_devices: devices,
|
||||||
|
hid_devices: hid,
|
||||||
|
storage_devices: storage,
|
||||||
|
checks,
|
||||||
|
},
|
||||||
|
) {
|
||||||
eprintln!("{PROGRAM}: failed to serialize JSON: {err}");
|
eprintln!("{PROGRAM}: failed to serialize JSON: {err}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,7 +182,10 @@ fn parse_args() -> Result<bool, String> {
|
|||||||
for arg in std::env::args().skip(1) {
|
for arg in std::env::args().skip(1) {
|
||||||
match arg.as_str() {
|
match arg.as_str() {
|
||||||
"--json" => json_mode = true,
|
"--json" => json_mode = true,
|
||||||
"-h" | "--help" => { println!("{USAGE}"); return Err(String::new()); }
|
"-h" | "--help" => {
|
||||||
|
println!("{USAGE}");
|
||||||
|
return Err(String::new());
|
||||||
|
}
|
||||||
_ => return Err(format!("unsupported argument: {arg}")),
|
_ => return Err(format!("unsupported argument: {arg}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,7 +195,10 @@ fn parse_args() -> Result<bool, String> {
|
|||||||
#[cfg(target_os = "redox")]
|
#[cfg(target_os = "redox")]
|
||||||
fn list_dir(path: &str) -> Vec<String> {
|
fn list_dir(path: &str) -> Vec<String> {
|
||||||
match fs::read_dir(path) {
|
match fs::read_dir(path) {
|
||||||
Ok(entries) => entries.filter_map(|e| e.ok()).filter_map(|e| e.file_name().to_str().map(|s| s.to_string())).collect(),
|
Ok(entries) => entries
|
||||||
|
.filter_map(|e| e.ok())
|
||||||
|
.filter_map(|e| e.file_name().to_str().map(|s| s.to_string()))
|
||||||
|
.collect(),
|
||||||
Err(_) => Vec::new(),
|
Err(_) => Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,9 +207,15 @@ fn list_dir(path: &str) -> Vec<String> {
|
|||||||
fn check_xhci_controller() -> Check {
|
fn check_xhci_controller() -> Check {
|
||||||
let xhci = list_dir("/scheme/xhci");
|
let xhci = list_dir("/scheme/xhci");
|
||||||
if !xhci.is_empty() {
|
if !xhci.is_empty() {
|
||||||
Check::pass("XHCI_CONTROLLER", &format!("{} xHCI controller(s): {}", xhci.len(), xhci.join(", ")))
|
Check::pass(
|
||||||
|
"XHCI_CONTROLLER",
|
||||||
|
&format!("{} xHCI controller(s): {}", xhci.len(), xhci.join(", ")),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
Check::fail("XHCI_CONTROLLER", "no xHCI controllers found under /scheme/xhci")
|
Check::fail(
|
||||||
|
"XHCI_CONTROLLER",
|
||||||
|
"no xHCI controllers found under /scheme/xhci",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +232,10 @@ fn check_usb_devices() -> Check {
|
|||||||
total += ports.len();
|
total += ports.len();
|
||||||
}
|
}
|
||||||
if total > 0 {
|
if total > 0 {
|
||||||
Check::pass("USB_DEVICES", &format!("found {} device(s) across {} hub(s)", total, entries.len()))
|
Check::pass(
|
||||||
|
"USB_DEVICES",
|
||||||
|
&format!("found {} device(s) across {} hub(s)", total, entries.len()),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
Check::skip("USB_DEVICES", "USB hubs present but no devices attached")
|
Check::skip("USB_DEVICES", "USB hubs present but no devices attached")
|
||||||
}
|
}
|
||||||
@@ -141,7 +252,9 @@ fn check_usb_hid() -> Check {
|
|||||||
if let Ok(data) = fs::read_to_string(&desc_path) {
|
if let Ok(data) = fs::read_to_string(&desc_path) {
|
||||||
if let Ok(desc) = serde_json::from_str::<serde_json::Value>(&data) {
|
if let Ok(desc) = serde_json::from_str::<serde_json::Value>(&data) {
|
||||||
let class = desc.get("class").and_then(|v| v.as_u64()).unwrap_or(0);
|
let class = desc.get("class").and_then(|v| v.as_u64()).unwrap_or(0);
|
||||||
if class == 3 { hid_count += 1; }
|
if class == 3 {
|
||||||
|
hid_count += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,7 +262,10 @@ fn check_usb_hid() -> Check {
|
|||||||
if hid_count > 0 {
|
if hid_count > 0 {
|
||||||
Check::pass("USB_HID", &format!("found {} HID device(s)", hid_count))
|
Check::pass("USB_HID", &format!("found {} HID device(s)", hid_count))
|
||||||
} else {
|
} else {
|
||||||
Check::skip("USB_HID", "no USB HID devices found (may need physical hardware)")
|
Check::skip(
|
||||||
|
"USB_HID",
|
||||||
|
"no USB HID devices found (may need physical hardware)",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,22 +280,33 @@ fn check_usb_storage() -> Check {
|
|||||||
if let Ok(data) = fs::read_to_string(&desc_path) {
|
if let Ok(data) = fs::read_to_string(&desc_path) {
|
||||||
if let Ok(desc) = serde_json::from_str::<serde_json::Value>(&data) {
|
if let Ok(desc) = serde_json::from_str::<serde_json::Value>(&data) {
|
||||||
let class = desc.get("class").and_then(|v| v.as_u64()).unwrap_or(0);
|
let class = desc.get("class").and_then(|v| v.as_u64()).unwrap_or(0);
|
||||||
if class == 8 { storage_count += 1; }
|
if class == 8 {
|
||||||
|
storage_count += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if storage_count > 0 {
|
if storage_count > 0 {
|
||||||
Check::pass("USB_STORAGE", &format!("found {} storage device(s)", storage_count))
|
Check::pass(
|
||||||
|
"USB_STORAGE",
|
||||||
|
&format!("found {} storage device(s)", storage_count),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
Check::skip("USB_STORAGE", "no USB storage devices found (may need physical hardware)")
|
Check::skip(
|
||||||
|
"USB_STORAGE",
|
||||||
|
"no USB storage devices found (may need physical hardware)",
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run() -> Result<(), String> {
|
fn run() -> Result<(), String> {
|
||||||
#[cfg(not(target_os = "redox"))]
|
#[cfg(not(target_os = "redox"))]
|
||||||
{
|
{
|
||||||
if std::env::args().any(|a| a == "-h" || a == "--help") { println!("{USAGE}"); return Err(String::new()); }
|
if std::env::args().any(|a| a == "-h" || a == "--help") {
|
||||||
|
println!("{USAGE}");
|
||||||
|
return Err(String::new());
|
||||||
|
}
|
||||||
println!("{PROGRAM}: USB check requires Redox runtime");
|
println!("{PROGRAM}: USB check requires Redox runtime");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -192,14 +319,18 @@ fn run() -> Result<(), String> {
|
|||||||
report.add(check_usb_hid());
|
report.add(check_usb_hid());
|
||||||
report.add(check_usb_storage());
|
report.add(check_usb_storage());
|
||||||
report.print();
|
report.print();
|
||||||
if report.any_failed() { return Err("one or more USB checks failed".to_string()); }
|
if report.any_failed() {
|
||||||
|
return Err("one or more USB checks failed".to_string());
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if let Err(err) = run() {
|
if let Err(err) = run() {
|
||||||
if err.is_empty() { process::exit(0); }
|
if err.is_empty() {
|
||||||
|
process::exit(0);
|
||||||
|
}
|
||||||
eprintln!("{PROGRAM}: {err}");
|
eprintln!("{PROGRAM}: {err}");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,48 +16,94 @@ const SECTOR_SIZE: usize = 512;
|
|||||||
const TEST_PATTERN: &[u8; 24] = b"REDBEAR-USB-RW-PROOF\0\0\0\0";
|
const TEST_PATTERN: &[u8; 24] = b"REDBEAR-USB-RW-PROOF\0\0\0\0";
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||||
enum CheckResult { Pass, Fail, Skip }
|
enum CheckResult {
|
||||||
|
Pass,
|
||||||
|
Fail,
|
||||||
|
Skip,
|
||||||
|
}
|
||||||
|
|
||||||
impl CheckResult {
|
impl CheckResult {
|
||||||
fn label(self) -> &'static str {
|
fn label(self) -> &'static str {
|
||||||
match self { Self::Pass => "PASS", Self::Fail => "FAIL", Self::Skip => "SKIP" }
|
match self {
|
||||||
|
Self::Pass => "PASS",
|
||||||
|
Self::Fail => "FAIL",
|
||||||
|
Self::Skip => "SKIP",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Check { name: String, result: CheckResult, detail: String }
|
struct Check {
|
||||||
|
name: String,
|
||||||
|
result: CheckResult,
|
||||||
|
detail: String,
|
||||||
|
}
|
||||||
|
|
||||||
impl Check {
|
impl Check {
|
||||||
fn pass(name: &str, detail: &str) -> Self {
|
fn pass(name: &str, detail: &str) -> Self {
|
||||||
Check { name: name.to_string(), result: CheckResult::Pass, detail: detail.to_string() }
|
Check {
|
||||||
|
name: name.to_string(),
|
||||||
|
result: CheckResult::Pass,
|
||||||
|
detail: detail.to_string(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn fail(name: &str, detail: &str) -> Self {
|
fn fail(name: &str, detail: &str) -> Self {
|
||||||
Check { name: name.to_string(), result: CheckResult::Fail, detail: detail.to_string() }
|
Check {
|
||||||
|
name: name.to_string(),
|
||||||
|
result: CheckResult::Fail,
|
||||||
|
detail: detail.to_string(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn skip(name: &str, detail: &str) -> Self {
|
fn skip(name: &str, detail: &str) -> Self {
|
||||||
Check { name: name.to_string(), result: CheckResult::Skip, detail: detail.to_string() }
|
Check {
|
||||||
|
name: name.to_string(),
|
||||||
|
result: CheckResult::Skip,
|
||||||
|
detail: detail.to_string(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Report { checks: Vec<Check>, json_mode: bool }
|
struct Report {
|
||||||
|
checks: Vec<Check>,
|
||||||
|
json_mode: bool,
|
||||||
|
}
|
||||||
|
|
||||||
impl Report {
|
impl Report {
|
||||||
fn new(json_mode: bool) -> Self { Report { checks: Vec::new(), json_mode } }
|
fn new(json_mode: bool) -> Self {
|
||||||
fn add(&mut self, check: Check) { self.checks.push(check); }
|
Report {
|
||||||
fn any_failed(&self) -> bool { self.checks.iter().any(|c| c.result == CheckResult::Fail) }
|
checks: Vec::new(),
|
||||||
|
json_mode,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn add(&mut self, check: Check) {
|
||||||
|
self.checks.push(check);
|
||||||
|
}
|
||||||
|
fn any_failed(&self) -> bool {
|
||||||
|
self.checks.iter().any(|c| c.result == CheckResult::Fail)
|
||||||
|
}
|
||||||
fn print(&self) {
|
fn print(&self) {
|
||||||
if self.json_mode { self.print_json(); } else { self.print_human(); }
|
if self.json_mode {
|
||||||
|
self.print_json();
|
||||||
|
} else {
|
||||||
|
self.print_human();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn print_human(&self) {
|
fn print_human(&self) {
|
||||||
for check in &self.checks {
|
for check in &self.checks {
|
||||||
let icon = match check.result {
|
let icon = match check.result {
|
||||||
CheckResult::Pass => "[PASS]", CheckResult::Fail => "[FAIL]", CheckResult::Skip => "[SKIP]",
|
CheckResult::Pass => "[PASS]",
|
||||||
|
CheckResult::Fail => "[FAIL]",
|
||||||
|
CheckResult::Skip => "[SKIP]",
|
||||||
};
|
};
|
||||||
println!("{icon} {}: {}", check.name, check.detail);
|
println!("{icon} {}: {}", check.name, check.detail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn print_json(&self) {
|
fn print_json(&self) {
|
||||||
#[derive(serde::Serialize)]
|
#[derive(serde::Serialize)]
|
||||||
struct JsonCheck { name: String, result: String, detail: String }
|
struct JsonCheck {
|
||||||
|
name: String,
|
||||||
|
result: String,
|
||||||
|
detail: String,
|
||||||
|
}
|
||||||
#[derive(serde::Serialize)]
|
#[derive(serde::Serialize)]
|
||||||
struct JsonReport {
|
struct JsonReport {
|
||||||
device_path: String,
|
device_path: String,
|
||||||
@@ -66,21 +112,42 @@ impl Report {
|
|||||||
sector_restored: bool,
|
sector_restored: bool,
|
||||||
checks: Vec<JsonCheck>,
|
checks: Vec<JsonCheck>,
|
||||||
}
|
}
|
||||||
let dev = self.checks.iter().find(|c| c.name == "STORAGE_DISCOVERY")
|
let dev = self
|
||||||
|
.checks
|
||||||
|
.iter()
|
||||||
|
.find(|c| c.name == "STORAGE_DISCOVERY")
|
||||||
.map_or("none".to_string(), |c| c.detail.clone());
|
.map_or("none".to_string(), |c| c.detail.clone());
|
||||||
let written = self.checks.iter().any(|c| c.name == "STORAGE_WRITE" && c.result == CheckResult::Pass);
|
let written = self
|
||||||
let verified = self.checks.iter().any(|c| c.name == "STORAGE_READBACK" && c.result == CheckResult::Pass);
|
.checks
|
||||||
let restored = self.checks.iter().any(|c| c.name == "STORAGE_RESTORE" && c.result == CheckResult::Pass);
|
.iter()
|
||||||
let checks: Vec<JsonCheck> = self.checks.iter().map(|c| JsonCheck {
|
.any(|c| c.name == "STORAGE_WRITE" && c.result == CheckResult::Pass);
|
||||||
name: c.name.clone(), result: c.result.label().to_string(), detail: c.detail.clone(),
|
let verified = self
|
||||||
}).collect();
|
.checks
|
||||||
if let Err(err) = serde_json::to_writer(std::io::stdout(), &JsonReport {
|
.iter()
|
||||||
device_path: dev,
|
.any(|c| c.name == "STORAGE_READBACK" && c.result == CheckResult::Pass);
|
||||||
sector_written: written,
|
let restored = self
|
||||||
sector_verified: verified,
|
.checks
|
||||||
sector_restored: restored,
|
.iter()
|
||||||
checks,
|
.any(|c| c.name == "STORAGE_RESTORE" && c.result == CheckResult::Pass);
|
||||||
}) {
|
let checks: Vec<JsonCheck> = self
|
||||||
|
.checks
|
||||||
|
.iter()
|
||||||
|
.map(|c| JsonCheck {
|
||||||
|
name: c.name.clone(),
|
||||||
|
result: c.result.label().to_string(),
|
||||||
|
detail: c.detail.clone(),
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
if let Err(err) = serde_json::to_writer(
|
||||||
|
std::io::stdout(),
|
||||||
|
&JsonReport {
|
||||||
|
device_path: dev,
|
||||||
|
sector_written: written,
|
||||||
|
sector_verified: verified,
|
||||||
|
sector_restored: restored,
|
||||||
|
checks,
|
||||||
|
},
|
||||||
|
) {
|
||||||
eprintln!("{PROGRAM}: failed to serialize JSON: {err}");
|
eprintln!("{PROGRAM}: failed to serialize JSON: {err}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,7 +159,10 @@ fn parse_args() -> Result<bool, String> {
|
|||||||
for arg in std::env::args().skip(1) {
|
for arg in std::env::args().skip(1) {
|
||||||
match arg.as_str() {
|
match arg.as_str() {
|
||||||
"--json" => json_mode = true,
|
"--json" => json_mode = true,
|
||||||
"-h" | "--help" => { println!("{USAGE}"); return Err(String::new()); }
|
"-h" | "--help" => {
|
||||||
|
println!("{USAGE}");
|
||||||
|
return Err(String::new());
|
||||||
|
}
|
||||||
_ => return Err(format!("unsupported argument: {arg}")),
|
_ => return Err(format!("unsupported argument: {arg}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,8 +172,10 @@ fn parse_args() -> Result<bool, String> {
|
|||||||
#[cfg(target_os = "redox")]
|
#[cfg(target_os = "redox")]
|
||||||
fn list_dir(path: &str) -> Vec<String> {
|
fn list_dir(path: &str) -> Vec<String> {
|
||||||
match fs::read_dir(path) {
|
match fs::read_dir(path) {
|
||||||
Ok(entries) => entries.filter_map(|e| e.ok())
|
Ok(entries) => entries
|
||||||
.filter_map(|e| e.file_name().to_str().map(|s| s.to_string())).collect(),
|
.filter_map(|e| e.ok())
|
||||||
|
.filter_map(|e| e.file_name().to_str().map(|s| s.to_string()))
|
||||||
|
.collect(),
|
||||||
Err(_) => Vec::new(),
|
Err(_) => Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,14 +230,25 @@ fn check_storage_discovery() -> Check {
|
|||||||
if let Ok(data) = fs::read_to_string(&desc_path) {
|
if let Ok(data) = fs::read_to_string(&desc_path) {
|
||||||
if let Ok(desc) = serde_json::from_str::<serde_json::Value>(&data) {
|
if let Ok(desc) = serde_json::from_str::<serde_json::Value>(&data) {
|
||||||
let class = desc.get("class").and_then(|v| v.as_u64()).unwrap_or(0);
|
let class = desc.get("class").and_then(|v| v.as_u64()).unwrap_or(0);
|
||||||
if class == 8 { storage_count += 1; }
|
if class == 8 {
|
||||||
|
storage_count += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Check::pass("STORAGE_DISCOVERY", &format!("{} ({} USB storage class device(s) visible)", path, storage_count))
|
Check::pass(
|
||||||
|
"STORAGE_DISCOVERY",
|
||||||
|
&format!(
|
||||||
|
"{} ({} USB storage class device(s) visible)",
|
||||||
|
path, storage_count
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
None => Check::fail("STORAGE_DISCOVERY", "no writable block device found under /scheme/disk/"),
|
None => Check::fail(
|
||||||
|
"STORAGE_DISCOVERY",
|
||||||
|
"no writable block device found under /scheme/disk/",
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,17 +258,32 @@ fn check_storage_write(disk_path: &str, original_out: &mut [u8; SECTOR_SIZE]) ->
|
|||||||
use std::io::{Read, Seek, SeekFrom, Write};
|
use std::io::{Read, Seek, SeekFrom, Write};
|
||||||
let offset = TEST_SECTOR * SECTOR_SIZE as u64;
|
let offset = TEST_SECTOR * SECTOR_SIZE as u64;
|
||||||
|
|
||||||
let mut f = match fs::OpenOptions::new().read(true).write(true).open(disk_path) {
|
let mut f = match fs::OpenOptions::new()
|
||||||
|
.read(true)
|
||||||
|
.write(true)
|
||||||
|
.open(disk_path)
|
||||||
|
{
|
||||||
Ok(f) => f,
|
Ok(f) => f,
|
||||||
Err(e) => return Check::fail("STORAGE_WRITE", &format!("failed to open {} for read/write: {e}", disk_path)),
|
Err(e) => {
|
||||||
|
return Check::fail(
|
||||||
|
"STORAGE_WRITE",
|
||||||
|
&format!("failed to open {} for read/write: {e}", disk_path),
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Save original content for later restore
|
// Save original content for later restore
|
||||||
if let Err(e) = f.seek(SeekFrom::Start(offset)) {
|
if let Err(e) = f.seek(SeekFrom::Start(offset)) {
|
||||||
return Check::fail("STORAGE_WRITE", &format!("failed to seek to sector {TEST_SECTOR}: {e}"));
|
return Check::fail(
|
||||||
|
"STORAGE_WRITE",
|
||||||
|
&format!("failed to seek to sector {TEST_SECTOR}: {e}"),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if let Err(e) = f.read_exact(original_out) {
|
if let Err(e) = f.read_exact(original_out) {
|
||||||
return Check::fail("STORAGE_WRITE", &format!("failed to read original sector {TEST_SECTOR}: {e}"));
|
return Check::fail(
|
||||||
|
"STORAGE_WRITE",
|
||||||
|
&format!("failed to read original sector {TEST_SECTOR}: {e}"),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let pattern = make_test_pattern();
|
let pattern = make_test_pattern();
|
||||||
@@ -193,12 +291,21 @@ fn check_storage_write(disk_path: &str, original_out: &mut [u8; SECTOR_SIZE]) ->
|
|||||||
return Check::fail("STORAGE_WRITE", &format!("failed to seek for write: {e}"));
|
return Check::fail("STORAGE_WRITE", &format!("failed to seek for write: {e}"));
|
||||||
}
|
}
|
||||||
if let Err(e) = f.write_all(&pattern) {
|
if let Err(e) = f.write_all(&pattern) {
|
||||||
return Check::fail("STORAGE_WRITE", &format!("failed to write test pattern to sector {TEST_SECTOR}: {e}"));
|
return Check::fail(
|
||||||
|
"STORAGE_WRITE",
|
||||||
|
&format!("failed to write test pattern to sector {TEST_SECTOR}: {e}"),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if let Err(e) = f.flush() {
|
if let Err(e) = f.flush() {
|
||||||
return Check::fail("STORAGE_WRITE", &format!("failed to flush write: {e}"));
|
return Check::fail("STORAGE_WRITE", &format!("failed to flush write: {e}"));
|
||||||
}
|
}
|
||||||
Check::pass("STORAGE_WRITE", &format!("wrote test pattern to sector {TEST_SECTOR} of {}", disk_path))
|
Check::pass(
|
||||||
|
"STORAGE_WRITE",
|
||||||
|
&format!(
|
||||||
|
"wrote test pattern to sector {TEST_SECTOR} of {}",
|
||||||
|
disk_path
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read back the test sector and verify the pattern matches.
|
/// Read back the test sector and verify the pattern matches.
|
||||||
@@ -209,29 +316,47 @@ fn check_storage_readback(disk_path: &str) -> Check {
|
|||||||
|
|
||||||
let mut f = match fs::File::open(disk_path) {
|
let mut f = match fs::File::open(disk_path) {
|
||||||
Ok(f) => f,
|
Ok(f) => f,
|
||||||
Err(e) => return Check::fail("STORAGE_READBACK", &format!("failed to reopen {}: {e}", disk_path)),
|
Err(e) => {
|
||||||
|
return Check::fail(
|
||||||
|
"STORAGE_READBACK",
|
||||||
|
&format!("failed to reopen {}: {e}", disk_path),
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(e) = f.seek(SeekFrom::Start(offset)) {
|
if let Err(e) = f.seek(SeekFrom::Start(offset)) {
|
||||||
return Check::fail("STORAGE_READBACK", &format!("failed to seek to sector {TEST_SECTOR}: {e}"));
|
return Check::fail(
|
||||||
|
"STORAGE_READBACK",
|
||||||
|
&format!("failed to seek to sector {TEST_SECTOR}: {e}"),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut buf = [0u8; SECTOR_SIZE];
|
let mut buf = [0u8; SECTOR_SIZE];
|
||||||
if let Err(e) = f.read_exact(&mut buf) {
|
if let Err(e) = f.read_exact(&mut buf) {
|
||||||
return Check::fail("STORAGE_READBACK", &format!("failed to read sector {TEST_SECTOR}: {e}"));
|
return Check::fail(
|
||||||
|
"STORAGE_READBACK",
|
||||||
|
&format!("failed to read sector {TEST_SECTOR}: {e}"),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let pattern = make_test_pattern();
|
let pattern = make_test_pattern();
|
||||||
if buf == pattern {
|
if buf == pattern {
|
||||||
Check::pass("STORAGE_READBACK", &format!("sector {TEST_SECTOR} readback matches test pattern"))
|
Check::pass(
|
||||||
|
"STORAGE_READBACK",
|
||||||
|
&format!("sector {TEST_SECTOR} readback matches test pattern"),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
let first_mismatch = buf.iter().zip(pattern.iter()).enumerate()
|
let first_mismatch = buf
|
||||||
|
.iter()
|
||||||
|
.zip(pattern.iter())
|
||||||
|
.enumerate()
|
||||||
.find(|(_, (a, b))| a != b)
|
.find(|(_, (a, b))| a != b)
|
||||||
.map(|(i, _)| i)
|
.map(|(i, _)| i)
|
||||||
.unwrap_or(SECTOR_SIZE);
|
.unwrap_or(SECTOR_SIZE);
|
||||||
Check::fail("STORAGE_READBACK", &format!(
|
Check::fail(
|
||||||
"sector {TEST_SECTOR} readback mismatch at byte offset {first_mismatch}"
|
"STORAGE_READBACK",
|
||||||
))
|
&format!("sector {TEST_SECTOR} readback mismatch at byte offset {first_mismatch}"),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,25 +368,42 @@ fn check_storage_restore(disk_path: &str, original: &[u8; SECTOR_SIZE]) -> Check
|
|||||||
|
|
||||||
let mut f = match fs::OpenOptions::new().write(true).open(disk_path) {
|
let mut f = match fs::OpenOptions::new().write(true).open(disk_path) {
|
||||||
Ok(f) => f,
|
Ok(f) => f,
|
||||||
Err(e) => return Check::fail("STORAGE_RESTORE", &format!("failed to open {} for restore: {e}", disk_path)),
|
Err(e) => {
|
||||||
|
return Check::fail(
|
||||||
|
"STORAGE_RESTORE",
|
||||||
|
&format!("failed to open {} for restore: {e}", disk_path),
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(e) = f.seek(SeekFrom::Start(offset)) {
|
if let Err(e) = f.seek(SeekFrom::Start(offset)) {
|
||||||
return Check::fail("STORAGE_RESTORE", &format!("failed to seek for restore: {e}"));
|
return Check::fail(
|
||||||
|
"STORAGE_RESTORE",
|
||||||
|
&format!("failed to seek for restore: {e}"),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if let Err(e) = f.write_all(original) {
|
if let Err(e) = f.write_all(original) {
|
||||||
return Check::fail("STORAGE_RESTORE", &format!("failed to restore original sector: {e}"));
|
return Check::fail(
|
||||||
|
"STORAGE_RESTORE",
|
||||||
|
&format!("failed to restore original sector: {e}"),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if let Err(e) = f.flush() {
|
if let Err(e) = f.flush() {
|
||||||
return Check::fail("STORAGE_RESTORE", &format!("failed to flush restore: {e}"));
|
return Check::fail("STORAGE_RESTORE", &format!("failed to flush restore: {e}"));
|
||||||
}
|
}
|
||||||
Check::pass("STORAGE_RESTORE", &format!("restored original content of sector {TEST_SECTOR}"))
|
Check::pass(
|
||||||
|
"STORAGE_RESTORE",
|
||||||
|
&format!("restored original content of sector {TEST_SECTOR}"),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run() -> Result<(), String> {
|
fn run() -> Result<(), String> {
|
||||||
#[cfg(not(target_os = "redox"))]
|
#[cfg(not(target_os = "redox"))]
|
||||||
{
|
{
|
||||||
if std::env::args().any(|a| a == "-h" || a == "--help") { println!("{USAGE}"); return Err(String::new()); }
|
if std::env::args().any(|a| a == "-h" || a == "--help") {
|
||||||
|
println!("{USAGE}");
|
||||||
|
return Err(String::new());
|
||||||
|
}
|
||||||
println!("{PROGRAM}: USB storage check requires Redox runtime");
|
println!("{PROGRAM}: USB storage check requires Redox runtime");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -271,7 +413,11 @@ fn run() -> Result<(), String> {
|
|||||||
let mut report = Report::new(json_mode);
|
let mut report = Report::new(json_mode);
|
||||||
|
|
||||||
let discovery = check_storage_discovery();
|
let discovery = check_storage_discovery();
|
||||||
let disk_path = discovery.detail.split_whitespace().next().map(|s| s.to_string());
|
let disk_path = discovery
|
||||||
|
.detail
|
||||||
|
.split_whitespace()
|
||||||
|
.next()
|
||||||
|
.map(|s| s.to_string());
|
||||||
report.add(discovery);
|
report.add(discovery);
|
||||||
|
|
||||||
let disk_path = match disk_path {
|
let disk_path = match disk_path {
|
||||||
@@ -290,24 +436,34 @@ fn run() -> Result<(), String> {
|
|||||||
if write_ok {
|
if write_ok {
|
||||||
report.add(check_storage_readback(&disk_path));
|
report.add(check_storage_readback(&disk_path));
|
||||||
} else {
|
} else {
|
||||||
report.add(Check::skip("STORAGE_READBACK", "skipped because write check failed"));
|
report.add(Check::skip(
|
||||||
|
"STORAGE_READBACK",
|
||||||
|
"skipped because write check failed",
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if write_ok {
|
if write_ok {
|
||||||
report.add(check_storage_restore(&disk_path, &original));
|
report.add(check_storage_restore(&disk_path, &original));
|
||||||
} else {
|
} else {
|
||||||
report.add(Check::skip("STORAGE_RESTORE", "skipped because write check failed"));
|
report.add(Check::skip(
|
||||||
|
"STORAGE_RESTORE",
|
||||||
|
"skipped because write check failed",
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
report.print();
|
report.print();
|
||||||
if report.any_failed() { return Err("one or more USB storage checks failed".to_string()); }
|
if report.any_failed() {
|
||||||
|
return Err("one or more USB storage checks failed".to_string());
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if let Err(err) = run() {
|
if let Err(err) = run() {
|
||||||
if err.is_empty() { process::exit(0); }
|
if err.is_empty() {
|
||||||
|
process::exit(0);
|
||||||
|
}
|
||||||
eprintln!("{PROGRAM}: {err}");
|
eprintln!("{PROGRAM}: {err}");
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/* Runtime null guard for wl_proxy_add_listener — interposed via LD_PRELOAD.
|
||||||
|
* Qt6 Wayland QPA passes NULL proxies during initialization on Redox.
|
||||||
|
* This shim prevents the page fault at null+8 (proxy->object.implementation)
|
||||||
|
* by returning an error code instead of crashing.
|
||||||
|
*
|
||||||
|
* Cross-referenced with libwayland wayland-client.c:649.
|
||||||
|
*/
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
/* Original function pointer */
|
||||||
|
static int (*real_wl_proxy_add_listener)(void *proxy,
|
||||||
|
void (**implementation)(void), void *data) = NULL;
|
||||||
|
|
||||||
|
static void *(*real_wl_proxy_get_display)(void *proxy) = NULL;
|
||||||
|
static unsigned int (*real_wl_proxy_get_version)(void *proxy) = NULL;
|
||||||
|
|
||||||
|
static void init(void) {
|
||||||
|
real_wl_proxy_add_listener = dlsym(RTLD_NEXT, "wl_proxy_add_listener");
|
||||||
|
real_wl_proxy_get_display = dlsym(RTLD_NEXT, "wl_proxy_get_display");
|
||||||
|
real_wl_proxy_get_version = dlsym(RTLD_NEXT, "wl_proxy_get_version");
|
||||||
|
}
|
||||||
|
|
||||||
|
int wl_proxy_add_listener(void *proxy,
|
||||||
|
void (**implementation)(void), void *data) {
|
||||||
|
if (!real_wl_proxy_add_listener) init();
|
||||||
|
if (!proxy) {
|
||||||
|
fprintf(stderr, "wayland-guard: wl_proxy_add_listener(NULL) prevented crash\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return real_wl_proxy_add_listener(proxy, implementation, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *wl_proxy_get_display(void *proxy) {
|
||||||
|
if (!real_wl_proxy_get_display) init();
|
||||||
|
if (!proxy) return NULL;
|
||||||
|
return real_wl_proxy_get_display(proxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int wl_proxy_get_version(void *proxy) {
|
||||||
|
if (!real_wl_proxy_get_version) init();
|
||||||
|
if (!proxy) return 0;
|
||||||
|
return real_wl_proxy_get_version(proxy);
|
||||||
|
}
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
#TODO: Requires a narrow Redox delta for native scanner discovery during
|
#TODO: Requires Redox compatibility patching for missing Linux header paths and
|
||||||
# cross-builds and a userspace eventfd fallback because relibc lacks sys/eventfd.h.
|
# some POSIX/Linux-only flags during cross-builds.
|
||||||
# redox.patch keeps only the active scanner/eventfd compatibility surface.
|
# redox.patch restores the Redox compatibility stubs plus Meson scanner detection.
|
||||||
[source]
|
[source]
|
||||||
tar = "https://gitlab.freedesktop.org/wayland/wayland/-/releases/1.24.0/downloads/wayland-1.24.0.tar.xz"
|
tar = "https://gitlab.freedesktop.org/wayland/wayland/-/releases/1.24.0/downloads/wayland-1.24.0.tar.xz"
|
||||||
blake3 = "8c3b2bc792e5e262e9fb821fb8222b376de6fdf5d7af9b86d46e51ecf79704b9"
|
|
||||||
patches = ["redox.patch"]
|
patches = ["redox.patch"]
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
@@ -15,30 +14,8 @@ dependencies = [
|
|||||||
"libxml2",
|
"libxml2",
|
||||||
]
|
]
|
||||||
script = """
|
script = """
|
||||||
COOKBOOK_CONFIGURE_FLAGS=(
|
DYNAMIC_INIT
|
||||||
--host="${GNU_TARGET}"
|
cookbook_meson -Ddocumentation=false -Dtests=false -Ddtd_validation=false -Dc_args=-Wno-error
|
||||||
--prefix="/usr"
|
|
||||||
--disable-shared
|
|
||||||
--enable-static
|
|
||||||
)
|
|
||||||
COOKBOOK_MESON_FLAGS=(
|
|
||||||
--buildtype release
|
|
||||||
--wrap-mode nofallback
|
|
||||||
-Ddefault_library=static
|
|
||||||
-Dprefix=/usr
|
|
||||||
)
|
|
||||||
cookbook_meson \
|
|
||||||
-Ddocumentation=false \
|
|
||||||
-Dtests=false \
|
|
||||||
-Ddtd_validation=false \
|
|
||||||
-Dscanner=false \
|
|
||||||
-Dc_args="['-I${COOKBOOK_SYSROOT}/include','-Wno-error']"
|
|
||||||
|
|
||||||
for pc in "${COOKBOOK_STAGE}/usr/lib/pkgconfig/wayland-client.pc" "${COOKBOOK_STAGE}/usr/lib/pkgconfig/wayland-server.pc"; do
|
|
||||||
if [ -f "$pc" ]; then
|
|
||||||
sed -i 's/^Libs: /Libs: -lffi /' "$pc"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
|
|||||||
@@ -649,6 +649,12 @@ WL_EXPORT int
|
|||||||
wl_proxy_add_listener(struct wl_proxy *proxy,
|
wl_proxy_add_listener(struct wl_proxy *proxy,
|
||||||
void (**implementation)(void), void *data)
|
void (**implementation)(void), void *data)
|
||||||
{
|
{
|
||||||
|
if (!proxy) {
|
||||||
|
fprintf(stderr, "FATAL: wl_proxy_add_listener(NULL) caller=%p -- returning error
|
||||||
|
",
|
||||||
|
__builtin_return_address(0));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (proxy->flags & WL_PROXY_FLAG_WRAPPER)
|
if (proxy->flags & WL_PROXY_FLAG_WRAPPER)
|
||||||
wl_abort("Proxy %p is a wrapper\n", proxy);
|
wl_abort("Proxy %p is a wrapper\n", proxy);
|
||||||
|
|
||||||
@@ -2442,6 +2448,7 @@ wl_proxy_get_user_data(struct wl_proxy *proxy)
|
|||||||
WL_EXPORT uint32_t
|
WL_EXPORT uint32_t
|
||||||
wl_proxy_get_version(struct wl_proxy *proxy)
|
wl_proxy_get_version(struct wl_proxy *proxy)
|
||||||
{
|
{
|
||||||
|
if (!proxy) return 0;
|
||||||
return proxy->version;
|
return proxy->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2560,6 +2567,7 @@ wl_proxy_get_interface(struct wl_proxy *proxy)
|
|||||||
WL_EXPORT struct wl_display *
|
WL_EXPORT struct wl_display *
|
||||||
wl_proxy_get_display(struct wl_proxy *proxy)
|
wl_proxy_get_display(struct wl_proxy *proxy)
|
||||||
{
|
{
|
||||||
|
if (!proxy) return NULL;
|
||||||
return proxy->display;
|
return proxy->display;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user