From owner-freebsd-hackers@freebsd.org Sun May 22 23:26:42 2016 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 2A0A1B3BD3C for ; Sun, 22 May 2016 23:26:42 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-oi0-f50.google.com (mail-oi0-f50.google.com [209.85.218.50]) (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 EE1741D9D for ; Sun, 22 May 2016 23:26:41 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-oi0-f50.google.com with SMTP id x19so253830978oix.2 for ; Sun, 22 May 2016 16:26:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :date:message-id:subject:from:to; bh=lJ67+3atXlDnTA2X5r01wCCzF0pOqOPK3DznIAnvt0M=; b=PNBCBfZlsiwhJEjZcf+M+0KJzDxekSDl8Rnb00iqfJINpkX+GH/VbWAQiOHSx+c8IO Bx6IQp2hBlAsV71dUGOKuigvZJONUxswJp9FLFvdBcLp8x/Z6kLzsxBmcGGCgZ6eQiav 6CVEPS8BTRmEvCF5kp2DN2Rar5uODE6YgqC2AUa7NH/0EPJ6y3ADhkHxAkaIvBtdxEeF SQkYOSI+AN4elXg34ufLOtDN7yrCJpNaEAsOxF0L5lqVIpwn0gqNCdO3UyEVCE9q19E1 vJKA0JrTr8xw6s6ubRsZIth8DC5EN5J9d7q4EVqqb27Kwu75ML/Wmz+R5kl08JZ96pke dF2Q== X-Gm-Message-State: ALyK8tKY7GyMwpN4KV831+mgQpesr0Cnj9iXjUfu+jCqbWGJQAEIjWyTapu4rf9HLCPbzw== X-Received: by 10.157.47.102 with SMTP id h93mr2379532otb.25.1463959594942; Sun, 22 May 2016 16:26:34 -0700 (PDT) Received: from mail-io0-f179.google.com (mail-io0-f179.google.com. [209.85.223.179]) by smtp.gmail.com with ESMTPSA id g93sm4363838otg.7.2016.05.22.16.26.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 May 2016 16:26:34 -0700 (PDT) Received: by mail-io0-f179.google.com with SMTP id t40so90102564ioi.0 for ; Sun, 22 May 2016 16:26:34 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.107.38.79 with SMTP id m76mr12132764iom.7.1463959594345; Sun, 22 May 2016 16:26:34 -0700 (PDT) Reply-To: cem@FreeBSD.org Received: by 10.36.205.70 with HTTP; Sun, 22 May 2016 16:26:34 -0700 (PDT) In-Reply-To: <20160522231048.GA25503@britannica.bec.de> References: <20160522231048.GA25503@britannica.bec.de> Date: Sun, 22 May 2016 16:26:34 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: read(2) and thus bsdiff is limited to 2^31 bytes From: Conrad Meyer To: Dirk Engling , FreeBSD Hackers Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 May 2016 23:26:42 -0000 On Sun, May 22, 2016 at 4:10 PM, Joerg Sonnenberger wrote: > On Sun, May 22, 2016 at 03:56:33PM -0700, Conrad Meyer wrote: >> ERRORS >> The read(), readv(), pread() and preadv() system calls will succeed >> unless: >> ... >> [EINVAL] The value nbytes is greater than INT_MAX. >> >> It does seem silly to me given nbytes is a size_t. I think it should >> error if nbytes is greater than SSIZE_T_MAX, but on platforms where >> size_t is larger than int (e.g. amd64) it shouldn't error for nbytes >> in [INT_MAX, SSIZE_T_MAX - 1]. > > There are a lot of valid reasons for not doing arbitrarily large > operations, especially since a certain amount of atomicity is expected > for local IO. That doesn't mean that it can't be turned into a short > read/write instead. Erroring out seeems completely unjustified. Sure; those reasons also apply to INT_MAX-sized IOs (2 GB). Conrad