Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Mar 2003 14:02:57 -0800 (PST)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 27145 for review
Message-ID:  <200303202202.h2KM2vJs064112@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=27145

Change 27145 by jhb@jhb_laptop on 2003/03/20 14:02:11

	IFC @27144.

Affected files ...

.. //depot/projects/smpng/sys/alpha/alpha/busdma_machdep.c#12 integrate
.. //depot/projects/smpng/sys/alpha/osf1/osf1_mount.c#8 integrate
.. //depot/projects/smpng/sys/compat/linux/linux_file.c#17 integrate
.. //depot/projects/smpng/sys/compat/linux/linux_getcwd.c#11 integrate
.. //depot/projects/smpng/sys/compat/linux/linux_stats.c#12 integrate
.. //depot/projects/smpng/sys/conf/files#67 integrate
.. //depot/projects/smpng/sys/conf/files.sparc64#25 integrate
.. //depot/projects/smpng/sys/contrib/dev/fla/fla.c#7 integrate
.. //depot/projects/smpng/sys/dev/ata/ata-all.c#32 integrate
.. //depot/projects/smpng/sys/dev/ata/atapi-tape.c#17 integrate
.. //depot/projects/smpng/sys/dev/ccd/ccd.c#22 integrate
.. //depot/projects/smpng/sys/dev/ciss/ciss.c#12 integrate
.. //depot/projects/smpng/sys/dev/drm/drm_fops.h#4 integrate
.. //depot/projects/smpng/sys/dev/fb/vga.c#11 integrate
.. //depot/projects/smpng/sys/dev/firewire/if_fwe.c#8 integrate
.. //depot/projects/smpng/sys/dev/ida/ida.c#7 integrate
.. //depot/projects/smpng/sys/dev/iir/iir_pci.c#5 integrate
.. //depot/projects/smpng/sys/dev/md/md.c#30 integrate
.. //depot/projects/smpng/sys/dev/musycc/musycc.c#4 integrate
.. //depot/projects/smpng/sys/dev/pccard/pccard.c#17 integrate
.. //depot/projects/smpng/sys/dev/pccard/pccard_cis.c#11 integrate
.. //depot/projects/smpng/sys/dev/pccard/pccarddevs#21 integrate
.. //depot/projects/smpng/sys/dev/pccard/pccarddevs.h#21 integrate
.. //depot/projects/smpng/sys/dev/raidframe/rf_threadstuff.h#2 integrate
.. //depot/projects/smpng/sys/dev/sio/sio.c#27 integrate
.. //depot/projects/smpng/sys/dev/sio/sioreg.h#5 integrate
.. //depot/projects/smpng/sys/dev/sound/pci/via8233.c#3 integrate
.. //depot/projects/smpng/sys/dev/sound/pcm/ac97.c#14 integrate
.. //depot/projects/smpng/sys/dev/ubsec/ubsec.c#10 integrate
.. //depot/projects/smpng/sys/dev/wi/if_wi.c#46 integrate
.. //depot/projects/smpng/sys/dev/wi/if_wi_pccard.c#11 integrate
.. //depot/projects/smpng/sys/dev/wi/if_wi_pci.c#10 integrate
.. //depot/projects/smpng/sys/dev/wi/if_wivar.h#13 integrate
.. //depot/projects/smpng/sys/geom/bde/g_bde.c#5 integrate
.. //depot/projects/smpng/sys/geom/bde/g_bde_crypt.c#8 integrate
.. //depot/projects/smpng/sys/geom/bde/g_bde_lock.c#6 integrate
.. //depot/projects/smpng/sys/geom/bde/g_bde_work.c#6 integrate
.. //depot/projects/smpng/sys/geom/geom.h#20 integrate
.. //depot/projects/smpng/sys/geom/geom_bsd.c#22 integrate
.. //depot/projects/smpng/sys/geom/geom_ctl.c#4 integrate
.. //depot/projects/smpng/sys/geom/geom_dev.c#19 integrate
.. //depot/projects/smpng/sys/geom/geom_disk.c#19 integrate
.. //depot/projects/smpng/sys/geom/geom_dump.c#15 integrate
.. //depot/projects/smpng/sys/geom/geom_int.h#7 integrate
.. //depot/projects/smpng/sys/geom/geom_io.c#15 integrate
.. //depot/projects/smpng/sys/geom/geom_kern.c#11 integrate
.. //depot/projects/smpng/sys/geom/geom_slice.c#15 integrate
.. //depot/projects/smpng/sys/geom/geom_stats.c#3 delete
.. //depot/projects/smpng/sys/geom/geom_stats.h#2 delete
.. //depot/projects/smpng/sys/geom/geom_subr.c#19 integrate
.. //depot/projects/smpng/sys/i386/i386/busdma_machdep.c#12 integrate
.. //depot/projects/smpng/sys/i386/i386/identcpu.c#17 integrate
.. //depot/projects/smpng/sys/i386/i386/initcpu.c#16 integrate
.. //depot/projects/smpng/sys/i386/i386/tsc.c#2 integrate
.. //depot/projects/smpng/sys/i386/isa/clock.c#22 integrate
.. //depot/projects/smpng/sys/i386/linux/linux_machdep.c#20 integrate
.. //depot/projects/smpng/sys/ia64/ia64/busdma_machdep.c#12 integrate
.. //depot/projects/smpng/sys/kern/kern_exit.c#57 integrate
.. //depot/projects/smpng/sys/kern/kern_lockf.c#13 integrate
.. //depot/projects/smpng/sys/kern/kern_mutex.c#65 integrate
.. //depot/projects/smpng/sys/kern/kern_switch.c#28 integrate
.. //depot/projects/smpng/sys/kern/kern_synch.c#43 integrate
.. //depot/projects/smpng/sys/kern/kern_tc.c#20 integrate
.. //depot/projects/smpng/sys/kern/kern_thread.c#20 integrate
.. //depot/projects/smpng/sys/kern/subr_devstat.c#7 integrate
.. //depot/projects/smpng/sys/kern/subr_disk.c#16 integrate
.. //depot/projects/smpng/sys/kern/subr_prf.c#26 integrate
.. //depot/projects/smpng/sys/kern/sys_process.c#25 integrate
.. //depot/projects/smpng/sys/kern/uipc_cow.c#8 integrate
.. //depot/projects/smpng/sys/kern/uipc_sem.c#5 integrate
.. //depot/projects/smpng/sys/kern/vfs_bio.c#38 integrate
.. //depot/projects/smpng/sys/kern/vfs_cache.c#18 integrate
.. //depot/projects/smpng/sys/kern/vfs_cluster.c#21 integrate
.. //depot/projects/smpng/sys/net/if.c#33 integrate
.. //depot/projects/smpng/sys/netncp/ncp_conn.c#8 integrate
.. //depot/projects/smpng/sys/pc98/pc98/clock.c#14 integrate
.. //depot/projects/smpng/sys/pci/if_rl.c#22 integrate
.. //depot/projects/smpng/sys/pci/if_rlreg.h#9 integrate
.. //depot/projects/smpng/sys/pci/if_xl.c#20 integrate
.. //depot/projects/smpng/sys/pci/if_xlreg.h#8 integrate
.. //depot/projects/smpng/sys/powerpc/powermac/macio.c#4 integrate
.. //depot/projects/smpng/sys/powerpc/powerpc/busdma_machdep.c#6 integrate
.. //depot/projects/smpng/sys/powerpc/powerpc/fpu.c#2 integrate
.. //depot/projects/smpng/sys/powerpc/powerpc/genassym.c#18 integrate
.. //depot/projects/smpng/sys/powerpc/powerpc/machdep.c#33 integrate
.. //depot/projects/smpng/sys/powerpc/powerpc/swtch.S#2 integrate
.. //depot/projects/smpng/sys/powerpc/powerpc/trap.c#30 integrate
.. //depot/projects/smpng/sys/security/mac_portacl/mac_portacl.c#3 integrate
.. //depot/projects/smpng/sys/sparc64/include/cache.h#6 integrate
.. //depot/projects/smpng/sys/sparc64/include/pcpu.h#7 integrate
.. //depot/projects/smpng/sys/sparc64/include/pmap.h#21 integrate
.. //depot/projects/smpng/sys/sparc64/include/smp.h#12 integrate
.. //depot/projects/smpng/sys/sparc64/sparc64/bus_machdep.c#13 integrate
.. //depot/projects/smpng/sys/sparc64/sparc64/cache.c#10 integrate
.. //depot/projects/smpng/sys/sparc64/sparc64/cheetah.c#1 branch
.. //depot/projects/smpng/sys/sparc64/sparc64/db_trace.c#12 integrate
.. //depot/projects/smpng/sys/sparc64/sparc64/identcpu.c#10 integrate
.. //depot/projects/smpng/sys/sparc64/sparc64/locore.S#3 integrate
.. //depot/projects/smpng/sys/sparc64/sparc64/machdep.c#43 integrate
.. //depot/projects/smpng/sys/sparc64/sparc64/mem.c#6 integrate
.. //depot/projects/smpng/sys/sparc64/sparc64/mp_exception.S#3 integrate
.. //depot/projects/smpng/sys/sparc64/sparc64/mp_machdep.c#15 integrate
.. //depot/projects/smpng/sys/sparc64/sparc64/spitfire.c#1 branch
.. //depot/projects/smpng/sys/sparc64/sparc64/tick.c#10 integrate
.. //depot/projects/smpng/sys/sys/devicestat.h#6 integrate
.. //depot/projects/smpng/sys/sys/kse.h#7 integrate
.. //depot/projects/smpng/sys/sys/proc.h#74 integrate
.. //depot/projects/smpng/sys/sys/stat.h#12 integrate
.. //depot/projects/smpng/sys/sys/systm.h#38 integrate
.. //depot/projects/smpng/sys/ufs/ffs/ffs_alloc.c#21 integrate
.. //depot/projects/smpng/sys/ufs/ffs/ffs_snapshot.c#25 integrate
.. //depot/projects/smpng/sys/ufs/ffs/ffs_softdep.c#25 integrate
.. //depot/projects/smpng/sys/ufs/ffs/ffs_subr.c#7 integrate
.. //depot/projects/smpng/sys/ufs/ffs/ffs_vfsops.c#39 integrate
.. //depot/projects/smpng/sys/ufs/ufs/ufs_extattr.c#22 integrate
.. //depot/projects/smpng/sys/vm/vm_map.c#31 integrate
.. //depot/projects/smpng/sys/vm/vm_object.c#27 integrate
.. //depot/projects/smpng/sys/vm/vm_page.c#31 integrate
.. //depot/projects/smpng/sys/vm/vnode_pager.c#27 integrate

Differences ...

==== //depot/projects/smpng/sys/alpha/alpha/busdma_machdep.c#12 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/alpha/alpha/busdma_machdep.c,v 1.32 2003/03/17 17:26:39 mux Exp $
+ * $FreeBSD: src/sys/alpha/alpha/busdma_machdep.c,v 1.33 2003/03/20 19:45:26 mux Exp $
  */
 
 #include <sys/param.h>
@@ -42,6 +42,7 @@
 #include <vm/vm_page.h>
 #include <vm/vm_map.h>
 
+#include <machine/atomic.h>
 #include <machine/bus.h>
 #include <machine/sgmap.h>
 #include <machine/md_var.h>
@@ -179,9 +180,8 @@
 			newtag->filterarg = parent->filterarg;
 			newtag->parent = parent->parent;
 		}
-		if (newtag->parent != NULL) {
-			parent->ref_count++;
-		}
+		if (newtag->parent != NULL)
+			atomic_add_int(&parent->ref_count, 1);
 	}
 	
 	if (newtag->lowaddr < ptoa(Maxmem) && (flags & BUS_DMA_ALLOCNOW) != 0) {
@@ -228,7 +228,7 @@
 			bus_dma_tag_t parent;
 
 			parent = dmat->parent;
-			dmat->ref_count--;
+			atomic_subtract_int(&dmat->ref_count, 1);
 			if (dmat->ref_count == 0) {
 				free(dmat, M_DEVBUF);
 			}

==== //depot/projects/smpng/sys/alpha/osf1/osf1_mount.c#8 (text+ko) ====

@@ -29,7 +29,7 @@
 
 /*
  * Additional Copyright (c) 1999 by Andrew Gallatin
- * $FreeBSD: src/sys/alpha/osf1/osf1_mount.c,v 1.13 2003/01/13 00:28:56 dillon Exp $
+ * $FreeBSD: src/sys/alpha/osf1/osf1_mount.c,v 1.14 2003/03/20 21:17:38 jhb Exp $
  */
 
 #include "opt_mac.h"
@@ -134,7 +134,7 @@
 	sp = &mp->mnt_stat;
 	vrele(nd.ni_vp);
 #ifdef MAC
-	error = mac_check_mount_stat(td->td_proc->p_ucred, mp);
+	error = mac_check_mount_stat(td->td_ucred, mp);
 	if (error)
 		return (error);
 #endif
@@ -161,7 +161,7 @@
 		return (error);
 	mp = ((struct vnode *)fp->f_data)->v_mount;
 #ifdef MAC
-	error = mac_check_mount_stat(td->td_proc->p_ucred, mp);
+	error = mac_check_mount_stat(td->td_ucred, mp);
 	if (error) {
 		fdrop(fp, td);
 		return (error);
@@ -198,7 +198,7 @@
 		nmp = TAILQ_NEXT(mp, mnt_list);
 		if (osf_sfsp && count < maxcount) {
 #ifdef MAC
-			error = mac_check_mount_stat(td->td_proc->p_ucred, mp);
+			error = mac_check_mount_stat(td->td_ucred, mp);
 			if (error)
 				continue;
 #endif

==== //depot/projects/smpng/sys/compat/linux/linux_file.c#17 (text+ko) ====

@@ -25,7 +25,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/compat/linux/linux_file.c,v 1.78 2003/03/03 09:17:12 des Exp $
+ * $FreeBSD: src/sys/compat/linux/linux_file.c,v 1.79 2003/03/20 21:17:38 jhb Exp $
  */
 
 #include "opt_compat.h"
@@ -320,7 +320,7 @@
 	/*
 	 * Do directory search MAC check using non-cached credentials.
 	 */
-	if ((error = mac_check_vnode_readdir(td->td_proc->p_ucred, vp)))
+	if ((error = mac_check_vnode_readdir(td->td_ucred, vp)))
 		goto out;
 #endif /* MAC */
 	if ((error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &ncookies,

==== //depot/projects/smpng/sys/compat/linux/linux_getcwd.c#11 (text+ko) ====

@@ -1,4 +1,4 @@
-/* $FreeBSD: src/sys/compat/linux/linux_getcwd.c,v 1.11 2003/03/17 12:21:08 phk Exp $ */
+/* $FreeBSD: src/sys/compat/linux/linux_getcwd.c,v 1.12 2003/03/20 10:40:45 phk Exp $ */
 /* $OpenBSD: linux_getcwd.c,v 1.2 2001/05/16 12:50:21 ho Exp $ */
 /* $NetBSD: vfs_getcwd.c,v 1.3.2.3 1999/07/11 10:24:09 sommerfeld Exp $ */
 
@@ -37,25 +37,432 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+#include "opt_compat.h"
+#include "opt_mac.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/filedesc.h>
+#include <sys/kernel.h>
+#include <sys/file.h>
+#include <sys/stat.h>
 #include <sys/syscallsubr.h>
+#include <sys/vnode.h>
+#include <sys/mount.h>
 #include <sys/proc.h>
+#include <sys/uio.h>
+#include <sys/mac.h>
+#include <sys/malloc.h>
+#include <sys/dirent.h>
+#include <ufs/ufs/dir.h>	/* XXX only for DIRBLKSIZ */
 
 #include <machine/../linux/linux.h>
 #include <machine/../linux/linux_proto.h>
+#include <compat/linux/linux_util.h>
+
+static int
+linux_getcwd_scandir(struct vnode **, struct vnode **,
+    char **, char *, struct thread *);
+static int
+linux_getcwd_common(struct vnode *, struct vnode *,
+		   char **, char *, int, int, struct thread *);
+
+#define DIRENT_MINSIZE (sizeof(struct dirent) - (MAXNAMLEN+1) + 4)
 
 /*
+ * Vnode variable naming conventions in this file:
+ *
+ * rvp: the current root we're aiming towards.
+ * lvp, *lvpp: the "lower" vnode
+ * uvp, *uvpp: the "upper" vnode.
+ *
+ * Since all the vnodes we're dealing with are directories, and the
+ * lookups are going *up* in the filesystem rather than *down*, the
+ * usual "pvp" (parent) or "dvp" (directory) naming conventions are
+ * too confusing.
+ */
+
+/*
+ * XXX Will infinite loop in certain cases if a directory read reliably
+ *	returns EINVAL on last block.
+ * XXX is EINVAL the right thing to return if a directory is malformed?
+ */
+
+/*
+ * XXX Untested vs. mount -o union; probably does the wrong thing.
+ */
+
+/*
+ * Find parent vnode of *lvpp, return in *uvpp
+ *
+ * If we care about the name, scan it looking for name of directory
+ * entry pointing at lvp.
+ *
+ * Place the name in the buffer which starts at bufp, immediately
+ * before *bpp, and move bpp backwards to point at the start of it.
+ *
+ * On entry, *lvpp is a locked vnode reference; on exit, it is vput and NULL'ed
+ * On exit, *uvpp is either NULL or is a locked vnode reference.
+ */
+static int
+linux_getcwd_scandir(lvpp, uvpp, bpp, bufp, td)
+	struct vnode **lvpp;
+	struct vnode **uvpp;
+	char **bpp;
+	char *bufp;
+	struct thread *td;
+{
+	int     error = 0;
+	int     eofflag;
+	off_t   off;
+	int     tries;
+	struct uio uio;
+	struct iovec iov;
+	char   *dirbuf = NULL;
+	int	dirbuflen;
+	ino_t   fileno;
+	struct vattr va;
+	struct vnode *uvp = NULL;
+	struct vnode *lvp = *lvpp;	
+	struct componentname cn;
+	int len, reclen;
+	tries = 0;
+
+	/*
+	 * If we want the filename, get some info we need while the
+	 * current directory is still locked.
+	 */
+	if (bufp != NULL) {
+		error = VOP_GETATTR(lvp, &va, td->td_ucred, td);
+		if (error) {
+			vput(lvp);
+			*lvpp = NULL;
+			*uvpp = NULL;
+			return error;
+		}
+	}
+
+	/*
+	 * Ok, we have to do it the hard way..
+	 * Next, get parent vnode using lookup of ..
+	 */
+	cn.cn_nameiop = LOOKUP;
+	cn.cn_flags = ISLASTCN | ISDOTDOT | RDONLY;
+	cn.cn_thread = td;
+	cn.cn_cred = td->td_ucred;
+	cn.cn_pnbuf = NULL;
+	cn.cn_nameptr = "..";
+	cn.cn_namelen = 2;
+	cn.cn_consume = 0;
+	
+	/*
+	 * At this point, lvp is locked and will be unlocked by the lookup.
+	 * On successful return, *uvpp will be locked
+	 */
+	error = VOP_LOOKUP(lvp, uvpp, &cn);
+	if (error) {
+		vput(lvp);
+		*lvpp = NULL;
+		*uvpp = NULL;
+		return error;
+	}
+	uvp = *uvpp;
+
+	/* If we don't care about the pathname, we're done */
+	if (bufp == NULL) {
+		vrele(lvp);
+		*lvpp = NULL;
+		return 0;
+	}
+	
+	fileno = va.va_fileid;
+
+	dirbuflen = DIRBLKSIZ;
+	if (dirbuflen < va.va_blocksize)
+		dirbuflen = va.va_blocksize;
+	dirbuf = (char *)malloc(dirbuflen, M_TEMP, M_WAITOK);
+
+#if 0
+unionread:
+#endif
+	off = 0;
+	do {
+		/* call VOP_READDIR of parent */
+		iov.iov_base = dirbuf;
+		iov.iov_len = dirbuflen;
+
+		uio.uio_iov = &iov;
+		uio.uio_iovcnt = 1;
+		uio.uio_offset = off;
+		uio.uio_resid = dirbuflen;
+		uio.uio_segflg = UIO_SYSSPACE;
+		uio.uio_rw = UIO_READ;
+		uio.uio_td = td;
+
+		eofflag = 0;
+
+#ifdef MAC
+		error = mac_check_vnode_readdir(td->td_ucred, uvp);
+		if (error == 0)
+#endif /* MAC */
+			error = VOP_READDIR(uvp, &uio, td->td_ucred, &eofflag,
+			    0, 0);
+
+		off = uio.uio_offset;
+
+		/*
+		 * Try again if NFS tosses its cookies.
+		 * XXX this can still loop forever if the directory is busted
+		 * such that the second or subsequent page of it always
+		 * returns EINVAL
+		 */
+		if ((error == EINVAL) && (tries < 3)) {
+			off = 0;
+			tries++;
+			continue;	/* once more, with feeling */
+		}
+
+		if (!error) {
+			char   *cpos;
+			struct dirent *dp;
+			
+			cpos = dirbuf;
+			tries = 0;
+				
+			/* scan directory page looking for matching vnode */ 
+			for (len = (dirbuflen - uio.uio_resid); len > 0; len -= reclen) {
+				dp = (struct dirent *) cpos;
+				reclen = dp->d_reclen;
+
+				/* check for malformed directory.. */
+				if (reclen < DIRENT_MINSIZE) {
+					error = EINVAL;
+					goto out;
+				}
+				/*
+				 * XXX should perhaps do VOP_LOOKUP to
+				 * check that we got back to the right place,
+				 * but getting the locking games for that
+				 * right would be heinous.
+				 */
+				if ((dp->d_type != DT_WHT) &&
+				    (dp->d_fileno == fileno)) {
+					char *bp = *bpp;
+					bp -= dp->d_namlen;
+					
+					if (bp <= bufp) {
+						error = ERANGE;
+						goto out;
+					}
+					bcopy(dp->d_name, bp, dp->d_namlen);
+					error = 0;
+					*bpp = bp;
+					goto out;
+				}
+				cpos += reclen;
+			}
+		}
+	} while (!eofflag);
+	error = ENOENT;
+		
+out:
+	vrele(lvp);
+	*lvpp = NULL;
+	free(dirbuf, M_TEMP);
+	return error;
+}
+
+
+/*
+ * common routine shared by sys___getcwd() and linux_vn_isunder()
+ */
+
+#define GETCWD_CHECK_ACCESS 0x0001
+
+static int
+linux_getcwd_common (lvp, rvp, bpp, bufp, limit, flags, td)
+	struct vnode *lvp;
+	struct vnode *rvp;
+	char **bpp;
+	char *bufp;
+	int limit;
+	int flags;
+	struct thread *td;
+{
+	struct filedesc *fdp = td->td_proc->p_fd;
+	struct vnode *uvp = NULL;
+	char *bp = NULL;
+	int error;
+	int perms = VEXEC;
+
+	if (rvp == NULL) {
+		rvp = fdp->fd_rdir;
+		if (rvp == NULL)
+			rvp = rootvnode;
+	}
+	
+	VREF(rvp);
+	VREF(lvp);
+
+	/*
+	 * Error handling invariant:
+	 * Before a `goto out':
+	 *	lvp is either NULL, or locked and held.
+	 *	uvp is either NULL, or locked and held.
+	 */
+
+	error = vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, td);
+	if (error) {
+		vrele(lvp);
+		lvp = NULL;
+		goto out;
+	}
+	if (bufp)
+		bp = *bpp;
+	/*
+	 * this loop will terminate when one of the following happens:
+	 *	- we hit the root
+	 *	- getdirentries or lookup fails
+	 *	- we run out of space in the buffer.
+	 */
+	if (lvp == rvp) {
+		if (bp)
+			*(--bp) = '/';
+		goto out;
+	}
+	do {
+		if (lvp->v_type != VDIR) {
+			error = ENOTDIR;
+			goto out;
+		}
+		
+		/*
+		 * access check here is optional, depending on
+		 * whether or not caller cares.
+		 */
+		if (flags & GETCWD_CHECK_ACCESS) {
+			error = VOP_ACCESS(lvp, perms, td->td_ucred, td);
+			if (error)
+				goto out;
+			perms = VEXEC|VREAD;
+		}
+		
+		/*
+		 * step up if we're a covered vnode..
+		 */
+		while (lvp->v_vflag & VV_ROOT) {
+			struct vnode *tvp;
+
+			if (lvp == rvp)
+				goto out;
+			
+			tvp = lvp;
+			lvp = lvp->v_mount->mnt_vnodecovered;
+			vput(tvp);
+			/*
+			 * hodie natus est radici frater
+			 */
+			if (lvp == NULL) {
+				error = ENOENT;
+				goto out;
+			}
+			VREF(lvp);
+			error = vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, td);
+			if (error != 0) {
+				vrele(lvp);
+				lvp = NULL;
+				goto out;
+			}
+		}
+		error = linux_getcwd_scandir(&lvp, &uvp, &bp, bufp, td);
+		if (error)
+			goto out;
+#if DIAGNOSTIC		
+		if (lvp != NULL)
+			panic("getcwd: oops, forgot to null lvp");
+		if (bufp && (bp <= bufp)) {
+			panic("getcwd: oops, went back too far");
+		}
+#endif		
+		if (bp) 
+			*(--bp) = '/';
+		lvp = uvp;
+		uvp = NULL;
+		limit--;
+	} while ((lvp != rvp) && (limit > 0)); 
+
+out:
+	if (bpp)
+		*bpp = bp;
+	if (uvp)
+		vput(uvp);
+	if (lvp)
+		vput(lvp);
+	vrele(rvp);
+	return error;
+}
+
+
+/*
  * Find pathname of process's current directory.
  *
  * Use vfs vnode-to-name reverse cache; if that fails, fall back
- * to reading directory contents.  Use the common routines in vfs_cache.c.
+ * to reading directory contents.
  */
 
 int
 linux_getcwd(struct thread *td, struct linux_getcwd_args *args)
 {
-	return (kern___getcwd (td, args->buf, UIO_USERSPACE, args->bufsize));
+	caddr_t bp, bend, path;
+	int error, len, lenused;
+
+#ifdef DEBUG
+	printf("Linux-emul(%ld): getcwd(%p, %ld)\n", (long)td->td_proc->p_pid,
+	       args->buf, (long)args->bufsize);
+#endif
+
+	len = args->bufsize;
+
+	if (len > MAXPATHLEN*4)
+		len = MAXPATHLEN*4;
+	else if (len < 2)
+		return ERANGE;
+
+	path = (char *)malloc(len, M_TEMP, M_WAITOK);
+
+	error = kern___getcwd(td, path, UIO_SYSSPACE, len);
+	if (!error) {
+		lenused = strlen(path) + 1;
+		if (lenused <= args->bufsize) {
+			td->td_retval[0] = lenused;
+			error = copyout(path, args->buf, lenused);
+		}
+		else
+			error = ERANGE;
+	} else {
+		bp = &path[len];
+		bend = bp;
+		*(--bp) = '\0';
+
+		/*
+		 * 5th argument here is "max number of vnodes to traverse".
+		 * Since each entry takes up at least 2 bytes in the output buffer,
+		 * limit it to N/2 vnodes for an N byte buffer.
+		 */
+
+		error = linux_getcwd_common (td->td_proc->p_fd->fd_cdir, NULL,
+		    &bp, path, len/2, GETCWD_CHECK_ACCESS, td);
+
+		if (error)
+			goto out;
+		lenused = bend - bp;
+		td->td_retval[0] = lenused;
+		/* put the result into user buffer */
+		error = copyout(bp, args->buf, lenused);
+	}
+out:
+	free(path, M_TEMP);
+	return (error);
 }
 

==== //depot/projects/smpng/sys/compat/linux/linux_stats.c#12 (text+ko) ====

@@ -25,7 +25,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/compat/linux/linux_stats.c,v 1.50 2003/03/03 09:17:12 des Exp $
+ * $FreeBSD: src/sys/compat/linux/linux_stats.c,v 1.51 2003/03/20 21:17:39 jhb Exp $
  */
 
 #include "opt_mac.h"
@@ -251,7 +251,7 @@
 	bsd_statfs = &mp->mnt_stat;
 	vrele(ndp->ni_vp);
 #ifdef MAC
-	error = mac_check_mount_stat(td->td_proc->p_ucred, mp);
+	error = mac_check_mount_stat(td->td_ucred, mp);
 	if (error)
 		return (error);
 #endif
@@ -290,7 +290,7 @@
 		return error;
 	mp = ((struct vnode *)fp->f_data)->v_mount;
 #ifdef MAC
-	error = mac_check_mount_stat(td->td_proc->p_ucred, mp);
+	error = mac_check_mount_stat(td->td_ucred, mp);
 	if (error) {
 		fdrop(fp, td);
 		return (error);
@@ -358,8 +358,7 @@
 		if (vp->v_mount == NULL)
 			return (EINVAL);
 #ifdef MAC
-		error = mac_check_mount_stat(td->td_proc->p_ucred,
-		    vp->v_mount);
+		error = mac_check_mount_stat(td->td_ucred, vp->v_mount);
 		if (error)
 			return (error);
 #endif

==== //depot/projects/smpng/sys/conf/files#67 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/files,v 1.770 2003/03/11 19:26:15 sam Exp $
+# $FreeBSD: src/sys/conf/files,v 1.771 2003/03/18 09:53:03 phk Exp $
 #
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and
@@ -897,7 +897,6 @@
 geom/geom_mirror.c	optional geom_mirror
 geom/geom_pc98.c	optional geom_pc98
 geom/geom_slice.c	standard
-geom/geom_stats.c	standard
 geom/geom_subr.c	standard
 geom/geom_sunlabel.c	optional geom_sunlabel
 geom/geom_vol_ffs.c	optional geom_vol

==== //depot/projects/smpng/sys/conf/files.sparc64#25 (text+ko) ====

@@ -1,7 +1,7 @@
 # This file tells config what files go into building a kernel,
 # files marked standard are always included.
 #
-# $FreeBSD: src/sys/conf/files.sparc64,v 1.39 2003/02/28 21:59:13 ru Exp $
+# $FreeBSD: src/sys/conf/files.sparc64,v 1.40 2003/03/19 06:55:36 jake Exp $
 #
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and
@@ -36,6 +36,7 @@
 sparc64/sparc64/autoconf.c	standard
 sparc64/sparc64/bus_machdep.c	standard
 sparc64/sparc64/cache.c		standard
+sparc64/sparc64/cheetah.c	standard
 sparc64/sparc64/clock.c		standard
 sparc64/sparc64/counter.c	standard
 sparc64/sparc64/critical.c	standard
@@ -68,6 +69,7 @@
 sparc64/sparc64/prof_machdep.c	optional	profiling-routine
 sparc64/sparc64/rwindow.c	standard
 sparc64/sparc64/sparcbus_if.m	standard
+sparc64/sparc64/spitfire.c	standard
 sparc64/sparc64/support.S	standard
 sparc64/sparc64/sys_machdep.c	standard
 sparc64/sparc64/swtch.S		standard

==== //depot/projects/smpng/sys/contrib/dev/fla/fla.c#7 (text+ko) ====

@@ -6,12 +6,11 @@
  * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
  * ----------------------------------------------------------------------------
  *
- * $FreeBSD: src/sys/contrib/dev/fla/fla.c,v 1.37 2003/03/08 08:01:27 phk Exp $ 
+ * $FreeBSD: src/sys/contrib/dev/fla/fla.c,v 1.38 2003/03/18 08:45:20 phk Exp $ 
  *
  */
 
 #include <sys/param.h>
-#include <sys/stdint.h>
 #include <sys/systm.h>
 #include <sys/sysctl.h>
 #include <sys/kernel.h>

==== //depot/projects/smpng/sys/dev/ata/ata-all.c#32 (text+ko) ====

@@ -25,7 +25,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/ata/ata-all.c,v 1.171 2003/03/12 10:59:35 sos Exp $
+ * $FreeBSD: src/sys/dev/ata/ata-all.c,v 1.172 2003/03/18 08:45:20 phk Exp $
  */
 
 #include "opt_ata.h"
@@ -39,7 +39,6 @@
 #include <sys/bus.h>
 #include <sys/bio.h>
 #include <sys/malloc.h>
-#include <sys/stdint.h>
 #include <sys/sysctl.h>
 #include <machine/stdarg.h>
 #include <machine/resource.h>

==== //depot/projects/smpng/sys/dev/ata/atapi-tape.c#17 (text+ko) ====

@@ -25,7 +25,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/ata/atapi-tape.c,v 1.76 2003/03/15 10:50:43 phk Exp $
+ * $FreeBSD: src/sys/dev/ata/atapi-tape.c,v 1.77 2003/03/18 08:45:20 phk Exp $
  */
 
 #include "opt_ata.h"
@@ -40,7 +40,6 @@
 #include <sys/mtio.h>
 #include <sys/disklabel.h>
 #include <sys/devicestat.h>
-#include <sys/stdint.h>
 #include <machine/bus.h>
 #include <dev/ata/ata-all.h>
 #include <dev/ata/atapi-all.h>

==== //depot/projects/smpng/sys/dev/ccd/ccd.c#22 (text+ko) ====

@@ -50,7 +50,7 @@
  *
  *	$NetBSD: ccd.c,v 1.22 1995/12/08 19:13:26 thorpej Exp $ 
  *
- * $FreeBSD: src/sys/dev/ccd/ccd.c,v 1.130 2003/03/08 08:01:28 phk Exp $
+ * $FreeBSD: src/sys/dev/ccd/ccd.c,v 1.131 2003/03/18 08:45:21 phk Exp $
  */
 
 #include <sys/param.h>
@@ -63,7 +63,6 @@
 #include <sys/namei.h>
 #include <sys/conf.h>
 #include <sys/stat.h>
-#include <sys/stdint.h>
 #include <sys/sysctl.h>
 #include <sys/disk.h>
 #include <sys/fcntl.h>

==== //depot/projects/smpng/sys/dev/ciss/ciss.c#12 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	$FreeBSD: src/sys/dev/ciss/ciss.c,v 1.18 2003/03/08 08:01:28 phk Exp $
+ *	$FreeBSD: src/sys/dev/ciss/ciss.c,v 1.19 2003/03/18 08:45:21 phk Exp $
  */
 
 /*
@@ -75,7 +75,6 @@
 #include <sys/bus.h>
 #include <sys/conf.h>
 #include <sys/stat.h>
-#include <sys/stdint.h>
 
 #include <cam/cam.h>
 #include <cam/cam_ccb.h>

==== //depot/projects/smpng/sys/dev/drm/drm_fops.h#4 (text+ko) ====

@@ -29,7 +29,7 @@
  *    Daryll Strauss <daryll@valinux.com>
  *    Gareth Hughes <gareth@valinux.com>
  *
- * $FreeBSD: src/sys/dev/drm/drm_fops.h,v 1.5 2003/03/09 02:08:28 anholt Exp $
+ * $FreeBSD: src/sys/dev/drm/drm_fops.h,v 1.6 2003/03/20 21:17:39 jhb Exp $
  */
 
 #include "dev/drm/drmP.h"
@@ -37,7 +37,7 @@
 drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_STRUCTPROC *p)
 {
 #if __FreeBSD_version >= 500021
-	uid_t uid = p->td_proc->p_ucred->cr_svuid;
+	uid_t uid = p->td_ucred->cr_svuid;
 	pid_t pid = p->td_proc->p_pid;
 #else
 	uid_t uid = p->p_cred->p_svuid;
@@ -75,7 +75,7 @@
 		priv = (drm_file_t *) DRM(alloc)(sizeof(*priv), DRM_MEM_FILES);
 		bzero(priv, sizeof(*priv));
 #if __FreeBSD_version >= 500000
-		priv->uid		= p->td_proc->p_ucred->cr_svuid;
+		priv->uid		= p->td_ucred->cr_svuid;
 		priv->pid		= p->td_proc->p_pid;
 #else
 		priv->uid		= p->p_cred->p_svuid;

==== //depot/projects/smpng/sys/dev/fb/vga.c#11 (text+ko) ====

@@ -26,7 +26,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/fb/vga.c,v 1.22 2003/02/25 03:21:19 mux Exp $
+ * $FreeBSD: src/sys/dev/fb/vga.c,v 1.23 2003/03/18 08:45:21 phk Exp $
  */
 
 #include "opt_vga.h"
@@ -40,7 +40,6 @@
 #include <sys/fcntl.h>
 #include <sys/malloc.h>
 #include <sys/fbio.h>
-#include <sys/stdint.h>
 
 #include <vm/vm.h>
 #include <vm/vm_param.h>

==== //depot/projects/smpng/sys/dev/firewire/if_fwe.c#8 (text+ko) ====

@@ -31,7 +31,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * 
- * $FreeBSD: src/sys/dev/firewire/if_fwe.c,v 1.11 2003/03/06 05:06:44 simokawa Exp $
+ * $FreeBSD: src/sys/dev/firewire/if_fwe.c,v 1.12 2003/03/19 07:04:11 simokawa Exp $
  */
 
 #include "opt_inet.h"
@@ -310,6 +310,7 @@
 		fwe->pkt_hdr.mode.stream.chtag = fwe->stream_ch;
 		/* allocate DMA channel and init packet mode */
 		xferq->flag |= FWXFERQ_OPEN | FWXFERQ_EXTBUF;
+		xferq->flag &= ~0xff;
 		xferq->flag |= fwe->stream_ch & 0xff;
 		/* register fwe_input handler */
 		xferq->sc = (caddr_t) fwe;

==== //depot/projects/smpng/sys/dev/ida/ida.c#7 (text+ko) ====

@@ -27,7 +27,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/ida/ida.c,v 1.23 2003/03/08 08:01:28 phk Exp $
+ * $FreeBSD: src/sys/dev/ida/ida.c,v 1.24 2003/03/18 08:45:21 phk Exp $
  */
 
 /*
@@ -40,7 +40,6 @@
 
 #include <sys/param.h>
 #include <sys/kernel.h>
-#include <sys/stdint.h>
 #include <sys/systm.h>
 #include <sys/malloc.h>
 

==== //depot/projects/smpng/sys/dev/iir/iir_pci.c#5 (text+ko) ====

@@ -1,4 +1,4 @@
-/* $FreeBSD: src/sys/dev/iir/iir_pci.c,v 1.5 2002/11/07 22:23:46 jhb Exp $ */
+/* $FreeBSD: src/sys/dev/iir/iir_pci.c,v 1.6 2003/03/18 08:45:21 phk Exp $ */
 /*
  *       Copyright (c) 2000-01 Intel Corporation
  *       All Rights Reserved
@@ -48,7 +48,6 @@
 #include <sys/kernel.h>
 #include <sys/module.h>
 #include <sys/bus.h> 
-#include <sys/stdint.h>
 
 #include <machine/bus_memio.h>
 #include <machine/bus_pio.h>

==== //depot/projects/smpng/sys/dev/md/md.c#30 (text+ko) ====

@@ -6,7 +6,7 @@
  * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
  * ----------------------------------------------------------------------------
  *
- * $FreeBSD: src/sys/dev/md/md.c,v 1.89 2003/03/08 08:01:28 phk Exp $
+ * $FreeBSD: src/sys/dev/md/md.c,v 1.90 2003/03/18 08:45:21 phk Exp $
  *
  */
 
@@ -76,7 +76,6 @@
 #include <sys/namei.h>
 #include <sys/proc.h>
 #include <sys/queue.h>
-#include <sys/stdint.h>
 #include <sys/sysctl.h>
 #include <sys/vnode.h>
 

==== //depot/projects/smpng/sys/dev/musycc/musycc.c#4 (text+ko) ====

@@ -6,7 +6,7 @@
  * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
  * ----------------------------------------------------------------------------
  *
- * $FreeBSD: src/sys/dev/musycc/musycc.c,v 1.25 2003/02/19 05:47:08 imp Exp $
+ * $FreeBSD: src/sys/dev/musycc/musycc.c,v 1.26 2003/03/18 08:45:21 phk Exp $
  *
  *
  *
@@ -47,7 +47,6 @@
 #include <sys/bus.h>
 #include <sys/mbuf.h>
 #include <sys/queue.h>
-#include <sys/stdint.h>
 #include <machine/bus.h>
 #include <machine/clock.h>

>>> TRUNCATED FOR MAIL (1000 lines) <<<

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200303202202.h2KM2vJs064112>