ldconfig.c (5f8d88ddd6ea894a96e97387b0f69803bb2cc4f2) ldconfig.c (614d19ca1041c9b2e664ad5647798a3c94852bbe)
1/*
2 * Copyright (c) 1993,1995 Paul Kranenburg
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef lint
32static const char rcsid[] =
1/*
2 * Copyright (c) 1993,1995 Paul Kranenburg
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#ifndef lint
32static const char rcsid[] =
33 "$Id: ldconfig.c,v 1.25 1998/09/05 03:30:54 jdp Exp $";
33 "$Id: ldconfig.c,v 1.26 1998/09/05 16:20:15 jdp Exp $";
34#endif /* not lint */
35
36#include <sys/param.h>
37#include <sys/types.h>
38#include <sys/stat.h>
39#include <sys/mman.h>
40#include <a.out.h>
41#include <ctype.h>

--- 122 unchanged lines hidden (view full) ---

164 /* Add any directories/files from the command line */
165 if (!justread) {
166 for (i = optind; i < argc; i++) {
167 struct stat stbuf;
168
169 if (stat(argv[i], &stbuf) == -1) {
170 warn("%s", argv[i]);
171 rval = -1;
34#endif /* not lint */
35
36#include <sys/param.h>
37#include <sys/types.h>
38#include <sys/stat.h>
39#include <sys/mman.h>
40#include <a.out.h>
41#include <ctype.h>

--- 122 unchanged lines hidden (view full) ---

164 /* Add any directories/files from the command line */
165 if (!justread) {
166 for (i = optind; i < argc; i++) {
167 struct stat stbuf;
168
169 if (stat(argv[i], &stbuf) == -1) {
170 warn("%s", argv[i]);
171 rval = -1;
172 }
173 else if (!strcmp(argv[i], "/usr/lib")) {
172 } else if (strcmp(argv[i], "/usr/lib") == 0) {
174 warnx("WARNING! '%s' can not be used", argv[i]);
175 rval = -1;
173 warnx("WARNING! '%s' can not be used", argv[i]);
174 rval = -1;
176 }
177 else {
175 } else {
178 /*
179 * See if this is a directory-containing
180 * file instead of a directory
181 */
182 if (S_ISREG(stbuf.st_mode))
183 rval |= dofile(argv[i], 0);
184 else
185 add_search_path(argv[i]);

--- 382 unchanged lines hidden (view full) ---

568
569 return 0;
570}
571
572static int
573readhints()
574{
575 int fd;
176 /*
177 * See if this is a directory-containing
178 * file instead of a directory
179 */
180 if (S_ISREG(stbuf.st_mode))
181 rval |= dofile(argv[i], 0);
182 else
183 add_search_path(argv[i]);

--- 382 unchanged lines hidden (view full) ---

566
567 return 0;
568}
569
570static int
571readhints()
572{
573 int fd;
576 caddr_t addr;
574 void *addr;
575 long fsize;
577 long msize;
578 struct hints_header *hdr;
579 struct hints_bucket *blist;
580 char *strtab;
581 struct shlib_list *shp;
582 int i;
583
584 if ((fd = open(hints_file, O_RDONLY, 0)) == -1) {
585 warn("%s", hints_file);
586 return -1;
587 }
588
589 msize = PAGE_SIZE;
590 addr = mmap(0, msize, PROT_READ, MAP_COPY, fd, 0);
591
576 long msize;
577 struct hints_header *hdr;
578 struct hints_bucket *blist;
579 char *strtab;
580 struct shlib_list *shp;
581 int i;
582
583 if ((fd = open(hints_file, O_RDONLY, 0)) == -1) {
584 warn("%s", hints_file);
585 return -1;
586 }
587
588 msize = PAGE_SIZE;
589 addr = mmap(0, msize, PROT_READ, MAP_COPY, fd, 0);
590
592 if (addr == (caddr_t)-1) {
591 if (addr == MAP_FAILED) {
593 warn("%s", hints_file);
594 return -1;
595 }
596
597 hdr = (struct hints_header *)addr;
598 if (HH_BADMAG(*hdr)) {
599 warnx("%s: bad magic: %lo", hints_file,
600 (unsigned long)hdr->hh_magic);
601 return -1;
602 }
603
604 if (hdr->hh_version != LD_HINTS_VERSION_1 &&
605 hdr->hh_version != LD_HINTS_VERSION_2) {
606 warnx("unsupported version: %ld", (long)hdr->hh_version);
607 return -1;
608 }
609
610 if (hdr->hh_ehints > msize) {
592 warn("%s", hints_file);
593 return -1;
594 }
595
596 hdr = (struct hints_header *)addr;
597 if (HH_BADMAG(*hdr)) {
598 warnx("%s: bad magic: %lo", hints_file,
599 (unsigned long)hdr->hh_magic);
600 return -1;
601 }
602
603 if (hdr->hh_version != LD_HINTS_VERSION_1 &&
604 hdr->hh_version != LD_HINTS_VERSION_2) {
605 warnx("unsupported version: %ld", (long)hdr->hh_version);
606 return -1;
607 }
608
609 if (hdr->hh_ehints > msize) {
611 if (mmap(addr+msize, hdr->hh_ehints - msize,
612 PROT_READ, MAP_COPY|MAP_FIXED,
613 fd, msize) != (caddr_t)(addr+msize)) {
614
610 fsize = hdr->hh_ehints;
611 munmap(addr, msize);
612 addr = mmap(0, fsize, PROT_READ, MAP_COPY, fd, 0);
613 if (addr == MAP_FAILED) {
615 warn("%s", hints_file);
616 return -1;
617 }
614 warn("%s", hints_file);
615 return -1;
616 }
617 hdr = (struct hints_header *)addr;
618 }
619 close(fd);
620
621 blist = (struct hints_bucket *)(addr + hdr->hh_hashtab);
622 strtab = (char *)(addr + hdr->hh_strtab);
623
624 if (hdr->hh_version >= LD_HINTS_VERSION_2)
625 add_search_path(strtab + hdr->hh_dirlist);

--- 50 unchanged lines hidden ---
618 }
619 close(fd);
620
621 blist = (struct hints_bucket *)(addr + hdr->hh_hashtab);
622 strtab = (char *)(addr + hdr->hh_strtab);
623
624 if (hdr->hh_version >= LD_HINTS_VERSION_2)
625 add_search_path(strtab + hdr->hh_dirlist);

--- 50 unchanged lines hidden ---