Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3686342imm; Mon, 10 Sep 2018 23:52:38 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZnOA7taC6YFSiSi+m1FHsaE2dWIiVRnhibFYiOjxcOZpCyp/GlD8WOOJpneP/bHGQJAyPi X-Received: by 2002:a63:e355:: with SMTP id o21-v6mr26963486pgj.251.1536648758905; Mon, 10 Sep 2018 23:52:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536648758; cv=none; d=google.com; s=arc-20160816; b=KsDVEx7TwOTwBtEzYN6XFJ6pMUZzkRuBvzp4yCDJekz/bZGDNJSSutVDj7NyDInBN0 VRy6yVtNlgdJeL8NGKEK7xuuRKOG/ztTWU8911KiWB5kQCXEIic2OktNisXDxstSuqN+ 7YXBZ53clU+vbk6BNMwuZynyKTIbQ73AeUdKUIDF1Owrt/FgtBDc9M81wTnGgVZhUzB/ TopgNekJJX0HOnc9wjk6KbBG/fCBKlbWKTt/q8vt4c74DkiMHoD0lKm5412B8eVQeD2/ Yv7dCLeGB/GiqrQEuDjtAsMd/WZp+QUEfHvqrZ3S1AOyPRcfxj5EKVBIiIYsNE8npBtK M+ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=4kDlDbCN97mPxrtE65M9hHpix1eaacpfZtmAr5ZP44A=; b=wLZlToig/1Vcq0cnvB45THNSE21M4+R/GiXard0wEKCAFT6mqsH2+osz2qljj+JP21 TSM8rZSu3nJUdFx4uk9EGfz3UesEPlldeE3mtsVv+098rww4vFQCF14DRFQwjTh27pfd 4qGcDiNHqV8+WF4BUkGRq7yJqo+dWxlwSFfshrtVwkoWjuFKUR3bf+QcD8fa0MtBn24f BreHvYKNhk83SPatdDZl1wdoNQ8HjAAMhZuZ3eMZHITtxfaTIdvWbFT/kTy5auW6zxch Alj/TkIYXNu+RshCHY9vR3TzKpTEkBkrPLcscwUk2mPWvhIul3KA4jj+XvHBTsX0wQ8q T8kQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n10-v6si20552237pfb.316.2018.09.10.23.52.20; Mon, 10 Sep 2018 23:52:38 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727771AbeIKLth convert rfc822-to-8bit (ORCPT + 99 others); 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] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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);