Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat rename elf32_read_from to exec_read_from since it...



details:   https://anonhg.NetBSD.org/src/rev/b9d7c59ac495
branches:  trunk
changeset: 512688:b9d7c59ac495
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jul 14 02:05:05 2001 +0000

description:
rename elf32_read_from to exec_read_from since it is used in many places
now.

diffstat:

 sys/compat/freebsd/freebsd_exec_elf32.c    |  10 +++---
 sys/compat/ibcs2/ibcs2_exec_elf32.c        |  10 +++---
 sys/compat/linux/common/linux_exec_elf32.c |  47 ++++++++++++++---------------
 sys/compat/pecoff/pecoff_exec.c            |  47 +++++------------------------
 4 files changed, 41 insertions(+), 73 deletions(-)

diffs (268 lines):

diff -r 91e0db5644ad -r b9d7c59ac495 sys/compat/freebsd/freebsd_exec_elf32.c
--- a/sys/compat/freebsd/freebsd_exec_elf32.c   Sat Jul 14 02:04:25 2001 +0000
+++ b/sys/compat/freebsd/freebsd_exec_elf32.c   Sat Jul 14 02:05:05 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: freebsd_exec_elf32.c,v 1.1 2000/12/01 19:13:47 jdolecek Exp $  */
+/*     $NetBSD: freebsd_exec_elf32.c,v 1.2 2001/07/14 02:05:05 christos Exp $  */
 
 /*
  * Copyright (c) 1993, 1994 Christopher G. Demetriou
@@ -78,8 +78,8 @@
        if (i != 0) {
                phsize = i * sizeof(Elf_Phdr);
                ph = (Elf_Phdr *) malloc(phsize, M_TEMP, M_WAITOK);
-               if ((error = ELFNAME(read_from)(p, epp->ep_vp, eh->e_phoff,
-                   (caddr_t) ph, phsize)) != 0)
+               if ((error = exec_read_from(p, epp->ep_vp, eh->e_phoff, ph,
+                   phsize)) != 0)
                        goto bad1;
 
                for (ephp = ph; i--; ephp++) {
@@ -93,8 +93,8 @@
                        np = (Elf_Nhdr *) malloc(ephp->p_filesz+1,
                            M_TEMP, M_WAITOK);
 
-                       if (((error = ELFNAME(read_from)(p, epp->ep_vp,
-                           ephp->p_offset, (caddr_t)np, ephp->p_filesz)) != 0))
+                       if (((error = exec_read_from(p, epp->ep_vp,
+                           ephp->p_offset, np, ephp->p_filesz)) != 0))
                                goto bad2;
 
                        if (strncmp((char *)np, wantInterp,
diff -r 91e0db5644ad -r b9d7c59ac495 sys/compat/ibcs2/ibcs2_exec_elf32.c
--- a/sys/compat/ibcs2/ibcs2_exec_elf32.c       Sat Jul 14 02:04:25 2001 +0000
+++ b/sys/compat/ibcs2/ibcs2_exec_elf32.c       Sat Jul 14 02:05:05 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ibcs2_exec_elf32.c,v 1.1 2000/12/01 19:17:41 jdolecek Exp $    */
+/*     $NetBSD: ibcs2_exec_elf32.c,v 1.2 2001/07/14 02:05:05 christos Exp $    */
 
 /*
  * Copyright (c) 1994, 1995, 1998 Scott Bartram
@@ -85,8 +85,8 @@
 
        sh = (Elf32_Shdr *)malloc(shsize, M_TEMP, M_WAITOK);
 
-       if ((error = elf32_read_from(p, epp->ep_vp, eh->e_shoff,
-           (caddr_t)sh, shsize)) != 0)
+       if ((error = exec_read_from(p, epp->ep_vp, eh->e_shoff, sh,
+           shsize)) != 0)
                goto out;
 
        for (i = 0; i < eh->e_shnum; i++) {
@@ -96,8 +96,8 @@
                    s->sh_size < sizeof(signature) - 1)
                        continue;
 
-               if ((error = elf32_read_from(p, epp->ep_vp, s->sh_offset,
-                   (caddr_t)buf, sizeof(signature) - 1)) != 0)
+               if ((error = exec_read_from(p, epp->ep_vp, s->sh_offset, buf,
+                   sizeof(signature) - 1)) != 0)
                        goto out;
 
                if (memcmp(buf, signature, sizeof(signature) - 1) == 0)
diff -r 91e0db5644ad -r b9d7c59ac495 sys/compat/linux/common/linux_exec_elf32.c
--- a/sys/compat/linux/common/linux_exec_elf32.c        Sat Jul 14 02:04:25 2001 +0000
+++ b/sys/compat/linux/common/linux_exec_elf32.c        Sat Jul 14 02:05:05 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_exec_elf32.c,v 1.51 2001/01/19 01:43:31 manu Exp $       */
+/*     $NetBSD: linux_exec_elf32.c,v 1.52 2001/07/14 02:05:06 christos Exp $   */
 
 /*-
  * Copyright (c) 1995, 1998, 2000, 2001 The NetBSD Foundation, Inc.
@@ -104,33 +104,32 @@
        
        int error;
 
-/*
- * load the section header table 
- */
+       /*
+        * load the section header table 
+        */
        shsize = eh->e_shnum * sizeof(Elf_Shdr);
        sh = (Elf_Shdr *) malloc(shsize, M_TEMP, M_WAITOK);
-       error = ELFNAME(read_from)(p, epp->ep_vp, eh->e_shoff, (caddr_t)sh,
-           shsize);
+       error = exec_read_from(p, epp->ep_vp, eh->e_shoff, sh, shsize);
        if (error)
                goto out;
 
-/* 
- * Now let's find the string table. If it does not exists, give up.
- */
+       /* 
+        * Now let's find the string table. If it does not exists, give up.
+        */
        strndx = (int)(eh->e_shstrndx);
-   if (strndx == SHN_UNDEF) {
+       if (strndx == SHN_UNDEF) {
                error = ENOEXEC;
                goto out;
        }
 
-/*
- * strndx is the index in section header table of the string table section
- * get the whole string table in strtable, and then we get access to the names
- * s->sh_name is the offset of the section name in strtable.
- */
+       /*
+        * strndx is the index in section header table of the string table
+        * section get the whole string table in strtable, and then we get access to the names
+        * s->sh_name is the offset of the section name in strtable.
+        */
        strtable = malloc(sh[strndx].sh_size, M_TEMP, M_WAITOK);
-       error = ELFNAME(read_from)(p, epp->ep_vp, sh[strndx].sh_offset, 
-                       (caddr_t)strtable, sh[strndx].sh_size);
+       error = exec_read_from(p, epp->ep_vp, sh[strndx].sh_offset, strtable,
+           sh[strndx].sh_size);
        if (error)
                goto out;
 
@@ -181,8 +180,7 @@
 
        shsize = eh->e_shnum * sizeof(Elf_Shdr);
        sh = (Elf_Shdr *) malloc(shsize, M_TEMP, M_WAITOK);
-       error = ELFNAME(read_from)(p, epp->ep_vp, eh->e_shoff, (caddr_t)sh,
-           shsize);
+       error = exec_read_from(p, epp->ep_vp, eh->e_shoff, sh, shsize);
        if (error)
                goto out;
 
@@ -200,8 +198,8 @@
                    s->sh_size < sizeof(signature) - 1)
                        continue;
 
-               error = ELFNAME(read_from)(p, epp->ep_vp, s->sh_offset,
-                   (caddr_t)buf, sizeof(signature) - 1);
+               error = exec_read_from(p, epp->ep_vp, s->sh_offset, buf,
+                   sizeof(signature) - 1);
                if (error)
                        continue;
 
@@ -238,8 +236,7 @@
 
        phsize = eh->e_phnum * sizeof(Elf_Phdr);
        ph = (Elf_Phdr *)malloc(phsize, M_TEMP, M_WAITOK);
-       error = ELFNAME(read_from)(p, epp->ep_vp, eh->e_phoff, (caddr_t)ph,
-           phsize);
+       error = exec_read_from(p, epp->ep_vp, eh->e_phoff, ph, phsize);
        if (error)
                goto out;
 
@@ -254,8 +251,8 @@
                        continue;
 
                np = (Elf_Nhdr *)malloc(ephp->p_filesz, M_TEMP, M_WAITOK);
-               error = ELFNAME(read_from)(p, epp->ep_vp, ephp->p_offset,
-                   (caddr_t)np, ephp->p_filesz);
+               error = exec_read_from(p, epp->ep_vp, ephp->p_offset, np,
+                   ephp->p_filesz);
                if (error)
                        goto next;
 
diff -r 91e0db5644ad -r b9d7c59ac495 sys/compat/pecoff/pecoff_exec.c
--- a/sys/compat/pecoff/pecoff_exec.c   Sat Jul 14 02:04:25 2001 +0000
+++ b/sys/compat/pecoff/pecoff_exec.c   Sat Jul 14 02:05:05 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pecoff_exec.c,v 1.9 2001/06/18 02:00:53 christos Exp $ */
+/*     $NetBSD: pecoff_exec.c,v 1.10 2001/07/14 02:05:06 christos Exp $        */
 
 /*
  * Copyright (c) 2000 Masaru OKI
@@ -77,8 +77,6 @@
 int exec_pecoff_prep_zmagic __P((struct proc *p, struct exec_package *epp,
                                     struct coff_filehdr *fp,
                                     struct coff_aouthdr *ap, int peofs));
-int pecoff_read_from __P((struct proc *p, struct vnode *vp, int pos,
-                        caddr_t buf, int siz));
 
 
 extern char sigcode[], esigcode[];
@@ -165,7 +163,7 @@
        if (DOS_BADMAG(dp)) {
                return ENOEXEC;
        }
-       error = pecoff_read_from(p, vp, dp->d_peofs, buf, sizeof(buf));
+       error = exec_read_from(p, vp, dp->d_peofs, buf, sizeof(buf));
        if (error) {
                return error;
        }
@@ -233,15 +231,14 @@
        /*
         * Read header.
         */
-       error = pecoff_read_from(p, vp, 0, (caddr_t)&dh, sizeof(dh));
+       error = exec_read_from(p, vp, 0, &dh, sizeof(dh));
        if (error != 0)
                goto bad;
        if ((error = pecoff_signature(p, vp, &dh)) != 0)
                goto bad;
        fp = malloc(PECOFF_HDR_SIZE, M_TEMP, M_WAITOK);
        peofs = dh.d_peofs + sizeof(signature) - 1;
-       if ((error = pecoff_read_from(p, vp, peofs, (caddr_t)fp,
-                                    PECOFF_HDR_SIZE)) != 0)
+       if ((error = exec_read_from(p, vp, peofs, fp, PECOFF_HDR_SIZE)) != 0)
                goto bad;
        if (COFF_BADMAG(fp)) {
                error = ENOEXEC;
@@ -252,8 +249,8 @@
        /* read section header */
        scnsiz = sizeof(struct coff_scnhdr) * fp->f_nscns;
        sh = malloc(scnsiz, M_TEMP, M_WAITOK);
-       if ((error = pecoff_read_from(p, vp, peofs + PECOFF_HDR_SIZE,
-                                    (caddr_t)sh, scnsiz)) != 0)
+       if ((error = exec_read_from(p, vp, peofs + PECOFF_HDR_SIZE, sh,
+           scnsiz)) != 0)
                goto bad;
 
        /*
@@ -365,8 +362,7 @@
                return error;
        peofs = dp->d_peofs + sizeof(signature) - 1;
        fp = malloc(PECOFF_HDR_SIZE, M_TEMP, M_WAITOK);
-       error = pecoff_read_from(p, epp->ep_vp, peofs, (caddr_t)fp,
-                               PECOFF_HDR_SIZE);
+       error = exec_read_from(p, epp->ep_vp, peofs, fp, PECOFF_HDR_SIZE);
        if (error) {
                free(fp, M_TEMP);
                return error;
@@ -480,8 +476,8 @@
        epp->ep_dsize = 0;
        /* read section header */
        sh = malloc(scnsiz, M_TEMP, M_WAITOK);
-       error = pecoff_read_from(p, epp->ep_vp, peofs + PECOFF_HDR_SIZE,
-                               (caddr_t)sh, scnsiz);
+       error = exec_read_from(p, epp->ep_vp, peofs + PECOFF_HDR_SIZE, sh,
+           scnsiz);
        if (error) {
                free(sh, M_TEMP);
                return error;
@@ -559,28 +555,3 @@
        free(sh, M_TEMP);
        return exec_pecoff_setup_stack(p, epp);
 }
-
-/*
- */
-int
-pecoff_read_from(p, vp, pos, buf, siz)
-       struct proc *p;
-       struct vnode *vp;
-       int pos;
-       caddr_t buf;
-       int siz;
-{
-       int error;
-       size_t resid;
-
-       error = vn_rdwr(UIO_READ, vp, buf, siz, pos,
-                       UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred,
-                       &resid, p);
-       if (error)
-               return error;
-
-       if (resid != 0) {
-               return ENOEXEC;
-       }
-       return 0;
-}



Home | Main Index | Thread Index | Old Index