From patchwork Thu Jul 17 14:09:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 33786 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f197.google.com (mail-ig0-f197.google.com [209.85.213.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3E5D520CA0 for ; Thu, 17 Jul 2014 14:10:29 +0000 (UTC) Received: by mail-ig0-f197.google.com with SMTP id r2sf9513410igi.8 for ; Thu, 17 Jul 2014 07:10:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=08IS0OWub5/D+bMN86NFgVr4WniYvVSNdYIsit2xyiI=; b=MVUVx6h96tpw2sHf+vjarKzGLcsSuuTYjNijSNk0431uQZtCgI/Rc8h5OePdH3HQiZ KEmc95+6RpFJoMlAd5cW3mptSfNAuiNTsJEydidpQr0t/X4+VLpQ3jfr+iKm9Gvi8tyW qAzzXuKqtqMm20j0DO/jutq/dKpHxzEaWUrsDBs7AT0wckgjO2fn78Ui9ou0q/M7cHGF KVJS6xtkFrzm8A09QtnqKFJnWl9aKdL3KB/QDBC3+7taFriOdHdiY7DXVjarGk9ghrFM 1c3PPWHWf733DHbcbRcOHmV+4z3OR4j0Z7U/GCosSJFuN5f1rwsHpYHN54YyZFFn1xHS UyCA== X-Gm-Message-State: ALoCoQl7EXsSfPDPrN6AcyesjXaHDNeyd4pDuaqoTEIGosH0vWd7lNQzoO9ZoOf/RfLLT4KFFrVs X-Received: by 10.50.13.6 with SMTP id d6mr9717433igc.1.1405606228817; Thu, 17 Jul 2014 07:10:28 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.48.132 with SMTP id o4ls714442qga.40.gmail; Thu, 17 Jul 2014 07:10:28 -0700 (PDT) X-Received: by 10.52.252.4 with SMTP id zo4mr33706522vdc.20.1405606228684; Thu, 17 Jul 2014 07:10:28 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id si10si2477361vcb.10.2014.07.17.07.10.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 17 Jul 2014 07:10:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id hu12so4743131vcb.28 for ; Thu, 17 Jul 2014 07:10:28 -0700 (PDT) X-Received: by 10.52.120.38 with SMTP id kz6mr4682556vdb.86.1405606227668; Thu, 17 Jul 2014 07:10:27 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp39482vcb; Thu, 17 Jul 2014 07:10:27 -0700 (PDT) X-Received: by 10.68.68.207 with SMTP id y15mr20066843pbt.25.1405606226754; Thu, 17 Jul 2014 07:10:26 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xs3si2483615pbb.247.2014.07.17.07.10.21; Thu, 17 Jul 2014 07:10:21 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933490AbaGQOJ5 (ORCPT + 23 others); Thu, 17 Jul 2014 10:09:57 -0400 Received: from mail-ig0-f179.google.com ([209.85.213.179]:43605 "EHLO mail-ig0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933040AbaGQOJR (ORCPT ); Thu, 17 Jul 2014 10:09:17 -0400 Received: by mail-ig0-f179.google.com with SMTP id h18so2908535igc.0 for ; Thu, 17 Jul 2014 07:09:16 -0700 (PDT) X-Received: by 10.50.62.80 with SMTP id w16mr18882509igr.21.1405606156723; Thu, 17 Jul 2014 07:09:16 -0700 (PDT) Received: from localhost.localdomain (c-24-245-18-91.hsd1.mn.comcast.net. [24.245.18.91]) by mx.google.com with ESMTPSA id hu10sm55538179igb.22.2014.07.17.07.09.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Jul 2014 07:09:16 -0700 (PDT) From: Alex Elder To: akpm@linux-foundation.org Cc: pmladek@suse.cz, bp@suse.de, john.stultz@linaro.org, jack@suse.cz, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/6] printk: insert newline in devkmsg_read() Date: Thu, 17 Jul 2014 09:09:10 -0500 Message-Id: <1405606151-19875-6-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1405606151-19875-1-git-send-email-elder@linaro.org> References: <1405606151-19875-1-git-send-email-elder@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: elder@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , If a log record has LOG_PREFIX set, its predecessor record should be terminated if it was marked LOG_CONT. In devkmsg_read(), this condition was being ignored, which would lead to such records showing up combined when reading /dev/kmsg. Fix this oversight. Reported-by: Petr Mládek Signed-off-by: Alex Elder --- kernel/printk/printk.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index e5ee1cb..3174ba9 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -575,6 +575,7 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf, char cont; size_t len; ssize_t ret; + bool insert_newline; if (!user) return -EBADF; @@ -626,7 +627,10 @@ static ssize_t devkmsg_read(struct file *file, char __user *buf, else cont = '-'; - len = sprintf(user->buf, "%u,%llu,%llu,%c;", + /* Insert a newline if we're terminating the previous record early */ + insert_newline = (user->prev & LOG_CONT) && (msg->flags & LOG_PREFIX); + len = sprintf(user->buf, "%s%u,%llu,%llu,%c;", + insert_newline ? "\n" : "", (msg->facility << 3) | msg->level, user->seq, ts_usec, cont); user->prev = msg->flags;