Subject: Re: fdclone() and FNONBLOCK
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@tac.gw.com>
List: tech-kern
Date: 02/12/2005 18:05:55
In article <20050212203453.GA8249@antioche.eu.org>,
Manuel Bouyer  <bouyer@antioche.eu.org> wrote:
>Hi,
>I have an application (initiallty written for linux) that
>open(O_NONBLOCK|O_RDWR) a device. This device uses fdclone() in its open:
>xenevtopen(dev_t dev, int flag, int mode, struct proc *p)
>{
>        struct xenevt_d *d;
>        struct file *fp;
>        int fd, error;  
>
>        printf("xenevtopen flags %d\n", flag);
>
>        /* falloc() will use the descriptor for us. */
>        if ((error = falloc(p, &fp, &fd)) != 0)
>                return error;
>
>        d = malloc(sizeof(*d), M_DEVBUF, M_WAITOK | M_ZERO);
>
>        return fdclone(p, fp, fd, &xenevt_fileops, d);
>}
>
>This works as expected, expect that FNONBLOCK isn't set in struct file
>passed to the read routine.
>First I'm not sure open(O_NONBLOCK) will cause FNONBLOCK to be set on
>read. The open(2) linux man page is clear about this, but the NetBSD one
>isn't (it doesn't say if the nonblock behavior is only for open, or for
>subsequent I/O as well).
>If open() is supposed to set FNONBLOCK for subsequent operations, then
>it's fdclone() which doesn't preserve the flags. Could someone explain
>me where the problem is here ?

I just fixed this; I am testing it and I will commit shortly.

christos