unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
blob e30d9f41343190ed7f9e4a103cfcdd0324cda35a 1189 bytes (raw)
name: gnu/packages/patches/parted-non-blocking-random.patch 	 # note: path name is non-authoritative(*)

 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
38
39
 
Explicitly use a non-blocking random primitive.  This is used primarily
to compute FAT "serial numbers" in libparted/fs/r/fat/fat.c:fat_create,
for which GRND_NONBLOCK is probably good enough.

Assume the running kernel does support 'getrandom', which is the case on
GuixSD.  See <https://bugs.gnu.org/31268>.

--- a/libparted/labels/misc.h
+++ b/libparted/labels/misc.h
@@ -17,7 +17,8 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 #include <inttypes.h>
-#include <uuid/uuid.h>
+#include <sys/random.h>
+#include <errno.h>
 
 /* hack: use the ext2 uuid library to generate a reasonably random (hopefully
  * with /dev/random) number.  Unfortunately, we can only use 4 bytes of it.
@@ -28,11 +29,17 @@ static inline uint32_t
 generate_random_uint32 (void)
 {
        union {
-               uuid_t uuid;
+               char uuid[4];
                uint32_t i;
        } uu32;
+       ssize_t ret;
 
-       uuid_generate (uu32.uuid);
+       do
+         ret = getrandom (uu32.uuid, sizeof uu32, GRND_NONBLOCK);
+       while (ret == EAGAIN);
+
+       if (ret < sizeof uu32)
+         abort ();
 
        return uu32.i > 0 ? uu32.i : 0xffffffff;
 }

debug log:

solving e30d9f413 ...
found e30d9f413 in https://yhetil.org/guix-bugs/87h8mz4q2g.fsf@gnu.org/

applying [1/1] https://yhetil.org/guix-bugs/87h8mz4q2g.fsf@gnu.org/
diff --git a/gnu/packages/patches/parted-non-blocking-random.patch b/gnu/packages/patches/parted-non-blocking-random.patch
new file mode 100644
index 000000000..e30d9f413

1:18: trailing whitespace.
 
1:23: trailing whitespace.
 
1:35: trailing whitespace.
 
1:43: trailing whitespace.
 
Checking patch gnu/packages/patches/parted-non-blocking-random.patch...
Applied patch gnu/packages/patches/parted-non-blocking-random.patch cleanly.
warning: 4 lines add whitespace errors.

index at:
100644 e30d9f41343190ed7f9e4a103cfcdd0324cda35a	gnu/packages/patches/parted-non-blocking-random.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).