PERFORCE change 147301 for review

Ed Schouten ed at FreeBSD.org
Wed Aug 13 14:25:45 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=147301

Change 147301 by ed at ed_mekker on 2008/08/13 14:24:46

	According to POSIX, we must implement fstat(), even for our new
	pseudo-terminals. Make the implementation a little more complete
	by implementing the st_uid and st_gid fields. We fill it up with
	cr_ruid and GID_TTY, which matches the user/group pair used to
	create the device node.

Affected files ...

.. //depot/projects/mpsafetty/sys/kern/tty_pts.c#8 edit

Differences ...

==== //depot/projects/mpsafetty/sys/kern/tty_pts.c#8 (text+ko) ====

@@ -388,7 +388,6 @@
 	return (revents);
 }
 
-#if defined(PTS_COMPAT) || defined(PTS_LINUX)
 static int
 ptsdev_stat(struct file *fp, struct stat *sb, struct ucred *active_cred,
     struct thread *td)
@@ -396,18 +395,23 @@
 	struct tty *tp = fp->f_data;
 
 	/*
-	 * To make older FreeBSD and Linux binaries work, implement a
-	 * basic fstat(), which should contain enough data to make
-	 * reverse device name lookups work.
+	 * According to POSIX, we must implement an fstat(). This also
+	 * makes this implementation compatible with Linux binaries,
+	 * 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?
 	 */
 
 	bzero(sb, sizeof *sb);
 	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;
 	
 	return (0);
 }
-#endif /* PTS_COMPAT || PTS_LINUX */
 
 static int
 ptsdev_close(struct file *fp, struct thread *td)
@@ -426,9 +430,7 @@
 	.fo_write	= ptsdev_write,
 	.fo_ioctl	= ptsdev_ioctl,
 	.fo_poll	= ptsdev_poll,
-#if defined(PTS_COMPAT) || defined(PTS_LINUX)
 	.fo_stat	= ptsdev_stat,
-#endif /* PTS_COMPAT || PTS_LINUX */
 	.fo_close	= ptsdev_close,
 	.fo_flags	= DFLAG_PASSABLE,
 };


More information about the p4-projects mailing list