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.  I found two problems in the current linux emulation. </P>
<P>(I hope the diff provided below will work as is since my mailing program is a bit limited :)  )</P>
<P>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</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, 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</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> </P>
<P>------------------------ cut -------------------- cut -----------------------------</P>
<P>*** linprocfs_vnops.c   2001/08/12 14:29:19     1.3.2.5<BR>--- linprocfs_vnops.c   2002/05/17 15:19:43<BR>***************<BR>*** 896,902 ****<BR>  <BR>  <BR>                        default:<BR>!                               while (pcnt < i) {<BR>                                        p = p->p_list.le_next;<BR>                                        if (!p)<BR>                                                goto done;<BR>--- 896,907 ----<BR>  <BR>  <BR>                        default:<BR>!                               /* Since we skip the first 9, by the time we<BR>!                                * get here i = 9 and we'll end up skipping <BR>!                                * the first 9 procs in the list, so we<BR>!                                * increment pcnt by the same value<BR>!                                */<BR>!                               while ((pcnt + 9) < i) {<BR>                                        p = p->p_list.le_next;<BR>                                        if (!p)<BR>                                                goto done;<BR></P>
<P>----------------- cut -------------- cut ------------------ cut ----------------</P>
<P>*** linux_ipc.c.old     Fri May 17 11:08:58 2002<BR>--- linux_ipc.c Fri May 17 11:09:29 2002<BR>***************<BR>*** 358,364 ****<BR>      bsd_args.msqid = args->msqid;<BR>      bsd_args.msgp = args->msgp;<BR>      bsd_args.msgsz = args->msgsz;<BR>!     bsd_args.msgtyp = 0; /* XXX - args->msgtyp; */<BR>      bsd_args.msgflg = args->msgflg;<BR>      return msgrcv(td, &bsd_args);<BR>  }<BR>--- 358,364 ----<BR>      bsd_args.msqid = args->msqid;<BR>      bsd_args.msgp = args->msgp;<BR>      bsd_args.msgsz = args->msgsz;<BR>!     bsd_args.msgtyp = args->msgtyp;<BR>      bsd_args.msgflg = args->msgflg;<BR>      return msgrcv(td, &bsd_args);<BR>  }<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>
