Il problema è stato risolto aggiornando la libreria C.srall casuale in C non trovato
Vorrei utilizzare il getrandom syscall (http://man7.org/linux/man-pages/man2/getrandom.2.html)
gcc-5 -std = c11 test.c
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
#include <errno.h>
#include <string.h>
#include <signal.h>
#include <linux/random.h>
#include <sys/syscall.h>
int main(void)
{
void *buf = NULL;
size_t l = 5;
unsigned int o = 1;
int r = syscall(SYS_getrandom, buf, l, o);
return 0;
}
o
int main(void)
{
void *buf = NULL;
size_t l = 5;
unsigned int o = 1;
int r = getrandom(buf, l, o);
return 0;
}
In ogni caso, quando Provo a compilarlo con gcc-5:
test.c: In function ‘main’:
test.c:14:17: warning: implicit declaration of function ‘getrandom’ [-Wimplicit-function-declaration]
int r = getrandom(buf, l, o);
^
/tmp/ccqFdJAJ.o: In function `main':
test.c:(.text+0x36): undefined reference to `getrandom'
collect2: error: ld returned 1 exit status
Sto usando Ubuntu 14.04, cosa posso fare per usare getrandom? Poiché è un "nuovo" syscall, come posso usarlo?
edit:
uname -r
-> 4.0.3-040003-generiC#201505131441 SMP Wed May 13 13:43:16 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
quando sostituisco r da int r = syscall(SYS_getrandom, buf, l, o);
o r = getrandom (buf, l, o) è lo stesso ..
Riferimento alla modifica: aggiungi il prototipo a 'syscall()' quando lo si utilizza! È in '' Anche il 'SYS_getrandom' dovrebbe essere disponibile. –
alk
Perché non usi [random (4)] (http://man7.org/linux/man-pages/man4/random.4.html), cioè leggi alcuni byte da '/ dev/random'? –
No, ma è necessario un kernel più recente .... –