On Wed, 13 Dec 2017, Jeremy Evans wrote:
> I think this may be a bug. I'm guessing either:
>
> 1) fcntl(fd,F_SETFL, O_NONBLOCK) shouldn't fail, because
> open("/dev/zero", O_NONBLOCK) doesn't fail; or
Yes.
> After more testing, it appears any fcntl/F_SETFL call on /dev/zero
> fails, even if you are setting the flags to the same value.
Looks like the MD mmioctl() implementations need to ignore the ioctls that
are used internally by fcntl(F_SETFL). Something like this untested diff:
--- arch/amd64/amd64/mem.c 14 Oct 2017 04:44:43 -0000 1.32
+++ arch/amd64/amd64/mem.c 13 Dec 2017 20:17:47 -0000
@@ -237,6 +237,13 @@ mmmmap(dev_t dev, off_t off, int prot)
int
mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p)
{
+ switch (cmd) {
+ case FIONBIO:
+ case FIOASYNC:
+ /* handled by fd layer */
+ return 0;
+ }
+
#ifdef MTRR
switch (minor(dev)) {
case 0: