linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: rmk+kernel@arm.linux.org.uk (Russell King)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] scripts: recordmcount: break hardlinks
Date: Fri, 11 Dec 2015 12:09:03 +0000	[thread overview]
Message-ID: <E1a7MVT-0000et-62@rmk-PC.arm.linux.org.uk> (raw)
In-Reply-To: <20151202090517.432556a4@gandalf.local.home>

recordmcount edits the file in-place, which can cause problems when
using ccache in hardlink mode.  Arrange for recordmcount to break a
hardlinked object.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
---
Steven, sorry it took a while to get this out...

 scripts/recordmcount.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index 698768bdc581..91705ef30402 100644
--- a/scripts/recordmcount.c
+++ b/scripts/recordmcount.c
@@ -211,6 +211,20 @@ static void *mmap_file(char const *fname)
 		addr = umalloc(sb.st_size);
 		uread(fd_map, addr, sb.st_size);
 	}
+	if (sb.st_nlink != 1) {
+		/* file is hard-linked, break the hard link */
+		close(fd_map);
+		if (unlink(fname) < 0) {
+			perror(fname);
+			fail_file();
+		}
+		fd_map = open(fname, O_RDWR | O_CREAT, sb.st_mode);
+		if (fd_map < 0) {
+			perror(fname);
+			fail_file();
+		}
+		uwrite(fd_map, addr, sb.st_size);
+	}
 	return addr;
 }
 
-- 
2.1.0

  reply	other threads:[~2015-12-11 12:09 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-25 21:51 [PATCH v2 0/2] ARM: Use udiv/sdiv for __aeabi_{u}idiv library functions Stephen Boyd
2015-11-25 21:51 ` [PATCH v2 1/2] scripts: Add a recorduidiv program Stephen Boyd
2015-11-25 23:47   ` Russell King - ARM Linux
2015-11-30 15:11     ` Michal Marek
2015-11-30 15:32       ` Russell King - ARM Linux
2015-11-30 15:40         ` Michal Marek
2015-12-01 16:07           ` Michal Marek
2015-12-01 16:19             ` Russell King - ARM Linux
2015-12-01 16:43               ` Michal Marek
2015-12-01 16:49               ` Steven Rostedt
2015-12-01 17:10                 ` Russell King - ARM Linux
2015-12-01 17:22                   ` Steven Rostedt
2015-12-01 18:16                     ` Russell King - ARM Linux
2015-12-01 21:39                       ` Michal Marek
2015-12-02 10:23                       ` Russell King - ARM Linux
2015-12-02 14:05                         ` Steven Rostedt
2015-12-11 12:09                           ` Russell King [this message]
2015-12-11 14:31                             ` [PATCH] scripts: recordmcount: break hardlinks Steven Rostedt
2015-12-11 14:45                               ` Russell King - ARM Linux
2015-12-11 15:08                                 ` Steven Rostedt
2015-12-11 18:10                                 ` Steven Rostedt
2015-12-11 18:33                                   ` Russell King - ARM Linux
2015-12-11 18:51                                     ` Steven Rostedt
2015-12-11 18:58                                       ` Russell King - ARM Linux
2015-12-11 19:28                                         ` Steven Rostedt
2015-11-25 21:51 ` [PATCH v2 2/2] ARM: Replace calls to __aeabi_{u}idiv with udiv/sdiv instructions Stephen Boyd
2015-11-25 23:09   ` Nicolas Pitre
2015-11-26  0:05     ` Russell King - ARM Linux
2015-11-26  0:07     ` Måns Rullgård
2015-11-26  0:44       ` Nicolas Pitre
2015-11-26  0:50         ` Måns Rullgård
2015-11-26  1:28           ` Russell King - ARM Linux
2015-11-26  2:19             ` Måns Rullgård
2015-11-26  5:32               ` Nicolas Pitre
2015-11-26 12:41                 ` Måns Rullgård
2015-11-26  0:08   ` Russell King - ARM Linux

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=E1a7MVT-0000et-62@rmk-PC.arm.linux.org.uk \
    --to=rmk+kernel@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).