From owner-freebsd-current@freebsd.org Sat Sep 3 10:49:01 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 2171BBCB892 for ; Sat, 3 Sep 2016 10:49:01 +0000 (UTC) (envelope-from etnapierala@gmail.com) Received: from mail-wm0-x229.google.com (mail-wm0-x229.google.com [IPv6:2a00:1450:400c:c09::229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B05B9E37 for ; Sat, 3 Sep 2016 10:49:00 +0000 (UTC) (envelope-from etnapierala@gmail.com) Received: by mail-wm0-x229.google.com with SMTP id c133so61226850wmd.1 for ; Sat, 03 Sep 2016 03:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=NNllryJ0muFBo4HVSoAwuh6yS1pRRs0+o6WKHwPgPVE=; b=Oabx7S4dWFWK2l0FC6I0ZBdIOPqBioV0/8KLkeZ2umStI4dZN4v6zi7aA0bWrN7kib GsGAlE/rkKOivoxgcB7z4Vbl+LAVxD0GzxE28I+jBHsubx6PotwgxPk5EkJ0LTaCGjie fJ1UyG3JNcE5bhws+oJDW9J5l1uDhBpIP5YN1T+33kstW8Htd/mA9PJKiOPqGFMc91t4 UemUreR1NnfJ9A1II6fahU6mOnweE3LfM8toZa2ZhQi2IsFD+Au8F2/yJRo1QXboFYBI KcjglatmvM//a9LCKClY8+9W/e53cgjLr4eOPg3RzQVn8HcEJDIOMz9gMnk9vxBKXFOx Gzdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=NNllryJ0muFBo4HVSoAwuh6yS1pRRs0+o6WKHwPgPVE=; b=KpAXAHZn7ji8ryHV65Nj3WtsaFk1QINJnzszLm9/FKtITgLlE+/A7+4JFJTGdx8GIN cqeeQG7KLqvOuALR1IhQ0M6D1VB0l9xfnUfs6LorooRnkzTpahXbKfYA4Vexq+Sxh10U UrZBy+vztYnSlPpLT5EYeNllFyC+DQu8Ti46D7fkg3q2347WFzF2iWReeAmMEt1tygyR OGBCxDZJm7+jGiWgFV+k3d3ygYFqjPLTtdQnbfbT5ot0PkQaln0qEHup11gd/TojHSyG r0kEJ8w/AEvWDUXBTxZlbe0up0GCtNs8LQrH2keXfbiIZklrIe6CPc19xzIPMmpXRk6b LbMQ== X-Gm-Message-State: AE9vXwNNZw8mxKMBjY9l5ZKIkWOgKoeCHku4bSviAt6Ruv54OGQIMUdt8vb4fLXMer/IjQ== X-Received: by 10.194.179.163 with SMTP id dh3mr22542737wjc.73.1472899739243; Sat, 03 Sep 2016 03:48:59 -0700 (PDT) Received: from brick (acyr75.neoplus.adsl.tpnet.pl. [83.11.201.75]) by smtp.gmail.com with ESMTPSA id v189sm7952610wmv.12.2016.09.03.03.48.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Sep 2016 03:48:58 -0700 (PDT) Sender: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= Date: Sat, 3 Sep 2016 12:48:55 +0200 From: Edward Tomasz =?utf-8?Q?Napiera=C5=82a?= To: "Lundberg, Johannes" Cc: FreeBSD Current Subject: Re: Weirdness in TTY & VT Message-ID: <20160903104855.GA12771@brick> Mail-Followup-To: "Lundberg, Johannes" , FreeBSD Current References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.6.1 (2016-04-27) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.22 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: Sat, 03 Sep 2016 10:49:01 -0000 On 0902T1712, Lundberg, Johannes wrote: > ​Hi > > 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? Device numbers don't really matter in FreeBSD. To get the current VT number, use VT_GETACTIVE ioctl. Take a look at vidcontrol(1) source to see how it's done ("vidcontrol -i active").