From nobody Thu Oct 07 15:55:44 2021 X-Original-To: dev-commits-src-all@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 4616C17EFEFB; Thu, 7 Oct 2021 15:54:43 +0000 (UTC) (envelope-from oshogbo.vx@gmail.com) Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (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 4HQG9H1HwNz3n9j; Thu, 7 Oct 2021 15:54:43 +0000 (UTC) (envelope-from oshogbo.vx@gmail.com) Received: by mail-lf1-f49.google.com with SMTP id x27so26905791lfu.5; Thu, 07 Oct 2021 08:54:43 -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=AlXfxgOKdK2R+z+NqeAkJAMBrxc6iwM/cURNsplm4r0=; b=Ob2V7QOX1oHTUqljJcecMdLxXjrECBeav8IX7oCeewUF2bRDVXMbimrNzZsSO6k0OH sMOiPU/E4/ekthB36vOwxQYVsUMIQpwJ7a90YH7e02ha6qTmqXhTH18sz4YZ0QvMSVG3 QuZ8Xxg5lFBBRSUqdrYtfnMpldvqIfB6rO/AteZMs9DEAfXCQjVGx0+q881Ie1dID7cd Abyj3/wZmyhdmSv1siL5ejWoeuGJuJQgYrYn71zc/wpgF+YkHTBcke5IHSimyol+vdw3 JJrgFxm76N3H/JjkLWk/QrzjNDA1KYHvtpnyQVjtqZSE0ccCKaqKPia1wdiTOio7AdGp tCag== X-Gm-Message-State: AOAM533udiqBckVZqR130ceSgjRwdCRm/4AmWxp0BEJUvBsY4YwDDtGV StBJ7vV2XpLHUN4KBFoeJG2vJeBumM7LaZCfd8QNGIvGHuk= X-Google-Smtp-Source: ABdhPJxZVtudTqFLtVDxnF+J4wvnRVzgrkWCrnzRyCrkyHVeq7yVbR0FBAqzEJh2oqiL8wTavAPa+2pqrL+8JTAO59k= X-Received: by 2002:a2e:9bd0:: with SMTP id w16mr5542852ljj.390.1633622081997; Thu, 07 Oct 2021 08:54:41 -0700 (PDT) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 References: <202110071509.197F9kqv094488@gitrepo.freebsd.org> In-Reply-To: From: Mariusz Zaborski Date: Thu, 7 Oct 2021 17:55:44 +0200 Message-ID: Subject: Re: git: 824bbb9a4082 - main - diff: consider two files with same inodes as identical To: Ian Lepore Cc: Alan Somers , src-committers , "" , dev-commits-src-main@freebsd.org Content-Type: multipart/alternative; boundary="000000000000e50eb905cdc54737" X-Rspamd-Queue-Id: 4HQG9H1HwNz3n9j X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[] X-Spam: Yes X-ThisMailContainsUnwantedMimeParts: N --000000000000e50eb905cdc54737 Content-Type: text/plain; charset="UTF-8" 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 > > > --000000000000e50eb905cdc54737--