On Mar 19, 9:51pm, net...@izyk.ru (Ilya Zykov) wrote: -- Subject: Re: Enhance ptyfs to handle multiple instances.
| Ok, but bug will stay in the system, temporarily. No problem, no worse than we have now. christos | | fs/ptyfs/ptyfs_vfsops.c | 16 +++++++++++----- | kern/tty_ptm.c | 9 ++++++++- | 2 files changed, 19 insertions(+), 6 deletions(-) | | Ilya. | | | --------------030108000701050802030304 | Content-Type: text/x-patch; | name="ptyfs.mi.02.patch" | Content-Transfer-Encoding: 7bit | Content-Disposition: attachment; | filename="ptyfs.mi.02.patch" | | Index: fs/ptyfs/ptyfs_vfsops.c | =================================================================== | RCS file: /cvsil/nbcur/src/sys/fs/ptyfs/ptyfs_vfsops.c,v | retrieving revision 1.1.1.1 | diff -u -p -r1.1.1.1 ptyfs_vfsops.c | --- fs/ptyfs/ptyfs_vfsops.c 4 Mar 2014 18:16:03 -0000 1.1.1.1 | +++ fs/ptyfs/ptyfs_vfsops.c 19 Mar 2014 17:36:48 -0000 | @@ -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; | Index: kern/tty_ptm.c | =================================================================== | RCS file: /cvsil/nbcur/src/sys/kern/tty_ptm.c,v | retrieving revision 1.1.1.2 | diff -u -p -r1.1.1.2 tty_ptm.c | --- kern/tty_ptm.c 17 Mar 2014 11:46:10 -0000 1.1.1.2 | +++ kern/tty_ptm.c 19 Mar 2014 17:36:48 -0000 | @@ -381,7 +381,9 @@ ptmioctl(dev_t dev, u_long cmd, void *da | goto bad; | | /* now, put the indices and names into struct ptmget */ | - return pty_fill_ptmget(l, newdev, cfd, sfd, data); | + if ((error = pty_fill_ptmget(l, newdev, cfd, sfd, data)) != 0) | + break; /* goto bad2 */ | + return 0; | default: | #ifdef COMPAT_60 | error = compat_60_ptmioctl(dev, cmd, data, flag, l); | @@ -391,6 +393,11 @@ ptmioctl(dev_t dev, u_long cmd, void *da | DPRINTF(("ptmioctl EINVAL\n")); | return EINVAL; | } | +/* bad2: close sfd too */ | + fp = fd_getfile(sfd); | + if (fp != NULL) { | + fd_close(sfd); | + } | bad: | fp = fd_getfile(cfd); | if (fp != NULL) { | | --------------030108000701050802030304-- -- End of excerpt from Ilya Zykov