| 240 | } |
| 241 | |
| 242 | static int ptsdev_ioctl(struct lwp_tty *tp, rt_ubase_t cmd, void *data, |
| 243 | struct ucred *active_cred, int fflags, |
| 244 | struct rt_thread *td) |
| 245 | { |
| 246 | struct pts_softc *psc = tty_softc(tp); |
| 247 | int error = 0, sig; |
| 248 | |
| 249 | switch (cmd) |
| 250 | { |
| 251 | #ifdef USING_BSD_IOCTL_EXT |
| 252 | case FIODTYPE: |
| 253 | *(int *)data = D_TTY; |
| 254 | return (0); |
| 255 | #endif |
| 256 | case FIONBIO: |
| 257 | /* This device supports non-blocking operation. */ |
| 258 | return (0); |
| 259 | case FIONREAD: |
| 260 | tty_lock(tp); |
| 261 | if (psc->pts_flags & PTS_FINISHED) |
| 262 | { |
| 263 | /* Force read() to be called. */ |
| 264 | *(int *)data = 1; |
| 265 | } |
| 266 | else |
| 267 | { |
| 268 | *(int *)data = ttydisc_getc_poll(tp); |
| 269 | } |
| 270 | tty_unlock(tp); |
| 271 | return (0); |
| 272 | #ifdef USING_BSD_IOCTL_EXT |
| 273 | case FIODGNAME: |
| 274 | #ifdef COMPAT_FREEBSD32 |
| 275 | case FIODGNAME_32: |
| 276 | #endif |
| 277 | { |
| 278 | struct fiodgname_arg *fgn; |
| 279 | const char *p; |
| 280 | int i; |
| 281 | |
| 282 | /* Reverse device name lookups, for ptsname() and ttyname(). */ |
| 283 | fgn = data; |
| 284 | p = tty_devname(tp); |
| 285 | i = strlen(p) + 1; |
| 286 | if (i > fgn->len) |
| 287 | return -EINVAL; |
| 288 | return (copyout(p, fiodgname_buf_get_ptr(fgn, cmd), i)); |
| 289 | } |
| 290 | #endif |
| 291 | /* |
| 292 | * We need to implement TIOCGPGRP and TIOCGSID here again. When |
| 293 | * called on the pseudo-terminal master, it should not check if |
| 294 | * the terminal is the foreground terminal of the calling |
| 295 | * process. |
| 296 | * |
| 297 | * TIOCGETA is also implemented here. Various Linux PTY routines |
| 298 | * often call isatty(), which is implemented by tcgetattr(). |
| 299 | */ |
nothing calls this directly
no test coverage detected