Re: Regarding getrandom syscall

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Well, in fact it is not hard.

Just use syscall(2) provided by libc.

You need to provide to this function syscall id and syscall args.
Syscall id can be retrieved from macro constant
Should look something like:

#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>

syscall(SYS_getrandom, -- your - args - here --);

It returns long value - the result of syscall.
If it is between [-4095; -1] then it is negated errno, otherways it is return value.


18.06.2016, 16:32, "Anoop" <anoop.chargotra@xxxxxxxxx>:
> Hi Avantika,
>
> On Sat, Jun 18, 2016 at 5:32 PM, Avantika Rawat <avani.rawat@xxxxxxxxx> wrote:
>>  Hi ALL,
>>
>>  I am trying to use getrandom syscall in kernel 3.10.20 by following this
>>  link
>>
>>  https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=c6e9d6f38894798696f23c8084ca7edbf16ee895
>>
>>  i have compiled the kernel and now want to call the getrandom syscall from
>>  userspace to generate random numbers. But i am getting following error while
>>  calling the getrandom () from userspace.
>>
>>  (.text.startup+0x18): undefined reference to `getrandom'
>>  (.text.startup+0x1c): undefined reference to `getrandom'
>
> Your user space program will not know where 'getrandom' is defined
> unless it's in the C library. You need to research more on how to call
> custom system calls.
>
> -Anoop
>
>>  --
>>  Regards,
>>  Avantika Rawat
>>
>>  _______________________________________________
>>  Kernelnewbies mailing list
>>  Kernelnewbies@xxxxxxxxxxxxxxxxx
>>  http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies@xxxxxxxxxxxxxxxxx
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-----
Sayutin Dmitry <cdkrot@xxxxxxxxxx>

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies




[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux