Date: Sun, 2 Jun 2002 16:08:30 +0800 From: "kai ouyang" <oykai@msn.com> To: "John Baldwin" <jhb@FreeBSD.org>, <current@FreeBSD.org> Subject: Help: from proc to thread? Message-ID: <OE50nubN6sBPo5X3a5i0000fbb5@hotmail.com>
next in thread | raw e-mail | index | archive | help
------=_NextPart_001_0003_01C20A4F.BD05C000
Content-Type: multipart/alternative; boundary="----=_NextPart_002_0004_01C20A4F.BD05C000"
------=_NextPart_002_0004_01C20A4F.BD05C000
Content-Type: text/plain; charset="gb2312"
Content-Transfer-Encoding: quoted-printable
Hi,
Very thank your help! Now the box can boot. =20
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. =20
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");
=20
if (!p->p_fd->fd_rdir)
p->p_fd->fd_rdir =3D rootvnode;
if (!p->p_fd->fd_cdir)
p->p_fd->fd_cdir =3D rootvnode;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, p);
flags =3D FREAD | FWRITE;
if ((error =3D vn_open(&nd, flags, 0)) !=3D 0) {
rf_printf(2, "RAIDframe: vn_open returned %d\n", error);
return (error);
}
vp =3D 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 =3D VOP_GETATTR(vp, &va, p->p_ucred, p)) !=3D 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 !=3D 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 =3D vp;
return (0);
}
Based on the explain of the thread: struct proc *td_proc; /* Associated p=
rocess. */ 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 =3D td->td_proc;
if (!p->p_fd->fd_rdir || !p->p_fd->fd_cdir)
printf("Warning: p_fd fields not set\n");
=20
if (!p->p_fd->fd_rdir)
p->p_fd->fd_rdir =3D rootvnode;
if (!p->p_fd->fd_cdir)
p->p_fd->fd_cdir =3D rootvnode;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, td);
flags =3D FREAD | FWRITE;
if ((error =3D vn_open(&nd, &flags, 0)) !=3D 0) {
rf_printf(2, "RAIDframe: vn_open returned %d\n", error);
return (error);
}
vp =3D 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 =3D VOP_GETATTR(vp, &va, td->td_ucred, td)) !=3D 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 !=3D 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 =3D vp;
return (0);
}
Now the system will be crash , when it excutes the "p =3D td->td_proc".
the system Information is :
kernel: type 12 trap, code=3D0
Stopped at raidlookup+0x19: movl 0(%eax),%ebx
If I mask the instructions form "p =3D td->td_proc" to "p->p_fd->fd_cdir =
=3D 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 t=
he second parameter.
Best Regards
Ouyang kai=B4=D3=CD=F8=D5=BE=B5=C3=B5=BD=B8=FC=B6=E0=D0=C5=CF=A2=A1=A3M=
SN Explorer =C3=E2=B7=D1=CF=C2=D4=D8:http://explorer.msn.com/lccn
------=_NextPart_002_0004_01C20A4F.BD05C000
Content-Type: text/html; charset="gb2312"
Content-Transfer-Encoding: quoted-printable
<HTML><BODY STYLE=3D"font:10pt verdana; border:none;"><DIV>Hi,</DIV> <DIV=
>Very thank your help! Now the box can boot. <BR>I have some other proble=
ms about proc and thread.<BR>From the FreeBSD5.0 viewpoint, there are rea=
l thread in kernel, there are associated with KSE.<BR>So many functions p=
arameters change from proc to thread.<BR>There is the function in RAIDFra=
me in FreeBSD4.x. </DIV> <DIV>int raidlookup(path, p, vpp)<BR> char&=
nbsp; *path;<BR> struct proc *p;<BR> struct vnode **vpp;&=
nbsp;/* result */<BR>{<BR> struct nameidata nd;<BR> struct vnod=
e *vp;<BR> struct vattr va;<BR> int err=
or, flags;</DIV> <DIV> /* Sanity check the p_fd fields. This i=
s really just a hack */<BR> if (!p->p_fd->fd_rdir || !p->p_=
fd->fd_cdir)<BR> printf("Warning: p_fd fields not set\n");<=
BR> <BR> if (!p->p_fd->fd_rdir)<BR> p->p_fd=
->fd_rdir =3D rootvnode;<BR> if (!p->p_fd->fd_cdir)<BR>&nbs=
p; p->p_fd->fd_cdir =3D rootvnode;<BR> NDINIT(&nd, LO=
OKUP, FOLLOW, UIO_SYSSPACE, path, p);<BR> flags =3D FREAD | FWRITE;<=
BR> if ((error =3D vn_open(&nd, flags, 0)) !=3D 0) {<BR> &n=
bsp;rf_printf(2, "RAIDframe: vn_open returned %d\n", error);<BR> &nb=
sp;return (error);<BR> }<BR> vp =3D nd.ni_vp;<BR> if (vp-&=
gt;v_usecount > 1) {<BR> VOP_UNLOCK(vp, 0, p);<BR> &nb=
sp;(void) vn_close(vp, FREAD | FWRITE, p->p_ucred, p);<BR> =
rf_printf(1, "raidlookup() vp->v_usecount > 1\n");<BR> r=
eturn (EBUSY);<BR> }<BR> if ((error =3D VOP_GETATTR(vp, &va=
, p->p_ucred, p)) !=3D 0) {<BR> VOP_UNLOCK(vp, 0, p);<BR>&n=
bsp; (void) vn_close(vp, FREAD | FWRITE, p->p_ucred, p);<BR> =
; rf_printf(1, "raidlookup() VOP_GETATTR returned %d", error);<BR>&n=
bsp; return (error);<BR> }<BR> /* XXX: eventually we shoul=
d handle VREG, too. */<BR> if (va.va_type !=3D VCHR) {<BR> &nbs=
p;VOP_UNLOCK(vp, 0, p);<BR> (void) vn_close(vp, FREAD | FWRITE=
, p->p_ucred, p);<BR> rf_printf(1, "Returning ENOTBLK\n");<=
BR> return (ENOTBLK);<BR> }<BR> VOP_UNLOCK(vp, 0, p)=
;<BR> NDFREE(&nd, NDF_ONLY_PNBUF);<BR> *vpp =3D vp;<BR>&nbs=
p;return (0);<BR>}</DIV> <DIV>Based on the explain of the thread: struct =
proc *td_proc; /* Associated process. */ in the struct thread.<=
BR>and refer to the CCD code.<BR>I modify this function as following:<BR>=
int raidlookup(path, td, vpp)<BR> char *path;<BR> s=
truct thread *td;<BR> struct vnode **vpp; /* result */<BR>{<BR>=
struct nameidata nd;<BR> struct vnode *vp;<BR> struct vat=
tr va;<BR> struct proc *p;<BR> int erro=
r, flags;</DIV> <DIV> /* Sanity check the p_fd fields. This is=
really just a hack */<BR> p =3D td->td_proc;<BR> if (!p->=
;p_fd->fd_rdir || !p->p_fd->fd_cdir)<BR> printf("Warn=
ing: p_fd fields not set\n");<BR> <BR> if (!p->p_fd->fd_r=
dir)<BR> p->p_fd->fd_rdir =3D rootvnode;<BR> if (!p=
->p_fd->fd_cdir)<BR> p->p_fd->fd_cdir =3D rootvnod=
e;<BR> NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, td);<BR>&=
nbsp;flags =3D FREAD | FWRITE;<BR> if ((error =3D vn_open(&nd, &=
amp;flags, 0)) !=3D 0) {<BR> rf_printf(2, "RAIDframe: vn_open =
returned %d\n", error);<BR> return (error);<BR> }<BR>&nbs=
p;vp =3D nd.ni_vp;<BR> if (vp->v_usecount > 1) {<BR> &nbs=
p;VOP_UNLOCK(vp, 0, td);<BR> (void) vn_close(vp, FREAD | FWRIT=
E, td->td_ucred, td);<BR> rf_printf(1, "raidlookup() vp->=
;v_usecount > 1\n");<BR> return (EBUSY);<BR> }<BR>&nbs=
p;if ((error =3D VOP_GETATTR(vp, &va, td->td_ucred, td)) !=3D 0) {=
<BR> VOP_UNLOCK(vp, 0, td);<BR> (void) vn_close(vp,=
FREAD | FWRITE, td->td_ucred, td);<BR> rf_printf(1, "raidl=
ookup() VOP_GETATTR returned %d", error);<BR> return (error);<=
BR> }<BR> /* XXX: eventually we should handle VREG, too. */<BR>=
if (va.va_type !=3D VCHR) {<BR> VOP_UNLOCK(vp, 0, td);<B=
R> (void) vn_close(vp, FREAD | FWRITE,td->td_ucred, td);<BR=
> rf_printf(1, "Returning ENOTBLK\n");<BR> return (=
ENOTBLK);<BR> }<BR> VOP_UNLOCK(vp, 0, td);<BR> NDFREE(&=
;nd, NDF_ONLY_PNBUF);<BR> *vpp =3D vp;<BR> return (0);<BR>}</DI=
V> <DIV>Now the system will be crash , when it excutes the "p =3D td->=
td_proc".<BR>the system Information is :<BR>kernel: type 12 trap, code=3D=
0<BR>Stopped at raidlookup+0x19: movl 0(%eax),%ebx</DIV> <DIV>If I mask t=
he instructions form "p =3D td->td_proc" to "p->p_fd->fd_cdir =3D=
rootvnode;",<BR>trace the code, I find it will be crash in vn_open.<BR>s=
ystem infor:<BR>Stopped at vn_open+0x9: pushl 0x78(%eax)<BR>Why?<BR>I ana=
lyse the ccd code, it transfered the vn_open function, only change the se=
cond parameter.</DIV> <DIV> </DIV> <DIV>Best Regards</DIV> <DIV>&nbs=
p; Ouyang kai</DIV></BODY></HTML><br clear=3Dall><hr>=B4=D3=CD=F8=D5=BE=B5=
=C3=B5=BD=B8=FC=B6=E0=D0=C5=CF=A2=A1=A3MSN Explorer =C3=E2=B7=D1=CF=C2=D4=
=D8=A3=BA<a href=3D'http://explorer.msn.com/lccn'>http://explorer.msn.com=
/lccn</a><br></p>
------=_NextPart_002_0004_01C20A4F.BD05C000--
------=_NextPart_001_0003_01C20A4F.BD05C000
Content-Type: text/plain; name="help.txt"
Content-Disposition: attachment; filename="help.txt"
Content-Transfer-Encoding: quoted-printable
Hi,
Very thank your help! Now the box can boot. =20
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. =20
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");
=20
if (!p->p_fd->fd_rdir)
p->p_fd->fd_rdir =3D rootvnode;
if (!p->p_fd->fd_cdir)
p->p_fd->fd_cdir =3D rootvnode;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, p);
flags =3D FREAD | FWRITE;
if ((error =3D vn_open(&nd, flags, 0)) !=3D 0) {
rf_printf(2, "RAIDframe: vn_open returned %d\n", error);
return (error);
}
vp =3D 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 =3D VOP_GETATTR(vp, &va, p->p_ucred, p)) !=3D 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 !=3D 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 =3D vp;
return (0);
}
Based on the explain of the thread: struct proc *td_proc; /* Associated p=
rocess. */ 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 =3D td->td_proc;
if (!p->p_fd->fd_rdir || !p->p_fd->fd_cdir)
printf("Warning: p_fd fields not set\n");
=20
if (!p->p_fd->fd_rdir)
p->p_fd->fd_rdir =3D rootvnode;
if (!p->p_fd->fd_cdir)
p->p_fd->fd_cdir =3D rootvnode;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, td);
flags =3D FREAD | FWRITE;
if ((error =3D vn_open(&nd, &flags, 0)) !=3D 0) {
rf_printf(2, "RAIDframe: vn_open returned %d\n", error);
return (error);
}
vp =3D 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 =3D VOP_GETATTR(vp, &va, td->td_ucred, td)) !=3D 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 !=3D 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 =3D vp;
return (0);
}
Now the system will be crash , when it excutes the "p =3D td->td_proc".
the system Information is :
kernel: type 12 trap, code=3D0
Stopped at raidlookup+0x19: movl 0(%eax),%ebx
If I mask the instructions form "p =3D td->td_proc" to "p->p_fd->fd_cdir =
=3D 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 t=
he second parameter.
Best Regards
Ouyang kai
------=_NextPart_001_0003_01C20A4F.BD05C000--
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?OE50nubN6sBPo5X3a5i0000fbb5>
