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

Function ptsdev_stat

freebsd/kern/tty_pts.c:537–572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

535}
536
537static int
538ptsdev_stat(struct file *fp, struct stat *sb, struct ucred *active_cred,
539 struct thread *td)
540{
541 struct tty *tp = fp->f_data;
542#ifdef PTS_EXTERNAL
543 struct pts_softc *psc = tty_softc(tp);
544#endif /* PTS_EXTERNAL */
545 struct cdev *dev = tp->t_dev;
546
547 /*
548 * According to POSIX, we must implement an fstat(). This also
549 * makes this implementation compatible with Linux binaries,
550 * because Linux calls fstat() on the pseudo-terminal master to
551 * obtain st_rdev.
552 *
553 * XXX: POSIX also mentions we must fill in st_dev, but how?
554 */
555
556 bzero(sb, sizeof *sb);
557#ifdef PTS_EXTERNAL
558 if (psc->pts_cdev != NULL)
559 sb->st_ino = sb->st_rdev = dev2udev(psc->pts_cdev);
560 else
561#endif /* PTS_EXTERNAL */
562 sb->st_ino = sb->st_rdev = tty_udev(tp);
563
564 sb->st_atim = dev->si_atime;
565 sb->st_ctim = dev->si_ctime;
566 sb->st_mtim = dev->si_mtime;
567 sb->st_uid = dev->si_uid;
568 sb->st_gid = dev->si_gid;
569 sb->st_mode = dev->si_mode | S_IFCHR;
570
571 return (0);
572}
573
574static int
575ptsdev_close(struct file *fp, struct thread *td)

Callers

nothing calls this directly

Calls 2

bzeroFunction · 0.85
tty_udevFunction · 0.70

Tested by

no test coverage detected