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.
This commit is contained in:
parent
d8f10c1117
commit
dd8e0158cf
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=2812
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user