erofs-utils: lib: uuid: fix compilation error if __NR_getrandom doesn't exist
authorGao Xiang <hsiangkao@linux.alibaba.com>
Mon, 29 Jul 2024 11:25:24 +0000 (19:25 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 30 Jul 2024 01:57:38 +0000 (09:57 +0800)
commitac0997ea32a465a6b0db7b782bb8d4d07952365a
treef2eb69c8939065f260277171a22d7a98b4951660
parent8f93c2f83962e0f082aa1be331bfa547be3592d2
erofs-utils: lib: uuid: fix compilation error if __NR_getrandom doesn't exist

Let's use rand() for insecure randomness without getrandom() support
on very old kernels to resolve issues as below:

uuid.c: In function ‘s_getrandom’:
uuid.c:44:32: error: ‘__NR_getrandom’ undeclared (first use in this function); did you mean ‘s_getrandom’?
   44 |   ssize_t r = (ssize_t)syscall(__NR_getrandom, out, size, flags);
      |                                ^~~~~~~~~~~~~~
      |                                s_getrandom

I'm not sure who cares since most users just use `--with-uuid` instead.

Fixes: 5de439566bc5 ("erofs-utils: Provide identical functionality without libuuid")
Reviewed-by: Sandeep Dhavale <dhavale@google.com>
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240729112524.930460-1-hsiangkao@linux.alibaba.com
lib/uuid.c