From owner-freebsd-current Sat Jul 29 9:44:31 2000 Delivered-To: freebsd-current@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 4803737B66C; Sat, 29 Jul 2000 09:44:25 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.8.7/8.8.7) with ESMTP id CAA08791; Sun, 30 Jul 2000 02:44:07 +1000 Date: Sun, 30 Jul 2000 02:44:04 +1000 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: Hiroyuki Hanai Cc: current@FreeBSD.ORG, markm@FreeBSD.ORG Subject: Re: fcntl and /dev/random In-Reply-To: <8266pp602g.wl@darkmatter.imgsrc.co.jp> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG n Sat, 29 Jul 2000, Hiroyuki Hanai wrote: > Setting status flags using F_SETFL command of fcntl(2) on the file > descriptor, which is returned by open(2)ing /dev/random, seems not to > be supported. For example, when I run following code; File flags should be handled at the file level, and mostly are, but drivers still need dummy FIONBIO and FIOASYNC ioctls to prevent the fo_ioctl()'s in kern_descrip.c:fcntl() from failing (there must be dummy for FIOASYNC for setting O_NONBLOCK to work, even if the device driver doesn't support async i/o :-(). Broken drivers use these ioctls to make copies of the file flags in the wrong place. Non-broken drivers use the flags passed to their i/o functions, so that the flags are per-i/o. > 3.4-RELEASE(and possibly 3.5 and 3.5.1) and 4.1-RELEASE/4.1-STABLE say > `Inappropriate ioctl for device' and 5-current says `Operation not > supported by device'. This is a different bug. The random device in -current doesn't support ioctls at all, so all ioctls on it return ENODEV instead of most ioctls on it returning ENOTTY. See the patch by Brian Feldman. > Actually, in BIND9, fd is already open(2)ed with `O_RDONLY | O_NONBLOCK' > and setting O_NONBLOCK status with fcntl(2) is not needed, which means > that fixing BIND9's code is very simple; just comment out the fcntl(2)ing line. Except the random device doesn't actually support the O_NONBLOCK flag. This makes no difference in the -current random device, since all i/o is non-blocking. In 3.x and 4.x, O_NONBLOCK should have caused reads on /dev/random to not block. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message