diff options
author | ed <ed@FreeBSD.org> | 2008-09-21 19:24:15 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2008-09-21 19:24:15 +0000 |
commit | acdad30e01fb738a92dc0b4e32ecae4ec055aca8 (patch) | |
tree | 75124fc728508220c0121c07abc24b0f31e987de /sys/kern | |
parent | 3c13ffd7b5bde102a37ff93d0cd94091bce5b3b5 (diff) | |
download | FreeBSD-src-acdad30e01fb738a92dc0b4e32ecae4ec055aca8.zip FreeBSD-src-acdad30e01fb738a92dc0b4e32ecae4ec055aca8.tar.gz |
Make fstat() on a pseudo-terminal master return sane timestamps.
Because pseudo-terminal master file descriptors no longer have a vnode
underneath, we have to fill in fstat() values ourselves. Make our
implementation somewhat sane by returning the timestamps of the TTY
device node that corresponds with our file descriptor.
Obtained from: //depot/projects/mpsafettty/...
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/tty_pts.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/sys/kern/tty_pts.c b/sys/kern/tty_pts.c index 03e78b8..95bab99 100644 --- a/sys/kern/tty_pts.c +++ b/sys/kern/tty_pts.c @@ -430,6 +430,7 @@ ptsdev_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, #ifdef PTS_EXTERNAL struct pts_softc *psc = tty_softc(tp); #endif /* PTS_EXTERNAL */ + struct cdev *dev = tp->t_dev; /* * According to POSIX, we must implement an fstat(). This also @@ -437,8 +438,7 @@ ptsdev_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, * because Linux calls fstat() on the pseudo-terminal master to * obtain st_rdev. * - * XXX: POSIX also mentions we must fill in st_dev, st_atime, - * st_ctime and st_mtime, but how? + * XXX: POSIX also mentions we must fill in st_dev, but how? */ bzero(sb, sizeof *sb); @@ -448,9 +448,13 @@ ptsdev_stat(struct file *fp, struct stat *sb, struct ucred *active_cred, else #endif /* PTS_EXTERNAL */ sb->st_ino = sb->st_rdev = tty_udev(tp); - sb->st_mode = S_IFCHR; - sb->st_uid = tp->t_dev->si_cred->cr_ruid; - sb->st_gid = GID_TTY; + + sb->st_atimespec = dev->si_atime; + sb->st_ctimespec = dev->si_ctime; + sb->st_mtimespec = dev->si_mtime; + sb->st_uid = dev->si_uid; + sb->st_gid = dev->si_gid; + sb->st_mode = dev->si_mode | S_IFCHR; return (0); } |