Hi, Very thank your help! Now the box can boot. I have some other problems about proc and thread. From the FreeBSD5.0 viewpoint, there are real thread in kernel, there are associated with KSE. So many functions parameters change from proc to thread. There is the function in RAIDFrame in FreeBSD4.x. int raidlookup(path, p, vpp) char *path; struct proc *p; struct vnode **vpp; /* result */ { struct nameidata nd; struct vnode *vp; struct vattr va; int error, flags; /* Sanity check the p_fd fields. This is really just a hack */ if (!p->p_fd->fd_rdir || !p->p_fd->fd_cdir) printf("Warning: p_fd fields not set\n"); if (!p->p_fd->fd_rdir) p->p_fd->fd_rdir = rootvnode; if (!p->p_fd->fd_cdir) p->p_fd->fd_cdir = rootvnode; NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, p); flags = FREAD | FWRITE; if ((error = vn_open(&nd, flags, 0)) != 0) { rf_printf(2, "RAIDframe: vn_open returned %d\n", error); return (error); } vp = nd.ni_vp; if (vp->v_usecount > 1) { VOP_UNLOCK(vp, 0, p); (void) vn_close(vp, FREAD | FWRITE, p->p_ucred, p); rf_printf(1, "raidlookup() vp->v_usecount > 1\n"); return (EBUSY); } if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)) != 0) { VOP_UNLOCK(vp, 0, p); (void) vn_close(vp, FREAD | FWRITE, p->p_ucred, p); rf_printf(1, "raidlookup() VOP_GETATTR returned %d", error); return (error); } /* XXX: eventually we should handle VREG, too. */ if (va.va_type != VCHR) { VOP_UNLOCK(vp, 0, p); (void) vn_close(vp, FREAD | FWRITE, p->p_ucred, p); rf_printf(1, "Returning ENOTBLK\n"); return (ENOTBLK); } VOP_UNLOCK(vp, 0, p); NDFREE(&nd, NDF_ONLY_PNBUF); *vpp = vp; return (0); } Based on the explain of the thread: struct proc *td_proc; /* Associated process. */ in the struct thread. and refer to the CCD code. I modify this function as following: int raidlookup(path, td, vpp) char *path; struct thread *td; struct vnode **vpp; /* result */ { struct nameidata nd; struct vnode *vp; struct vattr va; struct proc *p; int error, flags; /* Sanity check the p_fd fields. This is really just a hack */ p = td->td_proc; if (!p->p_fd->fd_rdir || !p->p_fd->fd_cdir) printf("Warning: p_fd fields not set\n"); if (!p->p_fd->fd_rdir) p->p_fd->fd_rdir = rootvnode; if (!p->p_fd->fd_cdir) p->p_fd->fd_cdir = rootvnode; NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, td); flags = FREAD | FWRITE; if ((error = vn_open(&nd, &flags, 0)) != 0) { rf_printf(2, "RAIDframe: vn_open returned %d\n", error); return (error); } vp = nd.ni_vp; if (vp->v_usecount > 1) { VOP_UNLOCK(vp, 0, td); (void) vn_close(vp, FREAD | FWRITE, td->td_ucred, td); rf_printf(1, "raidlookup() vp->v_usecount > 1\n"); return (EBUSY); } if ((error = VOP_GETATTR(vp, &va, td->td_ucred, td)) != 0) { VOP_UNLOCK(vp, 0, td); (void) vn_close(vp, FREAD | FWRITE, td->td_ucred, td); rf_printf(1, "raidlookup() VOP_GETATTR returned %d", error); return (error); } /* XXX: eventually we should handle VREG, too. */ if (va.va_type != VCHR) { VOP_UNLOCK(vp, 0, td); (void) vn_close(vp, FREAD | FWRITE,td->td_ucred, td); rf_printf(1, "Returning ENOTBLK\n"); return (ENOTBLK); } VOP_UNLOCK(vp, 0, td); NDFREE(&nd, NDF_ONLY_PNBUF); *vpp = vp; return (0); } Now the system will be crash , when it excutes the "p = td->td_proc". the system Information is : kernel: type 12 trap, code=0 Stopped at raidlookup+0x19: movl 0(%eax),%ebx If I mask the instructions form "p = td->td_proc" to "p->p_fd->fd_cdir = rootvnode;", trace the code, I find it will be crash in vn_open. system infor: Stopped at vn_open+0x9: pushl 0x78(%eax) Why? I analyse the ccd code, it transfered the vn_open function, only change the second parameter. Best Regards Ouyang kai 从网站得到更多信息。MSN Explorer 免费下载:http://explorer.msn.com/lccn |
Hi, Very thank your help! Now the box can boot. I have some other problems about proc and thread. >From the FreeBSD5.0 viewpoint, there are real thread in kernel, there are associated >with KSE. So many functions parameters change from proc to thread. There is the function in RAIDFrame in FreeBSD4.x. int raidlookup(path, p, vpp) char *path; struct proc *p; struct vnode **vpp; /* result */ { struct nameidata nd; struct vnode *vp; struct vattr va; int error, flags; /* Sanity check the p_fd fields. This is really just a hack */ if (!p->p_fd->fd_rdir || !p->p_fd->fd_cdir) printf("Warning: p_fd fields not set\n"); if (!p->p_fd->fd_rdir) p->p_fd->fd_rdir = rootvnode; if (!p->p_fd->fd_cdir) p->p_fd->fd_cdir = rootvnode; NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, p); flags = FREAD | FWRITE; if ((error = vn_open(&nd, flags, 0)) != 0) { rf_printf(2, "RAIDframe: vn_open returned %d\n", error); return (error); } vp = nd.ni_vp; if (vp->v_usecount > 1) { VOP_UNLOCK(vp, 0, p); (void) vn_close(vp, FREAD | FWRITE, p->p_ucred, p); rf_printf(1, "raidlookup() vp->v_usecount > 1\n"); return (EBUSY); } if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)) != 0) { VOP_UNLOCK(vp, 0, p); (void) vn_close(vp, FREAD | FWRITE, p->p_ucred, p); rf_printf(1, "raidlookup() VOP_GETATTR returned %d", error); return (error); } /* XXX: eventually we should handle VREG, too. */ if (va.va_type != VCHR) { VOP_UNLOCK(vp, 0, p); (void) vn_close(vp, FREAD | FWRITE, p->p_ucred, p); rf_printf(1, "Returning ENOTBLK\n"); return (ENOTBLK); } VOP_UNLOCK(vp, 0, p); NDFREE(&nd, NDF_ONLY_PNBUF); *vpp = vp; return (0); } Based on the explain of the thread: struct proc *td_proc; /* Associated process. */ in the struct thread. and refer to the CCD code. I modify this function as following: int raidlookup(path, td, vpp) char *path; struct thread *td; struct vnode **vpp; /* result */ { struct nameidata nd; struct vnode *vp; struct vattr va; struct proc *p; int error, flags; /* Sanity check the p_fd fields. This is really just a hack */ p = td->td_proc; if (!p->p_fd->fd_rdir || !p->p_fd->fd_cdir) printf("Warning: p_fd fields not set\n"); if (!p->p_fd->fd_rdir) p->p_fd->fd_rdir = rootvnode; if (!p->p_fd->fd_cdir) p->p_fd->fd_cdir = rootvnode; NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, td); flags = FREAD | FWRITE; if ((error = vn_open(&nd, &flags, 0)) != 0) { rf_printf(2, "RAIDframe: vn_open returned %d\n", error); return (error); } vp = nd.ni_vp; if (vp->v_usecount > 1) { VOP_UNLOCK(vp, 0, td); (void) vn_close(vp, FREAD | FWRITE, td->td_ucred, td); rf_printf(1, "raidlookup() vp->v_usecount > 1\n"); return (EBUSY); } if ((error = VOP_GETATTR(vp, &va, td->td_ucred, td)) != 0) { VOP_UNLOCK(vp, 0, td); (void) vn_close(vp, FREAD | FWRITE, td->td_ucred, td); rf_printf(1, "raidlookup() VOP_GETATTR returned %d", error); return (error); } /* XXX: eventually we should handle VREG, too. */ if (va.va_type != VCHR) { VOP_UNLOCK(vp, 0, td); (void) vn_close(vp, FREAD | FWRITE,td->td_ucred, td); rf_printf(1, "Returning ENOTBLK\n"); return (ENOTBLK); } VOP_UNLOCK(vp, 0, td); NDFREE(&nd, NDF_ONLY_PNBUF); *vpp = vp; return (0); } Now the system will be crash , when it excutes the "p = td->td_proc". the system Information is : kernel: type 12 trap, code=0 Stopped at raidlookup+0x19: movl 0(%eax),%ebx If I mask the instructions form "p = td->td_proc" to "p->p_fd->fd_cdir = rootvnode;", trace the code, I find it will be crash in vn_open. system infor: Stopped at vn_open+0x9: pushl 0x78(%eax) Why? I analyse the ccd code, it transfered the vn_open function, only change the second parameter.
Best Regards Ouyang kai