This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Add --print-dirs option for ldconfig


Build tools often want to determine whether a directory is part of the
system linker path or not when deciding to set an RPATH during linking.
For glibc based systems, this involves guessing the trusted directories
by platform and then parsing out ld.so.conf.

This patch adds a -P|--print-dirs option to ldconfig for printing the
system library directories. Here is sample output from a Fedora 9 x86_64
system:

$ ./elf/ldconfig -P
/usr/lib64/mysql
/usr/lib64/qt-3.3/lib
/usr/lib/wine
/usr/lib64/xulrunner-1.9
/lib
/lib64
/usr/lib
/usr/lib64

---
 elf/ldconfig.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

2008-12-19  Dan Nicholson  <dbn.lists@gmail.com>

	* elf/ldconfig.c (main): Add -P|--print-dirs option for printing
	the system library directories.

diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index e4dfdf5..769ca12 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -90,6 +90,9 @@ static struct dir_entry *dir_entries;
 /* Print Cache.  */
 static int opt_print_cache;
 
+/* Print system directories.  */
+static int opt_print_dirs;
+
 /* Be verbose.  */
 int opt_verbose;
 
@@ -136,6 +139,7 @@ void (*argp_program_version_hook) (FILE *, struct argp_state *)
 static const struct argp_option options[] =
 {
   { "print-cache", 'p', NULL, 0, N_("Print cache"), 0},
+  { "print-dirs", 'P', NULL, 0, N_("Print system directories"), 0},
   { "verbose", 'v', NULL, 0, N_("Generate verbose messages"), 0},
   { NULL, 'N', NULL, 0, N_("Don't build cache"), 0},
   { NULL, 'X', NULL, 0, N_("Don't generate links"), 0},
@@ -264,6 +268,9 @@ parse_opt (int key, char *arg, struct argp_state *state)
     case 'p':
       opt_print_cache = 1;
       break;
+    case 'P':
+      opt_print_dirs = 1;
+      break;
     case 'r':
       opt_chroot = arg;
       break;
@@ -1326,6 +1333,15 @@ main (int argc, char **argv)
 	add_system_dir (LIBDIR);
     }
 
+  if (opt_print_dirs)
+    {
+      struct dir_entry *entry;
+
+      for (entry = dir_entries; entry != NULL; entry = entry->next)
+        printf ("%s\n", entry->path);
+      exit (0);
+    }
+
   if (! opt_ignore_aux_cache)
     load_aux_cache (_PATH_LDCONFIG_AUX_CACHE);
   else
-- 
1.5.6.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]