Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3077258pxb; Tue, 13 Apr 2021 18:22:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw38CEqwhoBDLXQWj8HQZOpxxODEziqRsBkqToUWnCZETK1bOVNmi5Ko2a2Rv4v668hrnX9 X-Received: by 2002:a17:906:a155:: with SMTP id bu21mr34839487ejb.400.1618363347597; Tue, 13 Apr 2021 18:22:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618363347; cv=none; d=google.com; s=arc-20160816; b=z3usU7AyDuTNGsn8QO2qkkUPcY3wYem36Q9t1DX2R2anImQXpIC+GcoAOavzHQvTJD 74aA1h4nih/FNO5/tHdhHystOhohSmAp1bjAZTmh6cCd5zI4Afl1Urv2iL0rv9DFqDsZ +np4QnQvlpOVgSktHd7X4XltQYEwi7mYsr0q4+m5MvtlypVK6w4XyJRdMjU+ON9ESoiX X7b+irLAiB77ZfXGMgxVRvi7Yg1hsutbvG4hh2wr/cZ6UIzNqqQP12RDjHjlo4l0hYzS oJtSvHt5XUcE+Wukzp/r6u4PBzBJgweh+8cJWufFRaIrJhdg1qfWW4vg0nWBPSAmqj+i 4TFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=ve5MD0Wqox27pr67xueKgzVG1EaK00v8Q8RNNToOZVI=; b=rza5+0BkXue6CtfSHC17Xo1xrmus1DkUikMzanI0UYF1CzIYlmX1n6c0tp4NiHy4+w oe115zkZKvG1SR5PVOLk6g6DuiHggCr42S62vjG34fjmS9LUvlxE+fO5rZgoGPLvOch5 WzgBJzMPhkclMOC7wbrzlkxjJ5CJXWucBawTqrJu+Rrn46MQicWcFKKbhQ1lr6eXTXZN JDQCfULJLRCJkeatYcTc/J2hbzMJLbs6K75x6mfLzbTXXTFfCoo4G6sLV2YQN1uXvf0d yRmX7oiCaUsf4NaGJcrYmIOa0d58mB1gZ7Vq0fvSvSKV+NOgQvFj1/rqg2XuErDe+Dw7 /KYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@t-2.net header.s=smtp-out-2 header.b=aGbbXrE5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=t-2.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ox26si11673862ejb.16.2021.04.13.18.22.04; Tue, 13 Apr 2021 18:22:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@t-2.net header.s=smtp-out-2 header.b=aGbbXrE5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=REJECT dis=NONE) header.from=t-2.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239534AbhDMPYn (ORCPT + 99 others); Tue, 13 Apr 2021 11:24:43 -0400 Received: from smtp-good-out-4.t-2.net ([93.103.246.70]:53848 "EHLO smtp-good-out-4.t-2.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346700AbhDMPXk (ORCPT ); Tue, 13 Apr 2021 11:23:40 -0400 Received: from smtp-1.t-2.net (smtp-1.t-2.net [IPv6:2a01:260:1:4::1e]) by smtp-good-out-4.t-2.net (Postfix) with ESMTP id 4FKTrk6SWNzTyy; Tue, 13 Apr 2021 17:23:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-2.net; s=smtp-out-2; t=1618327398; bh=iTcQ2sTcmn98QMi8qBpLVKqPeR8uHdri8V0nrWRW6sw=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=aGbbXrE5Vgme8YKaV9wgm+Y+GOMiaszb1Y6J9Zo0sU4ym3QbV5MUA/WcwmaqCarOf ivs7s+uXN27i38uqUiKwZVwTfhEdPgu8o6QvtgIRPLZYRLZa/LLzNSIxl+MZ7gj8xV +8UQ4spa8F9nfP4T/ec8pGHrblpXBqgyaZMTAFt0= Received: from localhost (localhost [127.0.0.1]) by smtp-1.t-2.net (Postfix) with ESMTP id 4FKTrk6G8FzTg2xf; Tue, 13 Apr 2021 17:23:18 +0200 (CEST) X-Virus-Scanned: amavisd-new at t-2.net Received: from smtp-1.t-2.net ([127.0.0.1]) by localhost (smtp-1.t-2.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dGgxBC9fHpe4; Tue, 13 Apr 2021 17:23:18 +0200 (CEST) Received: from hpg3.u2up.net (89-212-91-172.static.t-2.net [89.212.91.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp-1.t-2.net (Postfix) with ESMTPS; Tue, 13 Apr 2021 17:22:47 +0200 (CEST) Message-ID: Subject: Re: How to handle concurrent access to /dev/ttyprintk ? From: Samo =?UTF-8?Q?Poga=C4=8Dnik?= To: Petr Mladek Cc: Tetsuo Handa , Jiri Slaby , Sergey Senozhatsky , Steven Rostedt , John Ogness , linux-kernel@vger.kernel.org, Greg Kroah-Hartman Date: Tue, 13 Apr 2021 17:22:46 +0200 In-Reply-To: References: <20210403041444.4081-1-penguin-kernel@I-love.SAKURA.ne.jp> <3c15d32f-c568-7f6f-fa7e-af4deb9b49f9@i-love.sakura.ne.jp> <051b550c-1cdd-6503-d2b7-0877bf0578fc@i-love.sakura.ne.jp> <157d81a5eb9e56e47e40c1cd652cdc7a915cb755.camel@t-2.net> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dne 13.04.2021 (tor) ob 16:32 +0200 je Petr Mladek napisal(a): > On Tue 2021-04-13 13:10:50, Samo Pogačnik wrote: > > Dne 13.04.2021 (tor) ob 11:41 +0200 je Petr Mladek napisal(a): > > > On Mon 2021-04-12 14:41:27, Samo Pogačnik wrote: > > > > Dne 12.04.2021 (pon) ob 19:39 +0900 je Tetsuo Handa napisal(a): > > > > > What is the intended usage of /dev/ttyprintk ? > > > > > > > > > > > > > The intended use of 'ttyprintk' is to redirect console to /dev/ttyprintk > > > > via the TIOCCONS ioctl. After successfull redirection, all console > > > > messages get "merged" with kernel messages and as such automatically > > > > processed > > > > (stored/transferred) by the syslog service for example. > > > > > > The same can be achieved by /dev/kmsg that was created by systemd > > > developers. > > > > > > > 'kmsg' and 'ttyprintk' are different types of drivers and as such rather > > complementary than exclusive. The 'ttyprintk' being a tty driver allows > > for a system wide automatic redirection of anything written to the > > console. > > I might miss something. But how can one setup ttyprintk as the system > wide console? I do not see any code that would use ttyprintk > in struct console. > You can compile this simple code below and call: # ./tioccons /dev/ttyprintk ... from now on all console output interleaves the kernel log (you can check dmesg or logs) # ./tioccons /dev/console ... sets things back they were. You will be able to recognize console messages by preceding "[U]" tag (meaning User). ------------------- #include #include #include #include #include #include int main(int argc, char **argv) { int fd; if (argc != 2) { printf("Wrong usage!\n"); exit(1); } if ((fd = open(argv[1], O_WRONLY)) == -1) { perror(argv[1]); exit(1); } if (ioctl(fd, TIOCCONS, NULL) == -1) { printf("ioctl: %s\n", strerror(errno)); exit(1); } exit(0); } -------------------- best regards, Samo