Skip site navigation (1)Skip section navigation (2)
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>&nbsp;char&=
nbsp;&nbsp; *path;<BR>&nbsp;struct proc *p;<BR>&nbsp;struct vnode **vpp;&=
nbsp;/* result */<BR>{<BR>&nbsp;struct nameidata nd;<BR>&nbsp;struct vnod=
e *vp;<BR>&nbsp;struct vattr va;<BR>&nbsp;int&nbsp;&nbsp;&nbsp;&nbsp; err=
or, flags;</DIV> <DIV>&nbsp;/* Sanity check the p_fd fields.&nbsp; This i=
s really just a hack */<BR>&nbsp;if (!p-&gt;p_fd-&gt;fd_rdir || !p-&gt;p_=
fd-&gt;fd_cdir)<BR>&nbsp;&nbsp;printf("Warning: p_fd fields not set\n");<=
BR>&nbsp;<BR>&nbsp;if (!p-&gt;p_fd-&gt;fd_rdir)<BR>&nbsp;&nbsp;p-&gt;p_fd=
-&gt;fd_rdir =3D rootvnode;<BR>&nbsp;if (!p-&gt;p_fd-&gt;fd_cdir)<BR>&nbs=
p;&nbsp;p-&gt;p_fd-&gt;fd_cdir =3D rootvnode;<BR>&nbsp;NDINIT(&amp;nd, LO=
OKUP, FOLLOW, UIO_SYSSPACE, path, p);<BR>&nbsp;flags =3D FREAD | FWRITE;<=
BR>&nbsp;if ((error =3D vn_open(&amp;nd, flags, 0)) !=3D 0) {<BR>&nbsp;&n=
bsp;rf_printf(2, "RAIDframe: vn_open returned %d\n", error);<BR>&nbsp;&nb=
sp;return (error);<BR>&nbsp;}<BR>&nbsp;vp =3D nd.ni_vp;<BR>&nbsp;if (vp-&=
gt;v_usecount &gt; 1) {<BR>&nbsp;&nbsp;VOP_UNLOCK(vp, 0, p);<BR>&nbsp;&nb=
sp;(void) vn_close(vp, FREAD | FWRITE, p-&gt;p_ucred, p);<BR>&nbsp;&nbsp;=
rf_printf(1, "raidlookup() vp-&gt;v_usecount &gt; 1\n");<BR>&nbsp;&nbsp;r=
eturn (EBUSY);<BR>&nbsp;}<BR>&nbsp;if ((error =3D VOP_GETATTR(vp, &amp;va=
, p-&gt;p_ucred, p)) !=3D 0) {<BR>&nbsp;&nbsp;VOP_UNLOCK(vp, 0, p);<BR>&n=
bsp;&nbsp;(void) vn_close(vp, FREAD | FWRITE, p-&gt;p_ucred, p);<BR>&nbsp=
;&nbsp;rf_printf(1, "raidlookup() VOP_GETATTR returned %d", error);<BR>&n=
bsp;&nbsp;return (error);<BR>&nbsp;}<BR>&nbsp;/* XXX: eventually we shoul=
d handle VREG, too. */<BR>&nbsp;if (va.va_type !=3D VCHR) {<BR>&nbsp;&nbs=
p;VOP_UNLOCK(vp, 0, p);<BR>&nbsp;&nbsp;(void) vn_close(vp, FREAD | FWRITE=
, p-&gt;p_ucred, p);<BR>&nbsp;&nbsp;rf_printf(1, "Returning ENOTBLK\n");<=
BR>&nbsp;&nbsp;return (ENOTBLK);<BR>&nbsp;}<BR>&nbsp;VOP_UNLOCK(vp, 0, p)=
;<BR>&nbsp;NDFREE(&amp;nd, NDF_ONLY_PNBUF);<BR>&nbsp;*vpp =3D vp;<BR>&nbs=
p;return (0);<BR>}</DIV> <DIV>Based on the explain of the thread: struct =
proc&nbsp;*td_proc;&nbsp;/* 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>&nbsp;char&nbsp;&nbsp; *path;<BR>&nbsp;s=
truct thread *td;<BR>&nbsp;struct vnode **vpp;&nbsp;/* result */<BR>{<BR>=
&nbsp;struct nameidata nd;<BR>&nbsp;struct vnode *vp;<BR>&nbsp;struct vat=
tr va;<BR>&nbsp;struct proc *p;<BR>&nbsp;int&nbsp;&nbsp;&nbsp;&nbsp; erro=
r, flags;</DIV> <DIV>&nbsp;/* Sanity check the p_fd fields.&nbsp; This is=
 really just a hack */<BR>&nbsp;p =3D td-&gt;td_proc;<BR>&nbsp;if (!p-&gt=
;p_fd-&gt;fd_rdir || !p-&gt;p_fd-&gt;fd_cdir)<BR>&nbsp;&nbsp;printf("Warn=
ing: p_fd fields not set\n");<BR>&nbsp;<BR>&nbsp;if (!p-&gt;p_fd-&gt;fd_r=
dir)<BR>&nbsp;&nbsp;p-&gt;p_fd-&gt;fd_rdir =3D rootvnode;<BR>&nbsp;if (!p=
-&gt;p_fd-&gt;fd_cdir)<BR>&nbsp;&nbsp;p-&gt;p_fd-&gt;fd_cdir =3D rootvnod=
e;<BR>&nbsp;NDINIT(&amp;nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, td);<BR>&=
nbsp;flags =3D FREAD | FWRITE;<BR>&nbsp;if ((error =3D vn_open(&amp;nd, &=
amp;flags, 0)) !=3D 0) {<BR>&nbsp;&nbsp;rf_printf(2, "RAIDframe: vn_open =
returned %d\n", error);<BR>&nbsp;&nbsp;return (error);<BR>&nbsp;}<BR>&nbs=
p;vp =3D nd.ni_vp;<BR>&nbsp;if (vp-&gt;v_usecount &gt; 1) {<BR>&nbsp;&nbs=
p;VOP_UNLOCK(vp, 0, td);<BR>&nbsp;&nbsp;(void) vn_close(vp, FREAD | FWRIT=
E, td-&gt;td_ucred, td);<BR>&nbsp;&nbsp;rf_printf(1, "raidlookup() vp-&gt=
;v_usecount &gt; 1\n");<BR>&nbsp;&nbsp;return (EBUSY);<BR>&nbsp;}<BR>&nbs=
p;if ((error =3D VOP_GETATTR(vp, &amp;va, td-&gt;td_ucred, td)) !=3D 0) {=
<BR>&nbsp;&nbsp;VOP_UNLOCK(vp, 0, td);<BR>&nbsp;&nbsp;(void) vn_close(vp,=
 FREAD | FWRITE, td-&gt;td_ucred, td);<BR>&nbsp;&nbsp;rf_printf(1, "raidl=
ookup() VOP_GETATTR returned %d", error);<BR>&nbsp;&nbsp;return (error);<=
BR>&nbsp;}<BR>&nbsp;/* XXX: eventually we should handle VREG, too. */<BR>=
&nbsp;if (va.va_type !=3D VCHR) {<BR>&nbsp;&nbsp;VOP_UNLOCK(vp, 0, td);<B=
R>&nbsp;&nbsp;(void) vn_close(vp, FREAD | FWRITE,td-&gt;td_ucred, td);<BR=
>&nbsp;&nbsp;rf_printf(1, "Returning ENOTBLK\n");<BR>&nbsp;&nbsp;return (=
ENOTBLK);<BR>&nbsp;}<BR>&nbsp;VOP_UNLOCK(vp, 0, td);<BR>&nbsp;NDFREE(&amp=
;nd, NDF_ONLY_PNBUF);<BR>&nbsp;*vpp =3D vp;<BR>&nbsp;return (0);<BR>}</DI=
V> <DIV>Now the system will be crash , when it excutes the "p =3D td-&gt;=
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-&gt;td_proc" to "p-&gt;p_fd-&gt;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>&nbsp;</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>