Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp859727imb; Fri, 1 Mar 2019 16:49:19 -0800 (PST) X-Google-Smtp-Source: AHgI3IY3JIRbbMCIykdDAfaR3YWXudgfMEgT5CDjpX3G7DOBfcda0rnFn4hbBIZgAdjiT/Vv5tWX X-Received: by 2002:a62:1303:: with SMTP id b3mr8785967pfj.147.1551487759058; Fri, 01 Mar 2019 16:49:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551487759; cv=none; d=google.com; s=arc-20160816; b=eXfDZO2QAbckWLEa62PLxAKJkgaV0L/kHQ9drx3hfYrN4Ms1ywADo2P/RYgr9RhH0W bNmv1F9b99LVAdvhXKcEO5sU+IlJZfzeanjGlisun6kiLoE2MVUYzx8HEvB1hGJcVI8f 9ORaj8/97lJaFVUTJu2jifNiniCg5PO7Dz2gdq9H/TbiYrtQqUQBV2tvme+YMG02y5sZ 15REOBHSrWgeLN58ZTbVQ6JtchVyRJOo+hfQxZbn3AnQJDK2DE3uu1ZJYeBiOAU12ht6 ZuxrkobZMfQ2le/Cc6Glla/mOc70d9c5ipPfnpq2L8FHR5DRVVX8EOv7Qs4V5Mika+Vh jQRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:smtp-origin-cluster:cc:to :smtp-origin-hostname:from:smtp-origin-hostprefix:dkim-signature; bh=MIHq4tU7qcFfmoetfTM1EQJ3mdEJ7twxaH8aGN9v1uk=; b=q8UunubX3lloWpLpIKl4cWnAeibjyJnk9QTo5A355WRVZlhO6kxMd+vsQHKhns6IDt yuyVN9y+biRfRjYpD0O/UfS0bPwGRsa9/tGufBio4cNjxw7d0k7q7pmleW472zX8ARQM rGclFgczvpaTjX8c0jrpee+Jw8XAsWm4XQjm5FAUUwSZk+FJvnhuV1GlohxFAAL0p/Me JqUN6FgEkgE4G+LRMWKdJYMEJ5SI84PI3mMeKnKRD4YUyrD2XnVg5NENNxRJqMa+l7VO wAyagNPbRykFbb2ZGQnk+9zgVjh30kdsiRL9pY0k883xkzJYAiNgrzPCNCnstkP1KjkU Lddw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b="PM+y/iWa"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i17si21383444pgk.233.2019.03.01.16.49.01; Fri, 01 Mar 2019 16:49:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b="PM+y/iWa"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727470AbfCBAsf (ORCPT + 99 others); Fri, 1 Mar 2019 19:48:35 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:45228 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727272AbfCBAsf (ORCPT ); Fri, 1 Mar 2019 19:48:35 -0500 Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x220jKEi029310 for ; Fri, 1 Mar 2019 16:48:34 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=facebook; bh=MIHq4tU7qcFfmoetfTM1EQJ3mdEJ7twxaH8aGN9v1uk=; b=PM+y/iWaGv/PYPVKt8lXB8z1tFpwMYAF+s9HZqn/hYHDMe7sXPRrAMJ5fTgN4Il263lB DYRIxwhfhw3jtBH1OynwpkMYuQzKRO9xgXj70v1uYbcJtFZkmcEzzIFIazxYF6C0cyqB L+2/7uUtx74VlfLOuCyXBpjq7KuMNlmajwQ= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2qycv50gn5-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 01 Mar 2019 16:48:34 -0800 Received: from mx-out.facebook.com (2620:10d:c081:10::13) by mail.thefacebook.com (2620:10d:c081:35::129) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.1.1713.5; Fri, 1 Mar 2019 16:48:33 -0800 Received: by devbig008.ftw2.facebook.com (Postfix, from userid 10532) id 1AD9E23A5AB7; Fri, 1 Mar 2019 16:48:32 -0800 (PST) Smtp-Origin-Hostprefix: devbig From: Calvin Owens Smtp-Origin-Hostname: devbig008.ftw2.facebook.com To: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Greg Kroah-Hartman , Jonathan Corbet CC: , , Calvin Owens Smtp-Origin-Cluster: ftw2c04 Subject: [PATCH 4/4] printk: Add a device attribute for the per-console loglevel Date: Fri, 1 Mar 2019 16:48:20 -0800 Message-ID: <4f71564063a07837e3c4df41326bad25e7dc4db4.1551486733.git.calvinowens@fb.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-FB-Internal: Safe MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-01_16:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Calvin Owens --- kernel/printk/printk.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 67e1e993ab80..e7e602fa2d0b 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2560,8 +2560,48 @@ static int __init keep_bootcon_setup(char *str) early_param("keep_bootcon", keep_bootcon_setup); +static ssize_t loglevel_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct console *con = container_of(dev, struct console, dev); + return sprintf(buf, "%d\n", con->level); +} + +static ssize_t loglevel_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct console *con = container_of(dev, struct console, dev); + ssize_t ret; + int tmp; + + ret = kstrtoint(buf, 10, &tmp); + if (ret < 0) + return ret; + + if (tmp < LOGLEVEL_EMERG) + return -ERANGE; + + /* + * Mimic the behavior of /dev/kmsg with respect to minimum_loglevel. + */ + if (tmp < minimum_console_loglevel) + tmp = minimum_console_loglevel; + + con->level = tmp; + return ret; +} + +static DEVICE_ATTR_RW(loglevel); + +static struct attribute *console_sysfs_attrs[] = { + &dev_attr_loglevel.attr, + NULL, +}; +ATTRIBUTE_GROUPS(console_sysfs); + static struct bus_type console_subsys = { .name = "console", + .dev_groups = console_sysfs_groups, }; static void console_release(struct device *dev) -- 2.17.1