Bug 104938 - [nullfs] [request] readlink("/proc/curproc/file") does not work over nullfs
Summary: [nullfs] [request] readlink("/proc/curproc/file") does not work over nullfs
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 7.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: Konstantin Belousov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-30 17:30 UTC by vova
Modified: 2009-05-31 16:05 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vova 2006-10-30 17:30:24 UTC

trying to find reason why jdk1.5 stop working, I have found that readlink
for /proc/curproc/file returns "unknown"

$ truss java
...
readlink("/proc/curproc/file","unknown",1024)    = 7 (0x7)
Error: could not find libjava.so
write(2,"Error: could not find libjava.so"...,33) = 33 (0x21)
Error: could not find Java 2 Runtime Environment.
write(2,"Error: could not find Java 2 Run"...,50) = 50 (0x32)
exit(0x2)
$

$ ps ax | fgrep java
49210  p0  S+     0:00.07 gdb /usr/local/jdk1.5.0/bin/java
49214  p0  TX     0:00.02 /usr/local/jdk1.5.0/bin/java
49224  p4  R+     0:00.00 fgrep java
$ ll /proc/49214/file 
lr--r--r--  1 vova  vova  0 Oct 30 20:16 /proc/49214/file -> unknown
$

How-To-Repeat: Just try to start jdk1.5 from nullfs-mounted partition
Comment 1 Robert Watson freebsd_committer freebsd_triage 2008-03-08 21:05:52 UTC
State Changed
From-To: open->suspended

This is a duplicate of kern/94269, and requires significant changes 
to nullfs in order to fix.  Leave as suspended as it's effectively 
a feature request; more detailed information may be found in the 
above-referenced PR.
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2009-05-18 05:25:07 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-fs

Over to maintainer(s).
Comment 3 Konstantin Belousov freebsd_committer freebsd_triage 2009-05-18 15:17:22 UTC
State Changed
From-To: suspended->open

Take it. I have prototyped VOP_VPTOCNP bypass for nullfs on CURRENT. 


Comment 4 Konstantin Belousov freebsd_committer freebsd_triage 2009-05-18 15:17:22 UTC
Responsible Changed
From-To: freebsd-fs->kib

Take.
Comment 5 dfilter service freebsd_committer freebsd_triage 2009-05-31 15:58:58 UTC
Author: kib
Date: Sun May 31 14:58:43 2009
New Revision: 193175
URL: http://svn.freebsd.org/changeset/base/193175

Log:
  Implement the bypass routine for VOP_VPTOCNP in nullfs.
  Among other things, this makes procfs <pid>/file working for executables
  started from nullfs mount.
  
  Tested by:	pho
  PR:	94269, 104938

Modified:
  head/sys/fs/nullfs/null_vnops.c

Modified: head/sys/fs/nullfs/null_vnops.c
==============================================================================
--- head/sys/fs/nullfs/null_vnops.c	Sun May 31 14:57:43 2009	(r193174)
+++ head/sys/fs/nullfs/null_vnops.c	Sun May 31 14:58:43 2009	(r193175)
@@ -741,6 +741,55 @@ null_vptofh(struct vop_vptofh_args *ap)
 	return VOP_VPTOFH(lvp, ap->a_fhp);
 }
 
+static int
+null_vptocnp(struct vop_vptocnp_args *ap)
+{
+	struct vnode *vp = ap->a_vp;
+	struct vnode **dvp = ap->a_vpp;
+	struct vnode *lvp, *ldvp;
+	int error, locked;
+
+	if (vp->v_type == VDIR)
+		return (vop_stdvptocnp(ap));
+
+	locked = VOP_ISLOCKED(vp);
+	lvp = NULLVPTOLOWERVP(vp);
+	vhold(lvp);
+	VOP_UNLOCK(vp, 0); /* vp is held by vn_vptocnp_locked that called us */
+	ldvp = lvp;
+	error = vn_vptocnp(&ldvp, ap->a_buf, ap->a_buflen);
+	vdrop(lvp);
+	if (error != 0) {
+		vn_lock(vp, locked | LK_RETRY);
+		return (ENOENT);
+	}
+
+	/*
+	 * Exclusive lock is required by insmntque1 call in
+	 * null_nodeget()
+	 */
+	error = vn_lock(ldvp, LK_EXCLUSIVE);
+	if (error != 0) {
+		vn_lock(vp, locked | LK_RETRY);
+		vdrop(ldvp);
+		return (ENOENT);
+	}
+	vref(ldvp);
+	vdrop(ldvp);
+	error = null_nodeget(vp->v_mount, ldvp, dvp);
+	if (error == 0) {
+#ifdef DIAGNOSTIC
+		NULLVPTOLOWERVP(*dvp);
+#endif
+		vhold(*dvp);
+		vput(*dvp);
+	} else
+		vput(ldvp);
+
+	vn_lock(vp, locked | LK_RETRY);
+	return (error);
+}
+
 /*
  * Global vfs data structures
  */
@@ -762,6 +811,6 @@ struct vop_vector null_vnodeops = {
 	.vop_setattr =		null_setattr,
 	.vop_strategy =		VOP_EOPNOTSUPP,
 	.vop_unlock =		null_unlock,
-	.vop_vptocnp =		vop_stdvptocnp,
+	.vop_vptocnp =		null_vptocnp,
 	.vop_vptofh =		null_vptofh,
 };
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 6 Konstantin Belousov freebsd_committer freebsd_triage 2009-05-31 16:05:03 UTC
State Changed
From-To: open->closed

Patch is in HEAD, no MFC planned.