Module Name:    src
Committed By:   christos
Date:           Wed Mar 19 18:09:00 UTC 2014

Modified Files:
        src/sys/fs/ptyfs: ptyfs_vfsops.c

Log Message:
- return an error if we could not get the pts pathname
- correct getting pathname if the mount point inside a chroot
(Ilya Zykov)


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/fs/ptyfs/ptyfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/ptyfs/ptyfs_vfsops.c
diff -u src/sys/fs/ptyfs/ptyfs_vfsops.c:1.45 src/sys/fs/ptyfs/ptyfs_vfsops.c:1.46
--- src/sys/fs/ptyfs/ptyfs_vfsops.c:1.45	Tue Feb 25 13:30:10 2014
+++ src/sys/fs/ptyfs/ptyfs_vfsops.c	Wed Mar 19 14:09:00 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: ptyfs_vfsops.c,v 1.45 2014/02/25 18:30:10 pooka Exp $	*/
+/*	$NetBSD: ptyfs_vfsops.c,v 1.46 2014/03/19 18:09:00 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993, 1995
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ptyfs_vfsops.c,v 1.45 2014/02/25 18:30:10 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ptyfs_vfsops.c,v 1.46 2014/03/19 18:09:00 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -109,14 +109,16 @@ ptyfs__getpath(struct lwp *l, const stru
 	buf = malloc(MAXBUF, M_TEMP, M_WAITOK);
 	bp = buf + MAXBUF;
 	*--bp = '\0';
-	error = getcwd_common(cwdi->cwdi_rdir, rootvnode, &bp,
+	error = getcwd_common(mp->mnt_vnodecovered, cwdi->cwdi_rdir, &bp,
 	    buf, MAXBUF / 2, 0, l);
-	if (error)	/* XXX */
+	if (error) {	/* Mount point is out of rdir */
+		rv = NULL;
 		goto out;
+	}
 
 	len = strlen(bp);
 	if (len < sizeof(mp->mnt_stat.f_mntonname))	/* XXX */
-		rv += len;
+		rv += strlen(rv) - len;
 out:
 	free(buf, M_TEMP);
 	return rv;
@@ -128,6 +130,7 @@ ptyfs__makename(struct ptm_pty *pt, stru
 {
 	struct mount *mp = pt->arg;
 	size_t len;
+	const char *np;
 
 	switch (ms) {
 	case 'p':
@@ -135,8 +138,11 @@ ptyfs__makename(struct ptm_pty *pt, stru
 		len = snprintf(tbuf, bufsiz, "/dev/null");
 		break;
 	case 't':
-		len = snprintf(tbuf, bufsiz, "%s/%llu", ptyfs__getpath(l, mp),
-		    (unsigned long long)minor(dev));
+		np = ptyfs__getpath(l, mp);
+		if (np == NULL)
+			return EOPNOTSUPP;
+		len = snprintf(tbuf, bufsiz, "%s/%llu", np,
+			(unsigned long long)minor(dev));
 		break;
 	default:
 		return EINVAL;

Reply via email to