From vsilyaev@mindspring.com  Fri Jun 16 04:33:48 2000
Return-Path: <vsilyaev@mindspring.com>
Received: from blount.mail.mindspring.net (blount.mail.mindspring.net [207.69.200.226])
	by hub.freebsd.org (Postfix) with ESMTP
	id 25B1F37BDDE; Fri, 16 Jun 2000 04:33:43 -0700 (PDT)
	(envelope-from vsilyaev@mindspring.com)
Received: from jupiter.delta.ny.us (nyf-ny7-25.ix.netcom.com [198.211.17.153])
	by blount.mail.mindspring.net (8.9.3/8.8.5) with ESMTP id HAA31546;
	Fri, 16 Jun 2000 07:33:40 -0400 (EDT)
Received: (from vsilyaev@localhost)
	by jupiter.delta.ny.us (8.9.3/8.9.3) id HAA00450;
	Fri, 16 Jun 2000 07:33:38 -0400 (EDT)
	(envelope-from vsilyaev)
Message-Id: <200006161133.HAA00450@jupiter.delta.ny.us>
Date: Fri, 16 Jun 2000 07:33:38 -0400 (EDT)
From: vns@delta.odessa.ua
Sender: vsilyaev@mindspring.com
Reply-To: vns@delta.odessa.ua
To: FreeBSD-gnats-submit@freebsd.org
Cc: emulation@freebsd.org
Subject: Broken linprocfs filesystem in -stable
X-Send-Pr-Version: 3.2

>Number:         19331
>Category:       kern
>Synopsis:       Broken linprocfs filesystem in -stable
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 16 04:40:01 PDT 2000
>Closed-Date:    Mon Jul 10 12:43:13 PDT 2000
>Last-Modified:  Mon Jul 10 12:46:23 PDT 2000
>Originator:     Vladimir N. Silyaev
>Release:        FreeBSD 4.0-STABLE i386
>Organization:
>Environment:

	FreeBSD 4.0-STABLE i386
>Description:

	Broken linprocfs filesystem in -stable. It was broken by MFC
	revision 1.3 of the src/sys/i386/linux/linprocfs/linprocfs_vnops.c

>How-To-Repeat:

	In the directory /sys/modules/linprocfs start the command
	'make load', you'll get exec format error (undefined symbol
	'textvp_fullpath'

>Fix:
	To do a MFC for revision 1.44 of the /src/sys/kern/vfs_cache.c and
	1.114 of the /src/sys/sys/vnode.h,v

	As a quick and dirty fix apply the following patch:

--- vfs_cache.c.orig	Mon Feb 14 01:09:01 2000
+++ vfs_cache.c	Fri May 26 06:11:22 2000
@@ -587,3 +587,97 @@
 	return (error);
 }
 
+/*
+ * Thus begins the fullpath magic.
+ */
+
+#undef STATNODE
+#define STATNODE(name)							\
+	static u_int name;						\
+	SYSCTL_INT(_vfs_cache, OID_AUTO, name, CTLFLAG_RD, &name, 0, "")
+
+static int disablefullpath;
+SYSCTL_INT(_debug, OID_AUTO, disablefullpath, CTLFLAG_RW,
+    &disablefullpath, 0, "");
+
+STATNODE(numfullpathcalls);
+STATNODE(numfullpathfail1);
+STATNODE(numfullpathfail2);
+STATNODE(numfullpathfail3);
+STATNODE(numfullpathfail4);
+STATNODE(numfullpathfound);
+
+int
+textvp_fullpath(struct proc *p, char **retbuf, char **retfreebuf) {
+	char *bp, *buf;
+	int i, slash_prefixed;
+	struct filedesc *fdp;
+	struct namecache *ncp;
+	struct vnode *vp, *textvp;
+
+	numfullpathcalls++;
+	if (disablefullpath)
+		return (ENODEV);
+	textvp = p->p_textvp;
+	if (textvp == NULL)
+		return (EINVAL);
+	buf = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
+	bp = buf + MAXPATHLEN - 1;
+	*bp = '\0';
+	fdp = p->p_fd;
+	slash_prefixed = 0;
+	for (vp = textvp; vp != fdp->fd_rdir && vp != rootvnode;) {
+		if (vp->v_flag & VROOT) {
+			if (vp->v_mount == NULL) {	/* forced unmount */
+				free(buf, M_TEMP);
+				return (EBADF);
+			}
+			vp = vp->v_mount->mnt_vnodecovered;
+			continue;
+		}
+		if (vp != textvp && vp->v_dd->v_id != vp->v_ddid) {
+			numfullpathfail1++;
+			free(buf, M_TEMP);
+			return (ENOTDIR);
+		}
+		ncp = TAILQ_FIRST(&vp->v_cache_dst);
+		if (!ncp) {
+			numfullpathfail2++;
+			free(buf, M_TEMP);
+			return (ENOENT);
+		}
+		if (vp != textvp && ncp->nc_dvp != vp->v_dd) {
+			numfullpathfail3++;
+			free(buf, M_TEMP);
+			return (EBADF);
+		}
+		for (i = ncp->nc_nlen - 1; i >= 0; i--) {
+			if (bp == buf) {
+				numfullpathfail4++;
+				free(buf, M_TEMP);
+				return (ENOMEM);
+			}
+			*--bp = ncp->nc_name[i];
+		}
+		if (bp == buf) {
+			numfullpathfail4++;
+			free(buf, M_TEMP);
+			return (ENOMEM);
+		}
+		*--bp = '/';
+		slash_prefixed = 1;
+		vp = ncp->nc_dvp;
+	}
+	if (!slash_prefixed) {
+		if (bp == buf) {
+			numfullpathfail4++;
+			free(buf, M_TEMP);
+			return (ENOMEM);
+		}
+		*--bp = '/';
+	}
+	numfullpathfound++;
+	*retbuf = bp; 
+	*retfreebuf = buf;
+	return (0);
+}



>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: ru 
State-Changed-When: Mon Jul 10 12:43:13 PDT 2000 
State-Changed-Why:  
Fixed. 


Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: ru 
Responsible-Changed-When: Mon Jul 10 12:43:13 PDT 2000 
Responsible-Changed-Why:  
The person who fixed that :-) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=19331 
>Unformatted:
