From 539842a4ea456e0caabc7dc00d46daa1a97c8c07 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 28 Jun 2004 05:07:08 +0000 Subject: Update. * elf/ldconfig.c (add_dir): Take chroot into account. Based on changes by HJ Lu and Hideki Iwamoto. --- elf/ldconfig.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'elf') diff --git a/elf/ldconfig.c b/elf/ldconfig.c index bf103c7269..d85bbc8f05 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -318,17 +318,13 @@ add_single_dir (struct dir_entry *entry, int verbose) static void add_dir (const char *line) { - char *equal_sign; - struct dir_entry *entry; unsigned int i; - struct stat64 stat_buf; - - entry = xmalloc (sizeof (struct dir_entry)); + struct dir_entry *entry = xmalloc (sizeof (struct dir_entry)); entry->next = NULL; /* Search for an '=' sign. */ entry->path = xstrdup (line); - equal_sign = strchr (entry->path, '='); + char *equal_sign = strchr (entry->path, '='); if (equal_sign) { *equal_sign = '\0'; @@ -358,19 +354,28 @@ add_dir (const char *line) while (entry->path[i] == '/' && i > 0) entry->path[i--] = '\0'; - if (stat64 (entry->path, &stat_buf)) + char *path = entry->path; + if (opt_chroot) + path = chroot_canon (opt_chroot, path); + + struct stat64 stat_buf; + if (path == NULL || stat64 (path, &stat_buf)) { if (opt_verbose) error (0, errno, _("Can't stat %s"), entry->path); free (entry->path); free (entry); - return; } + else + { + entry->ino = stat_buf.st_ino; + entry->dev = stat_buf.st_dev; - entry->ino = stat_buf.st_ino; - entry->dev = stat_buf.st_dev; + add_single_dir (entry, 1); + } - add_single_dir (entry, 1); + if (opt_chroot) + free (path); } -- cgit 1.4.1