* [nfs-utils 1/2] Fix build failure due to glibc <= 2.24 and check for Linux 3.17+
@ 2023-10-26 11:45 Giulio Benetti
2023-10-26 11:45 ` [nfs-utils 2/2] Drop unused <sys/random.h> Giulio Benetti
2023-10-26 19:47 ` [nfs-utils 1/2] Fix build failure due to glibc <= 2.24 and check for Linux 3.17+ Petr Vorel
0 siblings, 2 replies; 7+ messages in thread
From: Giulio Benetti @ 2023-10-26 11:45 UTC (permalink / raw)
To: linux-nfs; +Cc: Giulio Benetti
Function getrandom() is present only with glibc 2.24+ so add a direct
syscall otherwise. This is only possible with Linux 3.17+ so let's also
check for it and in case emit error on autotools configure.
Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
configure.ac | 32 +++++++++++++++++++++++++++++++
support/reexport/backend_sqlite.c | 17 +++++++++++++++-
2 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 6fbcb974..7efca90c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -328,6 +328,38 @@ AC_CHECK_HEADERS([sched.h], [], [])
AC_CHECK_FUNCS([unshare fstatat statx], [] , [])
AC_LIBPTHREAD([])
+AC_MSG_CHECKING([for getrandom (Linux 3.17+, glibc 2.25+)])
+AC_LINK_IFELSE([AC_LANG_SOURCE([
+ #include <stdlib.h> /* for NULL */
+ #include <sys/random.h>
+ int main() {
+ return getrandom(NULL, 0U, 0U);
+ }
+])], [
+ AC_DEFINE([HAVE_GETRANDOM], [1],
+ [Define to 1 if you have the `getrandom' function.])
+ AC_MSG_RESULT([yes])
+], [
+ AC_MSG_RESULT([no])
+
+ AC_MSG_CHECKING([for syscall SYS_getrandom (Linux 3.17+)])
+ AC_LINK_IFELSE([AC_LANG_SOURCE([
+ #include <stdlib.h> /* for NULL */
+ #include <unistd.h> /* for syscall */
+ #include <sys/syscall.h> /* for SYS_getrandom */
+ int main() {
+ syscall(SYS_getrandom, NULL, 0, 0);
+ return 0;
+ }
+ ])], [
+ AC_DEFINE([HAVE_SYSCALL_GETRANDOM], [1],
+ [Define to 1 if you have `syscall' and `SYS_getrandom'.])
+ AC_MSG_RESULT([yes])
+ ], [
+ AC_MSG_ERROR(['syscall' and 'SYS_getrandom' not found.])
+ ])
+])
+
# rpc/rpc.h can come from the glibc or from libtirpc
nfsutils_save_CPPFLAGS="${CPPFLAGS}"
CPPFLAGS="${CPPFLAGS} ${TIRPC_CFLAGS}"
diff --git a/support/reexport/backend_sqlite.c b/support/reexport/backend_sqlite.c
index 132f30c4..f1e390bc 100644
--- a/support/reexport/backend_sqlite.c
+++ b/support/reexport/backend_sqlite.c
@@ -7,13 +7,28 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/random.h>
#include <unistd.h>
#include "conffile.h"
#include "reexport_backend.h"
#include "xlog.h"
+/* Fix up glibc <= 2.24 not having getrandom() */
+#if defined HAVE_GETRANDOM
+#include <sys/random.h>
+#else
+#include <sys/syscall.h>
+static ssize_t getrandom(void *buffer, size_t length, unsigned flags)
+{
+# if defined(__NR_getrandom)
+ return syscall(__NR_getrandom, buffer, length, flags);
+# else
+ errno = ENOSYS;
+ return -1;
+# endif
+}
+#endif
+
#define REEXPDB_DBFILE NFS_STATEDIR "/reexpdb.sqlite3"
#define REEXPDB_DBFILE_WAIT_USEC (5000)
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [nfs-utils 2/2] Drop unused <sys/random.h>
2023-10-26 11:45 [nfs-utils 1/2] Fix build failure due to glibc <= 2.24 and check for Linux 3.17+ Giulio Benetti
@ 2023-10-26 11:45 ` Giulio Benetti
2023-10-26 19:47 ` [nfs-utils 1/2] Fix build failure due to glibc <= 2.24 and check for Linux 3.17+ Petr Vorel
1 sibling, 0 replies; 7+ messages in thread
From: Giulio Benetti @ 2023-10-26 11:45 UTC (permalink / raw)
To: linux-nfs; +Cc: Giulio Benetti
Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
support/reexport/fsidd.c | 1 -
support/reexport/reexport.c | 1 -
2 files changed, 2 deletions(-)
diff --git a/support/reexport/fsidd.c b/support/reexport/fsidd.c
index d4b245e8..352de1be 100644
--- a/support/reexport/fsidd.c
+++ b/support/reexport/fsidd.c
@@ -10,7 +10,6 @@
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
-#include <sys/random.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
diff --git a/support/reexport/reexport.c b/support/reexport/reexport.c
index d9a700af..c59e6b2f 100644
--- a/support/reexport/reexport.c
+++ b/support/reexport/reexport.c
@@ -7,7 +7,6 @@
#endif
#include <stdint.h>
#include <stdio.h>
-#include <sys/random.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/vfs.h>
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [nfs-utils 1/2] Fix build failure due to glibc <= 2.24 and check for Linux 3.17+
2023-10-26 11:45 [nfs-utils 1/2] Fix build failure due to glibc <= 2.24 and check for Linux 3.17+ Giulio Benetti
2023-10-26 11:45 ` [nfs-utils 2/2] Drop unused <sys/random.h> Giulio Benetti
@ 2023-10-26 19:47 ` Petr Vorel
2023-10-26 21:18 ` Giulio Benetti
2024-10-18 13:13 ` Steve Dickson
1 sibling, 2 replies; 7+ messages in thread
From: Petr Vorel @ 2023-10-26 19:47 UTC (permalink / raw)
To: Giulio Benetti; +Cc: linux-nfs, Richard Weinberger, Steve Dickson
interesting, I yesterday sent patch [1] solving the same problem (although it
might not be that obvious from the patchset name). Let's see which one will be
taken.
Kind regards,
Petr
[1] https://lore.kernel.org/linux-nfs/20231025205720.GB460410@pevik/T/#m4c02286afae09318f6b95ff837750708d5065cd5
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [nfs-utils 1/2] Fix build failure due to glibc <= 2.24 and check for Linux 3.17+
2023-10-26 19:47 ` [nfs-utils 1/2] Fix build failure due to glibc <= 2.24 and check for Linux 3.17+ Petr Vorel
@ 2023-10-26 21:18 ` Giulio Benetti
2024-10-18 13:13 ` Steve Dickson
1 sibling, 0 replies; 7+ messages in thread
From: Giulio Benetti @ 2023-10-26 21:18 UTC (permalink / raw)
To: Petr Vorel; +Cc: linux-nfs, Richard Weinberger, Steve Dickson
Hi Petr,
On 26/10/23 21:47, Petr Vorel wrote:
> interesting, I yesterday sent patch [1] solving the same problem (although it
> might not be that obvious from the patchset name). Let's see which one will be
> taken.
>
> Kind regards,
> Petr
>
> [1] https://lore.kernel.org/linux-nfs/20231025205720.GB460410@pevik/T/#m4c02286afae09318f6b95ff837750708d5065cd5
I totally forgotten to check Patchwork before working on it. Your patch
looks good, better than mine. Maybe you can improve the part of the
syscall because it's not always available. You can then send a patch for
Buildroot too with the patch you've pointed since there you're
nfs-utils package Maintainer too.
--
Giulio Benetti
CEO&CTO@Benetti Engineering sas
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [nfs-utils 1/2] Fix build failure due to glibc <= 2.24 and check for Linux 3.17+
2023-10-26 19:47 ` [nfs-utils 1/2] Fix build failure due to glibc <= 2.24 and check for Linux 3.17+ Petr Vorel
2023-10-26 21:18 ` Giulio Benetti
@ 2024-10-18 13:13 ` Steve Dickson
2024-10-18 13:43 ` Petr Vorel
1 sibling, 1 reply; 7+ messages in thread
From: Steve Dickson @ 2024-10-18 13:13 UTC (permalink / raw)
To: Petr Vorel, Giulio Benetti; +Cc: linux-nfs, Richard Weinberger
Hello,
On 10/26/23 3:47 PM, Petr Vorel wrote:
> interesting, I yesterday sent patch [1] solving the same problem (although it
> might not be that obvious from the patchset name). Let's see which one will be
> taken.
>
> Kind regards,
> Petr
>
> [1] https://lore.kernel.org/linux-nfs/20231025205720.GB460410@pevik/T/#m4c02286afae09318f6b95ff837750708d5065cd5
There are a number of patches in the above link
Could you please post, in the usual format, that
fixes the issue.
tia,
steved.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [nfs-utils 1/2] Fix build failure due to glibc <= 2.24 and check for Linux 3.17+
2024-10-18 13:13 ` Steve Dickson
@ 2024-10-18 13:43 ` Petr Vorel
2024-10-18 14:37 ` Steve Dickson
0 siblings, 1 reply; 7+ messages in thread
From: Petr Vorel @ 2024-10-18 13:43 UTC (permalink / raw)
To: Steve Dickson; +Cc: Giulio Benetti, linux-nfs, Richard Weinberger
Hi Steve, Giulio, Richard,
> Hello,
> On 10/26/23 3:47 PM, Petr Vorel wrote:
> > interesting, I yesterday sent patch [1] solving the same problem (although it
> > might not be that obvious from the patchset name). Let's see which one will be
> > taken.
> > Kind regards,
> > Petr
> > [1] https://lore.kernel.org/linux-nfs/20231025205720.GB460410@pevik/T/#m4c02286afae09318f6b95ff837750708d5065cd5
> There are a number of patches in the above link
> Could you please post, in the usual format, that
> fixes the issue.
@Steve IMHO all build failures on glibc <= 2.24 and Linux 3.17+ has been fixed
in f92fd6ca ("support/backend_sqlite.c: Add getrandom() fallback") [1].
I don't see any new issue in the thread which is from 2023.
Are you just double checking if any patch was left on ML?
Or do I miss something (it's Friday maybe I'm just tired)?
@Giulio @Richard feel free to correct me.
Kind regards,
Petr
> tia,
> steved.
[1] https://git.linux-nfs.org/?p=steved/nfs-utils.git;a=commit;h=f92fd6ca815025c435dabf45da28472ac0aa04a4
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [nfs-utils 1/2] Fix build failure due to glibc <= 2.24 and check for Linux 3.17+
2024-10-18 13:43 ` Petr Vorel
@ 2024-10-18 14:37 ` Steve Dickson
0 siblings, 0 replies; 7+ messages in thread
From: Steve Dickson @ 2024-10-18 14:37 UTC (permalink / raw)
To: Petr Vorel; +Cc: Giulio Benetti, linux-nfs, Richard Weinberger
On 10/18/24 9:43 AM, Petr Vorel wrote:
> Hi Steve, Giulio, Richard,
>
>> Hello,
>
>> On 10/26/23 3:47 PM, Petr Vorel wrote:
>>> interesting, I yesterday sent patch [1] solving the same problem (although it
>>> might not be that obvious from the patchset name). Let's see which one will be
>>> taken.
>
>>> Kind regards,
>>> Petr
>
>>> [1] https://lore.kernel.org/linux-nfs/20231025205720.GB460410@pevik/T/#m4c02286afae09318f6b95ff837750708d5065cd5
>> There are a number of patches in the above link
>> Could you please post, in the usual format, that
>> fixes the issue.
>
> @Steve IMHO all build failures on glibc <= 2.24 and Linux 3.17+ has been fixed
> in f92fd6ca ("support/backend_sqlite.c: Add getrandom() fallback") [1].
Perfect! Thank you!
steved.
>
> I don't see any new issue in the thread which is from 2023.
> Are you just double checking if any patch was left on ML?
> Or do I miss something (it's Friday maybe I'm just tired)?
>
> @Giulio @Richard feel free to correct me.
>
> Kind regards,
> Petr
>
>> tia,
>
>> steved.
>
> [1] https://git.linux-nfs.org/?p=steved/nfs-utils.git;a=commit;h=f92fd6ca815025c435dabf45da28472ac0aa04a4
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-10-18 14:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-26 11:45 [nfs-utils 1/2] Fix build failure due to glibc <= 2.24 and check for Linux 3.17+ Giulio Benetti
2023-10-26 11:45 ` [nfs-utils 2/2] Drop unused <sys/random.h> Giulio Benetti
2023-10-26 19:47 ` [nfs-utils 1/2] Fix build failure due to glibc <= 2.24 and check for Linux 3.17+ Petr Vorel
2023-10-26 21:18 ` Giulio Benetti
2024-10-18 13:13 ` Steve Dickson
2024-10-18 13:43 ` Petr Vorel
2024-10-18 14:37 ` Steve Dickson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox