From: "H.J. Lu" <hjl.tools@gmail.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: GNU C Library <libc-alpha@sourceware.org>
Subject: Re: [PATCH 1/2] Use sysdeps/posix/dl-fileid.h as the generic and only implementation
Date: Mon, 8 Nov 2021 07:54:57 -0800 [thread overview]
Message-ID: <CAMe9rOpHJiCSZYJPeponOaVsnNum4TPDDFRMT0ztFOeKc_NzOw@mail.gmail.com> (raw)
In-Reply-To: <8abecf436b4e0575a514aaacbf4be69c73823cd5.1636120354.git.fweimer@redhat.com>
On Fri, Nov 5, 2021 at 7:02 AM Florian Weimer via Libc-alpha
<libc-alpha@sourceware.org> 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 @@
> <https://www.gnu.org/licenses/>. */
>
> #include <stdbool.h>
> +#include <sys/stat.h>
>
> -/* 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
> - <https://www.gnu.org/licenses/>. */
> -
> -#include <stdbool.h>
> -#include <sys/stat.h>
> -
> -/* 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.
next prev parent reply other threads:[~2021-11-08 15:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-05 13:59 [PATCH 0/2] Avoid some crashes when loading separate debuginfo Florian Weimer
2021-11-05 13:59 ` [PATCH 1/2] Use sysdeps/posix/dl-fileid.h as the generic and only implementation Florian Weimer
2021-11-08 15:54 ` H.J. Lu [this message]
2021-11-05 13:59 ` [PATCH 2/2] elf: Detect PT_LOAD segments that extend beyond EOF and refuse loading Florian Weimer
2021-11-05 14:04 ` H.J. Lu
2021-11-05 14:07 ` Florian Weimer
2021-11-05 14:26 ` H.J. Lu
2021-11-05 14:31 ` Florian Weimer
2021-11-05 14:37 ` H.J. Lu
2021-11-05 14:41 ` Florian Weimer
2021-11-05 15:03 ` H.J. Lu
2021-11-05 15:50 ` Florian Weimer
2021-11-05 14:30 ` Adhemerval Zanella
2021-11-05 14:35 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAMe9rOpHJiCSZYJPeponOaVsnNum4TPDDFRMT0ztFOeKc_NzOw@mail.gmail.com \
--to=hjl.tools@gmail.com \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).