From nobody Fri Apr 5 13:54:01 2024 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VB0Mc11j5z5GVsp for ; Fri, 5 Apr 2024 13:54:04 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4VB0Mb591Vz44nf; Fri, 5 Apr 2024 13:54:03 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Authentication-Results: mx1.freebsd.org; none Received: from critter.freebsd.dk (unknown [192.168.55.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by phk.freebsd.dk (Postfix) with ESMTPS id 0F7418928B; Fri, 5 Apr 2024 13:54:02 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.18.1/8.16.1) with ESMTPS id 435Ds1ID086244 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 5 Apr 2024 13:54:01 GMT (envelope-from phk@critter.freebsd.dk) Received: (from phk@localhost) by critter.freebsd.dk (8.18.1/8.16.1/Submit) id 435Ds1KX086243; Fri, 5 Apr 2024 13:54:01 GMT (envelope-from phk) Message-Id: <202404051354.435Ds1KX086243@critter.freebsd.dk> To: Alan Somers cc: FreeBSD Hackers Subject: Re: SEEK_HOLE at EOF In-reply-to: From: "Poul-Henning Kamp" References: <202404050543.4355hDcS009860@critter.freebsd.dk> List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <86241.1712325241.1@critter.freebsd.dk> Date: Fri, 05 Apr 2024 13:54:01 +0000 X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:1835, ipnet:130.225.0.0/16, country:EU] X-Rspamd-Queue-Id: 4VB0Mb591Vz44nf -------- Alan Somers writes: > On Thu, Apr 4, 2024 at 11:43=E2=80=AFPM Poul-Henning Kamp dk> wrote: > > Just two minor quibbles: > > > > If the file position is EOF, then you /are/ "beyond the end of the file" > > because a read(2) would not be able to return any data. > > Do you distinguish between "at EOF" and "beyond EOF"? And does it not > trouble you that calling SEEK_HOLE from the beginning of the "virtual > hole at EOF" will return ENXIO, even though calling SEEK_HOLE from the > beginning of any real hole will return the current offset? EOF is where the file ends and there's no "hole" there, because there no more file on the other side of that "hole". When you stand on a cliff, the ocean is not "a hole in the landscape", it's where the landscape ends. > > And returning ENXIO is more informative than returning the size of the > > file, since it atomically tells you that there are no more holes. > > Ahh, that's a good point. It's the first point I've heard in favor of > this option. Are you aware of any applications that need to know > that? No, but that should not get in the way of good syscall architecture :-) It might be useful for archivers which try to be smart about sparse files. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.