From owner-freebsd-hackers@FreeBSD.ORG Tue Nov 14 19:46:11 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 65CCE16A416 for ; Tue, 14 Nov 2006 19:46:11 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id E839843D67 for ; Tue, 14 Nov 2006 19:46:00 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.6/8.13.6) with ESMTP id kAEJjqQM024703; Tue, 14 Nov 2006 14:45:53 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Tue, 14 Nov 2006 12:28:22 -0500 User-Agent: KMail/1.9.1 References: <20061109124119.GB16100@hoeg.nl> <20061109193342.GC16100@hoeg.nl> In-Reply-To: <20061109193342.GC16100@hoeg.nl> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200611141228.23195.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Tue, 14 Nov 2006 14:45:54 -0500 (EST) X-Virus-Scanned: ClamAV 0.88.3/2194/Tue Nov 14 12:26:01 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Ed Schouten Subject: Re: [Patch] sys/kern/kern_descrip.c: remove double limit check in fcntl() X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Nov 2006 19:46:11 -0000 On Thursday 09 November 2006 14:33, Ed Schouten wrote: > * Ed Schouten 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