From owner-p4-projects@FreeBSD.ORG Wed Aug 13 14:25:45 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 952BE106566C; Wed, 13 Aug 2008 14:25:45 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B0EE106564A for ; Wed, 13 Aug 2008 14:25:45 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 549748FC08 for ; Wed, 13 Aug 2008 14:25:45 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m7DEPjK2051412 for ; Wed, 13 Aug 2008 14:25:45 GMT (envelope-from ed@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m7DEPjcE051410 for perforce@freebsd.org; Wed, 13 Aug 2008 14:25:45 GMT (envelope-from ed@FreeBSD.org) Date: Wed, 13 Aug 2008 14:25:45 GMT Message-Id: <200808131425.m7DEPjcE051410@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to ed@FreeBSD.org using -f From: Ed Schouten To: Perforce Change Reviews Cc: Subject: PERFORCE change 147301 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Aug 2008 14:25:45 -0000 http://perforce.freebsd.org/chv.cgi?CH=147301 Change 147301 by ed@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, };