From nobody Sun Dec 12 19:01:16 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1842218D351C; Sun, 12 Dec 2021 19:01:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JBvB45cHGz3r5t; Sun, 12 Dec 2021 19:01:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A1C58265AC; Sun, 12 Dec 2021 19:01:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BCJ1GLM028894; Sun, 12 Dec 2021 19:01:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BCJ1Gd1028893; Sun, 12 Dec 2021 19:01:16 GMT (envelope-from git) Date: Sun, 12 Dec 2021 19:01:16 GMT Message-Id: <202112121901.1BCJ1Gd1028893@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: e048bd5c0954 - stable/12 - elfctl: avoid touching file if no change made List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e048bd5c0954814f72e04df8b7b7ff183da45a19 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639335676; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5BoyJ/H3Ccl7YLrfmOXzol9gZl18u1j7Sb7sOZAYits=; b=uoL4cQgjGKnMXKKTyTpu0t0siNRTDIzD8g8WbaT8nldoNtDhul39+c0AKNRbxcFTFNeXkg BYXUWcw3E/nP60ZJOJ7O+lQN39/AtVj9EQ7+wO88fa+P90/Fsu445jpD8ONmXEbwOmZVQw xmFW3LL0DMQ5/Ds2UEheIokMtaE9HP2x6O4eVLCVPLgMo+8Fl/Za1O0WLlLf+YrrvB97du RcOzjLhU6zdjxNCDSNSSzGqQbeXlIBeq5AVeDwQg+bArSb+l3p8EYD5bgPdRqRPnDPrg1L gCqDbLIl/wfGiNDCaVZ5vKDGmmZDkdA/c4+ei/Mf5GdsIf1c8L2tidLCD+ZHHw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639335676; a=rsa-sha256; cv=none; b=hJioxCtJor/k1wwZ7SKRJ27nZz58bOqfBH4IzHmuSuv8e776RyIpPMbc65oD9nGHLLILDJ emK6zj0DyeHqRxPm0gutxilQNbADRT/NigqRp/ZB7T2A+aDpWv2s/k0UMvrMp5azPFMjDe gzbc4Hqc9t1nAsQ+UUL0DzHdda5Re9ualCvN672MtlGdpPAjxLN+Hz7PcQaISdyJ7zEON5 yJlcoXHLcX/ieuk2L7EOlw0Pj5mgNDco830xF2mU7M9+NnEeYEVWlVLzbaAio72cqhzs5/ t7+5M5rSY4f1JIBiiiwgXBM3xXk7Du4FpXJF1NOH6nZLZFEgiZHBrAafjef4PQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=e048bd5c0954814f72e04df8b7b7ff183da45a19 commit e048bd5c0954814f72e04df8b7b7ff183da45a19 Author: Ed Maste AuthorDate: 2021-05-25 18:25:18 +0000 Commit: Ed Maste CommitDate: 2021-12-12 18:58:23 +0000 elfctl: avoid touching file if no change made Suggested by: brooks Reviewed by: brooks, markj MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D30452 (cherry picked from commit 3f2508b7f3855102abed99b846e30e728ba3d04d) (cherry picked from commit 5ceb90aa667afbd0941f045073d54aea35d40f1b) --- usr.bin/elfctl/elfctl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/usr.bin/elfctl/elfctl.c b/usr.bin/elfctl/elfctl.c index 205be39fadc7..6f23b6a94501 100644 --- a/usr.bin/elfctl/elfctl.c +++ b/usr.bin/elfctl/elfctl.c @@ -290,7 +290,7 @@ convert_to_feature_val(char *feature_str, uint32_t *feature_val) static bool edit_file_features(Elf *elf, int phcount, int fd, char *val) { - uint32_t features; + uint32_t features, prev_features; uint64_t off; if (!get_file_features(elf, phcount, fd, &features, &off)) { @@ -298,8 +298,12 @@ edit_file_features(Elf *elf, int phcount, int fd, char *val) return (false); } + prev_features = features; if (!convert_to_feature_val(val, &features)) return (false); + /* Avoid touching file if no change. */ + if (features == prev_features) + return (true); if (lseek(fd, off, SEEK_SET) == -1 || write(fd, &features, sizeof(features)) <