From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 6FCB93858D3C for ; Mon, 8 Nov 2021 15:55:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6FCB93858D3C Received: by mail-pf1-x432.google.com with SMTP id g18so11654768pfk.5 for ; Mon, 08 Nov 2021 07:55:34 -0800 (PST) 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=m6idYkrozOQ5Kryd2L7+YMU2bHVTytnqiubDVKEtQlA=; b=bhD0qHgzQlM1YKSC4oZSEmnGviemu1eIMg8iN/YNvA0DbRjapj2DLO5aRWVEJ5ZWp1 Gx+w/u/dSMvO0rBJ+l9G1G5evax8q/NRmZGiWvGg6dDvkTUivH15GIlBWNKX25npY52a 8ZzSE4AjrmDZG6FzmK3QNlJnCnUfmdxMkls83Xtb9b9H5gARexyj+0/fVN+9aDyPzY2/ /tLK91DYBZUkNIwFLGYKkjzVAWeQ0wwqULlPA4aBbvRo8vmDoxMWEHf88jN0Qq+i8Lu5 1jyce7aEe7EySRrYVZj/9WxMtombsjPrDF0CdSlPw1n8s4yJBoaMOzPbv+CnT9MABFLz XqUw== X-Gm-Message-State: AOAM533FYgxEOCL7RLwyMPuKUruRg+yFZtj0WYbNPh94oOeFGhvx//R1 aBTE90u0zr2GSxav+PVfL6gbjJtOpBgEUZK1/KUTzuQ+ X-Google-Smtp-Source: ABdhPJxu3Q3KC3CsHX1271GVx2QS4H5gG9kIWmtfiJY0DQu4yOUFzWgxdCqIj88j/70HQzeeSRb3PcT3KRzymxftxks= X-Received: by 2002:a05:6a00:2351:b0:47b:d092:d2e4 with SMTP id j17-20020a056a00235100b0047bd092d2e4mr168351pfj.76.1636386933558; Mon, 08 Nov 2021 07:55:33 -0800 (PST) MIME-Version: 1.0 References: <8abecf436b4e0575a514aaacbf4be69c73823cd5.1636120354.git.fweimer@redhat.com> In-Reply-To: <8abecf436b4e0575a514aaacbf4be69c73823cd5.1636120354.git.fweimer@redhat.com> From: "H.J. Lu" Date: Mon, 8 Nov 2021 07:54:57 -0800 Message-ID: Subject: Re: [PATCH 1/2] Use sysdeps/posix/dl-fileid.h as the generic and only implementation To: Florian Weimer Cc: GNU C Library Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3029.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Nov 2021 15:55:36 -0000 On Fri, Nov 5, 2021 at 7:02 AM Florian Weimer via Libc-alpha wrote: > > --- > sysdeps/generic/dl-fileid.h | 30 ++++++++++++---------- > sysdeps/posix/dl-fileid.h | 50 ------------------------------------- > 2 files changed, 17 insertions(+), 63 deletions(-) > delete mode 100644 sysdeps/posix/dl-fileid.h > > diff --git a/sysdeps/generic/dl-fileid.h b/sysdeps/generic/dl-fileid.h > index fb1e1c788b..bf437f3d71 100644 > --- a/sysdeps/generic/dl-fileid.h > +++ b/sysdeps/generic/dl-fileid.h > @@ -1,4 +1,4 @@ > -/* File identity for the dynamic linker. Stub version. > +/* File identity for the dynamic linker. Generic POSIX.1 version. > Copyright (C) 2015-2021 Free Software Foundation, Inc. > This file is part of the GNU C Library. > > @@ -17,30 +17,34 @@ > . */ > > #include > +#include > > -/* This type stores whatever information is fetched by _dl_get_file_id > - and compared by _dl_file_id_match_p. */ > +/* For POSIX.1 systems, the pair of st_dev and st_ino constitute > + a unique identifier for a file. */ > struct r_file_id > { > - /* In the stub version, we don't record anything at all. */ > + dev_t dev; > + ino64_t ino; > }; > > /* Sample FD to fill in *ID. Returns true on success. > On error, returns false, with errno set. */ > static inline bool > -_dl_get_file_id (int fd __attribute__ ((unused)), > - struct r_file_id *id __attribute__ ((unused))) > +_dl_get_file_id (int fd, struct r_file_id *id) > { > + struct __stat64_t64 st; > + > + if (__glibc_unlikely (__fstat64_time64 (fd, &st) < 0)) > + return false; > + > + id->dev = st.st_dev; > + id->ino = st.st_ino; > return true; > } > > -/* Compare two results from _dl_get_file_id for equality. > - It's crucial that this never return false-positive matches. > - It's ideal that it never return false-negative mismatches either, > - but lack of matches is survivable. */ > +/* Compare two results from _dl_get_file_id for equality. */ > static inline bool > -_dl_file_id_match_p (const struct r_file_id *a __attribute__ ((unused)), > - const struct r_file_id *b __attribute__ ((unused))) > +_dl_file_id_match_p (const struct r_file_id *a, const struct r_file_id *b) > { > - return false; > + return a->dev == b->dev && a->ino == b->ino; > } > diff --git a/sysdeps/posix/dl-fileid.h b/sysdeps/posix/dl-fileid.h > deleted file mode 100644 > index bf437f3d71..0000000000 > --- a/sysdeps/posix/dl-fileid.h > +++ /dev/null > @@ -1,50 +0,0 @@ > -/* File identity for the dynamic linker. Generic POSIX.1 version. > - Copyright (C) 2015-2021 Free Software Foundation, Inc. > - This file is part of the GNU C Library. > - > - The GNU C Library is free software; you can redistribute it and/or > - modify it under the terms of the GNU Lesser General Public > - License as published by the Free Software Foundation; either > - version 2.1 of the License, or (at your option) any later version. > - > - The GNU C Library is distributed in the hope that it will be useful, > - but WITHOUT ANY WARRANTY; without even the implied warranty of > - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > - Lesser General Public License for more details. > - > - You should have received a copy of the GNU Lesser General Public > - License along with the GNU C Library; if not, see > - . */ > - > -#include > -#include > - > -/* For POSIX.1 systems, the pair of st_dev and st_ino constitute > - a unique identifier for a file. */ > -struct r_file_id > - { > - dev_t dev; > - ino64_t ino; > - }; > - > -/* Sample FD to fill in *ID. Returns true on success. > - On error, returns false, with errno set. */ > -static inline bool > -_dl_get_file_id (int fd, struct r_file_id *id) > -{ > - struct __stat64_t64 st; > - > - if (__glibc_unlikely (__fstat64_time64 (fd, &st) < 0)) > - return false; > - > - id->dev = st.st_dev; > - id->ino = st.st_ino; > - return true; > -} > - > -/* Compare two results from _dl_get_file_id for equality. */ > -static inline bool > -_dl_file_id_match_p (const struct r_file_id *a, const struct r_file_id *b) > -{ > - return a->dev == b->dev && a->ino == b->ino; > -} > -- > 2.33.1 > > Please submit the v2 patch with the updated cover letter to indicate that this patch set doesn't fix any bug, but is a cleanup. Thanks. -- H.J.