From owner-freebsd-hackers@freebsd.org Mon May 23 12:31:19 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 87FE2B45C62 for ; Mon, 23 May 2016 12:31:19 +0000 (UTC) (envelope-from cedric.blancher@gmail.com) Received: from mail-pf0-x22a.google.com (mail-pf0-x22a.google.com [IPv6:2607:f8b0:400e:c00::22a]) (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 5ADA81D23 for ; Mon, 23 May 2016 12:31:19 +0000 (UTC) (envelope-from cedric.blancher@gmail.com) Received: by mail-pf0-x22a.google.com with SMTP id g64so11782070pfb.2 for ; Mon, 23 May 2016 05:31:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to; bh=ii3svPBaK7xV1A8Ud3Sf497OZlk9s0HcuaegPgYwzFA=; b=niMfDNH8sRRYm8+j68RxEItK33MOtlQONHB8WZ9tnLeamEnErchf75TCz2zQ7eYpVk r/V99yBpf0PvnVZl3BE61wUUGTkHpBwO5Qio0PPVwqDUadJ8fjp58HAa9vHSimdUWsaJ 8ruS6WbTCgjS0l5baZfC8/mGYvwGFMFepmHfMrlePnq3YOp539dpnOTEVfSMNFI5H549 AjavVTIXk9DpHeP9zi4CCTRabKxYbECtCK+cA464apqqzXYW+sHA4zHQEnDW/iKM6jgv JZtBA+/PVbN3bS49Gc2h9LPIcThxUk1jSCGUOPHjRyeySguvHmegJyzrI19l4BVLOWxH L4KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to; bh=ii3svPBaK7xV1A8Ud3Sf497OZlk9s0HcuaegPgYwzFA=; b=CRsnP1J6/xV9xBE8bGXv6tvExDeNidJAH32AsEPt7udZxDCFUTcojgDDkwQa42q85+ 1DDN+nWttQVva8WHrnJ47fbUa0LRVMTB50S28V4kSPn4nIZTNJUhE7u4i0NZyhT21QzM 03ZwVKlMCDG7X/zJ1wbJx9SxdVnT52kwd3WTQY3rqLSYKu88xR+5+jDFuyzpo33E/qp9 PbKBxjgSuWkxCDzFxsp3uPaNTxfu4ReBGDj7P0RfCVoB+m4RE35eIjymgnyCit7xyBzg HUdoAhfHawzRuLa6c7Ixh5YEayh7XlS+gEhuOS9m1tseg6hMP/J8kB2RmkwzOCKgFZR6 iS+g== X-Gm-Message-State: AOPr4FXLZH3WITJqbAKiOGQ7z2SV0Nbafu+NU8Lgz6r3ZKdSGYnTaSGKLhEv5w1iYwqhnjKOOjDFz5xExe82ww== MIME-Version: 1.0 X-Received: by 10.98.101.198 with SMTP id z189mr27369918pfb.76.1464006678777; Mon, 23 May 2016 05:31:18 -0700 (PDT) Received: by 10.66.183.232 with HTTP; Mon, 23 May 2016 05:31:18 -0700 (PDT) In-Reply-To: <20160523122131.GC8747@britannica.bec.de> References: <20160522225414.GB24398@britannica.bec.de> <154dab43060.11208cdfd132112.2616144627831899155@nextbsd.org> <20160522231203.GB25503@britannica.bec.de> <154db353935.dd5e87c1133922.4370692881788049491@nextbsd.org> <20160523122131.GC8747@britannica.bec.de> Date: Mon, 23 May 2016 14:31:18 +0200 Message-ID: Subject: Re: read(2) and thus bsdiff is limited to 2^31 bytes From: Cedric Blancher To: Matthew Macy , Joerg Sonnenberger , "" 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: Mon, 23 May 2016 12:31:19 -0000 Nothing in POSIX mandates that read()/write() are atomic. Old UNIX, SystemV, AIX, Solaris and HP-UX don't do that nor do they guarantee that. Ced On 23 May 2016 at 14:21, Joerg Sonnenberger wrote: > On Sun, May 22, 2016 at 06:22:58PM -0700, Matthew Macy wrote: >> >> >> >> ---- On Sun, 22 May 2016 16:12:03 -0700 Joerg Sonnenberger wrote ---- >> > On Sun, May 22, 2016 at 04:02:02PM -0700, Matthew Macy wrote: >> > > >> > > >> > > >> > > ---- On Sun, 22 May 2016 15:54:14 -0700 Joerg Sonnenberger wrote ---- >> > > > On Sun, May 22, 2016 at 10:54:30PM +0200, Dirk Engling wrote: >> > > > > When trying to bsdiff two DVD images, I noticed it failing due to >> > > > > read(2) returning EINVAL to the tool. man 2 read says, this would only >> > > > > happen for a negative value for fildes, which clearly was not true. >> > > > >> > > > I would classify that as implementation bug. It seems perfectly sensible >> > > > to turn overly large requests into a short read/write, even for blocking >> > > > files. But erroring out seems to be quite wrong to me. >> > > > >> > > >> > > read(2) takes a size_t so this is clearly an internal bug where it's an int and treating it as a negative value. >> > >> > Not exactly. The reason for cutting it off are many fold. Using int in >> > the kernel is one argument. The requirement for locking the IO range for >> > concurrent read/write operations from other threads is a bigger >> > argument. >> > >> That still doesn't justify EINVAL as a return. Does read(2) need to >> make atomicity guarantees? > > See my first sentence. I consider returning EINVAL for too large buffer > size a bug. Yes, read/write operations should be atomic with regard to > other processes on the system. Atomic meaning in this context that the > read can be observed either completely or not at all. This still doesn't > mean that read must execute the full size. Other cases for short > read/writes are socket, pipes etc. > > Joerg > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" -- Cedric Blancher Institute Pasteur