tty_pts.c (220279) | tty_pts.c (223575) |
---|---|
1/*- 2 * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Portions of this software were developed under sponsorship from Snow 6 * B.V., the Netherlands. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Portions of this software were developed under sponsorship from Snow 6 * B.V., the Netherlands. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/kern/tty_pts.c 220279 2011-04-02 15:02:42Z trasz $"); | 31__FBSDID("$FreeBSD: head/sys/kern/tty_pts.c 223575 2011-06-26 18:26:20Z ed $"); |
32 33/* Add compatibility bits for FreeBSD. */ 34#define PTS_COMPAT 35/* Add pty(4) compat bits. */ 36#define PTS_EXTERNAL 37/* Add bits to make Linux binaries work. */ 38#define PTS_LINUX 39 --- 250 unchanged lines hidden (view full) --- 290 /* Reverse device name lookups, for ptsname() and ttyname(). */ 291 fgn = data; 292 p = tty_devname(tp); 293 i = strlen(p) + 1; 294 if (i > fgn->len) 295 return (EINVAL); 296 return copyout(p, fgn->buf, i); 297 } | 32 33/* Add compatibility bits for FreeBSD. */ 34#define PTS_COMPAT 35/* Add pty(4) compat bits. */ 36#define PTS_EXTERNAL 37/* Add bits to make Linux binaries work. */ 38#define PTS_LINUX 39 --- 250 unchanged lines hidden (view full) --- 290 /* Reverse device name lookups, for ptsname() and ttyname(). */ 291 fgn = data; 292 p = tty_devname(tp); 293 i = strlen(p) + 1; 294 if (i > fgn->len) 295 return (EINVAL); 296 return copyout(p, fgn->buf, i); 297 } |
298 | 298 |
299 /* 300 * We need to implement TIOCGPGRP and TIOCGSID here again. When 301 * called on the pseudo-terminal master, it should not check if 302 * the terminal is the foreground terminal of the calling 303 * process. 304 * 305 * TIOCGETA is also implemented here. Various Linux PTY routines 306 * often call isatty(), which is implemented by tcgetattr(). --- 251 unchanged lines hidden (view full) --- 558 sb->st_ino = sb->st_rdev = tty_udev(tp); 559 560 sb->st_atim = dev->si_atime; 561 sb->st_ctim = dev->si_ctime; 562 sb->st_mtim = dev->si_mtime; 563 sb->st_uid = dev->si_uid; 564 sb->st_gid = dev->si_gid; 565 sb->st_mode = dev->si_mode | S_IFCHR; | 299 /* 300 * We need to implement TIOCGPGRP and TIOCGSID here again. When 301 * called on the pseudo-terminal master, it should not check if 302 * the terminal is the foreground terminal of the calling 303 * process. 304 * 305 * TIOCGETA is also implemented here. Various Linux PTY routines 306 * often call isatty(), which is implemented by tcgetattr(). --- 251 unchanged lines hidden (view full) --- 558 sb->st_ino = sb->st_rdev = tty_udev(tp); 559 560 sb->st_atim = dev->si_atime; 561 sb->st_ctim = dev->si_ctime; 562 sb->st_mtim = dev->si_mtime; 563 sb->st_uid = dev->si_uid; 564 sb->st_gid = dev->si_gid; 565 sb->st_mode = dev->si_mode | S_IFCHR; |
566 | 566 |
567 return (0); 568} 569 570static int 571ptsdev_close(struct file *fp, struct thread *td) 572{ 573 struct tty *tp = fp->f_data; 574 --- 243 unchanged lines hidden (view full) --- 818 struct file *fp; 819 820 /* 821 * POSIX states it's unspecified when other flags are passed. We 822 * don't allow this. 823 */ 824 if (uap->flags & ~(O_RDWR|O_NOCTTY)) 825 return (EINVAL); | 567 return (0); 568} 569 570static int 571ptsdev_close(struct file *fp, struct thread *td) 572{ 573 struct tty *tp = fp->f_data; 574 --- 243 unchanged lines hidden (view full) --- 818 struct file *fp; 819 820 /* 821 * POSIX states it's unspecified when other flags are passed. We 822 * don't allow this. 823 */ 824 if (uap->flags & ~(O_RDWR|O_NOCTTY)) 825 return (EINVAL); |
826 | 826 |
827 error = falloc(td, &fp, &fd, 0); 828 if (error) 829 return (error); 830 831 /* Allocate the actual pseudo-TTY. */ 832 error = pts_alloc(FFLAGS(uap->flags & O_ACCMODE), td, fp); 833 if (error != 0) { 834 fdclose(td->td_proc->p_fd, fp, fd, td); --- 18 unchanged lines hidden --- | 827 error = falloc(td, &fp, &fd, 0); 828 if (error) 829 return (error); 830 831 /* Allocate the actual pseudo-TTY. */ 832 error = pts_alloc(FFLAGS(uap->flags & O_ACCMODE), td, fp); 833 if (error != 0) { 834 fdclose(td->td_proc->p_fd, fp, fd, td); --- 18 unchanged lines hidden --- |