File: nix-0.24.patch

package info (click to toggle)
rust-libsystemd 0.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 420 kB
  • sloc: makefile: 2
file content (37 lines) | stat: -rw-r--r-- 1,236 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
commit eb9ea392636681bdea35a89b782edbb8010897f0
Author: Jonah Petri <jonah@petri.us>
Date:   Thu Feb 24 11:10:09 2022 -0500

    fix build for compatibility with nix 0.24
    
    See https://github.com/lucab/libsystemd-rs/issues/107.

diff --git a/src/activation.rs b/src/activation.rs
index 1c751dc78..9a0dd9d3f 100644
--- a/src/activation.rs
+++ b/src/activation.rs
@@ -2,1 +2,0 @@
-use nix::mqueue::mq_getattr;
@@ -192,7 +191,12 @@ impl IsType for RawFd {
     }
 
     fn is_mq(&self) -> bool {
-        mq_getattr(*self).is_ok()
+        // `nix` does not enable us to test if a raw fd is a mq, so we must drop to libc here.
+        // SAFETY: `mq_getattr` is specified to return -1 when passed a fd which is not a mq.
+        //         Furthermore, we ignore `attr` and rely only on the return value.
+        let mut attr = std::mem::MaybeUninit::<libc::mq_attr>::uninit();
+        let res = unsafe { libc::mq_getattr(*self, attr.as_mut_ptr()) };
+        res == 0
     }
 }
 
Index: libsystemd/Cargo.toml
===================================================================
--- libsystemd.orig/Cargo.toml
+++ libsystemd/Cargo.toml
@@ -43,3 +43,3 @@ version = "0.7"
 [dependencies.nix]
-version = "^0.23"
+version = "0.24"