From owner-freebsd-hackers@freebsd.org Tue Dec 8 17:32:49 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 47ACB9D438B; Tue, 8 Dec 2015 17:32:49 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-pa0-x232.google.com (mail-pa0-x232.google.com [IPv6:2607:f8b0:400e:c03::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1F8E01EF6; Tue, 8 Dec 2015 17:32:49 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by pacej9 with SMTP id ej9so15179357pac.2; Tue, 08 Dec 2015 09:32:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=X6WPJ2asx03m+jFClRzP+If50bXb3F0d3Hd1JQRq9vU=; b=iuXsHLcs4jdqWRezpF+HE3kSNN41W17v8D4KMZXL60YkjeFQ3OIJQBUcW4uNWgbFlv bfYJjSSd0YW0m8YIR/XRGqXbBrS3pUvh0+pRvlB9JAiSFC2+kPoCQUTq2TeE2TBoUsva UFDnA1J9HeP87HLWj02Fw4BVHx35KuXJyj2Qn1PBrM269UE1wispepIa07K9azNSUkRG S7aTjAq8T2EiC2wU4tQG9g0q/pdBFhHkNBU3B7qjouKaNlxALuPRSmbFNKvr0s+uirxI 6+8/qfS2P0rlGmke6PaDTnZwuxtarN7zew5px3oW3uoQqZ98k51MTTIywPL0iZDedxIq 2gxw== X-Received: by 10.66.224.165 with SMTP id rd5mr1508464pac.73.1449595968727; Tue, 08 Dec 2015 09:32:48 -0800 (PST) Received: from raichu ([104.232.114.184]) by smtp.gmail.com with ESMTPSA id 71sm6037676pfj.28.2015.12.08.09.32.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Dec 2015 09:32:48 -0800 (PST) Sender: Mark Johnston Date: Tue, 8 Dec 2015 09:32:36 -0800 From: Mark Johnston To: Maxim Sobolev Cc: freebsd-current@freebsd.org, freebsd-hackers@freebsd.org, Kirk McKusick , kib@freebsd.org Subject: Re: posix_fallocate(2) && posix_fadvise(2) are somewhat broken Message-ID: <20151208173236.GA11078@raichu> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Dec 2015 17:32:49 -0000 On Tue, Dec 08, 2015 at 01:35:31AM -0800, Maxim Sobolev wrote: > Hi, while working on some unrelated feature I've noticed that at least > those two system calls are not returning proper value (-1) on error. > Instead actual errno value is returned from the syscall verbatim, > i.e. posix_fadvise() returns 22 on EINVAL. Attached patch fixes that > problem, however I am not sure if I need to assign td->td_retval[0] at all, > those two operations by design never return anything but -1 on error and 0 > on success. Can someone comment on this? Thanks! This behaviour is documented and specified by POSIX. I'm not sure why these syscalls are inconsistent with everything else, but the current implementation is correct.