From patchwork Wed Dec 19 23:28:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 10738279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F972924 for ; Wed, 19 Dec 2018 23:28:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8091528864 for ; Wed, 19 Dec 2018 23:28:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 726A8288D7; Wed, 19 Dec 2018 23:28:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 176FE28864 for ; Wed, 19 Dec 2018 23:28:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728615AbeLSX2H (ORCPT ); Wed, 19 Dec 2018 18:28:07 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:38630 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727159AbeLSX2H (ORCPT ); Wed, 19 Dec 2018 18:28:07 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 43Krcs064CzKh; Thu, 20 Dec 2018 00:26:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1545261997; bh=MmVskWbwqEZ7wnnuljcwcVdo7LFrDR4SgUq72IELnGo=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=WdiiS3phyi3Nj137aLyHhzgqNRDa9nD3++ad9HnZG99j91WZ5Bz0bYe6moOjs3KyD DbgI3Yso7dJyXdio/mHuMBfF/9lX3w+L6Q54576DOzNYDkdPFl58WYNp/lNQCeWvlq pKW+ZwgHwQ/8T84YFigjYmQJLkSVZ1HABzhcm0jPlvfL58F04iyghZDR1vJoqm4Xva jWZG+QCU23mcWcckhbMChfUX9Q4AsvJJvLOGrOpdtLV1hPCC8tFSVIHJqbdlXorQh4 rIeJoPDHGx8YkoI4G5ecaxVIePEmp0sm7qsYOM4EKPNeR56J3OLcMCjesIVIp7LQsH FlbNrC41g/Lqg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.2 at mail Date: Thu, 20 Dec 2018 00:28:04 +0100 Message-Id: <5a08ab7483620b2aaf85b55ae9ba45800ade9e81.1545261970.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH 2/2] procfs: lseek(/proc/PID/comm, 0, SEEK_END) MIME-Version: 1.0 To: linux-fsdevel@vger.kernel.org Cc: Alexey Dobriyan , Andrew Morton , David Rientjes Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implement lseek(fd, 0, SEEK_END) for /proc/PID/comm to return max task name length. This will allow eg. pthread_getname_np() to be able to return ERANGE without modifying thread's name. Signed-off-by: Michał Mirosław --- fs/proc/base.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 3a3b566443e5..80f5911f2ea9 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -1575,11 +1575,20 @@ static int comm_open(struct inode *inode, struct file *filp) return single_open(filp, comm_show, inode); } +static loff_t comm_lseek(struct file *file, loff_t offset, int whence) +{ + /* SEEK_END for seq_files normally gets -EINVAL */ + if (whence == SEEK_END && offset == 0) + return TASK_COMM_LEN - 1; + + return seq_lseek(file, offset, whence); +} + static const struct file_operations proc_pid_set_comm_operations = { .open = comm_open, .read = seq_read, .write = comm_write, - .llseek = seq_lseek, + .llseek = comm_lseek, .release = single_release, };