From d4ba5766dde61481c91cb861ae7894fb7e3eac9b Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Fri, 22 Aug 1997 04:42:12 +0000 Subject: [PATCH] Add -R (rescan or refresh) option to rescan and rebuild the hints file based on the previous list of directories stored there which should overcome a weakness of the '-m' switch which can only add libs. This is an ideal way of updating the hints list after adding or removing a shlib since it will remove entries that are gone and doesn't need to have all the directories spelled out each time. (eg: rm -f /usr/lib/libtcl75*; ldconfig -R) This only works for version 2 hints files (which we've been generating for a year or so) which store the path. --- gnu/usr.bin/ld/ldconfig/ldconfig.8 | 11 ++++++++--- gnu/usr.bin/ld/ldconfig/ldconfig.c | 29 +++++++++++++++++++---------- sbin/ldconfig/ldconfig.8 | 11 ++++++++--- sbin/ldconfig/ldconfig.c | 29 +++++++++++++++++++---------- 4 files changed, 54 insertions(+), 26 deletions(-) diff --git a/gnu/usr.bin/ld/ldconfig/ldconfig.8 b/gnu/usr.bin/ld/ldconfig/ldconfig.8 index 3aee7bd533b4..6f97599e1bad 100644 --- a/gnu/usr.bin/ld/ldconfig/ldconfig.8 +++ b/gnu/usr.bin/ld/ldconfig/ldconfig.8 @@ -27,7 +27,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $Id: ldconfig.8,v 1.12 1997/02/22 15:46:37 peter Exp $ +.\" $Id: ldconfig.8,v 1.13 1997/07/11 14:45:40 jkh Exp $ .\" .Dd October 3, 1993 .Dt LDCONFIG 8 @@ -37,7 +37,7 @@ .Nd configure the shared library cache .Sh SYNOPSIS .Nm ldconfig -.Op Fl mrsv +.Op Fl Rmrsv .Op Fl f Ar hints_file .Op Ar directory | file Ar ... .Sh DESCRIPTION @@ -90,6 +90,10 @@ is typically run as part of the boot sequence. The following options recognized by .Nm ldconfig: .Bl -tag -width indent +.It Fl R +Rescan the previously configured directories. This opens the previous hints +file and fetches the directory list from the header. Any additional pathnames +on the command line are also processed. .It Fl f Ar hints_file Read and/or update the specified hints file, instead of .Pa /var/run/ld.so.hints . @@ -104,7 +108,8 @@ Directories recorded in the hints file by previous runs of are also rescanned for new shared libraries. .It Fl r List the current contents of the hints file -on the standard output. The hints file is not modified. +on the standard output. The hints file is not modified. The list of +directories stored in the hints file is included. .It Fl s Do not scan the built-in system directory .Pq Dq /usr/lib diff --git a/gnu/usr.bin/ld/ldconfig/ldconfig.c b/gnu/usr.bin/ld/ldconfig/ldconfig.c index 3eed70a3a049..1f54178ce7a0 100644 --- a/gnu/usr.bin/ld/ldconfig/ldconfig.c +++ b/gnu/usr.bin/ld/ldconfig/ldconfig.c @@ -27,7 +27,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: ldconfig.c,v 1.18 1997/02/22 15:46:38 peter Exp $ + * $Id: ldconfig.c,v 1.19 1997/07/11 14:45:41 jkh Exp $ */ #include @@ -66,12 +66,11 @@ #undef major #undef minor -extern char *__progname; - static int verbose; static int nostd; static int justread; static int merge; +static int rescan; static char *hints_file = _PATH_LD_HINTS; struct shlib_list { @@ -102,8 +101,11 @@ char *argv[]; int i, c; int rval = 0; - while ((c = getopt(argc, argv, "f:mrsv")) != EOF) { + while ((c = getopt(argc, argv, "Rf:mrsv")) != EOF) { switch (c) { + case 'R': + rescan = 1; + break; case 'f': hints_file = optarg; break; @@ -120,20 +122,20 @@ char *argv[]; verbose = 1; break; default: - errx(1, "Usage: %s [-mrsv] [-f hints_file] [dir | file ...]", - __progname); + errx(1, "Usage: %s [-Rmrsv] [-f hints_file] " + "[dir | file ...]", argv[0]); break; } } dir_list = strdup(""); - if (justread || merge) { + if (justread || merge || rescan) { if ((rval = readhints()) != 0) return rval; } - if (!nostd && !merge) + if (!nostd && !merge && !rescan) std_search_path(); /* Add any directories/files from the command line */ @@ -525,6 +527,15 @@ readhints() blist = (struct hints_bucket *)(addr + hdr->hh_hashtab); strtab = (char *)(addr + hdr->hh_strtab); + if (hdr->hh_version >= LD_HINTS_VERSION_2) + add_search_path(strtab + hdr->hh_dirlist); + else if (rescan) + errx(1, "%s too old and does not contain the search path", + hints_file); + + if (rescan) + return 0; + for (i = 0; i < hdr->hh_nbucket; i++) { struct hints_bucket *bp = &blist[i]; @@ -549,8 +560,6 @@ readhints() *shlib_tail = shp; shlib_tail = &shp->next; } - if (hdr->hh_version >= LD_HINTS_VERSION_2) - add_search_path(strtab + hdr->hh_dirlist); return 0; } diff --git a/sbin/ldconfig/ldconfig.8 b/sbin/ldconfig/ldconfig.8 index 3aee7bd533b4..6f97599e1bad 100644 --- a/sbin/ldconfig/ldconfig.8 +++ b/sbin/ldconfig/ldconfig.8 @@ -27,7 +27,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $Id: ldconfig.8,v 1.12 1997/02/22 15:46:37 peter Exp $ +.\" $Id: ldconfig.8,v 1.13 1997/07/11 14:45:40 jkh Exp $ .\" .Dd October 3, 1993 .Dt LDCONFIG 8 @@ -37,7 +37,7 @@ .Nd configure the shared library cache .Sh SYNOPSIS .Nm ldconfig -.Op Fl mrsv +.Op Fl Rmrsv .Op Fl f Ar hints_file .Op Ar directory | file Ar ... .Sh DESCRIPTION @@ -90,6 +90,10 @@ is typically run as part of the boot sequence. The following options recognized by .Nm ldconfig: .Bl -tag -width indent +.It Fl R +Rescan the previously configured directories. This opens the previous hints +file and fetches the directory list from the header. Any additional pathnames +on the command line are also processed. .It Fl f Ar hints_file Read and/or update the specified hints file, instead of .Pa /var/run/ld.so.hints . @@ -104,7 +108,8 @@ Directories recorded in the hints file by previous runs of are also rescanned for new shared libraries. .It Fl r List the current contents of the hints file -on the standard output. The hints file is not modified. +on the standard output. The hints file is not modified. The list of +directories stored in the hints file is included. .It Fl s Do not scan the built-in system directory .Pq Dq /usr/lib diff --git a/sbin/ldconfig/ldconfig.c b/sbin/ldconfig/ldconfig.c index 3eed70a3a049..1f54178ce7a0 100644 --- a/sbin/ldconfig/ldconfig.c +++ b/sbin/ldconfig/ldconfig.c @@ -27,7 +27,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: ldconfig.c,v 1.18 1997/02/22 15:46:38 peter Exp $ + * $Id: ldconfig.c,v 1.19 1997/07/11 14:45:41 jkh Exp $ */ #include @@ -66,12 +66,11 @@ #undef major #undef minor -extern char *__progname; - static int verbose; static int nostd; static int justread; static int merge; +static int rescan; static char *hints_file = _PATH_LD_HINTS; struct shlib_list { @@ -102,8 +101,11 @@ char *argv[]; int i, c; int rval = 0; - while ((c = getopt(argc, argv, "f:mrsv")) != EOF) { + while ((c = getopt(argc, argv, "Rf:mrsv")) != EOF) { switch (c) { + case 'R': + rescan = 1; + break; case 'f': hints_file = optarg; break; @@ -120,20 +122,20 @@ char *argv[]; verbose = 1; break; default: - errx(1, "Usage: %s [-mrsv] [-f hints_file] [dir | file ...]", - __progname); + errx(1, "Usage: %s [-Rmrsv] [-f hints_file] " + "[dir | file ...]", argv[0]); break; } } dir_list = strdup(""); - if (justread || merge) { + if (justread || merge || rescan) { if ((rval = readhints()) != 0) return rval; } - if (!nostd && !merge) + if (!nostd && !merge && !rescan) std_search_path(); /* Add any directories/files from the command line */ @@ -525,6 +527,15 @@ readhints() blist = (struct hints_bucket *)(addr + hdr->hh_hashtab); strtab = (char *)(addr + hdr->hh_strtab); + if (hdr->hh_version >= LD_HINTS_VERSION_2) + add_search_path(strtab + hdr->hh_dirlist); + else if (rescan) + errx(1, "%s too old and does not contain the search path", + hints_file); + + if (rescan) + return 0; + for (i = 0; i < hdr->hh_nbucket; i++) { struct hints_bucket *bp = &blist[i]; @@ -549,8 +560,6 @@ readhints() *shlib_tail = shp; shlib_tail = &shp->next; } - if (hdr->hh_version >= LD_HINTS_VERSION_2) - add_search_path(strtab + hdr->hh_dirlist); return 0; }