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: 7744281 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: X-Original-To: patchwork-linux-arm-msm@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 E01BB9F39D for ; Wed, 2 Dec 2015 10:24:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 168602063C for ; Wed, 2 Dec 2015 10:24:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 42C932056E for ; Wed, 2 Dec 2015 10:24:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752561AbbLBKYC (ORCPT ); Wed, 2 Dec 2015 05:24:02 -0500 Received: from pandora.arm.linux.org.uk ([78.32.30.218]:47338 "EHLO pandora.arm.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751762AbbLBKYA (ORCPT ); Wed, 2 Dec 2015 05:24:00 -0500 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 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 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) Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable 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; }