rust: fix fd_get() pointer dereference
All fd_get() functions in the Rust bindings were returning the pointer
address cast to i32 instead of dereferencing the pointer to retrieve
the actual file descriptor value.
The C API signature is:
cs_error_t xxx_fd_get(xxx_handle_t handle, int *fd);
Where fd is an output parameter - the C library writes the file
descriptor into the memory pointed to by fd. The Rust wrapper must
dereference this pointer to get the value.
Before (WRONG):
Ok(c_fd as i32) // Returns pointer address, e.g.
0xe60d9018 = -435318760
After (CORRECT):
Ok(unsafe { *c_fd }) // Returns actual fd value, e.g. 5
This bug caused "Bad file descriptor (os error 9)" errors when trying
to register the returned "file descriptors" with event loops (epoll,
tokio AsyncFd, etc.), as the values were actually stack addresses.
Affected functions:
- bindings/rust/src/cfg.rs:169 - corosync_cfg_fd_get
- bindings/rust/src/cmap.rs:152 - cmap_fd_get
- bindings/rust/src/cpg.rs:384 - cpg_fd_get
- bindings/rust/src/quorum.rs:238 - quorum_fd_get
- bindings/rust/src/votequorum.rs:271 - votequorum_fd_get
Signed-off-by: Kefu Chai <k.chai@proxmox.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>