From patchwork Wed Dec 2 10:23:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King - ARM Linux X-Patchwork-Id: 7744331 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 392639F39D for ; Wed, 2 Dec 2015 10:26:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 566FE2063E for ; Wed, 2 Dec 2015 10:26:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5ACD42063C for ; Wed, 2 Dec 2015 10:26:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1a44aO-00059N-0z; Wed, 02 Dec 2015 10:24:32 +0000 Received: from pandora.arm.linux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:1be6]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a44aK-0004yM-T1 for linux-arm-kernel@lists.infradead.org; Wed, 02 Dec 2015 10:24:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=Z0BXAXLgyF4WxjS12BhUSPMLu0pDOK8+s8CHMNVoLy4=; b=QcoisPtDBT3SUgGDpwsWrV7CXvu2/rjh7Lx14rq91j1TU2GUcE8w8I1LVkdNPfB/JGWEDhCxs0MYIYZkrEIEeEtiuGQqRXrLUllIT+eCoOulCdcB59YvVRv7MSFHOEKI6Jf7YuwpPvxCpzTrRmgfXZ6Ggq/GliDQBqKpafxSEZ8=; Received: from n2100.arm.linux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:4f86]:40079) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1a44Zb-0003x2-Qc; Wed, 02 Dec 2015 10:23:43 +0000 Received: from linux by n2100.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1a44ZY-0006Ae-9h; Wed, 02 Dec 2015 10:23:40 +0000 Date: Wed, 2 Dec 2015 10:23:39 +0000 From: Russell King - ARM Linux To: Steven Rostedt Subject: Re: [PATCH v2 1/2] scripts: Add a recorduidiv program Message-ID: <20151202102339.GB8644@n2100.arm.linux.org.uk> References: <20151125234711.GT8644@n2100.arm.linux.org.uk> <565C6714.802@suse.com> <20151130153208.GR8644@n2100.arm.linux.org.uk> <565C6DE9.2020302@suse.com> <565DC5A9.2010305@suse.cz> <20151201161944.GX8644@n2100.arm.linux.org.uk> <20151201114929.655433a2@gandalf.local.home> <20151201171014.GY8644@n2100.arm.linux.org.uk> <20151201122212.474afce5@gandalf.local.home> <20151201181643.GZ8644@n2100.arm.linux.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20151201181643.GZ8644@n2100.arm.linux.org.uk> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151202_022429_337153_9C3CDBFE X-CRM114-Status: GOOD ( 18.37 ) X-Spam-Score: -4.3 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Marek , Thomas Petazzoni , =?iso-8859-1?Q?M=E5ns_Rullg=E5rd?= , Arnd Bergmann , linux-kbuild@vger.kernel.org, linux-arm-msm@vger.kernel.org, Nicolas Pitre , Stephen Boyd , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Dec 01, 2015 at 06:16:43PM +0000, Russell King - ARM Linux wrote: > On Tue, Dec 01, 2015 at 12:22:12PM -0500, Steven Rostedt wrote: > > I guess another solution is to do a copy instead of modifying in place > > if it detects the multiple hard link? > > That would be the "transparent" solution. If you think it's worth > persuing, I'll have a go at fixing recordmcount to do that. Well, copying the file is easy - I've tested this and the linker appears happy with the result: scripts/recordmcount.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) Reviewed-by: Steven Rostedt 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; }