Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Feb 2001 18:30:47 -0500
From:      "Patrick Bihan-Faou" <patrick@netzuno.com>
To:        <freebsd-stable@freebsd.org>
Subject:   Problem with bootable CD...
Message-ID:  <HJEEKLMFLKEOKHOKNPBMIEHCCLAA.patrick@netzuno.com>

next in thread | raw e-mail | index | archive | help
Hi,


I am building a custom bootable CD for my own needs based on FreeBSD
4.x-STABLE. I am using stock FreeBSD code, and everything was working fine
until yesterday when I update the code.

The problem I am seeing is that during the boot of the CD I get a
"elf_loadexec: cannot seek" error and the kernel does not load.

I have added a trace in sys/boot/common/load_elf.c to see the values of
local variables at the time this message is printed and here is the output
(with my trace):


Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [kernel]...
/kernel text=0x1391c9 data=0x2eb4f4+0x165c0
elf_loadexec: cannot seek
fd=0, i=3, p_filesz=3060980, p_offset=1282528, fcopy=0, errno=94
can't load 'kernel'
can't load 'kernel.old'

Type '?' for a list of commands, 'help' for more detailed help.
ok


Now the strange thing is that errno has a value that is not defined anywhere
and does not correspond to the "official" error codes that lseek is supposed
to return. For this reason I am assuming that lseek() is failing in the
VOP_GETATTR call (cf. code snipet).

Would anybody have any idea as to what could be causing this ?

This code was checked out with the following tag/date: -r RELENG_4 -D
"2001/02/27 23:00 EST"


My last successfull build was with the following tag/date: -r RELENG_4 -D
"2001/02/15 12:00 EST"


The system I am using to do the builds is RELENG_4 as of mid january.


Thanks in advance for any suggestions.


Patrick.



-------------------------------------------------------------------------
Patch added in sys/boot/common/load_elf.c (rev 1.13.2.1):

Index: load_elf.c
===================================================================
RCS file: /cvs/freebsd/src/sys/boot/common/load_elf.c,v
retrieving revision 1.13.2.1
diff -u -r1.13.2.1 load_elf.c
--- load_elf.c  2000/12/28 13:12:35     1.13.2.1
+++ load_elf.c  2001/02/28 06:08:16
@@ -268,6 +268,7 @@
        if (phdr[i].p_filesz > fpcopy) {
            if (lseek(fd, phdr[i].p_offset + fpcopy, SEEK_SET) == -1) {
                printf("\nelf_loadexec: cannot seek\n");
+               printf("fd=%d, i=%d, p_filesz=%lu p_offset=%lu, fpcopy=%lu,
errno=%d\n", fd, i, phdr[i].p_filesz, phdr[i].p_offset, fpcopy, errno);
                goto out;
            }
            if (archsw.arch_readin(fd, phdr[i].p_vaddr + off + fpcopy,



--------------------------------------------------------------------------

lseek code from sys/kern/vfs_syscalls.c (rev 1.151.2.6):

lseek(p, uap)
    struct proc *p;
    register struct lseek_args /* {
        syscallarg(int) fd;
        syscallarg(int) pad;
        syscallarg(off_t) offset;
        syscallarg(int) whence;
    } */ *uap;
{
    struct ucred *cred = p->p_ucred;
    register struct filedesc *fdp = p->p_fd;
    register struct file *fp;
    struct vattr vattr;
    int error;

    if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
        (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
        return (EBADF);
    if (fp->f_type != DTYPE_VNODE)
        return (ESPIPE);
    switch (SCARG(uap, whence)) {
    case L_INCR:
        fp->f_offset += SCARG(uap, offset);
        break;
    case L_XTND:
        error=VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p);
        if (error)
            return (error);
        fp->f_offset = SCARG(uap, offset) + vattr.va_size;
        break;
    case L_SET:
        fp->f_offset = SCARG(uap, offset);
        break;
    default:
        return (EINVAL);
    }
    *(off_t *)(p->p_retval) = fp->f_offset;
    return (0);
}


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?HJEEKLMFLKEOKHOKNPBMIEHCCLAA.patrick>