MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sysctl_kern_ttys

Function sysctl_kern_ttys

freebsd/kern/tty.c:1307–1335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1305}
1306
1307static int
1308sysctl_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
1337SYSCTL_PROC(_kern, OID_AUTO, ttys, CTLTYPE_OPAQUE|CTLFLAG_RD|CTLFLAG_MPSAFE,
1338 0, 0, sysctl_kern_ttys, "S,xtty", "List of TTYs");

Callers

nothing calls this directly

Calls 3

mallocFunction · 0.85
tty_to_xttyFunction · 0.85
freeFunction · 0.70

Tested by

no test coverage detected