From: Namhyung Kim <namhyung@gmail.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Alan Maguire <alan.maguire@oracle.com>
Cc: dwarves@vger.kernel.org
Subject: [PATCH] btf_encoder: Add O_TRUNC to btf_encoder__write_raw_file()
Date: Fri, 17 Jul 2026 11:01:05 -0700 [thread overview]
Message-ID: <20260717180105.136705-1-namhyung@gmail.com> (raw)
When it creates a raw file, it should truncate the content in case there
is an old file with the same name. Otherwise it may have some garbage
at the end of the file and it could make the kernel fail to verify BTF.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
btf_encoder.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/btf_encoder.c b/btf_encoder.c
index d36984a..b810dd5 100644
--- a/btf_encoder.c
+++ b/btf_encoder.c
@@ -1878,7 +1878,7 @@ static int btf_encoder__write_raw_file(struct btf_encoder *encoder)
return -1;
}
- fd = open(filename, O_WRONLY | O_CREAT, 0640);
+ fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0640);
if (fd < 0) {
fprintf(stderr, "%s: Couldn't open %s for writing the raw BTF info: %s\n", __func__, filename, strerror(errno));
return -1;
--
2.55.0.229.g6434b31f56-goog
next reply other threads:[~2026-07-17 18:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-17 18:01 Namhyung Kim [this message]
2026-07-23 17:03 ` [PATCH] btf_encoder: Add O_TRUNC to btf_encoder__write_raw_file() Alan Maguire
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260717180105.136705-1-namhyung@gmail.com \
--to=namhyung@gmail.com \
--cc=acme@kernel.org \
--cc=alan.maguire@oracle.com \
--cc=dwarves@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox