kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: cdkrot@yandex.ru (Sayutin Dmitry)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Regarding getrandom syscall
Date: Sat, 18 Jun 2016 16:42:50 +0300	[thread overview]
Message-ID: <1466391466257370@web18o.yandex.ru> (raw)
In-Reply-To: <CA+t_1RAA3mt79vCZdcnfk61FXRTKH3kZR6g+P6MmidHy4iRiWg@mail.gmail.com>

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@gmail.com>:
> Hi Avantika,
>
> On Sat, Jun 18, 2016 at 5:32 PM, Avantika Rawat <avani.rawat@gmail.com> 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 at kernelnewbies.org
>> ?http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-----
Sayutin Dmitry <cdkrot@yandex.com>

  reply	other threads:[~2016-06-18 13:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-18 12:02 Regarding getrandom syscall Avantika Rawat
2016-06-18 13:30 ` Anoop
2016-06-18 13:42   ` Sayutin Dmitry [this message]
2016-06-21 13:41     ` Avantika Rawat
2016-06-21 19:10       ` Manuel Pégourié-Gonnard
2016-06-22 14:58         ` Avantika Rawat
2016-06-22 16:15           ` Navin P.S
2016-06-22 16:40             ` Avantika Rawat
2016-06-22 17:11           ` Markus Böhme
2016-06-24 14:44             ` Avantika Rawat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1466391466257370@web18o.yandex.ru \
    --to=cdkrot@yandex.ru \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).