From owner-freebsd-emulation@FreeBSD.ORG Wed Oct 1 17:31:47 2008 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0159F1065686 for ; Wed, 1 Oct 2008 17:31:47 +0000 (UTC) (envelope-from root@dchagin.dialup.corbina.ru) Received: from contrabass.post.ru (contrabass.post.ru [85.21.78.5]) by mx1.freebsd.org (Postfix) with ESMTP id 88E0A8FC12 for ; Wed, 1 Oct 2008 17:31:46 +0000 (UTC) (envelope-from root@dchagin.dialup.corbina.ru) Received: from corbina.ru (mail.post.ru [195.14.50.16]) by contrabass.post.ru (Postfix) with ESMTP id 1A5331FA742; Wed, 1 Oct 2008 21:31:45 +0400 (MSD) X-Virus-Scanned: by cgpav Uf39PSi9pFi9oFi9 Received: from dchagin.dialup.corbina.ru ([78.107.232.239] verified) by corbina.ru (CommuniGate Pro SMTP 5.1.14) with ESMTPS id 1249099108; Wed, 01 Oct 2008 21:31:44 +0400 Received: from dchagin.dialup.corbina.ru (localhost.chd.net [127.0.0.1]) by dchagin.dialup.corbina.ru (8.14.3/8.14.2) with ESMTP id m91HVicH006118; Wed, 1 Oct 2008 21:31:44 +0400 (MSD) (envelope-from root@dchagin.dialup.corbina.ru) Received: (from root@localhost) by dchagin.dialup.corbina.ru (8.14.3/8.14.2/Submit) id m91HVcte006117; Wed, 1 Oct 2008 21:31:38 +0400 (MSD) (envelope-from root) Date: Wed, 1 Oct 2008 21:31:38 +0400 (MSD) Message-Id: <200810011731.m91HVcte006117@dchagin.dialup.corbina.ru> To: bug-followup@FreeBSD.org, gibbs@scsiguy.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-URL: http://www.FreeBSD.org/cgi/query-pr.cgi?pr=101453&cat= X-Mailer: Lynx, Version 2.8.6rel.5 X-Personal_Name: : Chagin Dmitry From: dchagin@FreeBSD.org Cc: freebsd-emulation@FreeBSD.org Subject: Re: kern/101453: [linux] [patch] linprocfs disallows X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Oct 2008 17:31:47 -0000 > Unformatted: > The original implementation of this routine should have placed its > output into the sbuf provided as an argument. The following untested > patch from des@FreeBSD.org converts the code to make use of the sbuf. > Once the sbuf is properly filled, pseudofs should take care of handling > any offset into the fd. > Index: sys/compat/linprocfs/linprocfs.c > =================================================================== more comments: glibc pthread_getattr_np() uses /proc/self/maps for thread stack address && size calculation. Linux applications which uses NPTL cannot work without this patch. I have a little corrected a patch and have tested it with linux-flashplugin9. It works fine. It would be excellent to commit it and make MFC to RELENG_7 before 7.1R! Many our users waits it. Fix: diff --git a/src/sys/compat/linprocfs/linprocfs.c b/src/sys/compat/linprocfs/linprocfs.c index dd4bf77..715146a 100644 --- a/src/sys/compat/linprocfs/linprocfs.c +++ b/src/sys/compat/linprocfs/linprocfs.c @@ -872,14 +872,12 @@ linprocfs_doprocenviron(PFS_FILL_ARGS) static int linprocfs_doprocmaps(PFS_FILL_ARGS) { - char mebuffer[512]; vm_map_t map = &p->p_vmspace->vm_map; vm_map_entry_t entry, tmp_entry; vm_object_t obj, tobj, lobj; vm_offset_t saved_end; vm_ooffset_t off = 0; char *name = "", *freename = NULL; - size_t len; ino_t ino; unsigned int last_timestamp; int ref_count, shadow_count, flags; @@ -897,13 +895,9 @@ linprocfs_doprocmaps(PFS_FILL_ARGS) if (uio->uio_rw != UIO_READ) return (EOPNOTSUPP); - if (uio->uio_offset != 0) - return (0); - error = 0; vm_map_lock_read(map); - for (entry = map->header.next; - ((uio->uio_resid > 0) && (entry != &map->header)); + for (entry = map->header.next; entry != &map->header; entry = entry->next) { name = ""; freename = NULL; @@ -952,7 +946,7 @@ linprocfs_doprocmaps(PFS_FILL_ARGS) * format: * start, end, access, offset, major, minor, inode, name. */ - snprintf(mebuffer, sizeof mebuffer, + error = sbuf_printf(sb, "%08lx-%08lx %s%s%s%s %08lx %02x:%02x %lu%s%s\n", (u_long)entry->start, (u_long)entry->end, (entry->protection & VM_PROT_READ)?"r":"-", @@ -968,18 +962,11 @@ linprocfs_doprocmaps(PFS_FILL_ARGS) ); if (freename) free(freename, M_TEMP); - len = strlen(mebuffer); - if (len > uio->uio_resid) - len = uio->uio_resid; /* - * XXX We should probably return - * EFBIG here, as in procfs. - */ last_timestamp = map->timestamp; vm_map_unlock_read(map); - error = uiomove(mebuffer, len, uio); + if (error == -1) + return (0); vm_map_lock_read(map); - if (error) - break; if (last_timestamp + 1 != map->timestamp) { /* * Look again for the entry because the map was -- chd, Have fun!