From owner-freebsd-current@freebsd.org Thu Sep 8 17:36:37 2016 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 26739BD1941 for ; Thu, 8 Sep 2016 17:36:37 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "mailhost.stack.nl", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id E916EE6A for ; Thu, 8 Sep 2016 17:36:36 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id D39AD358C67; Thu, 8 Sep 2016 19:36:33 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id ACADF28494; Thu, 8 Sep 2016 19:36:33 +0200 (CEST) Date: Thu, 8 Sep 2016 19:36:33 +0200 From: Jilles Tjoelker To: "Lundberg, Johannes" Cc: FreeBSD Current Subject: Re: Weirdness in TTY & VT Message-ID: <20160908173633.GA50215@stack.nl> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Sep 2016 17:36:37 -0000 On Fri, Sep 02, 2016 at 05:12:12PM -0700, Lundberg, Johannes wrote: > I'm porting some Linux code and have some weird behavior. > In this (Linux) code fstat() and minor() is used on a /dev/tty file > descriptor to get a tty number to map to. In FreeBSD this returns a number > around 60-70 for st_rdev which means VT_ACTIVATE ioctl call will fail > because it only allows values 0-12. > Should not this be compatible with FreeBSD? If not, what is the FreeBSD way > to do this? > Is there some implementation missing in vt? minor() and major() are obsolete in FreeBSD. A (userland) dev_t is an opaque identifier. The direct equivalent is devname_r() or fdevname_r() followed by parsing the resulting string. There is also a VT_GETINDEX ioctl but I don't know whether it works. -- Jilles Tjoelker