[LEDE-DEV] [PATCH ubox] getrandom: Define SYS_getrandom if no definition exists
Florian Fainelli
f.fainelli at gmail.com
Sat Sep 17 17:13:49 PDT 2016
Le 17/09/2016 à 16:49, Etienne Champetier a écrit :
> Hi Florian,
>
> What is your use case?
Pre-built toolchain which ships with kernel headers 3.8 at the moment.
> If you run it on kernel less than 3.17 this will then fail at run time ...
I run a kernel newer than 3.17, but that's a good point.
> I would prefer to not compile it instead of having an unusable binary
Ok, so something more like that:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6cf0c934aac6..1d04c1d77662 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,10 +16,15 @@ IF(DEBUG)
ADD_DEFINITIONS(-DDEBUG -g3)
ENDIF()
-ADD_EXECUTABLE(getrandom getrandom.c)
-INSTALL(TARGETS getrandom
+INCLUDE (CheckSymbolExists)
+CHECK_SYMBOL_EXISTS(SYS_getrandom sycall.h getrandom)
+
+IF(getrandom)
+ ADD_EXECUTABLE(getrandom getrandom.c)
+ INSTALL(TARGETS getrandom
RUNTIME DESTINATION bin
-)
+ )
+ENDIF()
ADD_EXECUTABLE(kmodloader kmodloader.c)
TARGET_LINK_LIBRARIES(kmodloader ubox)
diff --git a/package/system/ubox/Makefile b/package/system/ubox/Makefile
index 9f0c4dc10250..48371e168fd3 100644
--- a/package/system/ubox/Makefile
+++ b/package/system/ubox/Makefile
@@ -32,7 +32,7 @@ define Package/ubox/install
$(INSTALL_DIR) $(1)/sbin $(1)/usr/sbin $(1)/lib $(1)/usr/bin
$(1)/etc/init.d
$(INSTALL_BIN)
$(PKG_INSTALL_DIR)/usr/sbin/{kmodloader,validate_data} $(1)/sbin/
- $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/getrandom $(1)/usr/bin/
+ -$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/getrandom $(1)/usr/bin/
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libvalidate.so $(1)/lib
$(LN) ../../sbin/kmodloader $(1)/usr/sbin/rmmod
>
> Regards
> Etienne
>
>
> Le 17 sept. 2016 10:17 PM, "Florian Fainelli" <f.fainelli at gmail.com
> <mailto:f.fainelli at gmail.com>> a écrit :
>
> Building ubox against kernel headers earlier than 3.17 would fail since
> SYS_getrandom was not defined, so provide a definition for it.
>
> Signed-off-by: Florian Fainelli <f.fainelli at gmail.com
> <mailto:f.fainelli at gmail.com>>
> ---
> getrandom.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/getrandom.c b/getrandom.c
> index 96712028589b..e324072fcf0e 100644
> --- a/getrandom.c
> +++ b/getrandom.c
> @@ -32,6 +32,10 @@ static int usage(char *name)
> return EXIT_FAILURE;
> }
>
> +#ifndef SYS_getrandom
> +#define SYS_getrandom 278
> +#endif
> +
> int main(int argc, char *argv[])
> {
> if (argc != 2)
> --
> 2.7.4
>
--
Florian
More information about the Lede-dev
mailing list