Date: Wed, 21 Mar 2018 12:33:25 +0200 From: Konstantin Belousov <kostikbel@gmail.com> To: Conrad Meyer <cem@FreeBSD.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r331279 - in head: include lib/libc/gen lib/libc/sys lib/libc/tests/gen sys/compat/freebsd32 sys/conf sys/kern sys/sys tests/sys/kern usr.bin/truss Message-ID: <20180321103325.GJ76926@kib.kiev.ua> In-Reply-To: <201803210115.w2L1Fjt9084698@repo.freebsd.org> References: <201803210115.w2L1Fjt9084698@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Mar 21, 2018 at 01:15:45AM +0000, Conrad Meyer wrote:
> +int
> +getentropy(void *buf, size_t buflen)
> +{
> + ssize_t rd;
> +
> + if (buflen > 256) {
> + errno = EIO;
> + return (-1);
> + }
> +
> + while (buflen > 0) {
> + rd = getrandom(buf, buflen, 0);
> + if (rd == -1) {
> + if (errno == EINTR)
> + continue;
> + else if (errno == ENOSYS)
> + abort();
Libraries must not abort the application.
Esp. libc.
> + else
> + return (-1);
> + }
> +
> + /* This cannot happen. */
> + if (rd == 0)
> + abort();
> +
> + buf = (char *)buf + rd;
> + buflen -= rd;
> + }
> +
> + return (0);
> +}
> @@ -627,6 +628,8 @@ FBSDprivate_1.0 {
> __sys_getppid;
> _getpriority;
> __sys_getpriority;
> + _getrandom;
> + __sys_getrandom;
> _getresgid;
> __sys_getresgid;
> _getresuid;
Is there any use planned for _getrandom and for __sys_ ? If not,
we do not add private symbols for newer syscalls in recent times.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180321103325.GJ76926>
