From owner-freebsd-hackers Fri May 17 8:33:15 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from web11104.mail.yahoo.com (web11104.mail.yahoo.com [216.136.131.151]) by hub.freebsd.org (Postfix) with SMTP id 092BF37B40A for ; Fri, 17 May 2002 08:32:40 -0700 (PDT) Message-ID: <20020517153239.98228.qmail@web11104.mail.yahoo.com> Received: from [65.211.103.2] by web11104.mail.yahoo.com via HTTP; Fri, 17 May 2002 08:32:39 PDT Date: Fri, 17 May 2002 08:32:39 -0700 (PDT) From: Reinier Bezuidenhout Subject: Patches for linprocfs and linux emulation - fix 'ls /proc' bug and ipc's To: freebsd-hackers@freebsd.org Cc: freebsd-emulation@freebsd.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1667895946-1021649559=:97425" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --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

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-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message