diff options
author | bde <bde@FreeBSD.org> | 1994-09-15 20:48:55 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1994-09-15 20:48:55 +0000 |
commit | 11fe93eee46a4b098564c2a70e919e8809ecd140 (patch) | |
tree | 68cd72f885411c15a3b585136be0228a6bc6618b /gnu/usr.bin | |
parent | f95a48ecbecaa1c8b35cd1f34ce9f535ad345b42 (diff) | |
download | FreeBSD-src-11fe93eee46a4b098564c2a70e919e8809ecd140.zip FreeBSD-src-11fe93eee46a4b098564c2a70e919e8809ecd140.tar.gz |
Unmap hints file when finished with it, so that it can go away
completely when ldconfig unlinks it. If init is shared, then the
referenced unlinked copy of the hints file created by running
ldconfig in /etc/rc caused the file system to be unclean after
every reboot.
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r-- | gnu/usr.bin/ld/rtld/rtld.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/gnu/usr.bin/ld/rtld/rtld.c b/gnu/usr.bin/ld/rtld/rtld.c index 96dd0fe..d1ab408 100644 --- a/gnu/usr.bin/ld/rtld/rtld.c +++ b/gnu/usr.bin/ld/rtld/rtld.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: rtld.c,v 1.16 1994/04/13 20:52:40 ats Exp $ + * $Id: rtld.c,v 1.17 1994/06/15 22:41:15 rich Exp $ */ #include <sys/param.h> @@ -162,6 +162,7 @@ static void init_map __P((struct so_map *, char *)); static char *rtfindlib __P((char *, int, int, int *)); void binder_entry __P((void)); long binder __P((jmpslot_t *)); +static void unmaphints __P((void)); static struct nzlist *lookup __P((char *, struct so_map **, int)); static inline struct rt_symbol *lookup_rts __P((char *)); static struct rt_symbol *enter_rts __P((char *, long, int, caddr_t, @@ -293,6 +294,9 @@ struct _dynamic *dp; ddp->dd_sym_loaded = 1; } + /* Forget hints so that hints file can go away if it is unlinked */ + unmaphints(); + /* Close our file descriptor */ (void)close(crtp->crt_ldfd); return 0; @@ -949,6 +953,7 @@ xprintf(" BINDER: %s located at = %#x in %s\n", sym, addr, src_map->som_path); static struct hints_header *hheader; +static long hmsize; static struct hints_bucket *hbuckets; static char *hstrtab; @@ -970,6 +975,7 @@ maphints() addr = mmap(0, msize, PROT_READ, MAP_FILE|MAP_COPY, fd, 0); if (addr == (caddr_t)-1) { + close(fd); hheader = (struct hints_header *)-1; return; } @@ -977,22 +983,27 @@ maphints() hheader = (struct hints_header *)addr; if (HH_BADMAG(*hheader)) { munmap(addr, msize); + close(fd); hheader = (struct hints_header *)-1; return; } if (hheader->hh_version != LD_HINTS_VERSION_1) { munmap(addr, msize); + close(fd); hheader = (struct hints_header *)-1; return; } + hmsize = msize; if (hheader->hh_ehints > msize) { + hmsize = hheader->hh_ehints; if (mmap(addr+msize, hheader->hh_ehints - msize, PROT_READ, MAP_FILE|MAP_COPY|MAP_FIXED, fd, msize) != (caddr_t)(addr+msize)) { munmap((caddr_t)hheader, msize); + close(fd); hheader = (struct hints_header *)-1; return; } @@ -1003,6 +1014,15 @@ maphints() hstrtab = (char *)(addr + hheader->hh_strtab); } + static void +unmaphints() +{ + if (HINTS_VALID) { + munmap((caddr_t)hheader, hmsize); + hheader = NULL; + } +} + int hinthash(cp, vmajor, vminor) char *cp; |