diff mbox series

[1/2] Use sysdeps/posix/dl-fileid.h as the generic and only implementation

Message ID 8abecf436b4e0575a514aaacbf4be69c73823cd5.1636120354.git.fweimer@redhat.com
State Under Review
Delegated to: H.J. Lu
Headers show
Series Avoid some crashes when loading separate debuginfo | expand

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Florian Weimer Nov. 5, 2021, 1:59 p.m. UTC
---
 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

Comments

H.J. Lu Nov. 8, 2021, 3:54 p.m. UTC | #1
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.
diff mbox series

Patch

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;
-}