This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: PATCH: Handle symlink to directory in ldconfig.
"H . J . Lu" <hjl@lucon.org> writes:
> On Mon, May 07, 2001 at 08:34:37PM +0200, Andreas Jaeger wrote:
> >
> > Please use error (EXIT_FAILURE,...) instead of the exit (1).
> >
>
> Thanks. Here is the new one.
>
>
> H.J.
> ----
> 2001-05-07 H.J. Lu <hjl@gnu.org>
>
> * elf/ldconfig.c (add_single_dir): Call stat to check if 2
> directory paths point to the same inode or not.
> (search_dir): Handle symlink to directory.
>
> --- libc/elf/ldconfig.c.link Mon Mar 19 10:36:17 2001
> +++ libc/elf/ldconfig.c Mon May 7 11:49:38 2001
> @@ -264,13 +264,22 @@ static void
> add_single_dir (struct dir_entry *entry, int verbose)
> {
> struct dir_entry *ptr, *prev;
> + struct stat64 stat_buf1, stat_buf2;
>
> ptr = dir_entries;
> prev = ptr;
> while (ptr != NULL)
> {
> /* Check for duplicates. */
> - if (strcmp (ptr->path, entry->path) == 0)
> + if (stat64 (ptr->path, &stat_buf1))
> + error (EXIT_FAILURE, errno, _("Fatal error: can't stat %s"),
> + ptr->path);
> +
> + if (stat64 (entry->path, &stat_buf2))
> + error (EXIT_FAILURE, errno, _("Fatal error: can't stat %s"),
> + entry->path);
> +
> + if (memcmp (&stat_buf1, &stat_buf2, sizeof (stat_buf1)) == 0)
Two questions:
- wouldn't it be better to cache the needed stat information in struct
dir_entry?
- can we really memcmp to stat bufs? I don't think so. We should
instead compare st_dev and st_ino only.
The patch for search_dir looks fine,
Andreas
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj