Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4695076imw; Tue, 12 Jul 2022 12:35:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vxIgQOpLo82UbEfaJYvA+mb3jeGgg7Quujm4TLtmIEgbFi43UE+GPQkTj4jaM/NPwy7hcU X-Received: by 2002:a05:6a00:1501:b0:525:5d78:ed69 with SMTP id q1-20020a056a00150100b005255d78ed69mr24519665pfu.27.1657654531934; Tue, 12 Jul 2022 12:35:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657654531; cv=none; d=google.com; s=arc-20160816; b=RN0NIHU4+55DbZJAV0MU7oMc2+OhkGqhT6aAjGR8dpPy8UfDlQp5hZfjbEZ4XPNvvN vD/7Yq+xBa+eF67WQfW65uR6jSrYeD33Y7Ax1ooEjR6rf/qV2g5Yn0/ad9xdXf6rBssZ RiYRlLk/S6/UvFnuYaGt2B5AoIeClxcWTrNNg0F5E1JX/AXgD7Y8FuhJ0HXIKHVQ8Upg Xod++pyhyHoO8pAMQd878zVlpUBZjwhczD3l/yKs02ime4YAuMy+4/i6xeQw/j4o7SCh WU/6ACMjbofs8/A5+EXlxub+oPRivt8Y7wTABo6eiQx3bvq6O+surBsjtuVT8mtmkmqV rl2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=OEY4SCaZOdzoodOggn7g2GbcN708PzYV4oDIBcVzPs8=; b=O/GUnkUfD2/B/TT78LUcH/2hz3YtU700ADFWgCNgaIE5dKgCPQjXCIJIYxazuUGfyN QHwxyedNAAKQyU0KANS6Ocp7abUp+245fV7QKhEMhW5m1dogQs50zN0Hqd0PFP1nbXZS wpIjte73sn9/y/g4Ak1HIuWQhAgB0VhK6NWGAIo7RIjDoYemJmXAAGF8V8JJ1De2uiec 9u0pdtwgcheb9qBpy/nNSqYZCDjcd4lGscF2sMbOWAt9MdDK1MmRBe0ydkvnIPAO+uh6 L5t88FFTHOLpOuPYf6JryTgpKFy8AxI8GFtNkwTTOTd21P02tyST2FH0ATGlFxch6jWK F4Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=jO0HxQK9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lk11-20020a17090b33cb00b001ecfcc0a97dsi23588931pjb.71.2022.07.12.12.35.20; Tue, 12 Jul 2022 12:35:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=jO0HxQK9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230470AbiGLSqb (ORCPT + 99 others); Tue, 12 Jul 2022 14:46:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234302AbiGLSpp (ORCPT ); Tue, 12 Jul 2022 14:45:45 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0C624DC18D; Tue, 12 Jul 2022 11:42:41 -0700 (PDT) Received: from pwmachine.numericable.fr (240.119.92.79.rev.sfr.net [79.92.119.240]) by linux.microsoft.com (Postfix) with ESMTPSA id C2BDC20B4774; Tue, 12 Jul 2022 11:42:37 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C2BDC20B4774 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1657651360; bh=OEY4SCaZOdzoodOggn7g2GbcN708PzYV4oDIBcVzPs8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jO0HxQK9lvP9P+x/pmco0rGE7YwmDMbKnHN9PE/y9aNWLDlBJHjKtN9DcLSmbiT61 10Pz2tcdcPzN4DyZjYkO9pIfoRR/Waf0csSxLbC6bS8Dhbo9upOeYFkG7IWnbnEhxh THDv77/yuDXeTGM8MzAG+uHF64+F2UbfD9SGsgpk= From: Francis Laniel To: bpf@vger.kernel.org Cc: Francis Laniel , Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , linux-kernel@vger.kernel.org (open list) Subject: [RFC PATCH v1 1/1] bpftool: Add generating command to C dumped file. Date: Tue, 12 Jul 2022 20:42:25 +0200 Message-Id: <20220712184225.52429-2-flaniel@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220712184225.52429-1-flaniel@linux.microsoft.com> References: <20220712184225.52429-1-flaniel@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This commit adds the following lines to file generated by dump: /* * File generated by bpftool using: * bpftool btf dump file /sys/kernel/btf/vmlinux format c * DO NOT EDIT. */ This warns users to not edit the file and documents the command used to generate the file. Signed-off-by: Francis Laniel --- tools/bpf/bpftool/btf.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c index 7e6accb9d9f7..eecfc27370c3 100644 --- a/tools/bpf/bpftool/btf.c +++ b/tools/bpf/bpftool/btf.c @@ -415,7 +415,8 @@ static void __printf(2, 0) btf_dump_printf(void *ctx, } static int dump_btf_c(const struct btf *btf, - __u32 *root_type_ids, int root_type_cnt) + __u32 *root_type_ids, int root_type_cnt, + int argc, char **argv) { struct btf_dump *d; int err = 0, i; @@ -425,6 +426,14 @@ static int dump_btf_c(const struct btf *btf, if (err) return err; + printf("/*\n"); + printf(" * File generated by bpftool using:\n"); + printf(" * bpftool btf dump"); + for (i = 0; i < argc; i++) + printf(" %s", argv[i]); + printf("\n"); + printf(" * DO NOT EDIT.\n"); + printf(" */\n"); printf("#ifndef __VMLINUX_H__\n"); printf("#define __VMLINUX_H__\n"); printf("\n"); @@ -507,8 +516,10 @@ static bool btf_is_kernel_module(__u32 btf_id) static int do_dump(int argc, char **argv) { struct btf *btf = NULL, *base = NULL; + char **orig_argv = argv; __u32 root_type_ids[2]; int root_type_cnt = 0; + int orig_argc = argc; bool dump_c = false; __u32 btf_id = -1; const char *src; @@ -649,7 +660,8 @@ static int do_dump(int argc, char **argv) err = -ENOTSUP; goto done; } - err = dump_btf_c(btf, root_type_ids, root_type_cnt); + err = dump_btf_c(btf, root_type_ids, root_type_cnt, + orig_argc, orig_argv); } else { err = dump_btf_raw(btf, root_type_ids, root_type_cnt); } -- 2.25.1