From nobody Thu Apr 4 20:59:25 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 4V9Ys65RPDz5G1wR for ; Thu, 4 Apr 2024 20:59:38 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-vk1-f178.google.com (mail-vk1-f178.google.com [209.85.221.178]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4V9Ys60cZfz4BLn for ; Thu, 4 Apr 2024 20:59:38 +0000 (UTC) (envelope-from asomers@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=freebsd.org (policy=none); spf=pass (mx1.freebsd.org: domain of asomers@gmail.com designates 209.85.221.178 as permitted sender) smtp.mailfrom=asomers@gmail.com Received: by mail-vk1-f178.google.com with SMTP id 71dfb90a1353d-4daa2b076beso328419e0c.1 for ; Thu, 04 Apr 2024 13:59:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712264377; x=1712869177; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W47NbeJUTqELp97PtD11oAZ66jphlgvnF6pzh6Ji9/A=; b=kTyNgIvJCImpBfmEqYVZNynaqzBBiNSbC2PqmfPEbIY8N3TNBJNQt0kFBPHhQJdQpH Rte8SFK4sSfm3jvNj3m2KUCnTaXtrzreKRwSwzeZFQZdJgvGnlUUBou1mhTl+tvsAHAT dKPL3D8ZErzyLVSUwGjnO6FtkBGSPus0JfYXfq590p8tauLKOzDApHt44sAbb1RhjSTR xoRonQUE+bjPHMyztzijuqBV4NIMjdCNA+f0ddYw25w/5cZaM94/IoUSpgEq4Dtyu5tN 2u6KcTNl1WPepsclJVOJgSubkn5kpvFVa1INnccyybvulEmzWRiNz/ZnG08sPZchQJ8t RpjA== X-Gm-Message-State: AOJu0YyAZZvXTh8nOK/i804cyUu+yiHXlT2Qh1kNjNa+zGBNf6uIL/3+ zNIy2Cm4cmipfktwiVcsVBSVU10tJyS5R+l8lYcURQcNLjKgpwred7Co/5+y/FRpdhp+iVXMePe rpW5N8bvOrASht0yCqRoLwGfqZAwqxdMG X-Google-Smtp-Source: AGHT+IGGFnXFOwce/hOQcINwTdbOayw8whtiJN30+Ev2wkLWN47xlq2ogTCxjMwZ5gSN/Y3AnHDYu/aS77oquM0ya5U= X-Received: by 2002:a1f:f20f:0:b0:4d3:35ac:3553 with SMTP id q15-20020a1ff20f000000b004d335ac3553mr2901408vkh.10.1712264376935; Thu, 04 Apr 2024 13:59:36 -0700 (PDT) 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 References: In-Reply-To: From: Alan Somers Date: Thu, 4 Apr 2024 14:59:25 -0600 Message-ID: Subject: Re: SEEK_HOLE at EOF To: Rick Macklem Cc: FreeBSD Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: / X-Spamd-Result: default: False [-0.50 / 15.00]; NEURAL_HAM_LONG(-0.96)[-0.959]; NEURAL_SPAM_SHORT(0.65)[0.653]; FORGED_SENDER(0.30)[asomers@freebsd.org,asomers@gmail.com]; NEURAL_HAM_MEDIUM(-0.30)[-0.297]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; MIME_GOOD(-0.10)[text/plain]; DMARC_POLICY_SOFTFAIL(0.10)[freebsd.org : SPF not aligned (relaxed), No valid DKIM,none]; TO_DN_ALL(0.00)[]; RCVD_TLS_LAST(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; ARC_NA(0.00)[]; FREEMAIL_TO(0.00)[gmail.com]; MIME_TRACE(0.00)[0:+]; MISSING_XM_UA(0.00)[]; FREEFALL_USER(0.00)[asomers]; FREEMAIL_ENVFROM(0.00)[gmail.com]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_NEQ_ENVFROM(0.00)[asomers@freebsd.org,asomers@gmail.com]; RCVD_COUNT_ONE(0.00)[1]; MLMMJ_DEST(0.00)[freebsd-hackers@freebsd.org]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.85.221.178:from]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; TAGGED_RCPT(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[209.85.221.178:from] X-Rspamd-Queue-Id: 4V9Ys60cZfz4BLn On Thu, Apr 4, 2024 at 2:56=E2=80=AFPM Rick Macklem wrote: > > On Thu, Apr 4, 2024 at 11:15=E2=80=AFAM Alan Somers = wrote: > > > > tldr; there are two problems: > > 1) tmpfs handles SEEK_HOLE differently than other file systems > > 2) everything else handles SEEK_HOLE at EOF poorly, IMHO > > > > Details: > > > > According to lseek(2), SEEK_HOLE should return the start of the next > > hole greater than or equal to the supplied offset. Also, each file > > has a zero-sized virtual hole at the very end of the file. So I would > > expect that calling SEEK_HOLE at EOF would return the file's size. > > However, the man page also says that SEEK_HOLE will return ENXIO when > > the offset points to EOF. Those two statements seem contradictory to > > me. The first behavior seems more logical. I would expect SEEK_HOLE > > to work the same way both at EOF and at any other file offset. > > > > What does the spec say? > > > > There is no POSIX standard for this. It was invented by Solaris, > > Illumos's man page does not say clearly say what should happen at EOF. > > Linux's man page is clear: "whence is SEEK_DATA or SEEK_HOLE, and > > offset is beyond the end of the file". That would seem to indicate > > behavior 1: SEEK_HOLE should return the file's size at EOF. Only > > beyond EOF should it return ENXIO. > Well, there is the Austin Group stuff (never ratified by POSIX as I > understand it). > > Here's what it says about SEEK_HOLE and offset: > If whence is SEEK_HOLE, the file offset shall be set to the smallest > location of a byte within a hole and not less than offset, except that > if offset falls within the last hole, then the file offset may be set > to the file size instead. It shall be an error if offset is greater > or equal to the size of the file. > > I'd suggest we follow this, since it is the closest to a standard that th= ere is. That sounds like behavior 2: return ENXIO at EOF. For reference, do you have a link to that somewhere?