| @@ -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 = { |
94 | static const char * | | 94 | static const char * |
95 | ptyfs__getpath(struct lwp *l, const struct mount *mp) | | 95 | ptyfs__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; |