From d9608d4a5254abdd5523486aa03b6e4968cedd8d 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: (cherry picked from commit 09122e2be0f49f339590e99783d14f7279d15cda) --- .pick_status.json | 2 +- src/intel/compiler/brw_eu.c | 2 +- src/intel/compiler/elk/elk_eu.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 28ddd74f87c..70215634d15 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -244,7 +244,7 @@ "description": "brw,elk: Fix opening flags on dumping shader binaries", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "4f41c44df22116d351d06c3a03711e8ee68a7869", "notes": null diff --git a/src/intel/compiler/brw_eu.c b/src/intel/compiler/brw_eu.c index ffacae05d1b..9cf2b1c97f8 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)