comments inline
On 1/7/26 10:16 AM, Kefu Chai wrote:
Add vendored rust-corosync library with CPG group name fix to support
optional trailing nuls in group names, ensuring compatibility between
Rust and C pmxcfs implementations.
The patch addresses a limitation in CString::new() which doesn't allow
trailing \0 in its input, while C code uses strlen(name) + 1 for CPG
group names (including the trailing nul).
This vendored version will be replaced once the fix is upstreamed and
a new rust-corosync crate version is published.
See: vendor/rust-corosync/README.PATCH.md for details
Could you please link the relevant GH issue / PR for more context? Also
please mention it in the README.PATCH.md.
---
src/pmxcfs-rs/Cargo.toml | 6 +
src/pmxcfs-rs/vendor/rust-corosync/Cargo.toml | 33 +
.../vendor/rust-corosync/Cargo.toml.orig | 19 +
src/pmxcfs-rs/vendor/rust-corosync/LICENSE | 21 +
.../vendor/rust-corosync/README.PATCH.md | 36 +
src/pmxcfs-rs/vendor/rust-corosync/README.md | 13 +
src/pmxcfs-rs/vendor/rust-corosync/build.rs | 64 +
.../vendor/rust-corosync/regenerate-sys.sh | 15 +
src/pmxcfs-rs/vendor/rust-corosync/src/cfg.rs | 392 ++
.../vendor/rust-corosync/src/cmap.rs | 812 ++++
src/pmxcfs-rs/vendor/rust-corosync/src/cpg.rs | 657 ++++
src/pmxcfs-rs/vendor/rust-corosync/src/lib.rs | 297 ++
.../vendor/rust-corosync/src/quorum.rs | 337 ++
.../vendor/rust-corosync/src/sys/cfg.rs | 1239 ++++++
.../vendor/rust-corosync/src/sys/cmap.rs | 3323 +++++++++++++++++
.../vendor/rust-corosync/src/sys/cpg.rs | 1310 +++++++
.../vendor/rust-corosync/src/sys/mod.rs | 8 +
.../vendor/rust-corosync/src/sys/quorum.rs | 537 +++
.../rust-corosync/src/sys/votequorum.rs | 574 +++
.../vendor/rust-corosync/src/votequorum.rs | 556 +++
20 files changed, 10249 insertions(+)
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/Cargo.toml
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/Cargo.toml.orig
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/LICENSE
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/README.PATCH.md
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/README.md
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/build.rs
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/regenerate-sys.sh
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/cfg.rs
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/cmap.rs
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/cpg.rs
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/lib.rs
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/quorum.rs
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/sys/cfg.rs
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/sys/cmap.rs
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/sys/cpg.rs
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/sys/mod.rs
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/sys/quorum.rs
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/sys/votequorum.rs
create mode 100644 src/pmxcfs-rs/vendor/rust-corosync/src/votequorum.rs
diff --git a/src/pmxcfs-rs/Cargo.toml b/src/pmxcfs-rs/Cargo.toml
index 4d18aa93..a178bc27 100644
--- a/src/pmxcfs-rs/Cargo.toml
+++ b/src/pmxcfs-rs/Cargo.toml
@@ -91,3 +91,9 @@ strip = true
[profile.dev]
opt-level = 1
debug = true
+
+[patch.crates-io]
+# Temporary patch for CPG group name length bug
+# Fixed in corosync upstream (commit 71d6d93c) but not yet released
+# Remove this patch when rust-corosync > 0.1.0 is published
+rust-corosync = { path = "vendor/rust-corosync" }
diff --git a/src/pmxcfs-rs/vendor/rust-corosync/Cargo.toml
b/src/pmxcfs-rs/vendor/rust-corosync/Cargo.toml
new file mode 100644
index 00000000..f299ca76
--- /dev/null
+++ b/src/pmxcfs-rs/vendor/rust-corosync/Cargo.toml
@@ -0,0 +1,33 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g., crates.io) dependencies
+#
+# If you believe there's an error in this file please file an
+# issue against the rust-lang/cargo repository. If you're
+# editing this file be aware that the upstream Cargo.toml
+# will likely look very different (and much more reasonable)
+
+[package]
+edition = "2018"
+name = "rust-corosync"
+version = "0.1.0"
Not fully sure I understand:
why are we using 0.1.0? Crates.io lists newer versions:
https://crates.io/crates/rust-corosync/versions
+authors = ["Christine Caulfield <[email protected]>"]
+description = "Rust bindings for corosync libraries"
+readme = "README.md"
+keywords = ["cluster", "high-availability"]
+categories = ["api-bindings"]
+license = "MIT OR Apache-2.0"
+repository = "https://github.com/chrissie-c/rust-corosync"
+[dependencies.bitflags]
+version = "1.2.1"
+
+[dependencies.lazy_static]
+version = "1.4.0"
+
+[dependencies.num_enum]
+version = "0.5.1"
+[build-dependencies.pkg-config]
+version = "0.3"
diff --git a/src/pmxcfs-rs/vendor/rust-corosync/Cargo.toml.orig
b/src/pmxcfs-rs/vendor/rust-corosync/Cargo.toml.orig
new file mode 100644
index 00000000..2165c8e9
--- /dev/null
+++ b/src/pmxcfs-rs/vendor/rust-corosync/Cargo.toml.orig
@@ -0,0 +1,19 @@
+[package]
+name = "rust-corosync"
+version = "0.1.0"
+authors = ["Christine Caulfield <[email protected]>"]
+edition = "2018"
+readme = "README.md"
+license = "MIT OR Apache-2.0"
+repository = "https://github.com/chrissie-c/rust-corosync"
+description = "Rust bindings for corosync libraries"
+categories = ["api-bindings"]
+keywords = ["cluster", "high-availability"]
+
+[dependencies]
+lazy_static = "1.4.0"
+num_enum = "0.5.1"
+bitflags = "1.2.1"
+
+[build-dependencies]
+pkg-config = "0.3"
diff --git a/src/pmxcfs-rs/vendor/rust-corosync/LICENSE
b/src/pmxcfs-rs/vendor/rust-corosync/LICENSE
new file mode 100644
index 00000000..43da7b99
--- /dev/null
+++ b/src/pmxcfs-rs/vendor/rust-corosync/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2021 Chrissie Caulfield
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/src/pmxcfs-rs/vendor/rust-corosync/README.PATCH.md
b/src/pmxcfs-rs/vendor/rust-corosync/README.PATCH.md
new file mode 100644
index 00000000..c8ba2d6f
--- /dev/null
+++ b/src/pmxcfs-rs/vendor/rust-corosync/README.PATCH.md
@@ -0,0 +1,36 @@
+# Temporary Vendored rust-corosync v0.1.0
+
+This is a temporary vendored copy of `rust-corosync` v0.1.0 with a critical
bug fix.
+
+## Why Vendored?
+
+The published `rust-corosync` v0.1.0 on crates.io has a bug that prevents Rust
and C applications from joining the same CPG groups. This bug has been fixed in
corosync upstream but not yet released.
Can you please link the commit?
+
+## Upstream Fix
+
+The fix has been committed to the corosync repository:
+- Repository: https://github.com/corosync/corosync
+- Local commit: `~/dev/corosync` commit 71d6d93c
So this is the local commit after applying the fix diff, right?
+- File: `bindings/rust/src/cpg.rs`
+- Lines changed: 209-220
Since the fix is quite small, can we please add the diff here?
+
+## The Bug
+
+CPG group name length calculation was excluding the null terminator:
+- C code: `length = strlen(name) + 1` (includes \0)
+- Rust (before): `length = name.len()` (excludes \0)
+- Rust (after): `length = name.len() + 1` (includes \0)
+
+This caused Rust and C nodes to be isolated in separate CPG groups even when
using identical group names.
+
+## Removal Plan
+
+Once `rust-corosync` v0.1.1+ is published with this fix:
+
+1. Remove this `vendor/rust-corosync` directory
+2. Remove the `[patch.crates-io]` section from `../Cargo.toml`
+3. Update workspace dependency to `rust-corosync = "0.1.1"`
+
+## Testing
+
+The fix has been tested with mixed C/Rust pmxcfs clusters and verified that
all nodes successfully join the same CPG group and communicate properly.
diff --git a/src/pmxcfs-rs/vendor/rust-corosync/README.md
b/src/pmxcfs-rs/vendor/rust-corosync/README.md
new file mode 100644
index 00000000..9c376b8a
--- /dev/null
+++ b/src/pmxcfs-rs/vendor/rust-corosync/README.md
@@ -0,0 +1,13 @@
+# rust-corosync
+Rust bindings for corosync
+
+This crate covers Rust bindings for the
+cfg, cmap, cpg, quorum, votequorum
+libraries in corosync.
+
+It is very much in an alpha state at the moment and APIs
+may well change as and when people start to use them.
+
+Please report bugs and offer any suggestions to [email protected]
+
+https://corosync.github.io/corosync/
diff --git a/src/pmxcfs-rs/vendor/rust-corosync/build.rs
b/src/pmxcfs-rs/vendor/rust-corosync/build.rs
new file mode 100644
index 00000000..8635b5e4
--- /dev/null
[..]