| 1305 | } |
| 1306 | |
| 1307 | static int |
| 1308 | sysctl_kern_ttys(SYSCTL_HANDLER_ARGS) |
| 1309 | { |
| 1310 | unsigned long lsize; |
| 1311 | struct xtty *xtlist, *xt; |
| 1312 | struct tty *tp; |
| 1313 | int error; |
| 1314 | |
| 1315 | sx_slock(&tty_list_sx); |
| 1316 | lsize = tty_list_count * sizeof(struct xtty); |
| 1317 | if (lsize == 0) { |
| 1318 | sx_sunlock(&tty_list_sx); |
| 1319 | return (0); |
| 1320 | } |
| 1321 | |
| 1322 | xtlist = xt = malloc(lsize, M_TTY, M_WAITOK); |
| 1323 | |
| 1324 | TAILQ_FOREACH(tp, &tty_list, t_list) { |
| 1325 | tty_lock(tp); |
| 1326 | tty_to_xtty(tp, xt); |
| 1327 | tty_unlock(tp); |
| 1328 | xt++; |
| 1329 | } |
| 1330 | sx_sunlock(&tty_list_sx); |
| 1331 | |
| 1332 | error = SYSCTL_OUT(req, xtlist, lsize); |
| 1333 | free(xtlist, M_TTY); |
| 1334 | return (error); |
| 1335 | } |
| 1336 | |
| 1337 | SYSCTL_PROC(_kern, OID_AUTO, ttys, CTLTYPE_OPAQUE|CTLFLAG_RD|CTLFLAG_MPSAFE, |
| 1338 | 0, 0, sysctl_kern_ttys, "S,xtty", "List of TTYs"); |
nothing calls this directly
no test coverage detected