Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Nov 2006 12:28:22 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-hackers@freebsd.org
Cc:        Ed Schouten <ed@fxq.nl>
Subject:   Re: [Patch] sys/kern/kern_descrip.c: remove double limit check in fcntl()
Message-ID:  <200611141228.23195.jhb@freebsd.org>
In-Reply-To: <20061109193342.GC16100@hoeg.nl>
References:  <20061109124119.GB16100@hoeg.nl> <20061109193342.GC16100@hoeg.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday 09 November 2006 14:33, Ed Schouten wrote:
> * Ed Schouten <ed@fxq.nl> wrote:
> > The patch below prevents this by performing this check by do_dup(). It
> > will prevent fcntl() from PROC_LOCK()'ing twice. It also fixes the
> > return value of fcntl(). The manual page states that it should return
> > EMFILE when it exceeds its limit, though the actual code sets EINVAL.
> 
> Woops - It looks like I wasn't awake when I was reading the fcntl()
> manual page. fcntl() should return EINVAL when the minimum value is
> higher than the limit and EMFILE when it can't find a free descriptor in
> the range from the minimum value to the maximum. dup() generalizes this
> to EMFILE. It cannot return EINVAL.
> 
> I decided to change the patch that do_dup() can return EINVAL for the
> fcntl() scenario and that the dup()/dup2() system calls readjust the
> errno right before returning. Please use the patch below.

I actually the resulting changes obfuscate the code more than the current 
code, so I'd prefer to just leave it as it is.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200611141228.23195.jhb>