Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Jul 2000 02:44:04 +1000 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Hiroyuki Hanai <hanai@imgsrc.co.jp>
Cc:        current@FreeBSD.ORG, markm@FreeBSD.ORG
Subject:   Re: fcntl and /dev/random
Message-ID:  <Pine.BSF.4.21.0007300225450.8697-100000@besplex.bde.org>
In-Reply-To: <8266pp602g.wl@darkmatter.imgsrc.co.jp>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0007300225450.8697-100000>