From 09122e2be0f49f339590e99783d14f7279d15cda Mon Sep 17 00:00:00 2001 From: Sviatoslav Peleshko Date: Thu, 8 Aug 2024 23:51:35 +0300 Subject: [PATCH] brw,elk: Fix opening flags on dumping shader binaries Truncation is needed for overwriting correctly in cases when old file is bigger than the one we want to dump (e.g. when the old one was edited inplace). Also, creation permissions are way too broad. Fixes: 4f41c44d ("intel/compiler: Add variable to dump binaries of all compiled shaders") Signed-off-by: Sviatoslav Peleshko Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/compiler/brw_eu.c | 2 +- src/intel/compiler/elk/elk_eu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/intel/compiler/brw_eu.c b/src/intel/compiler/brw_eu.c index ba5779f26ea..0e9f24e3026 100644 --- a/src/intel/compiler/brw_eu.c +++ b/src/intel/compiler/brw_eu.c @@ -310,7 +310,7 @@ void brw_dump_shader_bin(void *assembly, int start_offset, int end_offset, debug_get_option_shader_bin_dump_path(), identifier); - int fd = open(name, O_CREAT | O_WRONLY, 0777); + int fd = open(name, O_CREAT | O_WRONLY | O_TRUNC, 0644); ralloc_free(name); if (fd < 0) diff --git a/src/intel/compiler/elk/elk_eu.c b/src/intel/compiler/elk/elk_eu.c index 04338026c2a..39381f3200f 100644 --- a/src/intel/compiler/elk/elk_eu.c +++ b/src/intel/compiler/elk/elk_eu.c @@ -376,7 +376,7 @@ void elk_dump_shader_bin(void *assembly, int start_offset, int end_offset, debug_get_option_shader_bin_dump_path(), identifier); - int fd = open(name, O_CREAT | O_WRONLY, 0777); + int fd = open(name, O_CREAT | O_WRONLY | O_TRUNC, 0644); ralloc_free(name); if (fd < 0)