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

Function tty_makedevf

freebsd/kern/tty.c:1345–1471  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1343 */
1344
1345int
1346tty_makedevf(struct tty *tp, struct ucred *cred, int flags,
1347 const char *fmt, ...)
1348{
1349 va_list ap;
1350 struct make_dev_args args;
1351 struct cdev *dev, *init, *lock, *cua, *cinit, *clock;
1352 const char *prefix = "tty";
1353 char name[SPECNAMELEN - 3]; /* for "tty" and "cua". */
1354 uid_t uid;
1355 gid_t gid;
1356 mode_t mode;
1357 int error;
1358
1359 /* Remove "tty" prefix from devices like PTY's. */
1360 if (tp->t_flags & TF_NOPREFIX)
1361 prefix = "";
1362
1363 va_start(ap, fmt);
1364 vsnrprintf(name, sizeof name, 32, fmt, ap);
1365 va_end(ap);
1366
1367 if (cred == NULL) {
1368 /* System device. */
1369 uid = UID_ROOT;
1370 gid = GID_WHEEL;
1371 mode = S_IRUSR|S_IWUSR;
1372 } else {
1373 /* User device. */
1374 uid = cred->cr_ruid;
1375 gid = GID_TTY;
1376 mode = S_IRUSR|S_IWUSR|S_IWGRP;
1377 }
1378
1379 flags = flags & TTYMK_CLONING ? MAKEDEV_REF : 0;
1380 flags |= MAKEDEV_CHECKNAME;
1381
1382 /* Master call-in device. */
1383 make_dev_args_init(&args);
1384 args.mda_flags = flags;
1385 args.mda_devsw = &ttydev_cdevsw;
1386 args.mda_cr = cred;
1387 args.mda_uid = uid;
1388 args.mda_gid = gid;
1389 args.mda_mode = mode;
1390 args.mda_si_drv1 = tp;
1391 error = make_dev_s(&args, &dev, "%s%s", prefix, name);
1392 if (error != 0)
1393 return (error);
1394 tp->t_dev = dev;
1395
1396 init = lock = cua = cinit = clock = NULL;
1397
1398 /* Slave call-in devices. */
1399 if (tp->t_flags & TF_INITLOCK) {
1400 args.mda_devsw = &ttyil_cdevsw;
1401 args.mda_unit = TTYUNIT_INIT;
1402 args.mda_si_drv1 = tp;

Callers

nothing calls this directly

Calls 4

vsnrprintfFunction · 0.85
make_dev_sFunction · 0.85
dev_dependsFunction · 0.85
destroy_devFunction · 0.85

Tested by

no test coverage detected