From nobody Thu Oct 07 16:56:15 2021 X-Original-To: dev-commits-src-main@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 A2FA212BFC77; Thu, 7 Oct 2021 16:56:32 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (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 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HQHXc3zFxz3vDC; Thu, 7 Oct 2021 16:56:32 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-oi1-f175.google.com with SMTP id o204so1670233oih.13; Thu, 07 Oct 2021 09:56:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2IpyZMv3JRGOui2WkENFUhSFHKUWrAtTBPD3fi0e+Cs=; b=craZBfK6dvytakVL62R/KZCxoGhvCZ3De4xgFRjhIP5O6L1xCwDJ5cnl1Py0FghhhD KGMaEqZdvac1xW7/5jjI0T2OJpmifHsWEMD5tQ3IfTLxTru0eUCjThVfBKWWsyMvLkJI alku2XyuNQYU1Oppv8M/FqpcPONLYZKciIFiKk95gVDCnIwsmhrbFUWxEtblUwfcroqB lg8H/rST4hCSNb0xs78eOCeT2xVC4LmsNZUXUU8w/+nAbW74hu8LOAn6EjUYEu4F/6xn TNG/Zppasz8d/53mCq5/nAtsObihiua/OuANJESg65/Il3fJhKA1OAhWhmnGhlVByz82 vcCQ== X-Gm-Message-State: AOAM533VWU6E3qGmMkhJe2zszZ2uo2R2HdYImAl+O7y1Ss54MM2tdlYQ z+sYf4C3fjp4SjanAVL/C2eU/sWCt7HV936iznUDKeIV X-Google-Smtp-Source: ABdhPJwnyVT48SHA++nYySk2jrcazGQBn4HGjdAtOGwX2GOuMe6Zqdz+3q8PHQF4uswo1VL3ea8Sz2POLl8diRxax6g= X-Received: by 2002:a54:4e94:: with SMTP id c20mr3912293oiy.57.1633625786341; Thu, 07 Oct 2021 09:56:26 -0700 (PDT) List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 References: <202110071509.197F9kqv094488@gitrepo.freebsd.org> In-Reply-To: From: Alan Somers Date: Thu, 7 Oct 2021 10:56:15 -0600 Message-ID: Subject: Re: git: 824bbb9a4082 - main - diff: consider two files with same inodes as identical To: Mariusz Zaborski Cc: Ian Lepore , src-committers , "" , dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4HQHXc3zFxz3vDC X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Thu, Oct 7, 2021 at 9:54 AM Mariusz Zaborski wrote: > > Like Ian said from what I know this is the way of uniquely identify the file. > We use this technique in flopen(3), pidfile_open(3) or fts(3). > > On Thu, 7 Oct 2021 at 17:40, Ian Lepore wrote: >> >> On Thu, 2021-10-07 at 09:32 -0600, Alan Somers wrote: >> > On Thu, Oct 7, 2021 at 9:09 AM Mariusz Zaborski >> > wrote: >> > > >> > > The branch main has been updated by oshogbo: >> > > >> > > URL: >> > > https://cgit.FreeBSD.org/src/commit/?id=824bbb9a40820fb62bde0a91c0f13e0b894da149 >> > > >> > > commit 824bbb9a40820fb62bde0a91c0f13e0b894da149 >> > > Author: Mariusz Zaborski >> > > AuthorDate: 2021-10-07 15:07:00 +0000 >> > > Commit: Mariusz Zaborski >> > > CommitDate: 2021-10-07 15:07:00 +0000 >> > > >> > > diff: consider two files with same inodes as identical >> > > >> > > Obtained from: OpenBSD >> > > MFC after: 1 week >> > > --- >> > > usr.bin/diff/diffreg.c | 4 ++++ >> > > 1 file changed, 4 insertions(+) >> > > >> > > diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c >> > > index fc3c3406a073..995843f9e539 100644 >> > > --- a/usr.bin/diff/diffreg.c >> > > +++ b/usr.bin/diff/diffreg.c >> > > @@ -440,6 +440,10 @@ files_differ(FILE *f1, FILE *f2, int flags) >> > > if ((flags & (D_EMPTY1|D_EMPTY2)) || stb1.st_size != >> > > stb2.st_size || >> > > (stb1.st_mode & S_IFMT) != (stb2.st_mode & S_IFMT)) >> > > return (1); >> > > + >> > > + if (stb1.st_dev == stb2.st_dev && stb1.st_ino == >> > > stb2.st_ino) >> > > + return (0); >> > > + >> > >> > Checking st_dev is not correct. It does necessarily bear any >> > relation >> > to the specific mounted file system. It might, but that's up to the >> > file system driver. fusefs, for example, allows the server to >> > populate that field with whatever it damn well pleases. diff should >> > use statfs instead, and check the f_fsid field. That would probably >> > work. >> > -Alan >> >> That may be a fusefs bug, then. Posix states >> >> The st_ino and st_dev fields taken together uniquely identify the >> file within the system. >> >> And I've seen real-world code more than once that uses st_dev equality >> to decide whether to rename versus copy-and-delete a file. >> >> -- Ian Nevermind, I was confusing st_dev with st_rdev. Everything's fine, and this looks like a good optimization.