Tue Sep 18 21:33:55 2012 UTC ()
Always do the chroot filename mapping; it is pointless not to do it.


(christos)
diff -r1.8 -r1.9 src/sys/fs/ptyfs/ptyfs.h
diff -r1.42 -r1.43 src/sys/fs/ptyfs/ptyfs_vfsops.c

cvs diff -r1.8 -r1.9 src/sys/fs/ptyfs/ptyfs.h (expand / switch to unified diff)

--- src/sys/fs/ptyfs/ptyfs.h 2009/03/15 16:43:55 1.8
+++ src/sys/fs/ptyfs/ptyfs.h 2012/09/18 21:33:55 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ptyfs.h,v 1.8 2009/03/15 16:43:55 christos Exp $ */ 1/* $NetBSD: ptyfs.h,v 1.9 2012/09/18 21:33:55 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1993 4 * Copyright (c) 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Jan-Simon Pendry. 8 * Jan-Simon Pendry.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -114,31 +114,26 @@ struct ptyfsmount { @@ -114,31 +114,26 @@ struct ptyfsmount {
114#define VFSTOPTY(mp) ((struct ptyfsmount *)(mp)->mnt_data) 114#define VFSTOPTY(mp) ((struct ptyfsmount *)(mp)->mnt_data)
115 115
116#endif /* _KERNEL */ 116#endif /* _KERNEL */
117 117
118struct ptyfs_args { 118struct ptyfs_args {
119 int version; 119 int version;
120 gid_t gid; 120 gid_t gid;
121 mode_t mode; 121 mode_t mode;
122 int flags; 122 int flags;
123}; 123};
124 124
125#define PTYFS_ARGSVERSION 2 125#define PTYFS_ARGSVERSION 2
126 126
127#define PTYFSMNT_CHROOT 0x01 
128 
129#define PTYFSMNT_BITS "\177\20" \ 
130 "b\00chroot\0" 
131 
132/* 127/*
133 * Kernel stuff follows 128 * Kernel stuff follows
134 */ 129 */
135#ifdef _KERNEL 130#ifdef _KERNEL
136 131
137#define UIO_MX 32 132#define UIO_MX 32
138 133
139#define PTYFS_FILENO(pty, type) \ 134#define PTYFS_FILENO(pty, type) \
140 ((type == PTYFSroot) ? 2 : \ 135 ((type == PTYFSroot) ? 2 : \
141 ((((pty) + 1) * 2 + (((type) == PTYFSpts) ? 1 : 2)))) 136 ((((pty) + 1) * 2 + (((type) == PTYFSpts) ? 1 : 2))))
142 137
143#define PTYFS_MAKEDEV(ptyfs) \ 138#define PTYFS_MAKEDEV(ptyfs) \
144 pty_makedev((ptyfs)->ptyfs_type == PTYFSpts ? 't' : 'p', (ptyfs)->ptyfs_pty) 139 pty_makedev((ptyfs)->ptyfs_type == PTYFSpts ? 't' : 'p', (ptyfs)->ptyfs_pty)

cvs diff -r1.42 -r1.43 src/sys/fs/ptyfs/ptyfs_vfsops.c (expand / switch to unified diff)

--- src/sys/fs/ptyfs/ptyfs_vfsops.c 2010/01/08 11:35:09 1.42
+++ src/sys/fs/ptyfs/ptyfs_vfsops.c 2012/09/18 21:33:55 1.43
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ptyfs_vfsops.c,v 1.42 2010/01/08 11:35:09 pooka Exp $ */ 1/* $NetBSD: ptyfs_vfsops.c,v 1.43 2012/09/18 21:33:55 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1992, 1993, 1995 4 * Copyright (c) 1992, 1993, 1995
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software donated to Berkeley by 7 * This code is derived from software donated to Berkeley by
8 * Jan-Simon Pendry. 8 * Jan-Simon Pendry.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -28,27 +28,27 @@ @@ -28,27 +28,27 @@
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 * 33 *
34 */ 34 */
35 35
36/* 36/*
37 * Pseudo-tty Filesystem 37 * Pseudo-tty Filesystem
38 */ 38 */
39 39
40#include <sys/cdefs.h> 40#include <sys/cdefs.h>
41__KERNEL_RCSID(0, "$NetBSD: ptyfs_vfsops.c,v 1.42 2010/01/08 11:35:09 pooka Exp $"); 41__KERNEL_RCSID(0, "$NetBSD: ptyfs_vfsops.c,v 1.43 2012/09/18 21:33:55 christos Exp $");
42 42
43#include <sys/param.h> 43#include <sys/param.h>
44#include <sys/systm.h> 44#include <sys/systm.h>
45#include <sys/sysctl.h> 45#include <sys/sysctl.h>
46#include <sys/conf.h> 46#include <sys/conf.h>
47#include <sys/proc.h> 47#include <sys/proc.h>
48#include <sys/vnode.h> 48#include <sys/vnode.h>
49#include <sys/mount.h> 49#include <sys/mount.h>
50#include <sys/namei.h> 50#include <sys/namei.h>
51#include <sys/stat.h> 51#include <sys/stat.h>
52#include <sys/dirent.h> 52#include <sys/dirent.h>
53#include <sys/malloc.h> 53#include <sys/malloc.h>
54#include <sys/syslog.h> 54#include <sys/syslog.h>
@@ -94,28 +94,27 @@ struct ptm_pty ptm_ptyfspty = { @@ -94,28 +94,27 @@ struct ptm_pty ptm_ptyfspty = {
94static const char * 94static const char *
95ptyfs__getpath(struct lwp *l, const struct mount *mp) 95ptyfs__getpath(struct lwp *l, const struct mount *mp)
96{ 96{
97#define MAXBUF (sizeof(mp->mnt_stat.f_mntonname) + 32) 97#define MAXBUF (sizeof(mp->mnt_stat.f_mntonname) + 32)
98 struct cwdinfo *cwdi = l->l_proc->p_cwdi; 98 struct cwdinfo *cwdi = l->l_proc->p_cwdi;
99 char *buf; 99 char *buf;
100 const char *rv; 100 const char *rv;
101 size_t len; 101 size_t len;
102 char *bp; 102 char *bp;
103 int error; 103 int error;
104 struct ptyfsmount *pmnt = mp->mnt_data; 104 struct ptyfsmount *pmnt = mp->mnt_data;
105 105
106 rv = mp->mnt_stat.f_mntonname; 106 rv = mp->mnt_stat.f_mntonname;
107 if (cwdi->cwdi_rdir == NULL || 107 if (cwdi->cwdi_rdir == NULL)
108 (pmnt->pmnt_flags & PTYFSMNT_CHROOT) == 0) 
109 return rv; 108 return rv;
110 109
111 buf = malloc(MAXBUF, M_TEMP, M_WAITOK); 110 buf = malloc(MAXBUF, M_TEMP, M_WAITOK);
112 bp = buf + MAXBUF; 111 bp = buf + MAXBUF;
113 *--bp = '\0'; 112 *--bp = '\0';
114 error = getcwd_common(cwdi->cwdi_rdir, rootvnode, &bp, 113 error = getcwd_common(cwdi->cwdi_rdir, rootvnode, &bp,
115 buf, MAXBUF / 2, 0, l); 114 buf, MAXBUF / 2, 0, l);
116 if (error) /* XXX */ 115 if (error) /* XXX */
117 goto out; 116 goto out;
118 117
119 len = strlen(bp); 118 len = strlen(bp);
120 if (len < sizeof(mp->mnt_stat.f_mntonname)) /* XXX */ 119 if (len < sizeof(mp->mnt_stat.f_mntonname)) /* XXX */
121 rv += len; 120 rv += len;