From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6886 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?Daniel_Cegie=C5=82ka?= Newsgroups: gmane.linux.lib.musl.general Subject: Re: getrandom syscall Date: Wed, 28 Jan 2015 10:10:53 +0100 Message-ID: References: <20150128090212.GE32318@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1422436298 4811 80.91.229.3 (28 Jan 2015 09:11:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 28 Jan 2015 09:11:38 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-6899-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jan 28 10:11:33 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1YGOel-00040h-2s for gllmg-musl@m.gmane.org; Wed, 28 Jan 2015 10:11:27 +0100 Original-Received: (qmail 15389 invoked by uid 550); 28 Jan 2015 09:11:25 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 15360 invoked from network); 28 Jan 2015 09:11:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=X4I3J1Ka09WwrPhyod6Q2//gaIEo24BbtOZ4v1Kgp0I=; b=dCmOwzEGeqy4Zmz+jb7l1dTI4NE4bf8yLHysisfN1DRftBRcnyiKuBTC6LIbM6rlOO Y9ujj+R6t6k2xFzBTyh6rn/mVEkw6SgTpIIFeJLQcs0J1eBYm298aK0TVIFwT8UmEP2d sWCMZuNtyObrI0tiDs3nxnUYNAjmz3StVwqhNTt0fbHtlvrpzKL2IO4t2xJiL17c/sDe Zufknp/vNeSRfw5S5VkwPfDLNs9z2K8hmnYwp7tz/0xRxG6OfvI7v++kHivu2dCPCnjg TQbl1V8rXSP3U14ZTKE+3SrooWNNmLTBBpEWFrWeYQ/QTNTEVs6XDk0AORZiXv7n6v5h jL9Q== X-Received: by 10.202.56.133 with SMTP id f127mr1263185oia.101.1422436273653; Wed, 28 Jan 2015 01:11:13 -0800 (PST) In-Reply-To: <20150128090212.GE32318@port70.net> Xref: news.gmane.org gmane.linux.lib.musl.general:6886 Archived-At: 2015-01-28 10:02 GMT+01:00 Szabolcs Nagy : > * Daniel Cegie??ka [2015-01-27 23:12:46 +0100]: >> #include >> #include >> #include "syscall.h" >> > > #ifdef SYS_getrandom > >> int getrandom(void *buf, size_t len) >> { >> int ret, pre_errno = errno; >> >> if (len > 256) { >> errno = EIO; >> return -1; >> } >> do { >> ret = syscall(SYS_getrandom, buf, len, 0); >> } while (ret == -1 && errno == EINTR); >> if (ret != len) >> return -1; >> errno = pre_errno; >> return 0; >> } > > #endif > > eg sh does not have the syscall (linux is not consistent with > syscalls for whatever reason) SYS_getrandom is defined on musl, so #ifdef SYS_getrandom is not a good solution: http://git.musl-libc.org/cgit/musl/tree/arch/x86_64/bits/syscall.h#n657 It's better to return an error. Daniel