Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 May 2002 08:32:39 -0700 (PDT)
From:      Reinier Bezuidenhout <rbezuide@yahoo.com>
To:        freebsd-hackers@freebsd.org
Cc:        freebsd-emulation@freebsd.org
Subject:   Patches for linprocfs and linux emulation - fix 'ls /proc' bug and ipc's
Message-ID:  <20020517153239.98228.qmail@web11104.mail.yahoo.com>

next in thread | raw e-mail | index | archive | help
--0-1667895946-1021649559=:97425
Content-Type: text/plain; charset=us-ascii


Hi all

I have an application that uses the linux procfs extensively and also linux ipcs.  I found two problems in the current linux emulation. 

(I hope the diff provided below will work as is since my mailing program is a bit limited :)  )

1) linux_ipc.c has a pice of code commented that we can actually use now.  I think the other pieces were added later and this didn't get changed. The patch is valid for RELENG_4 and HEAD.  The current code will always remove only the first enry from a msg queue even if msgtyp was specified causing incorrect behaviour.  It's a one line change in linux_ipc.c in src/sys/compat/linux

2) When traversing the linprocfs with i.e. ls (the linux ls in /compat/linux/bin/ls ) I noticed that some entries in the proc table is missing, compared to doing a FreeBSD ls /bin/ls.   I traced the problem to a counter inconcistenct because linux reads smaller blocks at a time.  This problem is only in RELENG_4 and not HEAD since the linprocfs changed a lot in HEAD.   The loop skips the first 9 entries for the cpuinfo etc. in /compat/linux/proc, but on the second loop it skips the first 9 entries in the proc table and thus they do not show up in a /compat/linux/bin/ls

If someone responsible from the linux emulation can review these changes and maybe commit them, I'll appreciate it :)

Thanks 

Reinier

 

------------------------ cut -------------------- cut -----------------------------

*** linprocfs_vnops.c   2001/08/12 14:29:19     1.3.2.5
--- linprocfs_vnops.c   2002/05/17 15:19:43
***************
*** 896,902 ****
  
  
                        default:
!                               while (pcnt < i) {
                                        p = p->p_list.le_next;
                                        if (!p)
                                                goto done;
--- 896,907 ----
  
  
                        default:
!                               /* Since we skip the first 9, by the time we
!                                * get here i = 9 and we'll end up skipping 
!                                * the first 9 procs in the list, so we
!                                * increment pcnt by the same value
!                                */
!                               while ((pcnt + 9) < i) {
                                        p = p->p_list.le_next;
                                        if (!p)
                                                goto done;


----------------- cut -------------- cut ------------------ cut ----------------

*** linux_ipc.c.old     Fri May 17 11:08:58 2002
--- linux_ipc.c Fri May 17 11:09:29 2002
***************
*** 358,364 ****
      bsd_args.msqid = args->msqid;
      bsd_args.msgp = args->msgp;
      bsd_args.msgsz = args->msgsz;
!     bsd_args.msgtyp = 0; /* XXX - args->msgtyp; */
      bsd_args.msgflg = args->msgflg;
      return msgrcv(td, &bsd_args);
  }
--- 358,364 ----
      bsd_args.msqid = args->msqid;
      bsd_args.msgp = args->msgp;
      bsd_args.msgsz = args->msgsz;
!     bsd_args.msgtyp = args->msgtyp;
      bsd_args.msgflg = args->msgflg;
      return msgrcv(td, &bsd_args);
  }


----------------- cut ---------------- cut -------------- cut -----------------



---------------------------------
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
--0-1667895946-1021649559=:97425
Content-Type: text/html; charset=us-ascii

<P>Hi all</P>
<P>I have an application that uses the linux procfs extensively and also linux ipcs.&nbsp; I found two problems in the current linux emulation.&nbsp;</P>
<P>(I hope the diff provided below will work as is since my mailing program is a bit limited :)&nbsp; )</P>
<P>1) linux_ipc.c has a pice of code commented that we can actually use now.&nbsp; I think the other pieces were added later and this didn't get changed. The patch is valid for RELENG_4 and HEAD.&nbsp; The current code will always remove only the first enry from a msg queue even if msgtyp was specified causing incorrect behaviour.&nbsp; It's a one line change in linux_ipc.c in src/sys/compat/linux</P>
<P>2) When traversing the linprocfs with i.e. ls (the linux ls in /compat/linux/bin/ls ) I noticed that some entries in the proc table is missing,&nbsp;compared to doing a FreeBSD ls /bin/ls.&nbsp;&nbsp; I traced the problem to a counter inconcistenct because linux reads smaller blocks at a time.&nbsp; This problem is only in RELENG_4 and not HEAD since the linprocfs changed a lot in HEAD.&nbsp;&nbsp; The loop skips the first 9 entries for the cpuinfo etc. in /compat/linux/proc, but on the second loop it skips the first 9 entries in the proc table and thus they do not show up in a /compat/linux/bin/ls</P>
<P>If someone responsible from the linux emulation can review these changes and maybe commit them, I'll appreciate it :)</P>
<P>Thanks </P>
<P>Reinier</P>
<P>&nbsp;</P>
<P>------------------------ cut -------------------- cut -----------------------------</P>
<P>*** linprocfs_vnops.c&nbsp;&nbsp; 2001/08/12 14:29:19&nbsp;&nbsp;&nbsp;&nbsp; 1.3.2.5<BR>--- linprocfs_vnops.c&nbsp;&nbsp; 2002/05/17 15:19:43<BR>***************<BR>*** 896,902 ****<BR>&nbsp; <BR>&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default:<BR>!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (pcnt &lt; i) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p = p-&gt;p_list.le_next;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs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sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!p)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; goto done;<BR></P>
<P>----------------- cut -------------- cut ------------------ cut ----------------</P>
<P>*** linux_ipc.c.old&nbsp;&nbsp;&nbsp;&nbsp; Fri May 17 11:08:58 2002<BR>--- linux_ipc.c Fri May 17 11:09:29 2002<BR>***************<BR>*** 358,364 ****<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bsd_args.msqid = args-&gt;msqid;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bsd_args.msgp = args-&gt;msgp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bsd_args.msgsz = args-&gt;msgsz;<BR>!&nbsp;&nbsp;&nbsp;&nbsp; bsd_args.msgtyp = 0; /* XXX - args-&gt;msgtyp; */<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bsd_args.msgflg = args-&gt;msgflg;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return msgrcv(td, &amp;bsd_args);<BR>&nbsp; }<BR>--- 358,364 ----<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bsd_args.msqid = args-&gt;msqid;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bsd_args.msgp = args-&gt;msgp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bsd_args.msgsz = args-&gt;msgsz;<BR>!&nbsp;&nbsp;&nbsp;&nbsp; bsd_args.msgtyp = args-&gt;msgtyp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bsd_args.msgflg = args-&gt;msgflg;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return msgrcv(td, &amp;bsd_args);<BR>&nbsp; }<BR></P>
<P>----------------- cut ---------------- cut -------------- cut -----------------</P><p><br><hr size=1><b>Do You Yahoo!?</b><br>
<a href="http://rd.yahoo.com/welcome/*http://launch.yahoo.com">LAUNCH</a>; - Your Yahoo! Music Experience
--0-1667895946-1021649559=:97425--

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




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