From patchwork Tue Sep 11 06:51:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoming Ni X-Patchwork-Id: 10595107 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 493136CB for ; Tue, 11 Sep 2018 06:51:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3773B28D9B for ; Tue, 11 Sep 2018 06:51:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2909E28DCC; Tue, 11 Sep 2018 06:51:49 +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=-7.9 required=2.0 tests=BAYES_00,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 A27FE28D9B for ; Tue, 11 Sep 2018 06:51:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726896AbeIKLth convert rfc822-to-8bit (ORCPT ); Tue, 11 Sep 2018 07:49:37 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:6036 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726683AbeIKLth (ORCPT ); Tue, 11 Sep 2018 07:49:37 -0400 Received: from DGGEMM404-HUB.china.huawei.com (unknown [172.30.72.57]) by Forcepoint Email with ESMTP id 61CA1DFFDB9DE; Tue, 11 Sep 2018 14:51:43 +0800 (CST) Received: from DGGEMM507-MBS.china.huawei.com ([169.254.3.21]) by DGGEMM404-HUB.china.huawei.com ([10.3.20.212]) with mapi id 14.03.0399.000; Tue, 11 Sep 2018 14:51:43 +0800 From: Nixiaoming To: Eric Paris , "rlove@rlove.org" , "john@johnmccutchan.com" , "amir73il@gmail.com" , "jack@suse.cz" , "viro@zeniv.linux.org.uk" CC: "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" Subject: Is it possible to add pid and comm members to the event structure to increase the display of user and thread information? Thread-Topic: Is it possible to add pid and comm members to the event structure to increase the display of user and thread information? Thread-Index: AdRJmkzwtMeGnSbeRVCa8sLtVjSk6w== Date: Tue, 11 Sep 2018 06:51:43 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.57.88.168] MIME-Version: 1.0 X-CFilter-Loop: Reflected 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 Inotify api cannot display information about users and processes. That is, you can only know that the file event is generated, but you don't know who triggered the event, which is not conducive to fault location. Is it possible to add pid and comm members to the event structure to increase the display of user and thread information? Example: diff --git a/fs/notify/inotify/inotify.h b/fs/notify/inotify/inotify.h index 7e4578d..be91844 100644 --- a/fs/notify/inotify/inotify.h +++ b/fs/notify/inotify/inotify.h @@ -7,6 +7,8 @@ struct inotify_event_info { struct fsnotify_event fse; int wd; u32 sync_cookie; + int pid; + char comm[TASK_COMM_LEN]; int name_len; char name[]; }; diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c index f4184b4..f7ad298 100644 --- a/fs/notify/inotify/inotify_fsnotify.c +++ b/fs/notify/inotify/inotify_fsnotify.c @@ -117,6 +117,8 @@ int inotify_handle_event(struct fsnotify_group *group, fsnotify_init_event(fsn_event, inode, mask); event->wd = i_mark->wd; event->sync_cookie = cookie; + event->pid = current->pid; + strncpy(event->comm, current->comm, TASK_COMM_LEN); event->name_len = len; if (len) strcpy(event->name, file_name);