From patchwork Tue Feb 27 18:48:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 776282 Delivered-To: patch@linaro.org Received: by 2002:adf:a113:0:b0:33d:f458:43ce with SMTP id o19csp308974wro; Tue, 27 Feb 2024 10:51:00 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXXhkiPwrC4mp8Y49pVJD4dh9I2lbdQWup+zW13A8rAQ/MSSzJguF9GUA1AmMsVDg6QoW0NI695z9a9Da4Z2lFm X-Google-Smtp-Source: AGHT+IHAsEnwguWABNw4zcubWYBRSoxPQ+ZpvkViCya2Dg7KUuFv36JWrqtkh59XTsW1l3dzPLLl X-Received: by 2002:a05:6808:180e:b0:3c1:b603:d290 with SMTP id bh14-20020a056808180e00b003c1b603d290mr908828oib.25.1709059860011; Tue, 27 Feb 2024 10:51:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709059859; cv=none; d=google.com; s=arc-20160816; b=bJ5vjGi36f7k/5LRTOXSXrQbzu9dE/GZmYYwqyYV6gVZBBLnj9bLXW5naJlQGV5Lgx KRAg17qh/PGkKPN6pb3xg0cQFlCOugAMGayTQPQK+02d/6A5/yBhBrPdaw8iCv/iTcEC Ws3P0kf7Oo6ujpaVCHJSdIRNIl1i0T0rOfFhR6+WhtI5qp9h56O+n1L9DWE0iYrUKELY qLYOeTEDEZNYW1zDW6Q4h4DVM6OZzyBlO4tdr7ME3/GoEo4p81vBJHE0HYknByuBi5h4 FdY8bPj3Ykx607BTKSPiFDMlxXKzoD6K+bKLUbsYWfIKgNFDmnztbpXBs5RoCCd33RXH XdzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zYkpQqoaMHDWxrt9KPP15xrK5H9LSGOtZoW36Ee0L04=; fh=Vvliz9ENSk/yCY42nG87aL5dW+Zo0lduSx74U3lH2V8=; b=QQdb6SsnZ3Glk0bVQGGaDc73b+YFuvmzQMj3qeYjMmZfJSIL/UvYcQ/e/NY67I6FQc iZz8J00U4vP4IwQOEyntbvHfeYge5qhMcsTAzM5OwMBjbbMsA66iJpcaVD46HTDhtf8/ zWLZzOW1hUOEqjl2AZoUanNGy5TPds6/uFBhFqG7igiZbmhEkNnfbCUmANdcGNBjN9lQ N7ZapQrtXhLB40KfyJjH8hMEjUz9+ySWvr4TMOd5gDfeZSjrAfbrhxU+WLOvhLTdL1q0 8hCLTr3gCxyAjXg82z25ItuP5tQBuogoqW7SDqxBqUoyu294qObvOYDmKHsq5cMnelaG O/EA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VA8hDsFt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l1-20020a05620a210100b007874f43dd5dsi7719091qkl.445.2024.02.27.10.50.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Feb 2024 10:50:59 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VA8hDsFt; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rf2VW-0006YM-NC; Tue, 27 Feb 2024 13:48:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rf2VV-0006Xh-0F for qemu-devel@nongnu.org; Tue, 27 Feb 2024 13:48:49 -0500 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rf2VT-0001U9-FV for qemu-devel@nongnu.org; Tue, 27 Feb 2024 13:48:48 -0500 Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3c1af1e8b7eso445288b6e.2 for ; Tue, 27 Feb 2024 10:48:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709059726; x=1709664526; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zYkpQqoaMHDWxrt9KPP15xrK5H9LSGOtZoW36Ee0L04=; b=VA8hDsFtP/U5ZrVOFtU3Ar9rJaOaPmhzPwUj6uOh0SB5bc7mAJN+uFnI0GiTccwyJ+ mTrwRMP81OXovg9aYIRzXYnbsCZwerjMnyaDXi8X6URpMvgEAYI7znB6oV8brnJWdoWK rWtM64LlFJAuM8Cugkhvg6j4XRXLXi3NnqSC8YOdzxP3hgkcCuPhuI3H79Jk5Nobmw0s m3osep7lFdJ0eNTsZ9YO/SDtgq/RqrsU/jvWZHeiyrZAl6Ca8vu4JzsOAnm01LiFdDp5 w7yRLACAqp5G7OedZWCpql1Br9VTY31BHWeofdTS6ZLRgP8x4kP/uSVwqr4zjw1SEse9 u+Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709059726; x=1709664526; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zYkpQqoaMHDWxrt9KPP15xrK5H9LSGOtZoW36Ee0L04=; b=Ri5/wioFFVC8qKQ6eF9v5lUZ6s2QR3c4GG0NBse32ufmFYCjOS8I5zTMn4DJorgEdJ EtbnMaLRF5WaC3NxV90wrVbfKX64M7Nu0vaS8wABZn2O/3NWNrHdq3mcyoIYKY37gpKD R6tDRtJuaHQEQ+jw9ZRBKXy0jQjMtUCNjg2EGjfepSiGRebY2ahfk+hWg15svcLzA7L5 iPD220KHKaGvXHfQn+R3w4dhEdzNeFhdL3cCkjXPLa28bH1WNs91Ygq6fxUxsKGIr2lS 3SuloKwbLz7V5NN5bMa9l4t+qLBYV5+E3YaaYktjsjI8JH+7PI8nsNITQeO0jfOZ5aYK 0RbA== X-Gm-Message-State: AOJu0YwQs/HIi+oV10yYXGt8qP+rmqOJDj83+83yjitsZIEkbnfv2qNz iTP7iIwPacC2d8TjOvTYCvR2hEnzpsqIunbPml5xiXyYfFfD+xt0hpfwM2S0+5cEgWavD8Zah0G U X-Received: by 2002:aca:130f:0:b0:3c1:6526:1342 with SMTP id e15-20020aca130f000000b003c165261342mr2910324oii.45.1709059726331; Tue, 27 Feb 2024 10:48:46 -0800 (PST) Received: from stoup.. (098-147-055-211.res.spectrum.com. [98.147.55.211]) by smtp.gmail.com with ESMTPSA id h26-20020aa786da000000b006e555d40951sm533465pfo.188.2024.02.27.10.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 10:48:45 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org Subject: [PATCH 07/14] linux-user/elfload: Truncate core file on open Date: Tue, 27 Feb 2024 08:48:26 -1000 Message-Id: <20240227184833.193836-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240227184833.193836-1-richard.henderson@linaro.org> References: <20240227184833.193836-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22f; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org While we usually create a new corefile, truncate otherwise. Signed-off-by: Richard Henderson --- linux-user/elfload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 877799e9c7..16dd08a828 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -4652,7 +4652,7 @@ static int elf_core_dump(int signr, const CPUArchState *env) { g_autofree char *corefile = core_dump_filename(ts); - fd = open(corefile, O_WRONLY | O_CREAT, + fd = open(corefile, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); } if (fd < 0) {