Assaf Gordon <assafgordon@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Assaf Gordon <assafgordon@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at 25342) by debbugs.gnu.org; 8 Jan 2017 00:30:00 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 07 19:30:00 2017 Received: from localhost ([127.0.0.1]:46347 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1cQ1N2-0002Ag-8e for submit <at> debbugs.gnu.org; Sat, 07 Jan 2017 19:30:00 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:57736) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eggert@HIDDEN>) id 1cQ1N0-0002AT-UT for 25342 <at> debbugs.gnu.org; Sat, 07 Jan 2017 19:29:59 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id D481316005D; Sat, 7 Jan 2017 16:29:52 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id wNYJ33llnw3V; Sat, 7 Jan 2017 16:29:52 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 2E2D5160063; Sat, 7 Jan 2017 16:29:52 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id ujIaTz4WgXrL; Sat, 7 Jan 2017 16:29:52 -0800 (PST) Received: from [192.168.1.9] (unknown [47.153.178.162]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id F345C16005D; Sat, 7 Jan 2017 16:29:51 -0800 (PST) Subject: Re: bug#25342: GNU coreutils: race condition in "ln -f source dest" To: Mirsad Goran Todorovac <mtodorov3_69@HIDDEN>, "25342 <at> debbugs.gnu.org" <25342 <at> debbugs.gnu.org> References: <727818896.5504359.1483394315468.ref@HIDDEN> <727818896.5504359.1483394315468@HIDDEN> <f0b8dd92-16d5-7037-def7-764bba990ce3@HIDDEN> <1871443711.5629967.1483414377142@HIDDEN> <eab724e3-39e7-e141-b5cb-ac61839de4cd@HIDDEN> <99417190.6944768.1483563757518@HIDDEN> <9dbe3286-34a6-d5ed-0c6d-f72a57b8a7ef@HIDDEN> <531219774.392636.1483835179998@HIDDEN> From: Paul Eggert <eggert@HIDDEN> Organization: UCLA Computer Science Department Message-ID: <e9f83db5-1a2d-6528-29a5-dfa1c8f8a6d5@HIDDEN> Date: Sat, 7 Jan 2017 16:29:51 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <531219774.392636.1483835179998@HIDDEN> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -3.2 (---) X-Debbugs-Envelope-To: 25342 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.2 (---) Mirsad Goran Todorovac wrote: > Do you think our development team could write a paper on this issue? Then I could justify drawing a schematic diagram?Is it trivial or is there some justified reason to publish and explain in detail? Sorry, I don't know what "development team" you're talking about. I don't see a need to write a paper about it, no. It's just code that needs to be written and tested, that's all.
bug-coreutils@HIDDEN
:bug#25342
; Package coreutils
.
Full text available.Received: (at 25342) by debbugs.gnu.org; 8 Jan 2017 00:26:28 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 07 19:26:28 2017 Received: from localhost ([127.0.0.1]:46343 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1cQ1Jb-00025x-M1 for submit <at> debbugs.gnu.org; Sat, 07 Jan 2017 19:26:27 -0500 Received: from nm25-vm1.bullet.mail.bf1.yahoo.com ([98.139.212.155]:38599) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mtodorov3_69@HIDDEN>) id 1cQ1JZ-00025k-SK for 25342 <at> debbugs.gnu.org; Sat, 07 Jan 2017 19:26:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1483835180; bh=yEolL/yX5bgpcpumqAPp7A5QJmsNMueVfxouEO5lHiI=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=Oddc6vFmV+43LFsJWbjwmT+Y3z5CyYiDMc98vdD6Kxdgidfa24bKjGfniXY/D4plLS/jwljVVW7/V3Ge48kf4ujLrym9FCqQEncGXl4x7VX4OVwBTk/i323bmMGoUSQxgSQmBdXhHCx9ITFiViiT9eG2G4oq+ggBncW+8tAZMQ02GsHDf1FPge9rsq1DgrwKO/TUQx1sc+d3CUVm+hBl/2VMEMXBo4VzNLiiyOnDnCE4rfF/TPbUMZca5oANBFfQVmykgq86aGpkd7TtJMCWb7h37BhPMnutrFBKbTBxNo18kXGAdQ81v22GDtBrSZsgtDlOFq3/oMsJDfI7MPCZNA== Received: from [98.139.170.182] by nm25.bullet.mail.bf1.yahoo.com with NNFMP; 08 Jan 2017 00:26:20 -0000 Received: from [98.139.212.216] by tm25.bullet.mail.bf1.yahoo.com with NNFMP; 08 Jan 2017 00:26:20 -0000 Received: from [127.0.0.1] by omp1025.mail.bf1.yahoo.com with NNFMP; 08 Jan 2017 00:26:20 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 602234.80900.bm@HIDDEN X-YMail-OSG: tbCFbtwVM1m4Q4MOPqiQ.m7Stf4_vs6YJJXn1QIVe_5g7QLiAMYl_C9Da9DRr92 Pz66_kfxb2ArTBVIRN3zCh_FmH.iVjSIgp9v5d49ChcCxij7lNxRVzYSj0ntQD9W0g6Xe7Cc606d FLHJoUnP5Vvop40IBxWdJo4_n3mty9IZKW8fA436PPVkI.5wqPM6GsLmDWnVF9QhjNBQWVehKFVZ xJmP_I0h8HEP3sJhP.MVk5HC9zauqJIDt_GRSU2MraZd4WuZzCkl1.zkX2Ae_02p15WUQbI0sEE. jwVSZfWht5NUB3lnkFwgzyWTxTv7llqwlZLn3.r6A67l8qlBEOQBzs.nVJFyz8bphn_eIL5o8q3a NEVaiR03Q2pnz6EbnrPh7OxjADfXMb59fJd5msl9kqNrePQfXFbrLvqHA84DZHkeoEqiQjLkdHxO V65Ep5oS5GKhvzN0w3Z7Pmq5vnyabPAHvVMKu0Pr8FEpl_SHqBU7AruWMVbsqokao4VQLvYfGBqr 7klk93gL8XVjtssB9C5NqYZe5hg-- Received: from jws400116.mail.bf2.yahoo.com by sendmailws108.mail.bf1.yahoo.com; Sun, 08 Jan 2017 00:26:20 +0000; 1483835180.243 Date: Sun, 8 Jan 2017 00:26:19 +0000 (UTC) From: Mirsad Goran Todorovac <mtodorov3_69@HIDDEN> To: Paul Eggert <eggert@HIDDEN>, "25342 <at> debbugs.gnu.org" <25342 <at> debbugs.gnu.org> Message-ID: <531219774.392636.1483835179998@HIDDEN> In-Reply-To: <9dbe3286-34a6-d5ed-0c6d-f72a57b8a7ef@HIDDEN> References: <727818896.5504359.1483394315468.ref@HIDDEN> <727818896.5504359.1483394315468@HIDDEN> <f0b8dd92-16d5-7037-def7-764bba990ce3@HIDDEN> <1871443711.5629967.1483414377142@HIDDEN> <eab724e3-39e7-e141-b5cb-ac61839de4cd@HIDDEN> <99417190.6944768.1483563757518@HIDDEN> <9dbe3286-34a6-d5ed-0c6d-f72a57b8a7ef@HIDDEN> Subject: Re: bug#25342: GNU coreutils: race condition in "ln -f source dest" MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_392635_1898309003.1483835179996" Content-Length: 8269 X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 25342 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Reply-To: Mirsad Goran Todorovac <mtodorov3_69@HIDDEN> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.8 (--) ------=_Part_392635_1898309003.1483835179996 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable But really, the basic idea is simple: renameat mishandles the case where ol= d and=20 new names are already hard links, and any code based on renameat needs to w= ork=20 around this problem. (We can't easily change renameat's behavior, as the=20 behavior is required by POSIX.) It isn't that simple, since renameat is a no-op if the source and destinati= on=20 are already hard links. So the patch you sent in would not work. Dear Sir, I might have then misinterpreted following paragraph fromman renameat(2) ma= n page: DESCRIPTION =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rename()=C2=A0 renames=C2=A0 a=C2=A0 f= ile,=C2=A0 moving it between directories if required.=C2=A0 Any other hard =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 links to the file (as created using li= nk(2)) are unaffected.=C2=A0 Open file descriptors for =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 oldpath are also unaffected. =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 If newpath already exists, it will be = atomically replaced (subject to a few conditions; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 see ERRORS below), so that there is no= point at which=C2=A0 another=C2=A0 process=C2=A0 attempting=C2=A0 to =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 access newpath will find it missing. =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 If=C2=A0 oldpath=C2=A0 and=C2=A0 newpa= th=C2=A0 are=C2=A0 existing=C2=A0 hard=C2=A0 links=C2=A0 referring to the s= ame file, then =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 rename() does nothing, and returns a s= uccess status. In my test code, renamat (AT_CWDFD, oldpath, AT_CWDFD, newpath, flags); suc= cessfully renames directory entry, yet inode number name in dir refers to i= s unchanged. Do you think our development team could write a paper on this issue? Then I= could justify drawing a schematic diagram?Is it trivial or is there some j= ustified reason to publish and explain in detail? Thank you very much. Regards, M.T. =20 On Thursday, January 5, 2017 8:57 AM, Paul Eggert <eggert@HIDDEN> = wrote: =20 Mirsad Goran Todorovac wrote: > Please consider the trace below. As I don't know what you're tracing, I don't know what to consider. But really, the basic idea is simple: renameat mishandles the case where ol= d and=20 new names are already hard links, and any code based on renameat needs to w= ork=20 around this problem. (We can't easily change renameat's behavior, as the=20 behavior is required by POSIX.) =20 ------=_Part_392635_1898309003.1483835179996 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <html><head></head><body><div style=3D"color:#000; background-color:#fff; f= ont-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, = sans-serif;font-size:13px"><div id=3D"yui_3_16_0_ym19_1_1483832764759_7311"= dir=3D"ltr"><font id=3D"yui_3_16_0_ym19_1_1483832764759_7529" color=3D"#44= 0062">But really, the basic idea is simple: renameat mishandles the case wh= ere old and <br id=3D"yui_3_16_0_ym19_1_1483832764759_7405" clear=3D"none">= new names are already hard links, and any code based on renameat needs to w= ork <br id=3D"yui_3_16_0_ym19_1_1483832764759_7406" clear=3D"none">around t= his problem. (We can't easily change renameat's behavior, as the <br id=3D"= yui_3_16_0_ym19_1_1483832764759_7407" clear=3D"none">behavior is required b= y POSIX.)</font></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_148383276475= 9_7667"><font id=3D"yui_3_16_0_ym19_1_1483832764759_7529" color=3D"#440062"= ><br></font></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483832764759_75= 27"><font color=3D"#440062">It isn't that simple, since renameat is a no-op= if the source and destination <br id=3D"yui_3_16_0_ym19_1_1483832764759_76= 53" clear=3D"none">are already hard links. So the patch you sent in would n= ot work.</font></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483832764759= _7409"><br></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483832764759_769= 4">Dear Sir,</div><div dir=3D"ltr"><br></div><div dir=3D"ltr">I might have = then misinterpreted following paragraph fromman renameat(2) man page:</div>= <div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483832764759_7768"><br></div><div= dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483832764759_7767">DESCRIPTION<br id= =3D"yui_3_16_0_ym19_1_1483832764759_7823"> &nb= sp; rename() renames a file, moving it between dire= ctories if required. Any other hard<br id=3D"yui_3_16_0_ym19_1_148383= 2764759_7824"> links to the file (as cr= eated using link(2)) are unaffected. Open file descriptors for<br id= =3D"yui_3_16_0_ym19_1_1483832764759_7825"> &nb= sp; oldpath are also unaffected.<br id=3D"yui_3_16_0_ym19_1_1483832764759_7= 826"><br id=3D"yui_3_16_0_ym19_1_1483832764759_7827"> &nbs= p; If newpath already exists, it will be atomically replaced (s= ubject to a few conditions;<br id=3D"yui_3_16_0_ym19_1_1483832764759_7828">= see ERRORS below), so that there is no= point at which another process attempting to<br id= =3D"yui_3_16_0_ym19_1_1483832764759_7829"> &nb= sp; access newpath will find it missing.<br id=3D"yui_3_16_0_ym19_1_1483832= 764759_7830"><br id=3D"yui_3_16_0_ym19_1_1483832764759_7831"> &n= bsp; <b id=3D"yui_3_16_0_ym19_1_1483832764759_7889"> If&nb= sp; oldpath and newpath are existing <font id= =3D"yui_3_16_0_ym19_1_1483832764759_8141" color=3D"#9d1811"> hard lin= ks referring to the <font face=3D"Courier New, courier, monaco, monos= pace, sans-serif">same file</font></font>, then<br id=3D"yui_3_16_0_ym19_1_= 1483832764759_7832"> rename() does noth= ing, and returns a success status.<br id=3D"yui_3_16_0_ym19_1_1483832764759= _7833"></b><br id=3D"yui_3_16_0_ym19_1_1483832764759_7834">In my test code,= renamat (AT_CWDFD, oldpath, AT_CWDFD, newpath, flags); successfully rename= s directory entry, yet inode number name in dir refers to is unchanged.</di= v><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483832764759_8008"><br></div><d= iv dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483832764759_8252">Do you think our= development team could write a paper on this issue? Then I could justify d= rawing a schematic diagram?</div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1= 483832764759_8143">Is it trivial or is there some justified reason to publi= sh and explain in detail?</div><div dir=3D"ltr"><br></div><div dir=3D"ltr" = id=3D"yui_3_16_0_ym19_1_1483832764759_8254">Thank you very much.</div><div = dir=3D"ltr"><br></div><div dir=3D"ltr">Regards,<br></div><div dir=3D"ltr">M= .T.<br></div> <div class=3D"qtdSeparateBR"><br><br></div><div class=3D"yaho= o_quoted" style=3D"display: block;"> <div style=3D"font-family: HelveticaNe= ue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size:= 13px;"> <div style=3D"font-family: HelveticaNeue, Helvetica Neue, Helvetic= a, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir=3D"ltr"><f= ont size=3D"2" face=3D"Arial"> On Thursday, January 5, 2017 8:57 AM, Paul E= ggert <eggert@HIDDEN> wrote:<br></font></div> <br><br> <div cla= ss=3D"y_msg_container">Mirsad Goran Todorovac wrote:<div class=3D"yqt234850= 9626" id=3D"yqtfd51743"><br clear=3D"none">> Please consider the trace b= elow.</div><br clear=3D"none"><br clear=3D"none">As I don't know what you'r= e tracing, I don't know what to consider.<br clear=3D"none"><br clear=3D"no= ne">But really, the basic idea is simple: renameat mishandles the case wher= e old and <br clear=3D"none">new names are already hard links, and any code= based on renameat needs to work <br clear=3D"none">around this problem. (W= e can't easily change renameat's behavior, as the <br clear=3D"none">behavi= or is required by POSIX.)<div class=3D"yqt2348509626" id=3D"yqtfd83701"><br= clear=3D"none"></div><br><br></div> </div> </div> </div></div></body></h= tml> ------=_Part_392635_1898309003.1483835179996--
bug-coreutils@HIDDEN
:bug#25342
; Package coreutils
.
Full text available.Received: (at 25342) by debbugs.gnu.org; 5 Jan 2017 09:30:52 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 05 04:30:52 2017 Received: from localhost ([127.0.0.1]:41747 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1cP4Nn-0004Ef-FG for submit <at> debbugs.gnu.org; Thu, 05 Jan 2017 04:30:51 -0500 Received: from nm2-vm1.bullet.mail.bf1.yahoo.com ([98.139.213.158]:55985) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mtodorov3_69@HIDDEN>) id 1cP4Nl-0004EN-5Z for 25342 <at> debbugs.gnu.org; Thu, 05 Jan 2017 04:30:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1483608643; bh=DnkyAiiRMB91X66Rygw0+czwZSkV/rHWF8d6wFouxqY=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=l5wJW9xPtAJ+dbYhcA3NOsLgZ1l2FZN3m0hicgrvtEHSW4DBiq7rax022cNaKqS7mEmJkQHAhNj7RWBe1oMt+dEZ4OF6lbJh/gUuOBurVrqfaron/eVtg3vMFtSB9arKc8nX27V8z6lwOzdupdaBZMR8hZM93ahOoDlA6EKAn3AyrL2T6pKnJNZrXHJHOYhJmTQa0+497io1eGtR8bVoXnv4hjO1hLlIR5xtEMfEZ+WaCOGg17Z8OBAdk8pgc+x3/ltlEuShp2hjzAGEeHGBlsqlMiHxke1r1apweMbydfJkGOp+u3vUWzNh2PMax8iVE2FhHMUFiaEyvQJFbbo1VA== Received: from [66.196.81.174] by nm2.bullet.mail.bf1.yahoo.com with NNFMP; 05 Jan 2017 09:30:43 -0000 Received: from [98.139.212.230] by tm20.bullet.mail.bf1.yahoo.com with NNFMP; 05 Jan 2017 09:30:43 -0000 Received: from [127.0.0.1] by omp1039.mail.bf1.yahoo.com with NNFMP; 05 Jan 2017 09:30:43 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 374784.43938.bm@HIDDEN X-YMail-OSG: ck4NFPwVM1kepECbFrpZ0jbeUvZNdGrnUJ8olJnXi1NNc_CKAgHP_oIdNmEu94y xCtujYDs0mT9bAxkpPFp6QKE4jNASCzL7HTOJwVkxEAk7CkEpV8RR3esfHsXEhOPu_OdBRvOfrbh dZK5blNp_NM9bbkPlHdqhDkyO1_j3GOl_tSqsYUCxijO6hBYvHEIeoM0IT_cTtqNXfQ5.oVISldR KLBJzb.RbE00y.KZdqp8sxniXQ.rZkUiNdWEekLl2DxGgbiYMw5Eu85Eg3veU3vNWzYUDD6CSlrq QbZaRnrx_6Qz5DQ7Jqn_Zzf5MzqXpNM7WEXLJ_MKyzyTkQ7Sg2VZ4ECGN.CrSnokMrMdjnYdmBVt 7dpjAmay6EEG.tHTQUkZE228kABudzZ2gRi2LfwyGmoW1oM.TJ96tMMexMjhIVdITVbxNNPtc9DB 12H_1.svEICBUgOPms07.JhGkZnWvEx2Ew_qGel0SPUMjo0YX1NNDUCxtROGQCIMVNA8OhOB0hE2 KtAasLsqZr0LQ4Ck4CYkCZjU1Ag-- Received: from jws400007.mail.bf2.yahoo.com by sendmailws161.mail.bf1.yahoo.com; Thu, 05 Jan 2017 09:30:43 +0000; 1483608643.001 Date: Thu, 5 Jan 2017 09:30:42 +0000 (UTC) From: Mirsad Goran Todorovac <mtodorov3_69@HIDDEN> To: Paul Eggert <eggert@HIDDEN>, "25342 <at> debbugs.gnu.org" <25342 <at> debbugs.gnu.org> Message-ID: <1194968073.342732.1483608642647@HIDDEN> In-Reply-To: <969566941.326600.1483608254735@HIDDEN> References: <727818896.5504359.1483394315468.ref@HIDDEN> <727818896.5504359.1483394315468@HIDDEN> <f0b8dd92-16d5-7037-def7-764bba990ce3@HIDDEN> <1871443711.5629967.1483414377142@HIDDEN> <eab724e3-39e7-e141-b5cb-ac61839de4cd@HIDDEN> <99417190.6944768.1483563757518@HIDDEN> <9dbe3286-34a6-d5ed-0c6d-f72a57b8a7ef@HIDDEN> <1800336792.301174.1483606254527@HIDDEN> <969566941.326600.1483608254735@HIDDEN> Subject: Re: bug#25342: GNU coreutils: race condition in "ln -f source dest" MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_342731_496044063.1483608642637" Content-Length: 51832 X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 25342 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Reply-To: Mirsad Goran Todorovac <mtodorov3_69@HIDDEN> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.7 (--) ------=_Part_342731_496044063.1483608642637 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable P.S. Obvious advantage is that unlink ("dest") is not required if it exists, thu= s we offer a workaround for race condition.In first example: # ln -f /etc/resolv.conf.new /etc/resolv.conf there was a time period between unlink ("/etc/resolv.conf"); andlinkat (AT_CDWFD, "/etc/resolv.conf.new", A= T_CWDFD, "/etc/resolv.conf", logical ? AT_SYMLINK_FOLLOW : 0); between these two syscalls process or thread may be preempted and other pro= cess (like browser) could fail in gethostbyname().This is just one example. I will torment you no longer. Thank you for your patience Sir if you've rea= d thus far. God bless! little brother Mirsad=20 On Thursday, January 5, 2017 10:24 AM, Mirsad Goran Todorovac <mtodorov= 3_69@HIDDEN> wrote: =20 The trace above should do a ln -b -f src dest, linking (hard linking to ex= isting file providing a backup in "dest~", without at suffix and stuff, whi= ch is not important for the story): EXAMPLE WITH BACKUP: ln -b -f src dest =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A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=A0 "src" -> inode1=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "dest" -> inode1=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "dest~" -> inode2 Result is that "new" is backed up in "new~" "simulaneously", that is in sin= gle command while hard link "old" overwrites hard link "new". The -b (backup) is optional, in which case we have only black parts, as fol= lows: WITHOUT BACKUP: ln -f src dest =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=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C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 finally:=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "src"= -> inode1=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 "dest" -> inode1=20 Where initial content of file "dest" was lost.Of course, it would be much b= etter if linkat() had additional flag: int linkat (AT_CWDFD, "source", AT_CWDFD, "dest", AT_SYMLINK_FOLLOW | AT_FO= RCE_OVERWRITE); but as you have correctly said, we cannot influence POSIX and Linux kernel = makers. Sorry if I took too much of your time. Thank Heavens for such good and logi= cal design of UN*X filesystems. Regards and All the best,M.T. ___________________________________________________________________________= ____________ On Thursday, January 5, 2017 9:50 AM, Mirsad Goran Todorovac <mtodorov3= _69@HIDDEN> wrote: =20 Pity, 'cause it works for me with a small workaround:link("copy2", "copy2~= ")=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 =3D 0 getpid()=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 3085 linkat(AT_FDCWD, "copy", AT_FDCWD, "copy.003085.bak", 0) =3D 0 renameat(AT_FDCWD, "copy.003085.bak", AT_FDCWD, "copy2") =3D 0 I did not exactly understand? What else can be moved, if not two hard links= ?Directory entry can be one of pointer to inode (file, directory or less li= kely something else), or pointer to another directory entry (symbolic link)= , ain't that right? Can you please provide me with a reference of such behavior of renameat()? = I realized just now that you want to make your code universal and protable.= On Ubuntu Linux it works for me. marvin@marvin-desktop:~$ uname -a Linux marvin-desktop 3.5.0-34-generic #55-Ubuntu SMP Thu Jun 6 20:20:19 UTC= 2013 i686 athlon i686 GNU/Linux marvin@marvin-desktop:~$ dpkg -l | egrep 'libc6' ii=C2=A0 libc6:i386=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 2.23-0ubunt= u5=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 i386=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 GNU C=20 If you can provide me with a reference, I'll try to understand renameat() p= roblem. Best of luck in New Year,M.T. =20 On Thursday, January 5, 2017 8:57 AM, Paul Eggert <eggert@HIDDEN> = wrote: =20 Mirsad Goran Todorovac wrote: > Please consider the trace below. As I don't know what you're tracing, I don't know what to consider. But really, the basic idea is simple: renameat mishandles the case where ol= d and=20 new names are already hard links, and any code based on renameat needs to w= ork=20 around this problem. (We can't easily change renameat's behavior, as the=20 behavior is required by POSIX.) =20 =20 =20 ------=_Part_342731_496044063.1483608642637 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <html><head></head><body><div style=3D"color:#000; background-color:#fff; f= ont-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, = sans-serif;font-size:13px"><div id=3D"yui_3_16_0_ym19_1_1483589602794_49426= ">P.S.</div><div id=3D"yui_3_16_0_ym19_1_1483589602794_49431"><br></div><di= v>Obvious advantage is that unlink ("dest") is not required if it exists, t= hus we offer a workaround for race condition.</div><div>In first example:</= div><div id=3D"yui_3_16_0_ym19_1_1483589602794_49433"><br></div><div dir=3D= "ltr" id=3D"yui_3_16_0_ym19_1_1483589602794_49435"><font id=3D"yui_3_16_0_y= m19_1_1483589602794_49513" face=3D"Courier New, courier, monaco, monospace,= sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_49512"># ln -f /etc/r= esolv.conf.new /etc/resolv.conf</b></font></div><div dir=3D"ltr" id=3D"yui_= 3_16_0_ym19_1_1483589602794_49437"><br></div><div dir=3D"ltr" id=3D"yui_3_1= 6_0_ym19_1_1483589602794_49515">there was a time period between</div><div d= ir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483589602794_49673"><br></div><div dir= =3D"ltr" id=3D"yui_3_16_0_ym19_1_1483589602794_49683"><b id=3D"yui_3_16_0_y= m19_1_1483589602794_49911">unlink ("/etc/resolv.conf"); </b>and</div><div d= ir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483589602794_49684"><b id=3D"yui_3_16_0= _ym19_1_1483589602794_49909">linkat (AT_CDWFD, "/etc/resolv.conf.new", AT_C= WDFD, "/etc/resolv.conf", logical ? AT_SYMLINK_FOLLOW : 0);</b><br></div><d= iv id=3D"yui_3_16_0_ym19_1_1483589602794_49439"><span><br></span></div><div= id=3D"yui_3_16_0_ym19_1_1483589602794_49688" dir=3D"ltr"><span id=3D"yui_3= _16_0_ym19_1_1483589602794_49717">between these two syscalls process or thr= ead may be preempted and other process (like browser) could fail in gethost= byname().</span></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_148358960279= 4_49745"><span id=3D"yui_3_16_0_ym19_1_1483589602794_49717">This is just on= e example.</span></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_14835896027= 94_49774"><span id=3D"yui_3_16_0_ym19_1_1483589602794_49717"><br></span></d= iv><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483589602794_49845"><span id= =3D"yui_3_16_0_ym19_1_1483589602794_49717">I will torment you no longer. Th= ank you for your patience Sir if you've read thus far. God bless!<br></span= ></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483589602794_49805"><span = id=3D"yui_3_16_0_ym19_1_1483589602794_49717"><br></span></div><div dir=3D"l= tr" id=3D"yui_3_16_0_ym19_1_1483589602794_49806"><span id=3D"yui_3_16_0_ym1= 9_1_1483589602794_49717">little brother Mirsad</span></div><div dir=3D"ltr"= id=3D"yui_3_16_0_ym19_1_1483589602794_49843"><span id=3D"yui_3_16_0_ym19_1= _1483589602794_49717"></span></div> <div class=3D"qtdSeparateBR"><br><br></= div><div class=3D"yahoo_quoted" style=3D"display: block;"> <div style=3D"fo= nt-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, = sans-serif; font-size: 13px;"> <div style=3D"font-family: HelveticaNeue, He= lvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;= "> <div dir=3D"ltr"><font size=3D"2" face=3D"Arial"> On Thursday, January 5= , 2017 10:24 AM, Mirsad Goran Todorovac <mtodorov3_69@HIDDEN> wrot= e:<br></font></div> <br><br> <div class=3D"y_msg_container"><div id=3D"yiv= 8943697467"><div><div style=3D"color:#000;background-color:#fff;font-family= :HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif= ;font-size:13px;"><div id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_4= 3035"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_43040">The t= race above should do a <b id=3D"yiv8943697467yui_3_16_0_ym19_1_148358960279= 4_47544">ln -b -f src dest</b>, linking (hard linking to existing file prov= iding a backup in <b>"dest~"</b>, without at suffix and stuff, which is not= important for the story):<br clear=3D"none"></span></div><div id=3D"yiv894= 3697467yui_3_16_0_ym19_1_1483589602794_43140"><span id=3D"yiv8943697467yui_= 3_16_0_ym19_1_1483589602794_43040"><br clear=3D"none"></span></div><div dir= =3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47809"><span id= =3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_43040">EXAMPLE WITH BACKUP= : <font face=3D"Courier New, courier, monaco, monospace, sans-serif"><b id= =3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47937">ln -b -f src dest</= b></font><br clear=3D"none"></span></div><div dir=3D"ltr" id=3D"yiv89436974= 67yui_3_16_0_ym19_1_1483589602794_45218"><font id=3D"yiv8943697467yui_3_16_= 0_ym19_1_1483589602794_47680" face=3D"Courier New, courier, monaco, monospa= ce, sans-serif"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47679= "><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_43040"> &nb= sp; = &nb= sp; = initially we h= ave:</span></b></font></div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_= ym19_1_1483589602794_43392"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_1483= 589602794_47678" face=3D"Courier New, courier, monaco, monospace, sans-seri= f"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47677"><span id=3D= "yiv8943697467yui_3_16_0_ym19_1_1483589602794_43040"> &nbs= p; &= nbsp; &nbs= p; &= nbsp; "src" -> inode1</span></= b></font></div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_148358= 9602794_45555"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_477= 04" face=3D"Courier New, courier, monaco, monospace, sans-serif"><b id=3D"y= iv8943697467yui_3_16_0_ym19_1_1483589602794_47703"><span id=3D"yiv894369746= 7yui_3_16_0_ym19_1_1483589602794_43040">  = ; &n= bsp;  = ; &n= bsp; "dest" -> inode2<br clear=3D"none"></= span></b></font></div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1= _1483589602794_43233"><font face=3D"Courier New, courier, monaco, monospace= , sans-serif"><b><font id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_4= 5217" color=3D"#4c76a2"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_14835896= 02794_43040">link ("dest", "dest~");<br clear=3D"none"></span></font></b></= font></div><div id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_44932"><= font id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47711" face=3D"Cour= ier New, courier, monaco, monospace, sans-serif"><b id=3D"yiv8943697467yui_= 3_16_0_ym19_1_1483589602794_47710"><font id=3D"yiv8943697467yui_3_16_0_ym19= _1_1483589602794_45396" color=3D"#4c76a2"><span id=3D"yiv8943697467yui_3_16= _0_ym19_1_1483589602794_43040"> &n= bsp;  = ; &n= bsp;  = ; now:</span></font></b></font></div><div id=3D"yiv= 8943697467yui_3_16_0_ym19_1_1483589602794_44935"><font id=3D"yiv8943697467y= ui_3_16_0_ym19_1_1483589602794_47709" face=3D"Courier New, courier, monaco,= monospace, sans-serif"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_14835896027= 94_47708"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_45402" c= olor=3D"#4c76a2"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_4= 3040"> &nb= sp; = &nb= sp; = "src" -> inode1<br clear=3D"none"></span></font></b></font></div><div i= d=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_44930"><font id=3D"yiv894= 3697467yui_3_16_0_ym19_1_1483589602794_47723" face=3D"Courier New, courier,= monaco, monospace, sans-serif"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_148= 3589602794_47722"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_= 45216" color=3D"#4c76a2"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589= 602794_43040"> &= nbsp; &nbs= p; &= nbsp; &nbs= p; "dest" -> inode2</span></font></b></font></div><div id=3D"yiv89= 43697467yui_3_16_0_ym19_1_1483589602794_43520"><font id=3D"yiv8943697467yui= _3_16_0_ym19_1_1483589602794_47733" face=3D"Courier New, courier, monaco, m= onospace, sans-serif"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794= _47732"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_43040"><fo= nt id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_45214" color=3D"#4c76= a2">  = ; &n= bsp;  = ; "= dest~" -> inode2</font><br clear=3D"none"></span></b></font></div><div d= ir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_43245"><font = face=3D"Courier New, courier, monaco, monospace, sans-serif"><b><span id=3D= "yiv8943697467yui_3_16_0_ym19_1_1483589602794_43040">link ("src", "src.####= ##.bak");</span></b></font></div><div id=3D"yiv8943697467yui_3_16_0_ym19_1_= 1483589602794_44941"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_14835896027= 94_47748" face=3D"Courier New, courier, monaco, monospace, sans-serif"><b i= d=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47747"><span id=3D"yiv894= 3697467yui_3_16_0_ym19_1_1483589602794_43040">  = ; &n= bsp;  = ; &n= bsp; now:</span></b></font></div><div i= d=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_43618"><font id=3D"yiv894= 3697467yui_3_16_0_ym19_1_1483589602794_47746" face=3D"Courier New, courier,= monaco, monospace, sans-serif"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_148= 3589602794_47745"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_= 43040"> &n= bsp;  = ; &n= bsp;  = ; "src" -> inode1</span></b></font></div><div id=3D"yiv8943697467yui_3_1= 6_0_ym19_1_1483589602794_45073"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_= 1483589602794_47676" face=3D"Courier New, courier, monaco, monospace, sans-= serif"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47675"><span i= d=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_43040"> = &nb= sp; = &nb= sp; "src.######.bak" -> = inode1</span></b></font></div><div id=3D"yiv8943697467yui_3_16_0_ym19_1_148= 3589602794_45075"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_= 47754" face=3D"Courier New, courier, monaco, monospace, sans-serif"><b id= =3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47753"><span id=3D"yiv8943= 697467yui_3_16_0_ym19_1_1483589602794_43040"> = &nb= sp; = &nb= sp; "dest" -> inode2</span></b></fon= t></div><div id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_45074"><fon= t id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47757" face=3D"Courier= New, courier, monaco, monospace, sans-serif"><b id=3D"yiv8943697467yui_3_1= 6_0_ym19_1_1483589602794_47756"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_= 1483589602794_43040"> = &nb= sp; = &nb= sp; <font id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47= 755" color=3D"#4c76a2">"dest~" -> inode2</font><br clear=3D"none"></span= ></b></font></div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_148= 3589602794_43243"><font face=3D"Courier New, courier, monaco, monospace, sa= ns-serif"><b><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_43040= ">rename ("src.######.bak", "dest");</span></b></font></div><div id=3D"yiv8= 943697467yui_3_16_0_ym19_1_1483589602794_43235"><font id=3D"yiv8943697467yu= i_3_16_0_ym19_1_1483589602794_47780" face=3D"Courier New, courier, monaco, = monospace, sans-serif"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_148358960279= 4_47779"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_43040">&n= bsp;  = ; &n= bsp;  = ; finally= :</span></b></font></div><div id=3D"yiv8943697467yui_3_16_0_ym19_1_14835896= 02794_45633"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47789= " face=3D"Courier New, courier, monaco, monospace, sans-serif"><b id=3D"yiv= 8943697467yui_3_16_0_ym19_1_1483589602794_47788"><span id=3D"yiv8943697467y= ui_3_16_0_ym19_1_1483589602794_43040"> &= nbsp; &nbs= p; &= nbsp; &nbs= p; "src</span><span id=3D"yiv8943697467yui_3_= 16_0_ym19_1_1483589602794_43040">" -> inode1</span></b></font></div><div= id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_44942"><font id=3D"yiv8= 943697467yui_3_16_0_ym19_1_1483589602794_47787" face=3D"Courier New, courie= r, monaco, monospace, sans-serif"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_1= 483589602794_47786"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_148358960279= 4_43040"> = &nb= sp; = &nb= sp; "dest" -> inode1</span></b></font></div><div id=3D"yiv8943697467yui_= 3_16_0_ym19_1_1483589602794_44887"><font id=3D"yiv8943697467yui_3_16_0_ym19= _1_1483589602794_47785" face=3D"Courier New, courier, monaco, monospace, sa= ns-serif"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47784"><spa= n id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_43040"> &nb= sp; = &nb= sp; = <font id=3D"yiv89436= 97467yui_3_16_0_ym19_1_1483589602794_45616" color=3D"#4c76a2">"dest~" ->= inode2</font></span></b></font></div><div id=3D"yiv8943697467yui_3_16_0_ym= 19_1_1483589602794_44944"><font face=3D"Courier New, courier, monaco, monos= pace, sans-serif"><b><span id=3D"yiv8943697467yui_3_16_0_ym19_1_14835896027= 94_43040"><br clear=3D"none"></span></b></font></div><div id=3D"yiv89436974= 67yui_3_16_0_ym19_1_1483589602794_45083"><font id=3D"yiv8943697467yui_3_16_= 0_ym19_1_1483589602794_47669"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_14= 83589602794_43040">Result is that "new" is backed up in "new~" "simulaneous= ly", that is in single command while hard link "old" overwrites hard link "= new".<br clear=3D"none"></span></font></div><div id=3D"yiv8943697467yui_3_1= 6_0_ym19_1_1483589602794_45608"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_= 1483589602794_43040"><br clear=3D"none"></span></div><div id=3D"yiv89436974= 67yui_3_16_0_ym19_1_1483589602794_43237"><font id=3D"yiv8943697467yui_3_16_= 0_ym19_1_1483589602794_47867" face=3D"Courier New, courier, monaco, monospa= ce, sans-serif"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_43= 040"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47899" face= =3D"HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-se= rif">The -b (backup) is optional, in which case we have only black parts, a= s follows:</font></span><b id=3D"yiv8943697467yui_3_16_0_ym19_1_14835896027= 94_47866"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_43040"><= br clear=3D"none"></span></b></font></div><div id=3D"yiv8943697467yui_3_16_= 0_ym19_1_1483589602794_47901"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_14= 83589602794_47867" face=3D"Courier New, courier, monaco, monospace, sans-se= rif"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47866"><span id= =3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_43040"><br clear=3D"none">= </span></b></font></div><div id=3D"yiv8943697467yui_3_16_0_ym19_1_148358960= 2794_47921"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47867"= face=3D"Courier New, courier, monaco, monospace, sans-serif"><span id=3D"y= iv8943697467yui_3_16_0_ym19_1_1483589602794_43040">WITHOUT BACKUP:</span><b= id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47866"><span id=3D"yiv8= 943697467yui_3_16_0_ym19_1_1483589602794_43040"> ln -f src dest<br clear=3D= "none"></span></b></font></div><div id=3D"yiv8943697467yui_3_16_0_ym19_1_14= 83589602794_45301"><font face=3D"Courier New, courier, monaco, monospace, s= ans-serif"><b><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_4530= 2"><br id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_45303" clear=3D"n= one"></span></b></font></div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0= _ym19_1_1483589602794_45304"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_148= 3589602794_47980" face=3D"Courier New, courier, monaco, monospace, sans-ser= if"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47979"><span id= =3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_45305"> &= nbsp; &nbs= p; &= nbsp; &nbs= p; initially we have:= </span></b></font></div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19= _1_1483589602794_45306"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_14835896= 02794_47844" face=3D"Courier New, courier, monaco, monospace, sans-serif"><= b id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47843"><span id=3D"yiv= 8943697467yui_3_16_0_ym19_1_1483589602794_45307"> &n= bsp;  = ; &n= bsp;  = ; "src" -> inode1</span>= </b></font></div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_1483= 589602794_45308"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_4= 7842" face=3D"Courier New, courier, monaco, monospace, sans-serif"><b id=3D= "yiv8943697467yui_3_16_0_ym19_1_1483589602794_47841"><span id=3D"yiv8943697= 467yui_3_16_0_ym19_1_1483589602794_45309"> &nb= sp; = &nb= sp; = "dest" -> inode2<br id=3D"yiv= 8943697467yui_3_16_0_ym19_1_1483589602794_45310" clear=3D"none"></span></b>= </font></div><font face=3D"Courier New, courier, monaco, monospace, sans-se= rif"><b><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_45330">lin= k ("src", "src.######.bak");</span></b></font><div id=3D"yiv8943697467yui_3= _16_0_ym19_1_1483589602794_45331"><font id=3D"yiv8943697467yui_3_16_0_ym19_= 1_1483589602794_47924" face=3D"Courier New, courier, monaco, monospace, san= s-serif"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47923"><span= id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_45332"> &nbs= p; &= nbsp; &nbs= p; &= nbsp; now:</span></b>= </font></div><div id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_45333"= ><font id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47840" face=3D"Co= urier New, courier, monaco, monospace, sans-serif"><b id=3D"yiv8943697467yu= i_3_16_0_ym19_1_1483589602794_47839"><span id=3D"yiv8943697467yui_3_16_0_ym= 19_1_1483589602794_45334"> &= nbsp; &nbs= p; &= nbsp; &nbs= p; "src" -> inode1</span></b></font></div><div i= d=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_45335"><font id=3D"yiv894= 3697467yui_3_16_0_ym19_1_1483589602794_47898" face=3D"Courier New, courier,= monaco, monospace, sans-serif"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_148= 3589602794_47897"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_= 45336"> &n= bsp;  = ; &n= bsp;  = ; "src.######.bak" -> inode1</span></b></font></div><div id=3D"yiv= 8943697467yui_3_16_0_ym19_1_1483589602794_45337"><font id=3D"yiv8943697467y= ui_3_16_0_ym19_1_1483589602794_47834" face=3D"Courier New, courier, monaco,= monospace, sans-serif"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_14835896027= 94_47833"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_45338">&= nbsp; &nbs= p; &= nbsp; &nbs= p; = "src" -> inode2</span></b></font></div><font face=3D"Courier New, courie= r, monaco, monospace, sans-serif"><b><span id=3D"yiv8943697467yui_3_16_0_ym= 19_1_1483589602794_45344">rename ("src.######.bak", "dest");</span></b></fo= nt><div id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_45345"><font id= =3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_48020" face=3D"Courier New= , courier, monaco, monospace, sans-serif"><b id=3D"yiv8943697467yui_3_16_0_= ym19_1_1483589602794_48019"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483= 589602794_45346"> &nbs= p; &= nbsp; &nbs= p; &= nbsp; finally:</span></b></font></div><div id=3D"yiv8943697467y= ui_3_16_0_ym19_1_1483589602794_45347"><font id=3D"yiv8943697467yui_3_16_0_y= m19_1_1483589602794_48018" face=3D"Courier New, courier, monaco, monospace,= sans-serif"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_48017"><= span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_45348"> = &nb= sp; = &nb= sp; "src" ->= inode1</span></b></font></div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16= _0_ym19_1_1483589602794_45349"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_1= 483589602794_47896" face=3D"Courier New, courier, monaco, monospace, sans-s= erif"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_47895"><span id= =3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_45350"> &= nbsp; &nbs= p; &= nbsp; &nbs= p; "dest" -> inode= 1</span></b></font></div> <div class=3D"yiv8943697467qtdSeparateBR" id=3D"y= iv8943697467yui_3_16_0_ym19_1_1483589602794_45099"><div id=3D"yiv8943697467= yui_3_16_0_ym19_1_1483589602794_45369"><br clear=3D"none"></div><div id=3D"= yiv8943697467yui_3_16_0_ym19_1_1483589602794_45698">Where initial content o= f file <b>"dest"</b> was lost.</div><div id=3D"yiv8943697467yui_3_16_0_ym19= _1_1483589602794_45703">Of course, it would be much better if <b>linkat()</= b> had additional flag:</div><div id=3D"yiv8943697467yui_3_16_0_ym19_1_1483= 589602794_45718"><br clear=3D"none"></div><div dir=3D"ltr" id=3D"yiv8943697= 467yui_3_16_0_ym19_1_1483589602794_47339"><b id=3D"yiv8943697467yui_3_16_0_= ym19_1_1483589602794_47470">int linkat (AT_CWDFD, "source", AT_CWDFD, "dest= ", AT_SYMLINK_FOLLOW | AT_FORCE_OVERWRITE);</b></div><div dir=3D"ltr" id=3D= "yiv8943697467yui_3_16_0_ym19_1_1483589602794_47390"><br clear=3D"none"></d= iv><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_4739= 6">but as you have correctly said, we cannot influence POSIX and Linux kern= el makers.</div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_14835= 89602794_47429"><br clear=3D"none"></div><div dir=3D"ltr" id=3D"yiv89436974= 67yui_3_16_0_ym19_1_1483589602794_47430">Sorry if I took too much of your t= ime. Thank Heavens for such good and logical design of UN*X filesystems.<br= clear=3D"none"></div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1= _1483589602794_47435"><br clear=3D"none"></div><div dir=3D"ltr" id=3D"yiv89= 43697467yui_3_16_0_ym19_1_1483589602794_47436">Regards and All the best,</d= iv><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_4745= 1">M.T.</div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_14835896= 02794_47452"><br clear=3D"none"></div><div dir=3D"ltr" id=3D"yiv8943697467y= ui_3_16_0_ym19_1_1483589602794_48063">_____________________________________= __________________________________________________<br clear=3D"none"></div>= <br clear=3D"none"></div><div class=3D"yiv8943697467yqt2949173975" id=3D"yi= v8943697467yqt55311"><div class=3D"yiv8943697467yahoo_quoted" id=3D"yiv8943= 697467yui_3_16_0_ym19_1_1483589602794_45158" style=3D"display:block;"> <div= id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_45157" style=3D"font-fa= mily:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-s= erif;font-size:13px;"> <div id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602= 794_45156" style=3D"font-family:HelveticaNeue, Helvetica Neue, Helvetica, A= rial, Lucida Grande, sans-serif;font-size:16px;"> <div dir=3D"ltr" id=3D"yi= v8943697467yui_3_16_0_ym19_1_1483589602794_45165"><font id=3D"yiv8943697467= yui_3_16_0_ym19_1_1483589602794_45163" size=3D"2" face=3D"Arial"> On Thursd= ay, January 5, 2017 9:50 AM, Mirsad Goran Todorovac <mtodorov3_69@yahoo.= com> wrote:<br clear=3D"none"></font></div> <br clear=3D"none"><br clea= r=3D"none"> <div class=3D"yiv8943697467y_msg_container" id=3D"yiv8943697467= yui_3_16_0_ym19_1_1483589602794_45190"><div id=3D"yiv8943697467"><div id=3D= "yiv8943697467yui_3_16_0_ym19_1_1483589602794_45189"><div id=3D"yiv89436974= 67yui_3_16_0_ym19_1_1483589602794_45188" style=3D"color:#000;background-col= or:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida= Grande, sans-serif;font-size:13px;"><div id=3D"yiv8943697467yui_3_16_0_ym1= 9_1_1483589602794_39521"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589= 602794_45187">Pity, 'cause it works for me with a small workaround:</span><= /div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39= 540"><span></span><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_= 39548"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39549" face= =3D"Courier New, courier, monaco, monospace, sans-serif"><b id=3D"yiv894369= 7467yui_3_16_0_ym19_1_1483589602794_39550">link("copy2", "copy2~") &nb= sp; = =3D 0<br id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39= 551" clear=3D"none">getpid()  = ; &n= bsp; =3D 3085<b= r id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39552" clear=3D"none">= linkat(AT_FDCWD, "copy", AT_FDCWD, "copy.003085.bak", 0) =3D 0<br id=3D"yiv= 8943697467yui_3_16_0_ym19_1_1483589602794_39553" clear=3D"none">renameat(AT= _FDCWD, "copy.003085.bak", AT_FDCWD, "copy2") =3D 0</b></font></span></div>= <div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39573">= <span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39548"><font id=3D= "yiv8943697467yui_3_16_0_ym19_1_1483589602794_39549"><b id=3D"yiv8943697467= yui_3_16_0_ym19_1_1483589602794_39550"><br clear=3D"none"></b></font></span= ></div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_= 39598"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39548"><fon= t id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39549">I did not exact= ly understand? What else can be moved, if not two hard links?</font></span>= </div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_3= 9901"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39548"><font= id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39549">Directory entry = can be one of pointer to inode (file, directory or less likely something el= se), or pointer to another directory entry (symbolic link), ain't that righ= t?</font></span></div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1= _1483589602794_39736"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602= 794_39548"><br clear=3D"none"></span></div><div dir=3D"ltr" id=3D"yiv894369= 7467yui_3_16_0_ym19_1_1483589602794_39895"><span id=3D"yiv8943697467yui_3_1= 6_0_ym19_1_1483589602794_39548">Can you please provide me with a reference = of such behavior of renameat()? I realized just now that you want to make y= our code universal and protable.</span></div><div dir=3D"ltr" id=3D"yiv8943= 697467yui_3_16_0_ym19_1_1483589602794_39982"><span id=3D"yiv8943697467yui_3= _16_0_ym19_1_1483589602794_39548">On Ubuntu Linux it works for me.</span></= div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_416= 56"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39548"><br cle= ar=3D"none"></span></div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym1= 9_1_1483589602794_41731"><font face=3D"Courier New, courier, monaco, monosp= ace, sans-serif"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_4200= 2"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39548">marvin@m= arvin-desktop:~$ uname -a<br id=3D"yiv8943697467yui_3_16_0_ym19_1_148358960= 2794_41853" clear=3D"none">Linux marvin-desktop 3.5.0-34-generic #55-Ubuntu= SMP Thu Jun 6 20:20:19 UTC 2013 i686 athlon i686 GNU/Linux<br id=3D"yiv894= 3697467yui_3_16_0_ym19_1_1483589602794_41854" clear=3D"none">marvin@marvin-= desktop:~$ dpkg -l | egrep 'libc6'<br clear=3D"none"></span></b></font></di= v><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_41655= "><font face=3D"Courier New, courier, monaco, monospace, sans-serif"><span = id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39548"><b id=3D"yiv89436= 97467yui_3_16_0_ym19_1_1483589602794_42006">ii libc6:i386 = &nb= sp; = 2.23-0ubuntu5 &= nbsp; &nbs= p; &= nbsp; i386 GNU C </b>= <br clear=3D"none"></span></font></div><div dir=3D"ltr" id=3D"yiv8943697467= yui_3_16_0_ym19_1_1483589602794_39594"><span id=3D"yiv8943697467yui_3_16_0_= ym19_1_1483589602794_39548"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_1483= 589602794_39549" face=3D"Courier New, courier, monaco, monospace, sans-seri= f"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39550"><br clear= =3D"none"></b></font></span></div><div dir=3D"ltr" id=3D"yiv8943697467yui_3= _16_0_ym19_1_1483589602794_42000"><span id=3D"yiv8943697467yui_3_16_0_ym19_= 1_1483589602794_39548"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_148358960= 2794_39549" face=3D"Courier New, courier, monaco, monospace, sans-serif"><b= id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39550">If you can provi= de me with a reference, I'll try to understand renameat() problem.</b></fon= t></span></div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_148358= 9602794_42089"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_395= 48"><font id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39549" face=3D= "Courier New, courier, monaco, monospace, sans-serif"><b id=3D"yiv894369746= 7yui_3_16_0_ym19_1_1483589602794_39550"><br clear=3D"none"></b></font></spa= n></div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794= _42119"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39548"><fo= nt id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39549" face=3D"Courie= r New, courier, monaco, monospace, sans-serif"><b id=3D"yiv8943697467yui_3_= 16_0_ym19_1_1483589602794_39550">Best of luck in New Year,</b></font></span= ></div><div dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_= 42121"><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39548"><fon= t id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39549" face=3D"Courier= New, courier, monaco, monospace, sans-serif"><b id=3D"yiv8943697467yui_3_1= 6_0_ym19_1_1483589602794_39550">M.T.</b></font></span></div><div dir=3D"ltr= "><span id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39548"><font id= =3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39549" face=3D"Courier New= , courier, monaco, monospace, sans-serif"><b id=3D"yiv8943697467yui_3_16_0_= ym19_1_1483589602794_39550"><br clear=3D"none"></b></font></span></div><div= dir=3D"ltr" id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39682"><spa= n id=3D"yiv8943697467yui_3_16_0_ym19_1_1483589602794_39548"><font id=3D"yiv= 8943697467yui_3_16_0_ym19_1_1483589602794_39549" face=3D"Courier New, couri= er, monaco, monospace, sans-serif"><b id=3D"yiv8943697467yui_3_16_0_ym19_1_= 1483589602794_39550"><br clear=3D"none"></b></font></span></div> <div class= =3D"yiv8943697467qtdSeparateBR"><br clear=3D"none"><br clear=3D"none"></div= ><div class=3D"yiv8943697467yqt9226908023" id=3D"yiv8943697467yqt03673"><di= v class=3D"yiv8943697467yahoo_quoted" style=3D"display:block;"> <div style= =3D"font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Gra= nde, sans-serif;font-size:13px;"> <div style=3D"font-family:HelveticaNeue, = Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;= "> <div dir=3D"ltr"><font size=3D"2" face=3D"Arial"> On Thursday, January 5= , 2017 8:57 AM, Paul Eggert <eggert@HIDDEN> wrote:<br clear=3D"n= one"></font></div> <br clear=3D"none"><br clear=3D"none"> <div class=3D"yi= v8943697467y_msg_container">Mirsad Goran Todorovac wrote:<div class=3D"yiv8= 943697467yqt0726665938" id=3D"yiv8943697467yqtfd23706"><br clear=3D"none">&= gt; Please consider the trace below.</div><br clear=3D"none"><br clear=3D"n= one">As I don't know what you're tracing, I don't know what to consider.<br= clear=3D"none"><br clear=3D"none">But really, the basic idea is simple: re= nameat mishandles the case where old and <br clear=3D"none">new names are a= lready hard links, and any code based on renameat needs to work <br clear= =3D"none">around this problem. (We can't easily change renameat's behavior,= as the <br clear=3D"none">behavior is required by POSIX.)<div class=3D"yiv= 8943697467yqt0726665938" id=3D"yiv8943697467yqtfd50656"><br clear=3D"none">= </div><br clear=3D"none"><br clear=3D"none"></div> </div> </div> </div></= div></div></div></div><br clear=3D"none"><br clear=3D"none"></div> </div> = </div> </div></div></div></div></div><br><br></div> </div> </div> </div>= </div></body></html> ------=_Part_342731_496044063.1483608642637--
bug-coreutils@HIDDEN
:bug#25342
; Package coreutils
.
Full text available.Received: (at 25342) by debbugs.gnu.org; 5 Jan 2017 09:24:24 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 05 04:24:24 2017 Received: from localhost ([127.0.0.1]:41729 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1cP4HY-00043q-0V for submit <at> debbugs.gnu.org; Thu, 05 Jan 2017 04:24:24 -0500 Received: from nm6.bullet.mail.bf1.yahoo.com ([98.139.212.165]:44599) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mtodorov3_69@HIDDEN>) id 1cP4HV-00043d-OQ for 25342 <at> debbugs.gnu.org; Thu, 05 Jan 2017 04:24:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1483608255; bh=uPxEItDmZRDIOwKk2gM6tjeF0qGw3XV1YTQdgak9HZM=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=lqsnf46NHaCIqN8pjesJOz+O9uN1bEEoWKRlgMKHFd/AvKk/M5/bT/z35UOgTbAwLJup44rOjiLL2CXj/amNUW+FlvYmaoE+45Ka1HeZJRCesvvCc7VQVWizZfndNwej6MVhvpBuqEJU83TYmXZ6eg5jSolqYmfaUna4Hv6/9IDYNXuRWeoCw0yuAkhAVfUP8zfbxJVhK0O8Q7l+Oee1BpOYVqMZquqtU6H3MEzNLXYjQwcwnfp3CiTunv49FV2+mFvmjzgSzeSUzCEvzvnWgngwzi0F6kL1nW0EQyXaxUrNiG/xJIgRfWA3Hnh1XrS7GbLw6lfNsY7N4Fa7+teZ8w== Received: from [98.139.215.142] by nm6.bullet.mail.bf1.yahoo.com with NNFMP; 05 Jan 2017 09:24:15 -0000 Received: from [98.139.215.250] by tm13.bullet.mail.bf1.yahoo.com with NNFMP; 05 Jan 2017 09:24:15 -0000 Received: from [127.0.0.1] by omp1063.mail.bf1.yahoo.com with NNFMP; 05 Jan 2017 09:24:15 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 489762.55848.bm@HIDDEN X-YMail-OSG: 79YrIE4VM1kZoC4b7lU8f.FmDX_zxvI_02K.RwViUJvzGTULQqhvnLhCS_pijd9 t73ExYGtZrB_fPtVW9AVN0U7MELTPc7JWv.3b3cgaVX9G5Fx0CLz47L5C1apLBqmDcmJRwvzdBuo DdiNnbZ6HdiAvP.DtLlqK1_bLY6jMselpNaGlw_7G_xcdW_vgr7zkVTERqSMLHCsfX.RUORR7wEd BVt0jIvh0ruHwCZqh5N_Dg.SAMa3HriT3VwMqAlBX9VXLVpdeXIxPfqoGGHndGnm.75JykG6RPV7 AcpsTRkbvkVkArXBt.uxrxLG7UdzlmuV7nImAeh0KAbofEifUu3.RIR0sseo1z97D7g32dhjgi4p Tgyebx08tew7TOR9tnsFbWT7oj0N0osZbuf3mk4SOdUp.StfxqJe4KBUnm.F1LGP44lEbdeIweXj 5nnupkkTwmzBe7Z5uWeZ2WaZ9e4C6Ilg.TIWkUP__5AWtwsazQkGwGO74Eu6Oo2arG5Np2xEbNO3 aOjwgK3SJolPR8ta2S5r0siLDfw-- Received: from jws400103.mail.bf2.yahoo.com by sendmailws119.mail.bf1.yahoo.com; Thu, 05 Jan 2017 09:24:15 +0000; 1483608255.047 Date: Thu, 5 Jan 2017 09:24:14 +0000 (UTC) From: Mirsad Goran Todorovac <mtodorov3_69@HIDDEN> To: Paul Eggert <eggert@HIDDEN>, "25342 <at> debbugs.gnu.org" <25342 <at> debbugs.gnu.org> Message-ID: <969566941.326600.1483608254735@HIDDEN> In-Reply-To: <1800336792.301174.1483606254527@HIDDEN> References: <727818896.5504359.1483394315468.ref@HIDDEN> <727818896.5504359.1483394315468@HIDDEN> <f0b8dd92-16d5-7037-def7-764bba990ce3@HIDDEN> <1871443711.5629967.1483414377142@HIDDEN> <eab724e3-39e7-e141-b5cb-ac61839de4cd@HIDDEN> <99417190.6944768.1483563757518@HIDDEN> <9dbe3286-34a6-d5ed-0c6d-f72a57b8a7ef@HIDDEN> <1800336792.301174.1483606254527@HIDDEN> Subject: Re: bug#25342: GNU coreutils: race condition in "ln -f source dest" MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_326599_453837390.1483608254726" Content-Length: 44759 X-Spam-Score: -2.2 (--) X-Debbugs-Envelope-To: 25342 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Reply-To: Mirsad Goran Todorovac <mtodorov3_69@HIDDEN> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.2 (--) ------=_Part_326599_453837390.1483608254726 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable The trace above should do a ln -b -f src dest, linking (hard linking to exi= sting file providing a backup in "dest~", without at suffix and stuff, whic= h is not important for the story): EXAMPLE WITH BACKUP: ln -b -f src dest =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 initi= ally we have:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 "src" -> inode1=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A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C2=A0=C2=A0 "dest~" -> inode2 Result is that "new" is backed up in "new~" "simulaneously", that is in sin= gle command while hard link "old" overwrites hard link "new". The -b (backup) is optional, in which case we have only black parts, as fol= lows: WITHOUT BACKUP: ln -f src dest =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= initially we have:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 "src" -> inode1=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2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0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 "dest" -> inode1=20 Where initial content of file "dest" was lost.Of course, it would be much b= etter if linkat() had additional flag: int linkat (AT_CWDFD, "source", AT_CWDFD, "dest", AT_SYMLINK_FOLLOW | AT_FO= RCE_OVERWRITE); but as you have correctly said, we cannot influence POSIX and Linux kernel = makers. Sorry if I took too much of your time. Thank Heavens for such good and logi= cal design of UN*X filesystems. Regards and All the best,M.T. ___________________________________________________________________________= ____________ On Thursday, January 5, 2017 9:50 AM, Mirsad Goran Todorovac <mtodorov3= _69@HIDDEN> wrote: =20 Pity, 'cause it works for me with a small workaround:link("copy2", "copy2~= ")=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 =3D 0 getpid()=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 3085 linkat(AT_FDCWD, "copy", AT_FDCWD, "copy.003085.bak", 0) =3D 0 renameat(AT_FDCWD, "copy.003085.bak", AT_FDCWD, "copy2") =3D 0 I did not exactly understand? What else can be moved, if not two hard links= ?Directory entry can be one of pointer to inode (file, directory or less li= kely something else), or pointer to another directory entry (symbolic link)= , ain't that right? Can you please provide me with a reference of such behavior of renameat()? = I realized just now that you want to make your code universal and protable.= On Ubuntu Linux it works for me. marvin@marvin-desktop:~$ uname -a Linux marvin-desktop 3.5.0-34-generic #55-Ubuntu SMP Thu Jun 6 20:20:19 UTC= 2013 i686 athlon i686 GNU/Linux marvin@marvin-desktop:~$ dpkg -l | egrep 'libc6' ii=C2=A0 libc6:i386=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 2.23-0ubunt= u5=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 i386=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 GNU C=20 If you can provide me with a reference, I'll try to understand renameat() p= roblem. Best of luck in New Year,M.T. =20 On Thursday, January 5, 2017 8:57 AM, Paul Eggert <eggert@HIDDEN> = wrote: =20 Mirsad Goran Todorovac wrote: > Please consider the trace below. As I don't know what you're tracing, I don't know what to consider. But really, the basic idea is simple: renameat mishandles the case where ol= d and=20 new names are already hard links, and any code based on renameat needs to w= ork=20 around this problem. (We can't easily change renameat's behavior, as the=20 behavior is required by POSIX.) =20 =20 ------=_Part_326599_453837390.1483608254726 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <html><head></head><body><div style=3D"color:#000; background-color:#fff; f= ont-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, = sans-serif;font-size:13px"><div id=3D"yui_3_16_0_ym19_1_1483589602794_43035= "><span id=3D"yui_3_16_0_ym19_1_1483589602794_43040">The trace above should= do a <b id=3D"yui_3_16_0_ym19_1_1483589602794_47544">ln -b -f src dest</b>= , linking (hard linking to existing file providing a backup in <b>"dest~"</= b>, without at suffix and stuff, which is not important for the story):<br>= </span></div><div id=3D"yui_3_16_0_ym19_1_1483589602794_43140"><span id=3D"= yui_3_16_0_ym19_1_1483589602794_43040"><br></span></div><div id=3D"yui_3_16= _0_ym19_1_1483589602794_47809" dir=3D"ltr"><span id=3D"yui_3_16_0_ym19_1_14= 83589602794_43040">EXAMPLE WITH BACKUP: <font face=3D"Courier New, courier,= monaco, monospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_47= 937">ln -b -f src dest</b></font><br></span></div><div dir=3D"ltr" id=3D"yu= i_3_16_0_ym19_1_1483589602794_45218"><font id=3D"yui_3_16_0_ym19_1_14835896= 02794_47680" face=3D"Courier New, courier, monaco, monospace, sans-serif"><= b id=3D"yui_3_16_0_ym19_1_1483589602794_47679"><span id=3D"yui_3_16_0_ym19_= 1_1483589602794_43040"> &nbs= p; &= nbsp; &nbs= p; &= nbsp; initially we have:</span></b></font></div><div dir=3D"ltr= " id=3D"yui_3_16_0_ym19_1_1483589602794_43392"><font id=3D"yui_3_16_0_ym19_= 1_1483589602794_47678" face=3D"Courier New, courier, monaco, monospace, san= s-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_47677"><span id=3D"yui_3_= 16_0_ym19_1_1483589602794_43040"> = &nb= sp; = &nb= sp; "src" -> inode1</span></b></font></div><div = dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483589602794_45555"><font id=3D"yui_3_= 16_0_ym19_1_1483589602794_47704" face=3D"Courier New, courier, monaco, mono= space, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_47703"><span id= =3D"yui_3_16_0_ym19_1_1483589602794_43040"> &n= bsp;  = ; &n= bsp;  = ; "dest" -> inode2<br></span></b></f= ont></div><div id=3D"yui_3_16_0_ym19_1_1483589602794_43233" dir=3D"ltr"><fo= nt face=3D"Courier New, courier, monaco, monospace, sans-serif"><b><font id= =3D"yui_3_16_0_ym19_1_1483589602794_45217" color=3D"#4c76a2"><span id=3D"yu= i_3_16_0_ym19_1_1483589602794_43040">link ("dest", "dest~");<br></span></fo= nt></b></font></div><div id=3D"yui_3_16_0_ym19_1_1483589602794_44932"><font= id=3D"yui_3_16_0_ym19_1_1483589602794_47711" face=3D"Courier New, courier,= monaco, monospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_47= 710"><font id=3D"yui_3_16_0_ym19_1_1483589602794_45396" color=3D"#4c76a2"><= span id=3D"yui_3_16_0_ym19_1_1483589602794_43040"> &= nbsp; &nbs= p; &= nbsp; &nbs= p; now:</span></font></b></font><= /div><div id=3D"yui_3_16_0_ym19_1_1483589602794_44935"><font id=3D"yui_3_16= _0_ym19_1_1483589602794_47709" face=3D"Courier New, courier, monaco, monosp= ace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_47708"><font id= =3D"yui_3_16_0_ym19_1_1483589602794_45402" color=3D"#4c76a2"><span id=3D"yu= i_3_16_0_ym19_1_1483589602794_43040"> &n= bsp;  = ; &n= bsp;  = ; "src" -> inode1<br></span></font></b></f= ont></div><div id=3D"yui_3_16_0_ym19_1_1483589602794_44930"><font id=3D"yui= _3_16_0_ym19_1_1483589602794_47723" face=3D"Courier New, courier, monaco, m= onospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_47722"><font= id=3D"yui_3_16_0_ym19_1_1483589602794_45216" color=3D"#4c76a2"><span id=3D= "yui_3_16_0_ym19_1_1483589602794_43040">  = ; &n= bsp;  = ; &n= bsp; "dest" -> inode2</span></font></b></f= ont></div><div id=3D"yui_3_16_0_ym19_1_1483589602794_43520"><font id=3D"yui= _3_16_0_ym19_1_1483589602794_47733" face=3D"Courier New, courier, monaco, m= onospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_47732"><span= id=3D"yui_3_16_0_ym19_1_1483589602794_43040"><font id=3D"yui_3_16_0_ym19_1= _1483589602794_45214" color=3D"#4c76a2">  = ; &n= bsp;  = ; &n= bsp; "dest~" -> inode2</font><br></span></= b></font></div><div id=3D"yui_3_16_0_ym19_1_1483589602794_43245" dir=3D"ltr= "><font face=3D"Courier New, courier, monaco, monospace, sans-serif"><b><sp= an id=3D"yui_3_16_0_ym19_1_1483589602794_43040">link ("src", "src.######.ba= k");</span></b></font></div><div id=3D"yui_3_16_0_ym19_1_1483589602794_4494= 1"><font id=3D"yui_3_16_0_ym19_1_1483589602794_47748" face=3D"Courier New, = courier, monaco, monospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_14835896= 02794_47747"><span id=3D"yui_3_16_0_ym19_1_1483589602794_43040">  = ; &n= bsp;  = ; &n= bsp; now:</span></b><= /font></div><div id=3D"yui_3_16_0_ym19_1_1483589602794_43618"><font id=3D"y= ui_3_16_0_ym19_1_1483589602794_47746" face=3D"Courier New, courier, monaco,= monospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_47745"><sp= an id=3D"yui_3_16_0_ym19_1_1483589602794_43040"> &nb= sp; = &nb= sp; = "src" -> inode1</span></b></f= ont></div><div id=3D"yui_3_16_0_ym19_1_1483589602794_45073"><font id=3D"yui= _3_16_0_ym19_1_1483589602794_47676" face=3D"Courier New, courier, monaco, m= onospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_47675"><span= id=3D"yui_3_16_0_ym19_1_1483589602794_43040">  = ; &n= bsp;  = ; &n= bsp; "src.######.bak" -> inode1</spa= n></b></font></div><div id=3D"yui_3_16_0_ym19_1_1483589602794_45075"><font = id=3D"yui_3_16_0_ym19_1_1483589602794_47754" face=3D"Courier New, courier, = monaco, monospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_477= 53"><span id=3D"yui_3_16_0_ym19_1_1483589602794_43040"> &n= bsp;  = ; &n= bsp;  = ; "dest" -> inode2</span= ></b></font></div><div id=3D"yui_3_16_0_ym19_1_1483589602794_45074"><font i= d=3D"yui_3_16_0_ym19_1_1483589602794_47757" face=3D"Courier New, courier, m= onaco, monospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_4775= 6"><span id=3D"yui_3_16_0_ym19_1_1483589602794_43040"> &nb= sp; = &nb= sp; = <font id=3D"yui_3_16_0_ym1= 9_1_1483589602794_47755" color=3D"#4c76a2">"dest~" -> inode2</font><br><= /span></b></font></div><div id=3D"yui_3_16_0_ym19_1_1483589602794_43243" di= r=3D"ltr"><font face=3D"Courier New, courier, monaco, monospace, sans-serif= "><b><span id=3D"yui_3_16_0_ym19_1_1483589602794_43040">rename ("src.######= .bak", "dest");</span></b></font></div><div id=3D"yui_3_16_0_ym19_1_1483589= 602794_43235"><font id=3D"yui_3_16_0_ym19_1_1483589602794_47780" face=3D"Co= urier New, courier, monaco, monospace, sans-serif"><b id=3D"yui_3_16_0_ym19= _1_1483589602794_47779"><span id=3D"yui_3_16_0_ym19_1_1483589602794_43040">= &nb= sp; = &nb= sp; final= ly:</span></b></font></div><div id=3D"yui_3_16_0_ym19_1_1483589602794_45633= "><font id=3D"yui_3_16_0_ym19_1_1483589602794_47789" face=3D"Courier New, c= ourier, monaco, monospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_148358960= 2794_47788"><span id=3D"yui_3_16_0_ym19_1_1483589602794_43040"> = &nb= sp; = &nb= sp; "src</span><span = id=3D"yui_3_16_0_ym19_1_1483589602794_43040">" -> inode1</span></b></fon= t></div><div id=3D"yui_3_16_0_ym19_1_1483589602794_44942"><font id=3D"yui_3= _16_0_ym19_1_1483589602794_47787" face=3D"Courier New, courier, monaco, mon= ospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_47786"><span i= d=3D"yui_3_16_0_ym19_1_1483589602794_43040"> &= nbsp; &nbs= p; &= nbsp; &nbs= p; "dest" -> inode1</span></b></font= ></div><div id=3D"yui_3_16_0_ym19_1_1483589602794_44887"><font id=3D"yui_3_= 16_0_ym19_1_1483589602794_47785" face=3D"Courier New, courier, monaco, mono= space, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_47784"><span id= =3D"yui_3_16_0_ym19_1_1483589602794_43040"> &n= bsp;  = ; &n= bsp;  = ; <font id=3D"yui_3_16_0_ym19_1_1483589= 602794_45616" color=3D"#4c76a2">"dest~" -> inode2</font></span></b></fon= t></div><div id=3D"yui_3_16_0_ym19_1_1483589602794_44944"><font face=3D"Cou= rier New, courier, monaco, monospace, sans-serif"><b><span id=3D"yui_3_16_0= _ym19_1_1483589602794_43040"><br></span></b></font></div><div id=3D"yui_3_1= 6_0_ym19_1_1483589602794_45083"><font id=3D"yui_3_16_0_ym19_1_1483589602794= _47669"><span id=3D"yui_3_16_0_ym19_1_1483589602794_43040">Result is that "= new" is backed up in "new~" "simulaneously", that is in single command whil= e hard link "old" overwrites hard link "new".<br></span></font></div><div i= d=3D"yui_3_16_0_ym19_1_1483589602794_45608"><span id=3D"yui_3_16_0_ym19_1_1= 483589602794_43040"><br></span></div><div id=3D"yui_3_16_0_ym19_1_148358960= 2794_43237"><font id=3D"yui_3_16_0_ym19_1_1483589602794_47867" face=3D"Cour= ier New, courier, monaco, monospace, sans-serif"><span id=3D"yui_3_16_0_ym1= 9_1_1483589602794_43040"><font id=3D"yui_3_16_0_ym19_1_1483589602794_47899"= face=3D"HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sa= ns-serif">The -b (backup) is optional, in which case we have only black par= ts, as follows:</font></span><b id=3D"yui_3_16_0_ym19_1_1483589602794_47866= "><span id=3D"yui_3_16_0_ym19_1_1483589602794_43040"><br></span></b></font>= </div><div id=3D"yui_3_16_0_ym19_1_1483589602794_47901"><font id=3D"yui_3_1= 6_0_ym19_1_1483589602794_47867" face=3D"Courier New, courier, monaco, monos= pace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_47866"><span id= =3D"yui_3_16_0_ym19_1_1483589602794_43040"><br></span></b></font></div><div= id=3D"yui_3_16_0_ym19_1_1483589602794_47921"><font id=3D"yui_3_16_0_ym19_1= _1483589602794_47867" face=3D"Courier New, courier, monaco, monospace, sans= -serif"><span id=3D"yui_3_16_0_ym19_1_1483589602794_43040">WITHOUT BACKUP:<= /span><b id=3D"yui_3_16_0_ym19_1_1483589602794_47866"><span id=3D"yui_3_16_= 0_ym19_1_1483589602794_43040"> ln -f src dest<br></span></b></font></div><d= iv id=3D"yui_3_16_0_ym19_1_1483589602794_45301"><font face=3D"Courier New, = courier, monaco, monospace, sans-serif"><b><span id=3D"yui_3_16_0_ym19_1_14= 83589602794_45302"><br id=3D"yui_3_16_0_ym19_1_1483589602794_45303"></span>= </b></font></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483589602794_453= 04"><font id=3D"yui_3_16_0_ym19_1_1483589602794_47980" face=3D"Courier New,= courier, monaco, monospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589= 602794_47979"><span id=3D"yui_3_16_0_ym19_1_1483589602794_45305"> &nbs= p; &= nbsp; &nbs= p; &= nbsp; initially= we have:</span></b></font></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1= 483589602794_45306"><font id=3D"yui_3_16_0_ym19_1_1483589602794_47844" face= =3D"Courier New, courier, monaco, monospace, sans-serif"><b id=3D"yui_3_16_= 0_ym19_1_1483589602794_47843"><span id=3D"yui_3_16_0_ym19_1_1483589602794_4= 5307"> &nb= sp; = &nb= sp; = "src" -> inode1</span></b></font></div><div dir=3D"ltr" id=3D"yui= _3_16_0_ym19_1_1483589602794_45308"><font id=3D"yui_3_16_0_ym19_1_148358960= 2794_47842" face=3D"Courier New, courier, monaco, monospace, sans-serif"><b= id=3D"yui_3_16_0_ym19_1_1483589602794_47841"><span id=3D"yui_3_16_0_ym19_1= _1483589602794_45309">  = ; &n= bsp;  = ; &n= bsp; "dest" -> inode2<br id=3D"yui_3_16_0_ym19_1_14835= 89602794_45310"></span></b></font></div><font face=3D"Courier New, courier,= monaco, monospace, sans-serif"><b><span id=3D"yui_3_16_0_ym19_1_1483589602= 794_45330">link ("src", "src.######.bak");</span></b></font><div id=3D"yui_= 3_16_0_ym19_1_1483589602794_45331"><font id=3D"yui_3_16_0_ym19_1_1483589602= 794_47924" face=3D"Courier New, courier, monaco, monospace, sans-serif"><b = id=3D"yui_3_16_0_ym19_1_1483589602794_47923"><span id=3D"yui_3_16_0_ym19_1_= 1483589602794_45332"> = &nb= sp; = &nb= sp; now:</span></b></font></div><div id=3D"yui_3_16_0_ym1= 9_1_1483589602794_45333"><font id=3D"yui_3_16_0_ym19_1_1483589602794_47840"= face=3D"Courier New, courier, monaco, monospace, sans-serif"><b id=3D"yui_= 3_16_0_ym19_1_1483589602794_47839"><span id=3D"yui_3_16_0_ym19_1_1483589602= 794_45334"> &nbs= p; &= nbsp; &nbs= p; &= nbsp; "src" -> inode1</span></b></font></div><div id=3D"yui_3_16_0= _ym19_1_1483589602794_45335"><font id=3D"yui_3_16_0_ym19_1_1483589602794_47= 898" face=3D"Courier New, courier, monaco, monospace, sans-serif"><b id=3D"= yui_3_16_0_ym19_1_1483589602794_47897"><span id=3D"yui_3_16_0_ym19_1_148358= 9602794_45336"> = &nb= sp; = &nb= sp; "src.######.bak" -> inode1</span></b></font></div><div i= d=3D"yui_3_16_0_ym19_1_1483589602794_45337"><font id=3D"yui_3_16_0_ym19_1_1= 483589602794_47834" face=3D"Courier New, courier, monaco, monospace, sans-s= erif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_47833"><span id=3D"yui_3_16_= 0_ym19_1_1483589602794_45338"> &nb= sp; = &nb= sp; = "src" -> inode2</span></b></font></div><f= ont face=3D"Courier New, courier, monaco, monospace, sans-serif"><b><span i= d=3D"yui_3_16_0_ym19_1_1483589602794_45344">rename ("src.######.bak", "dest= ");</span></b></font><div id=3D"yui_3_16_0_ym19_1_1483589602794_45345"><fon= t id=3D"yui_3_16_0_ym19_1_1483589602794_48020" face=3D"Courier New, courier= , monaco, monospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_4= 8019"><span id=3D"yui_3_16_0_ym19_1_1483589602794_45346"> = &nb= sp; = &nb= sp; finally:</span></= b></font></div><div id=3D"yui_3_16_0_ym19_1_1483589602794_45347"><font id= =3D"yui_3_16_0_ym19_1_1483589602794_48018" face=3D"Courier New, courier, mo= naco, monospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_48017= "><span id=3D"yui_3_16_0_ym19_1_1483589602794_45348"> &nbs= p; &= nbsp; &nbs= p; &= nbsp; "src" -> inode1</s= pan></b></font></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483589602794= _45349"><font id=3D"yui_3_16_0_ym19_1_1483589602794_47896" face=3D"Courier = New, courier, monaco, monospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_148= 3589602794_47895"><span id=3D"yui_3_16_0_ym19_1_1483589602794_45350"> = &nb= sp; = &nb= sp; "dest= " -> inode1</span></b></font></div> <div class=3D"qtdSeparateBR" id=3D"y= ui_3_16_0_ym19_1_1483589602794_45099"><div id=3D"yui_3_16_0_ym19_1_14835896= 02794_45369"><br></div><div id=3D"yui_3_16_0_ym19_1_1483589602794_45698">Wh= ere initial content of file <b>"dest"</b> was lost.</div><div id=3D"yui_3_1= 6_0_ym19_1_1483589602794_45703">Of course, it would be much better if <b>li= nkat()</b> had additional flag:</div><div id=3D"yui_3_16_0_ym19_1_148358960= 2794_45718"><br></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_148358960279= 4_47339"><b id=3D"yui_3_16_0_ym19_1_1483589602794_47470">int linkat (AT_CWD= FD, "source", AT_CWDFD, "dest", AT_SYMLINK_FOLLOW | AT_FORCE_OVERWRITE);</b= ></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483589602794_47390"><br></= div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483589602794_47396">but as yo= u have correctly said, we cannot influence POSIX and Linux kernel makers.</= div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483589602794_47429"><br></div= ><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483589602794_47430">Sorry if I t= ook too much of your time. Thank Heavens for such good and logical design o= f UN*X filesystems.<br></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_14835= 89602794_47435"><br></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_14835896= 02794_47436">Regards and All the best,</div><div dir=3D"ltr" id=3D"yui_3_16= _0_ym19_1_1483589602794_47451">M.T.</div><div dir=3D"ltr" id=3D"yui_3_16_0_= ym19_1_1483589602794_47452"><br></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym1= 9_1_1483589602794_48063">__________________________________________________= _____________________________________<br></div><br></div><div class=3D"yaho= o_quoted" id=3D"yui_3_16_0_ym19_1_1483589602794_45158" style=3D"display: bl= ock;"> <div style=3D"font-family: HelveticaNeue, Helvetica Neue, Helvetica,= Arial, Lucida Grande, sans-serif; font-size: 13px;" id=3D"yui_3_16_0_ym19_= 1_1483589602794_45157"> <div style=3D"font-family: HelveticaNeue, Helvetica= Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id=3D= "yui_3_16_0_ym19_1_1483589602794_45156"> <div dir=3D"ltr" id=3D"yui_3_16_0_= ym19_1_1483589602794_45165"><font id=3D"yui_3_16_0_ym19_1_1483589602794_451= 63" size=3D"2" face=3D"Arial"> On Thursday, January 5, 2017 9:50 AM, Mirsad= Goran Todorovac <mtodorov3_69@HIDDEN> wrote:<br></font></div> <b= r><br> <div class=3D"y_msg_container" id=3D"yui_3_16_0_ym19_1_1483589602794= _45190"><div id=3D"yiv0006961443"><div id=3D"yui_3_16_0_ym19_1_148358960279= 4_45189"><div style=3D"color:#000;background-color:#fff;font-family:Helveti= caNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-si= ze:13px;" id=3D"yui_3_16_0_ym19_1_1483589602794_45188"><div id=3D"yiv000696= 1443yui_3_16_0_ym19_1_1483589602794_39521"><span id=3D"yui_3_16_0_ym19_1_14= 83589602794_45187">Pity, 'cause it works for me with a small workaround:</s= pan></div><div dir=3D"ltr" id=3D"yiv0006961443yui_3_16_0_ym19_1_14835896027= 94_39540"><span></span><span id=3D"yiv0006961443yui_3_16_0_ym19_1_148358960= 2794_39548"><font id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39549"= face=3D"Courier New, courier, monaco, monospace, sans-serif"><b id=3D"yiv0= 006961443yui_3_16_0_ym19_1_1483589602794_39550">link("copy2", "copy2~")&nbs= p; &= nbsp; =3D 0<br id=3D"yiv0006961443yui_3_16_0_ym19_1_14835896027= 94_39551" clear=3D"none">getpid() = &nb= sp; =3D 3= 085<br id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39552" clear=3D"n= one">linkat(AT_FDCWD, "copy", AT_FDCWD, "copy.003085.bak", 0) =3D 0<br id= =3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39553" clear=3D"none">rena= meat(AT_FDCWD, "copy.003085.bak", AT_FDCWD, "copy2") =3D 0</b></font></span= ></div><div dir=3D"ltr" id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_= 39573"><span id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39548"><fon= t id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39549"><b id=3D"yiv000= 6961443yui_3_16_0_ym19_1_1483589602794_39550"><br clear=3D"none"></b></font= ></span></div><div dir=3D"ltr" id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589= 602794_39598"><span id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_3954= 8"><font id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39549">I did no= t exactly understand? What else can be moved, if not two hard links?</font>= </span></div><div dir=3D"ltr" id=3D"yiv0006961443yui_3_16_0_ym19_1_14835896= 02794_39901"><span id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39548= "><font id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39549">Directory= entry can be one of pointer to inode (file, directory or less likely somet= hing else), or pointer to another directory entry (symbolic link), ain't th= at right?</font></span></div><div dir=3D"ltr" id=3D"yiv0006961443yui_3_16_0= _ym19_1_1483589602794_39736"><span id=3D"yiv0006961443yui_3_16_0_ym19_1_148= 3589602794_39548"><br clear=3D"none"></span></div><div dir=3D"ltr" id=3D"yi= v0006961443yui_3_16_0_ym19_1_1483589602794_39895"><span id=3D"yiv0006961443= yui_3_16_0_ym19_1_1483589602794_39548">Can you please provide me with a ref= erence of such behavior of renameat()? I realized just now that you want to= make your code universal and protable.</span></div><div dir=3D"ltr" id=3D"= yiv0006961443yui_3_16_0_ym19_1_1483589602794_39982"><span id=3D"yiv00069614= 43yui_3_16_0_ym19_1_1483589602794_39548">On Ubuntu Linux it works for me.</= span></div><div dir=3D"ltr" id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602= 794_41656"><span id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39548">= <br clear=3D"none"></span></div><div dir=3D"ltr" id=3D"yiv0006961443yui_3_1= 6_0_ym19_1_1483589602794_41731"><font face=3D"Courier New, courier, monaco,= monospace, sans-serif"><b id=3D"yiv0006961443yui_3_16_0_ym19_1_14835896027= 94_42002"><span id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39548">m= arvin@marvin-desktop:~$ uname -a<br id=3D"yiv0006961443yui_3_16_0_ym19_1_14= 83589602794_41853" clear=3D"none">Linux marvin-desktop 3.5.0-34-generic #55= -Ubuntu SMP Thu Jun 6 20:20:19 UTC 2013 i686 athlon i686 GNU/Linux<br id=3D= "yiv0006961443yui_3_16_0_ym19_1_1483589602794_41854" clear=3D"none">marvin@= marvin-desktop:~$ dpkg -l | egrep 'libc6'<br clear=3D"none"></span></b></fo= nt></div><div dir=3D"ltr" id=3D"yiv0006961443yui_3_16_0_ym19_1_148358960279= 4_41655"><font face=3D"Courier New, courier, monaco, monospace, sans-serif"= ><span id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39548"><b id=3D"y= iv0006961443yui_3_16_0_ym19_1_1483589602794_42006">ii libc6:i386 = ; &n= bsp;  = ; 2.23-0ubuntu5 = &nb= sp; = i386 GNU= C </b><br clear=3D"none"></span></font></div><div dir=3D"ltr" id=3D"yiv000= 6961443yui_3_16_0_ym19_1_1483589602794_39594"><span id=3D"yiv0006961443yui_= 3_16_0_ym19_1_1483589602794_39548"><font id=3D"yiv0006961443yui_3_16_0_ym19= _1_1483589602794_39549" face=3D"Courier New, courier, monaco, monospace, sa= ns-serif"><b id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39550"><br = clear=3D"none"></b></font></span></div><div dir=3D"ltr" id=3D"yiv0006961443= yui_3_16_0_ym19_1_1483589602794_42000"><span id=3D"yiv0006961443yui_3_16_0_= ym19_1_1483589602794_39548"><font id=3D"yiv0006961443yui_3_16_0_ym19_1_1483= 589602794_39549" face=3D"Courier New, courier, monaco, monospace, sans-seri= f"><b id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39550">If you can = provide me with a reference, I'll try to understand renameat() problem.</b>= </font></span></div><div dir=3D"ltr" id=3D"yiv0006961443yui_3_16_0_ym19_1_1= 483589602794_42089"><span id=3D"yiv0006961443yui_3_16_0_ym19_1_148358960279= 4_39548"><font id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39549" fa= ce=3D"Courier New, courier, monaco, monospace, sans-serif"><b id=3D"yiv0006= 961443yui_3_16_0_ym19_1_1483589602794_39550"><br clear=3D"none"></b></font>= </span></div><div dir=3D"ltr" id=3D"yiv0006961443yui_3_16_0_ym19_1_14835896= 02794_42119"><span id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39548= "><font id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39549" face=3D"C= ourier New, courier, monaco, monospace, sans-serif"><b id=3D"yiv0006961443y= ui_3_16_0_ym19_1_1483589602794_39550">Best of luck in New Year,</b></font><= /span></div><div dir=3D"ltr" id=3D"yiv0006961443yui_3_16_0_ym19_1_148358960= 2794_42121"><span id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39548"= ><font id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39549" face=3D"Co= urier New, courier, monaco, monospace, sans-serif"><b id=3D"yiv0006961443yu= i_3_16_0_ym19_1_1483589602794_39550">M.T.</b></font></span></div><div dir= =3D"ltr"><span id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39548"><f= ont id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39549" face=3D"Couri= er New, courier, monaco, monospace, sans-serif"><b id=3D"yiv0006961443yui_3= _16_0_ym19_1_1483589602794_39550"><br clear=3D"none"></b></font></span></di= v><div dir=3D"ltr" id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39682= "><span id=3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39548"><font id= =3D"yiv0006961443yui_3_16_0_ym19_1_1483589602794_39549" face=3D"Courier New= , courier, monaco, monospace, sans-serif"><b id=3D"yiv0006961443yui_3_16_0_= ym19_1_1483589602794_39550"><br clear=3D"none"></b></font></span></div> <di= v class=3D"yiv0006961443qtdSeparateBR"><br clear=3D"none"><br clear=3D"none= "></div><div class=3D"yiv0006961443yqt9226908023" id=3D"yiv0006961443yqt036= 73"><div class=3D"yiv0006961443yahoo_quoted" style=3D"display:block;"> <div= style=3D"font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Luci= da Grande, sans-serif;font-size:13px;"> <div style=3D"font-family:Helvetica= Neue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size= :16px;"> <div dir=3D"ltr"><font size=3D"2" face=3D"Arial"> On Thursday, Jan= uary 5, 2017 8:57 AM, Paul Eggert <eggert@HIDDEN> wrote:<br clea= r=3D"none"></font></div> <br clear=3D"none"><br clear=3D"none"> <div class= =3D"yiv0006961443y_msg_container">Mirsad Goran Todorovac wrote:<div class= =3D"yiv0006961443yqt0726665938" id=3D"yiv0006961443yqtfd23706"><br clear=3D= "none">> Please consider the trace below.</div><br clear=3D"none"><br cl= ear=3D"none">As I don't know what you're tracing, I don't know what to cons= ider.<br clear=3D"none"><br clear=3D"none">But really, the basic idea is si= mple: renameat mishandles the case where old and <br clear=3D"none">new nam= es are already hard links, and any code based on renameat needs to work <br= clear=3D"none">around this problem. (We can't easily change renameat's beh= avior, as the <br clear=3D"none">behavior is required by POSIX.)<div class= =3D"yiv0006961443yqt0726665938" id=3D"yiv0006961443yqtfd50656"><br clear=3D= "none"></div><br clear=3D"none"><br clear=3D"none"></div> </div> </div> <= /div></div></div></div></div><br><br></div> </div> </div> </div></div></b= ody></html> ------=_Part_326599_453837390.1483608254726--
bug-coreutils@HIDDEN
:bug#25342
; Package coreutils
.
Full text available.Received: (at 25342) by debbugs.gnu.org; 5 Jan 2017 08:51:03 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 05 03:51:03 2017 Received: from localhost ([127.0.0.1]:41721 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1cP3lH-0003IV-7B for submit <at> debbugs.gnu.org; Thu, 05 Jan 2017 03:51:03 -0500 Received: from nm28.bullet.mail.bf1.yahoo.com ([98.139.212.187]:38081) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mtodorov3_69@HIDDEN>) id 1cP3lE-0003Hy-Sm for 25342 <at> debbugs.gnu.org; Thu, 05 Jan 2017 03:51:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1483606255; bh=i9kR+1kMaFjkoTKRBWyTJbL6rKkx8nGHr2Foi8FDE7o=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=JcAXdMzbBDZ9rmc5ksvVQwX+AwFlXrXw0Yj6OHE/ee0cVETeopoa2J3v+XJ0ije4dBoSUzVQr8PByD7KHssIY8UVgX/bYn62FeAwhH2h9P7WXH1pjCaGX19W5nSHRVsNxEmR9G7HimlB6JZQ2mh/Wv0zKbQIFGLjLckGIeusAZHQH85kPIXoLJdXm/QfX3HoIT0uw7eo0pG3/BHogQMxFXNrkIxZj0/mjAgnOSpC/hPL5N6ggTOVXwGWkwRiFCeb44ANXmUmcM+5RFOY9eMX6aIRA93xcskpG/P1lRHM7MOSbCuw6sRtLYVRsWMOC+hjzwwJFeH3smqc53xEsQPk7w== Received: from [98.139.170.178] by nm28.bullet.mail.bf1.yahoo.com with NNFMP; 05 Jan 2017 08:50:55 -0000 Received: from [98.139.215.251] by tm21.bullet.mail.bf1.yahoo.com with NNFMP; 05 Jan 2017 08:50:55 -0000 Received: from [127.0.0.1] by omp1064.mail.bf1.yahoo.com with NNFMP; 05 Jan 2017 08:50:55 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 141314.62285.bm@HIDDEN X-YMail-OSG: Q8KK4QcVM1nEdvViWzZUpFju6MNLwAOQcphKqSwJKvt6f1dP3rBauxMxDiiViR2 t0Bbu6YyYSTI.iszg0D8fcJgVjH7PPQdpv27HOqt3V_0ePo4SdE_R505XfJPsMMrKerKKtz3Ccsn 0g.IKtntezLZnZcBAGRAIOC6q2KBdI1IvaE3vGCeRaBqdNP_f2Iw741T58rdB0oiKExIHVJ5.wfO i1OkhxkxImkCqrcod9abWZoee5O7E0kwJwcGe9Aa8vf2ecfjZduY.5lO3OoUPFFWidHov7zZIvYX 9.fzL_si3cLBAFFt7qCACr8mQ2tPW2joRovxj1i_6o0hxXY8dDIH.puJqRAcXZ17GEpLyJwWdOwo gREYn5_bWsyALgUWf5vW4lr4wkrMxIwbwkfwqnCdM883V4v8Ba12jkRx9FK0KIybfoyyKfRQrbd5 uyOzlCx4LfEt8v96KueznlsKyYK47wY_x4ldiQE_Oh.qo5FnzZLdMQXCAcM5o1c0XKuMhartbyI2 uDpBMwC_mHupPkV8yW96xRiw4Vg-- Received: from jws400084.mail.bf2.yahoo.com by sendmailws146.mail.bf1.yahoo.com; Thu, 05 Jan 2017 08:50:54 +0000; 1483606254.784 Date: Thu, 5 Jan 2017 08:50:54 +0000 (UTC) From: Mirsad Goran Todorovac <mtodorov3_69@HIDDEN> To: Paul Eggert <eggert@HIDDEN>, "25342 <at> debbugs.gnu.org" <25342 <at> debbugs.gnu.org> Message-ID: <1800336792.301174.1483606254527@HIDDEN> In-Reply-To: <9dbe3286-34a6-d5ed-0c6d-f72a57b8a7ef@HIDDEN> References: <727818896.5504359.1483394315468.ref@HIDDEN> <727818896.5504359.1483394315468@HIDDEN> <f0b8dd92-16d5-7037-def7-764bba990ce3@HIDDEN> <1871443711.5629967.1483414377142@HIDDEN> <eab724e3-39e7-e141-b5cb-ac61839de4cd@HIDDEN> <99417190.6944768.1483563757518@HIDDEN> <9dbe3286-34a6-d5ed-0c6d-f72a57b8a7ef@HIDDEN> Subject: Re: bug#25342: GNU coreutils: race condition in "ln -f source dest" MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_301173_574814205.1483606254523" Content-Length: 10278 X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 25342 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Reply-To: Mirsad Goran Todorovac <mtodorov3_69@HIDDEN> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.7 (--) ------=_Part_301173_574814205.1483606254523 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Pity, 'cause it works for me with a small workaround:link("copy2", "copy2~"= )=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 =3D 0 getpid()=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 3085 linkat(AT_FDCWD, "copy", AT_FDCWD, "copy.003085.bak", 0) =3D 0 renameat(AT_FDCWD, "copy.003085.bak", AT_FDCWD, "copy2") =3D 0 I did not exactly understand? What else can be moved, if not two hard links= ?Directory entry can be one of pointer to inode (file, directory or less li= kely something else), or pointer to another directory entry (symbolic link)= , ain't that right? Can you please provide me with a reference of such behavior of renameat()? = I realized just now that you want to make your code universal and protable.= On Ubuntu Linux it works for me. marvin@marvin-desktop:~$ uname -a Linux marvin-desktop 3.5.0-34-generic #55-Ubuntu SMP Thu Jun 6 20:20:19 UTC= 2013 i686 athlon i686 GNU/Linux marvin@marvin-desktop:~$ dpkg -l | egrep 'libc6' ii=C2=A0 libc6:i386=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 2.23-0ubunt= u5=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 i386=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 GNU C=20 If you can provide me with a reference, I'll try to understand renameat() p= roblem. Best of luck in New Year,M.T. =20 On Thursday, January 5, 2017 8:57 AM, Paul Eggert <eggert@HIDDEN> = wrote: =20 Mirsad Goran Todorovac wrote: > Please consider the trace below. As I don't know what you're tracing, I don't know what to consider. But really, the basic idea is simple: renameat mishandles the case where ol= d and=20 new names are already hard links, and any code based on renameat needs to w= ork=20 around this problem. (We can't easily change renameat's behavior, as the=20 behavior is required by POSIX.) =20 ------=_Part_301173_574814205.1483606254523 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <html><head></head><body><div style=3D"color:#000; background-color:#fff; f= ont-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, = sans-serif;font-size:13px"><div id=3D"yui_3_16_0_ym19_1_1483589602794_39521= "><span>Pity, 'cause it works for me with a small workaround:</span></div><= div id=3D"yui_3_16_0_ym19_1_1483589602794_39540" dir=3D"ltr"><span></span><= span id=3D"yui_3_16_0_ym19_1_1483589602794_39548"><font id=3D"yui_3_16_0_ym= 19_1_1483589602794_39549" face=3D"Courier New, courier, monaco, monospace, = sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_39550">link("copy2", "= copy2~") &= nbsp; =3D 0<br id=3D"yui_3_16_0_ym19_1_148358960279= 4_39551" clear=3D"none">getpid() &= nbsp; &nbs= p; =3D 30= 85<br id=3D"yui_3_16_0_ym19_1_1483589602794_39552" clear=3D"none">linkat(AT= _FDCWD, "copy", AT_FDCWD, "copy.003085.bak", 0) =3D 0<br id=3D"yui_3_16_0_y= m19_1_1483589602794_39553" clear=3D"none">renameat(AT_FDCWD, "copy.003085.b= ak", AT_FDCWD, "copy2") =3D 0</b></font></span></div><div dir=3D"ltr" id=3D= "yui_3_16_0_ym19_1_1483589602794_39573"><span id=3D"yui_3_16_0_ym19_1_14835= 89602794_39548"><font id=3D"yui_3_16_0_ym19_1_1483589602794_39549"><b id=3D= "yui_3_16_0_ym19_1_1483589602794_39550"><br></b></font></span></div><div di= r=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483589602794_39598"><span id=3D"yui_3_16= _0_ym19_1_1483589602794_39548"><font id=3D"yui_3_16_0_ym19_1_1483589602794_= 39549">I did not exactly understand? What else can be moved, if not two har= d links?</font></span></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_148358= 9602794_39901"><span id=3D"yui_3_16_0_ym19_1_1483589602794_39548"><font id= =3D"yui_3_16_0_ym19_1_1483589602794_39549">Directory entry can be one of po= inter to inode (file, directory or less likely something else), or pointer = to another directory entry (symbolic link), ain't that right?</font></span>= </div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483589602794_39736"><span i= d=3D"yui_3_16_0_ym19_1_1483589602794_39548"><br></span></div><div dir=3D"lt= r" id=3D"yui_3_16_0_ym19_1_1483589602794_39895"><span id=3D"yui_3_16_0_ym19= _1_1483589602794_39548">Can you please provide me with a reference of such = behavior of renameat()? I realized just now that you want to make your code= universal and protable.</span></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19= _1_1483589602794_39982"><span id=3D"yui_3_16_0_ym19_1_1483589602794_39548">= On Ubuntu Linux it works for me.</span></div><div dir=3D"ltr" id=3D"yui_3_1= 6_0_ym19_1_1483589602794_41656"><span id=3D"yui_3_16_0_ym19_1_1483589602794= _39548"><br></span></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_148358960= 2794_41731"><font face=3D"Courier New, courier, monaco, monospace, sans-ser= if"><b id=3D"yui_3_16_0_ym19_1_1483589602794_42002"><span id=3D"yui_3_16_0_= ym19_1_1483589602794_39548">marvin@marvin-desktop:~$ uname -a<br id=3D"yui_= 3_16_0_ym19_1_1483589602794_41853">Linux marvin-desktop 3.5.0-34-generic #5= 5-Ubuntu SMP Thu Jun 6 20:20:19 UTC 2013 i686 athlon i686 GNU/Linux<br id= =3D"yui_3_16_0_ym19_1_1483589602794_41854">marvin@marvin-desktop:~$ dpkg -l= | egrep 'libc6'<br></span></b></font></div><div dir=3D"ltr" id=3D"yui_3_16= _0_ym19_1_1483589602794_41655"><font face=3D"Courier New, courier, monaco, = monospace, sans-serif"><span id=3D"yui_3_16_0_ym19_1_1483589602794_39548"><= b id=3D"yui_3_16_0_ym19_1_1483589602794_42006">ii libc6:i386 &nb= sp; = &nb= sp; 2.23-0ubuntu5 &nbs= p; &= nbsp; &nbs= p; i386 GNU C <= /b><br></span></font></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483589= 602794_39594"><span id=3D"yui_3_16_0_ym19_1_1483589602794_39548"><font id= =3D"yui_3_16_0_ym19_1_1483589602794_39549" face=3D"Courier New, courier, mo= naco, monospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_39550= "><br></b></font></span></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483= 589602794_42000"><span id=3D"yui_3_16_0_ym19_1_1483589602794_39548"><font i= d=3D"yui_3_16_0_ym19_1_1483589602794_39549" face=3D"Courier New, courier, m= onaco, monospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_3955= 0">If you can provide me with a reference, I'll try to understand renameat(= ) problem.</b></font></span></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_= 1483589602794_42089"><span id=3D"yui_3_16_0_ym19_1_1483589602794_39548"><fo= nt id=3D"yui_3_16_0_ym19_1_1483589602794_39549" face=3D"Courier New, courie= r, monaco, monospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_= 39550"><br></b></font></span></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1= _1483589602794_42119"><span id=3D"yui_3_16_0_ym19_1_1483589602794_39548"><f= ont id=3D"yui_3_16_0_ym19_1_1483589602794_39549" face=3D"Courier New, couri= er, monaco, monospace, sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794= _39550">Best of luck in New Year,</b></font></span></div><div dir=3D"ltr" i= d=3D"yui_3_16_0_ym19_1_1483589602794_42121"><span id=3D"yui_3_16_0_ym19_1_1= 483589602794_39548"><font id=3D"yui_3_16_0_ym19_1_1483589602794_39549" face= =3D"Courier New, courier, monaco, monospace, sans-serif"><b id=3D"yui_3_16_= 0_ym19_1_1483589602794_39550">M.T.</b></font></span></div><div dir=3D"ltr">= <span id=3D"yui_3_16_0_ym19_1_1483589602794_39548"><font id=3D"yui_3_16_0_y= m19_1_1483589602794_39549" face=3D"Courier New, courier, monaco, monospace,= sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_39550"><br></b></font= ></span></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483589602794_39682"= ><span id=3D"yui_3_16_0_ym19_1_1483589602794_39548"><font id=3D"yui_3_16_0_= ym19_1_1483589602794_39549" face=3D"Courier New, courier, monaco, monospace= , sans-serif"><b id=3D"yui_3_16_0_ym19_1_1483589602794_39550"><br></b></fon= t></span></div> <div class=3D"qtdSeparateBR"><br><br></div><div class=3D"ya= hoo_quoted" style=3D"display: block;"> <div style=3D"font-family: Helvetica= Neue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-siz= e: 13px;"> <div style=3D"font-family: HelveticaNeue, Helvetica Neue, Helvet= ica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir=3D"ltr">= <font size=3D"2" face=3D"Arial"> On Thursday, January 5, 2017 8:57 AM, Paul= Eggert <eggert@HIDDEN> wrote:<br></font></div> <br><br> <div c= lass=3D"y_msg_container">Mirsad Goran Todorovac wrote:<div class=3D"yqt0726= 665938" id=3D"yqtfd23706"><br clear=3D"none">> Please consider the trace= below.</div><br clear=3D"none"><br clear=3D"none">As I don't know what you= 're tracing, I don't know what to consider.<br clear=3D"none"><br clear=3D"= none">But really, the basic idea is simple: renameat mishandles the case wh= ere old and <br clear=3D"none">new names are already hard links, and any co= de based on renameat needs to work <br clear=3D"none">around this problem. = (We can't easily change renameat's behavior, as the <br clear=3D"none">beha= vior is required by POSIX.)<div class=3D"yqt0726665938" id=3D"yqtfd50656"><= br clear=3D"none"></div><br><br></div> </div> </div> </div></div></body><= /html> ------=_Part_301173_574814205.1483606254523--
bug-coreutils@HIDDEN
:bug#25342
; Package coreutils
.
Full text available.Received: (at 25342) by debbugs.gnu.org; 5 Jan 2017 07:57:39 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 05 02:57:39 2017 Received: from localhost ([127.0.0.1]:41712 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1cP2va-000236-VE for submit <at> debbugs.gnu.org; Thu, 05 Jan 2017 02:57:39 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:35092) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eggert@HIDDEN>) id 1cP2vZ-00022s-8o for 25342 <at> debbugs.gnu.org; Thu, 05 Jan 2017 02:57:38 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 0C36716009F; Wed, 4 Jan 2017 23:57:30 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id CIYrp985ebFF; Wed, 4 Jan 2017 23:57:29 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 60AB31600BE; Wed, 4 Jan 2017 23:57:29 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id JzVdIWFNDQ8r; Wed, 4 Jan 2017 23:57:29 -0800 (PST) Received: from [192.168.1.9] (unknown [47.153.178.162]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 436FA16009F; Wed, 4 Jan 2017 23:57:29 -0800 (PST) Subject: Re: bug#25342: GNU coreutils: race condition in "ln -f source dest" To: Mirsad Goran Todorovac <mtodorov3_69@HIDDEN>, "25342 <at> debbugs.gnu.org" <25342 <at> debbugs.gnu.org> References: <727818896.5504359.1483394315468.ref@HIDDEN> <727818896.5504359.1483394315468@HIDDEN> <f0b8dd92-16d5-7037-def7-764bba990ce3@HIDDEN> <1871443711.5629967.1483414377142@HIDDEN> <eab724e3-39e7-e141-b5cb-ac61839de4cd@HIDDEN> <99417190.6944768.1483563757518@HIDDEN> From: Paul Eggert <eggert@HIDDEN> Organization: UCLA Computer Science Department Message-ID: <9dbe3286-34a6-d5ed-0c6d-f72a57b8a7ef@HIDDEN> Date: Wed, 4 Jan 2017 23:57:29 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <99417190.6944768.1483563757518@HIDDEN> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -3.2 (---) X-Debbugs-Envelope-To: 25342 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.2 (---) Mirsad Goran Todorovac wrote: > Please consider the trace below. As I don't know what you're tracing, I don't know what to consider. But really, the basic idea is simple: renameat mishandles the case where old and new names are already hard links, and any code based on renameat needs to work around this problem. (We can't easily change renameat's behavior, as the behavior is required by POSIX.)
bug-coreutils@HIDDEN
:bug#25342
; Package coreutils
.
Full text available.Received: (at 25342) by debbugs.gnu.org; 4 Jan 2017 21:02:46 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jan 04 16:02:46 2017 Received: from localhost ([127.0.0.1]:41495 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1cOshp-0000El-PJ for submit <at> debbugs.gnu.org; Wed, 04 Jan 2017 16:02:46 -0500 Received: from nm19-vm0.bullet.mail.bf1.yahoo.com ([98.139.213.162]:47531) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mtodorov3_69@HIDDEN>) id 1cOshn-0000EV-Rg for 25342 <at> debbugs.gnu.org; Wed, 04 Jan 2017 16:02:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1483563758; bh=YxtD8ItIxZJdQZGJpXduF77xV1vtcxFPf3wESyK4Wys=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=NkryYvx82BrtIwpEXux/Oi+vrjuy8HErGbthHwYl6hyMdDKKNkPiYNgxRJVZpIPJK0jtTDHdZW3rRKgUwGRbqLVQXuTzBFFouqDwL8GirLrvTvo2R/0q6jc5hdi8mcBxdHgHqwj7Qhy+RvCVo8pJ9PrQmGbreYTOMZqtSoE7IhGLe5hWsqLc4Fsmt24xUHeVN1OOd1hs8/Sb92sYtKnYF+8OZt6+oqb9F5tZefbtqM3HGztT4FjN8psgoEaZ1xksZL5jLZVvQhQqj6Np3d5p3Dbv8HC2yNCR8v9SSkIlcnR/G9ePgJaj/Pt6xEZc9pEIIEZ26wspa5Nw5Qd3diY/mQ== Received: from [98.139.215.143] by nm19.bullet.mail.bf1.yahoo.com with NNFMP; 04 Jan 2017 21:02:38 -0000 Received: from [98.139.212.216] by tm14.bullet.mail.bf1.yahoo.com with NNFMP; 04 Jan 2017 21:02:38 -0000 Received: from [127.0.0.1] by omp1025.mail.bf1.yahoo.com with NNFMP; 04 Jan 2017 21:02:38 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 248399.83118.bm@HIDDEN X-YMail-OSG: P1FbCKEVM1l6AH07a2tCW113yA28NEHfNLdunL5kgOCfn9R0_BWPZj3lv39bqxF UxjJDAhgvB1W..v8Q9SuMqdOMLfk1fCRXgUtOlu2VJNTVztLOorSV4xAPpjEv90VrdmrSbqw0Q3K kezOonlG.119QfrV7WORH.iOR7LYW5mf0FcnHOS1LcT0H8aocmd1BMI3KOCqxHQEPmKtBqXh.Z52 fu13fxuVDtFwfJvRzmQ7tdwhD3.n.sWhZQz9fpLlH7RpTaGARv1zha4wb1Oeo1EyL7OtQbjZUrbW XEAqYYdFUZMQPw8o_NEHG8g5_iGcLZnnsGisOySRjzOMngfTcviXxF3hJvvrEXaxXTwFjhPKp_OT KJRgPE.6u3J9iBL4VlzmqE9Xjpu.xI.Sa9sMu8enKF4aJuE7tbUTIpZiDFLg.p9EbqOpjpSHY1o9 QiLQdbntyH3PNbe7QQ8u_uoDVJK0R2t3Iwh_.c8zal0YryfbwzzfUrcPgG9AekplpPxt5a57YZPH OwZm_0yzGRdMpFHuI4nQnMIaXfk7EsKE5409cIJQ- Received: from jws400173.mail.bf2.yahoo.com by sendmailws125.mail.bf1.yahoo.com; Wed, 04 Jan 2017 21:02:37 +0000; 1483563757.801 Date: Wed, 4 Jan 2017 21:02:37 +0000 (UTC) From: Mirsad Goran Todorovac <mtodorov3_69@HIDDEN> To: Paul Eggert <eggert@HIDDEN>, "25342 <at> debbugs.gnu.org" <25342 <at> debbugs.gnu.org> Message-ID: <99417190.6944768.1483563757518@HIDDEN> In-Reply-To: <eab724e3-39e7-e141-b5cb-ac61839de4cd@HIDDEN> References: <727818896.5504359.1483394315468.ref@HIDDEN> <727818896.5504359.1483394315468@HIDDEN> <f0b8dd92-16d5-7037-def7-764bba990ce3@HIDDEN> <1871443711.5629967.1483414377142@HIDDEN> <eab724e3-39e7-e141-b5cb-ac61839de4cd@HIDDEN> Subject: Re: bug#25342: GNU coreutils: race condition in "ln -f source dest" MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_6944767_100673996.1483563757515" Content-Length: 25778 X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 25342 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Reply-To: Mirsad Goran Todorovac <mtodorov3_69@HIDDEN> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.7 (--) ------=_Part_6944767_100673996.1483563757515 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I did not understand this no-op behavior. It is unlike what my Ubuntu kerne= l experienced. I may later try to see what 4.x kernels do ... Please consider the trace below. Thank you. M.T. marvin@marvin-desktop:~$ uname -a Linux marvin-desktop 3.5.0-34-generic #55-Ubuntu SMP Thu Jun 6 20:20:19 UTC= 2013 i686 athlon i686 GNU/Linux marvin@marvin-desktop:~$=20 marvin@marvin-desktop:~$ rm -f copy copy2 copy2~ ; cp /etc/resolv.conf.orig= copy ; cp /etc/resolv.conf copy2 marvin@marvin-desktop:~$ cat copy copy2 # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf= (8) #=C2=A0=C2=A0=C2=A0=C2=A0 DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WIL= L BE OVERWRITTEN nameserver 127.0.1.1 search lan # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf= (8) #=C2=A0=C2=A0=C2=A0=C2=A0 DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WIL= L BE OVERWRITTEN nameserver 194.146.109.223 nameserver 194.146.109.224 search lan marvin@marvin-desktop:~$ strace coreutils-devel/bin/ln -b -fo copy copy2 execve("coreutils-devel/bin/ln", ["coreutils-devel/bin/ln", "-b", "-fo", "c= opy", "copy2"], [/* 65 vars */]) =3D 0 brk(NULL)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 0xa036000 access("/etc/ld.so.nohwcap", F_OK)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D -1 ENO= ENT (No such file or directory) mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = =3D 0xb7745000 access("/etc/ld.so.preload", R_OK)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D -1 ENO= ENT (No such file or directory) open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) =3D 3 fstat64(3, {st_mode=3DS_IFREG|0644, st_size=3D127411, ...}) =3D 0 mmap2(NULL, 127411, PROT_READ, MAP_PRIVATE, 3, 0) =3D 0xb7725000 close(3)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 0 access("/etc/ld.so.nohwcap", F_OK)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D -1 ENO= ENT (No such file or directory) open("/lib/i386-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) =3D 3 read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\320\207\1\0004\0\0= \0"..., 512) =3D 512 fstat64(3, {st_mode=3DS_IFREG|0755, st_size=3D1786484, ...}) =3D 0 mmap2(NULL, 1792540, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = =3D 0xb756f000 mprotect(0xb771e000, 4096, PROT_NONE)=C2=A0=C2=A0 =3D 0 mmap2(0xb771f000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DE= NYWRITE, 3, 0x1af000) =3D 0xb771f000 mmap2(0xb7722000, 10780, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_AN= ONYMOUS, -1, 0) =3D 0xb7722000 close(3)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 0 mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = =3D 0xb756e000 set_thread_area({entry_number:-1, base_addr:0xb756e940, limit:1048575, seg_= 32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0,= useable:1}) =3D 0 (entry_number:6) mprotect(0xb771f000, 8192, PROT_READ)=C2=A0=C2=A0 =3D 0 mprotect(0x8058000, 4096, PROT_READ)=C2=A0=C2=A0=C2=A0 =3D 0 mprotect(0xb776a000, 4096, PROT_READ)=C2=A0=C2=A0 =3D 0 munmap(0xb7725000, 127411)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 0 brk(NULL)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 0xa036000 brk(0xa057000)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 =3D 0xa057000 open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE|O_CLOEXEC) =3D = 3 fstat64(3, {st_mode=3DS_IFREG|0644, st_size=3D4229984, ...}) =3D 0 mmap2(NULL, 2097152, PROT_READ, MAP_PRIVATE, 3, 0) =3D 0xb736e000 mmap2(NULL, 4096, PROT_READ, MAP_PRIVATE, 3, 0x2d4000) =3D 0xb7744000 close(3)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 0 stat64("copy2", {st_mode=3DS_IFREG|0644, st_size=3D216, ...}) =3D 0 open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) =3D 3 fstat64(3, {st_mode=3DS_IFREG|0644, st_size=3D2995, ...}) =3D 0 read(3, "# Locale name alias data base.\n#"..., 4096) =3D 2995 read(3, "", 4096)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =3D 0 close(3)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 0 open("/home/marvin/coreutils-devel/share/locale/en_US/LC_MESSAGES/coreutils= .mo", O_RDONLY) =3D -1 ENOENT (No such file or directory) open("/home/marvin/coreutils-devel/share/locale/en/LC_MESSAGES/coreutils.mo= ", O_RDONLY) =3D -1 ENOENT (No such file or directory) open("/usr/share/locale-langpack/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY)= =3D -1 ENOENT (No such file or directory) open("/usr/share/locale-langpack/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = =3D 3 fstat64(3, {st_mode=3DS_IFREG|0644, st_size=3D619, ...}) =3D 0 mmap2(NULL, 619, PROT_READ, MAP_PRIVATE, 3, 0) =3D 0xb7743000 close(3)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 0 lstat64("copy", {st_mode=3DS_IFREG|0644, st_size=3D183, ...}) =3D 0 lstat64("copy2", {st_mode=3DS_IFREG|0644, st_size=3D216, ...}) =3D 0 open(".", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) =3D 3 fstat64(3, {st_mode=3DS_IFDIR|0755, st_size=3D12288, ...}) =3D 0 getdents64(3, /* 152 entries */, 32768) =3D 5808 getdents64(3, /* 0 entries */, 32768)=C2=A0=C2=A0 =3D 0 close(3)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 0 link("copy2", "copy2~")=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 0 getpid()=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 3085 linkat(AT_FDCWD, "copy", AT_FDCWD, "copy.003085.bak", 0) =3D 0 renameat(AT_FDCWD, "copy.003085.bak", AT_FDCWD, "copy2") =3D 0 _llseek(0, 0, 0xbf9087a8, SEEK_CUR)=C2=A0=C2=A0=C2=A0=C2=A0 =3D -1 ESPIPE (= Illegal seek) close(0)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 0 close(1)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 0 close(2)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D 0 exit_group(0)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 =3D ? +++ exited with 0 +++ marvin@marvin-desktop:~$=20 marvin@marvin-desktop:~$ cat copy copy2 copy2~ # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf= (8) #=C2=A0=C2=A0=C2=A0=C2=A0 DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WIL= L BE OVERWRITTEN nameserver 127.0.1.1 search lan # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf= (8) #=C2=A0=C2=A0=C2=A0=C2=A0 DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WIL= L BE OVERWRITTEN nameserver 127.0.1.1 search lan # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf= (8) #=C2=A0=C2=A0=C2=A0=C2=A0 DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WIL= L BE OVERWRITTEN nameserver 194.146.109.223 nameserver 194.146.109.224 search lan marvin@marvin-desktop:~$=20 =20 On Tuesday, January 3, 2017 6:38 AM, Paul Eggert <eggert@HIDDEN> w= rote: =20 Mirsad Goran Todorovac wrote: > It would suffice that: > linkat (AT_CWDFD, source, AT_CWDFD, dest, 0) =3D=3D 0 || unlink (dest) = =3D=3D 0 && linkat (AT_CWDFD, source, AT_CWDFD, dest, 0) =3D=3D 0; > be replaced with: > linkat (AT_CWDFD, source, AT_CWDFD, dest_tmp, 0) =3D=3D 0 && renameat (AT= _CWDFD, dest_tmp, AT_CWDFD, dest) =3D=3D 0; It isn't that simple, since renameat is a no-op if the source and destinati= on=20 are already hard links. So the patch you sent in would not work. Anyway, I'm not disagreeing with the basic idea, I'm merely saying I don't = see=20 why we should have an option to keep the old behavior. Anybody who really w= ants=20 the old behavior can do 'rm -f new && ln old new' instead. =20 ------=_Part_6944767_100673996.1483563757515 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <html><head></head><body><div style=3D"color:#000; background-color:#fff; f= ont-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, = sans-serif;font-size:13px">I did not understand this no-op behavior. It is = unlike what my Ubuntu kernel experienced. I may later try to see what 4.x k= ernels do ...<br><div id=3D"yui_3_16_0_ym19_1_1483558894421_19563" dir=3D"l= tr"><span id=3D"yui_3_16_0_ym19_1_1483558894421_19855"><br></span></div><di= v dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483558894421_20826"><span id=3D"yui_= 3_16_0_ym19_1_1483558894421_19855">Please consider the trace below. Thank y= ou.</span></div><div dir=3D"ltr"><span id=3D"yui_3_16_0_ym19_1_148355889442= 1_19855"><br></span></div><div dir=3D"ltr"><span id=3D"yui_3_16_0_ym19_1_14= 83558894421_19855">M.T.</span></div><div dir=3D"ltr"><span id=3D"yui_3_16_0= _ym19_1_1483558894421_19855"><br></span></div><div dir=3D"ltr" id=3D"yui_3_= 16_0_ym19_1_1483558894421_19965"><span id=3D"yui_3_16_0_ym19_1_148355889442= 1_19855"><font id=3D"yui_3_16_0_ym19_1_1483558894421_20018" face=3D"Courier= New, courier, monaco, monospace, sans-serif">marvin@marvin-desktop:~$ <b>u= name -a</b><br id=3D"yui_3_16_0_ym19_1_1483558894421_19973">Linux marvin-de= sktop 3.5.0-34-generic #55-Ubuntu SMP Thu Jun 6 20:20:19 UTC 2013 i686 athl= on i686 GNU/Linux<br id=3D"yui_3_16_0_ym19_1_1483558894421_19974">marvin@ma= rvin-desktop:~$ </font><br></span></div><div id=3D"yui_3_16_0_ym19_1_148355= 8894421_19197" dir=3D"ltr"><span id=3D"yui_3_16_0_ym19_1_1483558894421_1919= 6"><font id=3D"yui_3_16_0_ym19_1_1483558894421_19541" face=3D"Courier New, = courier, monaco, monospace, sans-serif">marvin@marvin-desktop:~$ <b id=3D"y= ui_3_16_0_ym19_1_1483558894421_20016">rm -f copy copy2 copy2~ ; cp /etc/res= olv.conf.orig copy ; cp /etc/resolv.conf copy</b>2<br id=3D"yui_3_16_0_ym19= _1_1483558894421_19328">marvin@marvin-desktop:~$ <b>cat copy copy2</b><br i= d=3D"yui_3_16_0_ym19_1_1483558894421_19329"># Dynamic resolv.conf(5) file f= or glibc resolver(3) generated by resolvconf(8)<br id=3D"yui_3_16_0_ym19_1_= 1483558894421_19330"># DO NOT EDIT THIS FILE BY HAN= D -- YOUR CHANGES WILL BE OVERWRITTEN<br id=3D"yui_3_16_0_ym19_1_1483558894= 421_19331">nameserver 127.0.1.1<br id=3D"yui_3_16_0_ym19_1_1483558894421_19= 332">search lan<br id=3D"yui_3_16_0_ym19_1_1483558894421_19333"># Dynamic r= esolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)<br id= =3D"yui_3_16_0_ym19_1_1483558894421_19334"># DO NOT= EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN<br id=3D"yui_3_= 16_0_ym19_1_1483558894421_19335">nameserver 194.146.109.223<br id=3D"yui_3_= 16_0_ym19_1_1483558894421_19336">nameserver 194.146.109.224<br id=3D"yui_3_= 16_0_ym19_1_1483558894421_19337">search lan<br id=3D"yui_3_16_0_ym19_1_1483= 558894421_19338">marvin@marvin-desktop:~$ <b>strace coreutils-devel/bin/ln = -b -fo copy copy2</b><br id=3D"yui_3_16_0_ym19_1_1483558894421_20544">execv= e("coreutils-devel/bin/ln", ["coreutils-devel/bin/ln", "-b", "-fo", "copy",= "copy2"], [/* 65 vars */]) =3D 0<br id=3D"yui_3_16_0_ym19_1_1483558894421_= 20545">brk(NULL)  = ; &n= bsp; =3D 0xa036000<br id=3D"yui_3= _16_0_ym19_1_1483558894421_20546">access("/etc/ld.so.nohwcap", F_OK) &= nbsp; =3D -1 ENOENT (No such file or directory)<br id=3D"= yui_3_16_0_ym19_1_1483558894421_20547">mmap2(NULL, 8192, PROT_READ|PROT_WRI= TE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =3D 0xb7745000<br id=3D"yui_3_16_0_ym= 19_1_1483558894421_20548">access("/etc/ld.so.preload", R_OK) &nb= sp; =3D -1 ENOENT (No such file or directory)<br id=3D"yui_3_16= _0_ym19_1_1483558894421_20549">open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC)= =3D 3<br id=3D"yui_3_16_0_ym19_1_1483558894421_20550">fstat64(3, {st_mode= =3DS_IFREG|0644, st_size=3D127411, ...}) =3D 0<br id=3D"yui_3_16_0_ym19_1_1= 483558894421_20551">mmap2(NULL, 127411, PROT_READ, MAP_PRIVATE, 3, 0) =3D 0= xb7725000<br id=3D"yui_3_16_0_ym19_1_1483558894421_20552">close(3) &nb= sp; = &nb= sp; =3D 0<br id=3D"yui_3_16_0_ym19_1_1483558894421_= 20553">access("/etc/ld.so.nohwcap", F_OK) =3D= -1 ENOENT (No such file or directory)<br id=3D"yui_3_16_0_ym19_1_148355889= 4421_20554">open("/lib/i386-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) =3D 3= <br id=3D"yui_3_16_0_ym19_1_1483558894421_20555">read(3, "\177ELF\1\1\1\3\0= \0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\320\207\1\0004\0\0\0"..., 512) =3D 512<br id= =3D"yui_3_16_0_ym19_1_1483558894421_20556">fstat64(3, {st_mode=3DS_IFREG|07= 55, st_size=3D1786484, ...}) =3D 0<br id=3D"yui_3_16_0_ym19_1_1483558894421= _20557">mmap2(NULL, 1792540, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE= , 3, 0) =3D 0xb756f000<br id=3D"yui_3_16_0_ym19_1_1483558894421_20558">mpro= tect(0xb771e000, 4096, PROT_NONE) =3D 0<br id=3D"yui_3_16_0_ym1= 9_1_1483558894421_20559">mmap2(0xb771f000, 12288, PROT_READ|PROT_WRITE, MAP= _PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1af000) =3D 0xb771f000<br id=3D"yui_= 3_16_0_ym19_1_1483558894421_20560">mmap2(0xb7722000, 10780, PROT_READ|PROT_= WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) =3D 0xb7722000<br id=3D"= yui_3_16_0_ym19_1_1483558894421_20561">close(3) &nbs= p; &= nbsp; &nbs= p; =3D 0<br id=3D"yui_3_16_0_ym19_1_1483558894421_20562">mmap2(NULL, = 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =3D 0xb756e00= 0<br id=3D"yui_3_16_0_ym19_1_1483558894421_20563">set_thread_area({entry_nu= mber:-1, base_addr:0xb756e940, limit:1048575, seg_32bit:1, contents:0, read= _exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) =3D 0 (entry= _number:6)<br id=3D"yui_3_16_0_ym19_1_1483558894421_20564">mprotect(0xb771f= 000, 8192, PROT_READ) =3D 0<br id=3D"yui_3_16_0_ym19_1_14835588= 94421_20565">mprotect(0x8058000, 4096, PROT_READ) =3D 0<b= r id=3D"yui_3_16_0_ym19_1_1483558894421_20566">mprotect(0xb776a000, 4096, P= ROT_READ) =3D 0<br id=3D"yui_3_16_0_ym19_1_1483558894421_20567"= >munmap(0xb7725000, 127411) = =3D 0<br id=3D"yui_3_16_0_ym19_1_14835588944= 21_20568">brk(NULL) &n= bsp;  = ; =3D 0xa036000<br id=3D"yu= i_3_16_0_ym19_1_1483558894421_20569">brk(0xa057000) = &nb= sp; =3D 0xa057000<br id=3D"= yui_3_16_0_ym19_1_1483558894421_20570">open("/usr/lib/locale/locale-archive= ", O_RDONLY|O_LARGEFILE|O_CLOEXEC) =3D 3<br id=3D"yui_3_16_0_ym19_1_1483558= 894421_20571">fstat64(3, {st_mode=3DS_IFREG|0644, st_size=3D4229984, ...}) = =3D 0<br id=3D"yui_3_16_0_ym19_1_1483558894421_20572">mmap2(NULL, 2097152, = PROT_READ, MAP_PRIVATE, 3, 0) =3D 0xb736e000<br id=3D"yui_3_16_0_ym19_1_148= 3558894421_20573">mmap2(NULL, 4096, PROT_READ, MAP_PRIVATE, 3, 0x2d4000) = =3D 0xb7744000<br id=3D"yui_3_16_0_ym19_1_1483558894421_20574">close(3)&nbs= p; &= nbsp; &nbs= p; =3D 0<br id=3D"yui_3_16_0_ym19_1_148355889= 4421_20575">stat64("copy2", {st_mode=3DS_IFREG|0644, st_size=3D216, ...}) = =3D 0<br id=3D"yui_3_16_0_ym19_1_1483558894421_20576">open("/usr/share/loca= le/locale.alias", O_RDONLY|O_CLOEXEC) =3D 3<br id=3D"yui_3_16_0_ym19_1_1483= 558894421_20577">fstat64(3, {st_mode=3DS_IFREG|0644, st_size=3D2995, ...}) = =3D 0<br id=3D"yui_3_16_0_ym19_1_1483558894421_20578">read(3, "# Locale nam= e alias data base.\n#"..., 4096) =3D 2995<br id=3D"yui_3_16_0_ym19_1_148355= 8894421_20579">read(3, "", 4096) &= nbsp; &nbs= p; =3D 0<br id=3D"yui_3_16_0_ym19_1_1483558894421_20580">close(= 3) &= nbsp; &nbs= p; =3D 0<br id=3D"yui_3_16_0_ym19_1_148= 3558894421_20581">open("/home/marvin/coreutils-devel/share/locale/en_US/LC_= MESSAGES/coreutils.mo", O_RDONLY) =3D -1 ENOENT (No such file or directory)= <br id=3D"yui_3_16_0_ym19_1_1483558894421_20582">open("/home/marvin/coreuti= ls-devel/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) =3D -1 ENOENT= (No such file or directory)<br id=3D"yui_3_16_0_ym19_1_1483558894421_20583= ">open("/usr/share/locale-langpack/en_US/LC_MESSAGES/coreutils.mo", O_RDONL= Y) =3D -1 ENOENT (No such file or directory)<br id=3D"yui_3_16_0_ym19_1_148= 3558894421_20584">open("/usr/share/locale-langpack/en/LC_MESSAGES/coreutils= .mo", O_RDONLY) =3D 3<br id=3D"yui_3_16_0_ym19_1_1483558894421_20585">fstat= 64(3, {st_mode=3DS_IFREG|0644, st_size=3D619, ...}) =3D 0<br id=3D"yui_3_16= _0_ym19_1_1483558894421_20586">mmap2(NULL, 619, PROT_READ, MAP_PRIVATE, 3, = 0) =3D 0xb7743000<br id=3D"yui_3_16_0_ym19_1_1483558894421_20587">close(3)&= nbsp; &nbs= p; &= nbsp; =3D 0<br id=3D"yui_3_16_0_ym19_1_148355= 8894421_20588">lstat64("copy", {st_mode=3DS_IFREG|0644, st_size=3D183, ...}= ) =3D 0<br id=3D"yui_3_16_0_ym19_1_1483558894421_20589">lstat64("copy2", {s= t_mode=3DS_IFREG|0644, st_size=3D216, ...}) =3D 0<br id=3D"yui_3_16_0_ym19_= 1_1483558894421_20590">open(".", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTOR= Y|O_CLOEXEC) =3D 3<br id=3D"yui_3_16_0_ym19_1_1483558894421_20591">fstat64(= 3, {st_mode=3DS_IFDIR|0755, st_size=3D12288, ...}) =3D 0<br id=3D"yui_3_16_= 0_ym19_1_1483558894421_20592">getdents64(3, /* 152 entries */, 32768) =3D 5= 808<br id=3D"yui_3_16_0_ym19_1_1483558894421_20593">getdents64(3, /* 0 entr= ies */, 32768) =3D 0<br id=3D"yui_3_16_0_ym19_1_1483558894421_2= 0594">close(3) &= nbsp; &nbs= p; =3D 0<br id=3D"yui_3_16_= 0_ym19_1_1483558894421_20595"><b>link("copy2", "copy2~") &= nbsp; &nbs= p; =3D 0<br id=3D"yui_3_16_0_ym19_1_1483558894421_20596">getpid() &nbs= p; &= nbsp; &nbs= p; =3D 3085<br id=3D"yui_3_16_0_ym19_1_148355889442= 1_20597">linkat(AT_FDCWD, "copy", AT_FDCWD, "copy.003085.bak", 0) =3D 0<br = id=3D"yui_3_16_0_ym19_1_1483558894421_20598">renameat(AT_FDCWD, "copy.00308= 5.bak", AT_FDCWD, "copy2") =3D 0</b><br id=3D"yui_3_16_0_ym19_1_14835588944= 21_20599">_llseek(0, 0, 0xbf9087a8, SEEK_CUR) =3D -= 1 ESPIPE (Illegal seek)<br id=3D"yui_3_16_0_ym19_1_1483558894421_20600">clo= se(0) &nbs= p; &= nbsp; =3D 0<br id=3D"yui_3_16_0_ym19_1_= 1483558894421_20601">close(1) &nbs= p; &= nbsp; =3D 0<br = id=3D"yui_3_16_0_ym19_1_1483558894421_20602">close(2) &nbs= p; &= nbsp; &nbs= p; =3D 0<br id=3D"yui_3_16_0_ym19_1_1483558894421_20603">exit_g= roup(0) &n= bsp;  = ; =3D ?<br id=3D"yui_3_16_0_ym19_1_1483558894421_20604">+++ exi= ted with 0 +++<br id=3D"yui_3_16_0_ym19_1_1483558894421_20605">marvin@marvi= n-desktop:~$ <br id=3D"yui_3_16_0_ym19_1_1483558894421_20606">marvin@marvin= -desktop:~$ <b>cat copy copy2 copy2~</b><br id=3D"yui_3_16_0_ym19_1_1483558= 894421_20744"># Dynamic resolv.conf(5) file for glibc resolver(3) generated= by resolvconf(8)<br id=3D"yui_3_16_0_ym19_1_1483558894421_20745"># &n= bsp; DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVER= WRITTEN<br id=3D"yui_3_16_0_ym19_1_1483558894421_20746">nameserver 127.0.1.= 1<br id=3D"yui_3_16_0_ym19_1_1483558894421_20747">search lan<br id=3D"yui_3= _16_0_ym19_1_1483558894421_20748"># Dynamic resolv.conf(5) file for glibc r= esolver(3) generated by resolvconf(8)<br id=3D"yui_3_16_0_ym19_1_1483558894= 421_20749"># DO NOT EDIT THIS FILE BY HAND -- YOUR = CHANGES WILL BE OVERWRITTEN<br id=3D"yui_3_16_0_ym19_1_1483558894421_20750"= >nameserver 127.0.1.1<br id=3D"yui_3_16_0_ym19_1_1483558894421_20751">searc= h lan<br id=3D"yui_3_16_0_ym19_1_1483558894421_20752"># Dynamic resolv.conf= (5) file for glibc resolver(3) generated by resolvconf(8)<br id=3D"yui_3_16= _0_ym19_1_1483558894421_20753"># DO NOT EDIT THIS F= ILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN<br id=3D"yui_3_16_0_ym19_1_= 1483558894421_20754">nameserver 194.146.109.223<br id=3D"yui_3_16_0_ym19_1_= 1483558894421_20755">nameserver 194.146.109.224<br id=3D"yui_3_16_0_ym19_1_= 1483558894421_20756">search lan<br id=3D"yui_3_16_0_ym19_1_1483558894421_20= 757">marvin@marvin-desktop:~$ <br id=3D"yui_3_16_0_ym19_1_1483558894421_207= 58"></font></span></div> <div class=3D"qtdSeparateBR"><br><br></div><div cl= ass=3D"yahoo_quoted" style=3D"display: block;"> <div style=3D"font-family: = HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;= font-size: 13px;"> <div style=3D"font-family: HelveticaNeue, Helvetica Neu= e, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir= =3D"ltr"><font size=3D"2" face=3D"Arial"> On Tuesday, January 3, 2017 6:38 = AM, Paul Eggert <eggert@HIDDEN> wrote:<br></font></div> <br><br= > <div class=3D"y_msg_container">Mirsad Goran Todorovac wrote:<div class=3D= "yqt5397295578" id=3D"yqtfd50581"><br clear=3D"none">> It would suffice = that:<br clear=3D"none">> linkat (AT_CWDFD, source, AT_CWDFD, dest, 0) = =3D=3D 0 || unlink (dest) =3D=3D 0 && linkat (AT_CWDFD, source, AT_= CWDFD, dest, 0) =3D=3D 0;<br clear=3D"none">> be replaced with:<br clear= =3D"none">> linkat (AT_CWDFD, source, AT_CWDFD, dest_tmp, 0) =3D=3D 0 &a= mp;& renameat (AT_CWDFD, dest_tmp, AT_CWDFD, dest) =3D=3D 0;</div><br c= lear=3D"none"><br clear=3D"none">It isn't that simple, since renameat is a = no-op if the source and destination <br clear=3D"none">are already hard lin= ks. So the patch you sent in would not work.<br clear=3D"none"><br clear=3D= "none">Anyway, I'm not disagreeing with the basic idea, I'm merely saying I= don't see <br clear=3D"none">why we should have an option to keep the old = behavior. Anybody who really wants <br clear=3D"none">the old behavior can = do 'rm -f new && ln old new' instead.<div class=3D"yqt5397295578" i= d=3D"yqtfd50027"><br clear=3D"none"></div><br><br></div> </div> </div> </= div></div></body></html> ------=_Part_6944767_100673996.1483563757515--
bug-coreutils@HIDDEN
:bug#25342
; Package coreutils
.
Full text available.Received: (at 25342) by debbugs.gnu.org; 3 Jan 2017 05:38:07 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 03 00:38:07 2017 Received: from localhost ([127.0.0.1]:39956 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1cOHnS-0000xp-QC for submit <at> debbugs.gnu.org; Tue, 03 Jan 2017 00:38:06 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:34370) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eggert@HIDDEN>) id 1cOHnR-0000xK-Jc for 25342 <at> debbugs.gnu.org; Tue, 03 Jan 2017 00:38:06 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 531E21600AF; Mon, 2 Jan 2017 21:37:59 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id DnrOJ5EHfxah; Mon, 2 Jan 2017 21:37:58 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id A28A71600B0; Mon, 2 Jan 2017 21:37:58 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 0Z6n60Q__G39; Mon, 2 Jan 2017 21:37:58 -0800 (PST) Received: from [192.168.1.9] (unknown [47.153.178.162]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 858351600AF; Mon, 2 Jan 2017 21:37:58 -0800 (PST) Subject: Re: bug#25342: GNU coreutils: race condition in "ln -f source dest" To: Mirsad Goran Todorovac <mtodorov3_69@HIDDEN>, "25342 <at> debbugs.gnu.org" <25342 <at> debbugs.gnu.org> References: <727818896.5504359.1483394315468.ref@HIDDEN> <727818896.5504359.1483394315468@HIDDEN> <f0b8dd92-16d5-7037-def7-764bba990ce3@HIDDEN> <1871443711.5629967.1483414377142@HIDDEN> From: Paul Eggert <eggert@HIDDEN> Organization: UCLA Computer Science Department Message-ID: <eab724e3-39e7-e141-b5cb-ac61839de4cd@HIDDEN> Date: Mon, 2 Jan 2017 21:37:58 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <1871443711.5629967.1483414377142@HIDDEN> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -3.2 (---) X-Debbugs-Envelope-To: 25342 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.2 (---) Mirsad Goran Todorovac wrote: > It would suffice that: > linkat (AT_CWDFD, source, AT_CWDFD, dest, 0) == 0 || unlink (dest) == 0 && linkat (AT_CWDFD, source, AT_CWDFD, dest, 0) == 0; > be replaced with: > linkat (AT_CWDFD, source, AT_CWDFD, dest_tmp, 0) == 0 && renameat (AT_CWDFD, dest_tmp, AT_CWDFD, dest) == 0; It isn't that simple, since renameat is a no-op if the source and destination are already hard links. So the patch you sent in would not work. Anyway, I'm not disagreeing with the basic idea, I'm merely saying I don't see why we should have an option to keep the old behavior. Anybody who really wants the old behavior can do 'rm -f new && ln old new' instead.
bug-coreutils@HIDDEN
:bug#25342
; Package coreutils
.
Full text available.Received: (at 25342) by debbugs.gnu.org; 3 Jan 2017 03:33:10 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 02 22:33:10 2017 Received: from localhost ([127.0.0.1]:39889 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1cOFqY-0004gh-IF for submit <at> debbugs.gnu.org; Mon, 02 Jan 2017 22:33:10 -0500 Received: from nm32-vm0.bullet.mail.bf1.yahoo.com ([72.30.239.136]:45844) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mtodorov3_69@HIDDEN>) id 1cOFqW-0004gG-9W for 25342 <at> debbugs.gnu.org; Mon, 02 Jan 2017 22:33:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1483414382; bh=Jk2mD33wS6fXteEt7g/T3FHDkZUng/ky6U0xHFgZ01s=; h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=RkXyVxt5YZATS5tiyqwVP6cyJjPU3BbshbkK+Grr0ItVh0aIYKymUnkTF9Xcvlqn8fviX/iNm8W/+SoIw6Y+F5+/ZZ1wDIcgFEMcynFG7k7/Cz2Le9km9WN4d7g9uI7UgQ3vtwifXZZMwOh1rbfQPhPTWIV18tX+Y/HxgUEoTcUNUqSLKcnDKpA/wF44v51yj2jk82vge3+D8yTDTytgFdXROfhUvVQo9/2sf98GcSKImvHywZUJONtg6UHnxhSpBw+SUywlgvLNPdyjm3xXwAL4ianJWMhSWKx2xHldhUUHKyfKwncFLRarxbg26XpQ8/bFXIq0QXk6oS/Ak2aG5A== Received: from [98.139.215.141] by nm32.bullet.mail.bf1.yahoo.com with NNFMP; 03 Jan 2017 03:33:02 -0000 Received: from [98.139.212.229] by tm12.bullet.mail.bf1.yahoo.com with NNFMP; 03 Jan 2017 03:33:02 -0000 Received: from [127.0.0.1] by omp1038.mail.bf1.yahoo.com with NNFMP; 03 Jan 2017 03:33:02 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 133692.54548.bm@HIDDEN X-YMail-OSG: D6plH4YVM1mfB1vT38F_ZP6mlBok0O0znkjuO4JXLfQ_GflNizQsujMhUGASjYt tVNdnyRBhbyISau_SGJUaJ8wD.TQEn9SObOhMZXlq8.d4xvmUyKJpGjfJoYR0szeecr9U2SfQD8h rptd7EF74YhpXJOagt7e2gEPABAoyVOyiXAnPZKL.Kn._KU18Z.O8_DKjTbvqPC5TpgJ9zI0xtoU GwuU3ue8FNwqBEt86Vi2mkhVL5MEKI5ekGMDFc2d.fubhpZ_AOig.rhkiJxFgsgXpxng88VgO5uT kPxl4PSjmwsOU7_ljGCRez.Wk82EJBaa9eougRZhI4PerTOjRXeqSVrb98Smx8UcIJaphgBJ9gs. l3tBxMqdi.T4m3txPcvkYQ5l876SIWfgWMS76daeE.TJZ3VlztlAq3yoP8cWP5YMtxtGplrkanBz BJNIocEJnJGLpmYMZ4rFDQEouC_wLIhksy1ay9sN5oHai86UsgDyfpy8sUHGXEJ9AMK3TGYTAwrO T9IcsZbFtWUzzItBaubU_PFWV Received: from jws400002.mail.bf2.yahoo.com by sendmailws133.mail.bf1.yahoo.com; Tue, 03 Jan 2017 03:33:01 +0000; 1483414381.767 Date: Tue, 3 Jan 2017 03:32:57 +0000 (UTC) From: Mirsad Goran Todorovac <mtodorov3_69@HIDDEN> To: Paul Eggert <eggert@HIDDEN>, "25342 <at> debbugs.gnu.org" <25342 <at> debbugs.gnu.org> Message-ID: <1871443711.5629967.1483414377142@HIDDEN> In-Reply-To: <f0b8dd92-16d5-7037-def7-764bba990ce3@HIDDEN> References: <727818896.5504359.1483394315468.ref@HIDDEN> <727818896.5504359.1483394315468@HIDDEN> <f0b8dd92-16d5-7037-def7-764bba990ce3@HIDDEN> Subject: Re: bug#25342: GNU coreutils: race condition in "ln -f source dest" MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_5629966_468280540.1483414377139" Content-Length: 7314 X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: 25342 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Reply-To: Mirsad Goran Todorovac <mtodorov3_69@HIDDEN> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.8 (--) ------=_Part_5629966_468280540.1483414377139 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Dear Sir, It would suffice that: linkat (AT_CWDFD, source, AT_CWDFD, dest, 0) == 0 || unlink (dest) == 0 && linkat (AT_CWDFD, source, AT_CWDFD, dest, 0) == 0; be replaced with: linkat (AT_CWDFD, source, AT_CWDFD, dest_tmp, 0) == 0 && renameat (AT_CWDFD, dest_tmp, AT_CWDFD, dest) == 0; . This is exact equivalent of "ln -f A B.tmp; mv B.tmp B", true, as it had been cited, the rest is generating unique filename (MT safety is not yet done) and installing -o (--force-overwrite) option to command line. Alternate behavior could be that default is to replace existing file atomically by default, and option is required or already existing to no-clobber. If I do, for example: # ln -f /etc/resolv.conf /etc/resolv.conf.orig# ln -f /etc/resolv.conf.ISP /etc/resolv.conf there is a window in which ln comand can be preempted, and other processes trying i.e. gethostbyname() may or will fail (unless they have cached result). This is equivalent to workaround with mv you provided above, but I think unlink() variant involves a race condition. And if I may assert - what is then forced? If desired behavior is to unlink() old existing target, then race condition involved is clearly a bug. IMHO. I hope I am not too arrogant in these observations. And thank you very much for your time. Regards,MT On Tuesday, January 3, 2017 2:07 AM, Paul Eggert <eggert@HIDDEN> wrote: Although I like the idea of changing "ln -f A B" to do the equivalent of "ln -f A B.tmp; mv B.tmp B" when B already exists, I'm not sure I'd want to have a new option to restore the old behavior, as that would add complexity for little real benefit. Also, this behavior shouldn't be limited to ln; it should also be done by cp -l. ------=_Part_5629966_468280540.1483414377139 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <html><head></head><body><div style=3D"color:#000; background-color:#fff; f= ont-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, = sans-serif;font-size:13px"><div id=3D"yui_3_16_0_ym19_1_1483413061595_11260= ">Dear Sir,</div><div id=3D"yui_3_16_0_ym19_1_1483413061595_10786"><br></di= v><div>It would suffice that:</div><div id=3D"yui_3_16_0_ym19_1_14834130615= 95_12188"><br></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483413061595_= 10808"><font id=3D"yui_3_16_0_ym19_1_1483413061595_12436" face=3D"Courier N= ew, courier, monaco, monospace, sans-serif">linkat (AT_CWDFD, source, AT_CW= DFD, dest, 0) =3D=3D 0 || unlink (dest) =3D=3D 0 && linkat (AT_CWDF= D, source, AT_CWDFD, dest, 0) =3D=3D 0;</font></div><div dir=3D"ltr" id=3D"= yui_3_16_0_ym19_1_1483413061595_10807"><br></div><div dir=3D"ltr" id=3D"yui= _3_16_0_ym19_1_1483413061595_10787">be replaced with:</div><div dir=3D"ltr"= id=3D"yui_3_16_0_ym19_1_1483413061595_11261"><br></div><div dir=3D"ltr" id= =3D"yui_3_16_0_ym19_1_1483413061595_12234"><font face=3D"Courier New, couri= er, monaco, monospace, sans-serif">linkat (AT_CWDFD, source, AT_CWDFD, dest= _tmp, 0) =3D=3D 0 && renameat (AT_CWDFD, dest_tmp, AT_CWDFD, dest) = =3D=3D 0;</font></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_148341306159= 5_12305"><br></div><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483413061595_1= 2304">. This is exact equivalent of "ln -f A B.tmp; mv B.tmp B", true, as i= t had been cited, the rest is generating unique filename (MT safety is not = yet done) and installing -o (--force-overwrite) option to command line.</di= v><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483413061595_12303"><br></div><= div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483413061595_11264">Alternate beha= vior could be that default is to replace existing file atomically by defaul= t, and option is required or already existing to no-clobber.</div><div dir= =3D"ltr" id=3D"yui_3_16_0_ym19_1_1483413061595_11262"><br></div><div dir=3D= "ltr" id=3D"yui_3_16_0_ym19_1_1483413061595_11298">If I do, for example:</d= iv><div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483413061595_12307"><br></div>= <div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483413061595_11448"><font id=3D"y= ui_3_16_0_ym19_1_1483413061595_12376" face=3D"Courier New, courier, monaco,= monospace, sans-serif"># <b id=3D"yui_3_16_0_ym19_1_1483413061595_12435">l= n -f /etc/resolv.conf /etc/resolv.conf.orig</b></font></div><div dir=3D"ltr= " id=3D"yui_3_16_0_ym19_1_1483413061595_12187"><font id=3D"yui_3_16_0_ym19_= 1_1483413061595_12375" face=3D"Courier New, courier, monaco, monospace, san= s-serif"># <b>ln -f /etc/resolv.conf.ISP /etc/resolv.conf</b></font></div><= div dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483413061595_11572"><br></div><div= dir=3D"ltr" id=3D"yui_3_16_0_ym19_1_1483413061595_12373">there is a window= in which ln comand can be preempted, and other processes trying i.e. getho= stbyname() may or will fail (unless they have cached result).</div><div dir= =3D"ltr" id=3D"yui_3_16_0_ym19_1_1483413061595_12186"><br></div><div dir=3D= "ltr" id=3D"yui_3_16_0_ym19_1_1483413061595_11661">This is equivalent to wo= rkaround with mv you provided above, but I think unlink() variant involves = a <b>race condition</b>. And if I may assert - what is then forced? If desi= red behavior is to <b>unlink() </b>old existing target, then race condition= involved is clearly a bug. IMHO.<br></div><div dir=3D"ltr" id=3D"yui_3_16_= 0_ym19_1_1483413061595_11888"><br></div><div dir=3D"ltr" id=3D"yui_3_16_0_y= m19_1_1483413061595_11931">I hope I am not too arrogant in these observatio= ns. And thank you very much for your time.<br></div><div dir=3D"ltr" id=3D"= yui_3_16_0_ym19_1_1483413061595_12068"><br></div><div dir=3D"ltr" id=3D"yui= _3_16_0_ym19_1_1483413061595_12169">Regards,</div><div dir=3D"ltr" id=3D"yu= i_3_16_0_ym19_1_1483413061595_12074">MT<br></div><div dir=3D"ltr" id=3D"yui= _3_16_0_ym19_1_1483413061595_11263"><br></div><div dir=3D"ltr" id=3D"yui_3_= 16_0_ym19_1_1483413061595_11618"><br></div><div dir=3D"ltr" id=3D"yui_3_16_= 0_ym19_1_1483413061595_11838"><br></div><div id=3D"yui_3_16_0_ym19_1_148341= 3061595_11827"><br></div><div id=3D"yui_3_16_0_ym19_1_1483413061595_12120">= <span></span></div> <div class=3D"qtdSeparateBR"><br><br></div><div class= =3D"yahoo_quoted" style=3D"display: block;"> <div style=3D"font-family: Hel= veticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; fo= nt-size: 13px;"> <div style=3D"font-family: HelveticaNeue, Helvetica Neue, = Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir=3D= "ltr"><font size=3D"2" face=3D"Arial"> On Tuesday, January 3, 2017 2:07 AM,= Paul Eggert <eggert@HIDDEN> wrote:<br></font></div> <br><br> <= div class=3D"y_msg_container">Although I like the idea of changing "ln -f A= B" to do the equivalent of "ln -f <br clear=3D"none">A B.tmp; mv B.tmp B" = when B already exists, I'm not sure I'd want to have a new <br clear=3D"non= e">option to restore the old behavior, as that would add complexity for lit= tle real <br clear=3D"none">benefit.<br clear=3D"none"><br clear=3D"none">A= lso, this behavior shouldn't be limited to ln; it should also be done by cp= -l.<br><br></div> </div> </div> </div></div></body></html> ------=_Part_5629966_468280540.1483414377139--
bug-coreutils@HIDDEN
:bug#25342
; Package coreutils
.
Full text available.Received: (at 25342) by debbugs.gnu.org; 3 Jan 2017 01:08:07 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 02 20:08:07 2017 Received: from localhost ([127.0.0.1]:39869 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1cODaB-0001FB-7C for submit <at> debbugs.gnu.org; Mon, 02 Jan 2017 20:08:07 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:44906) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eggert@HIDDEN>) id 1cODa8-0001Eh-PU for 25342 <at> debbugs.gnu.org; Mon, 02 Jan 2017 20:08:05 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E1BFB1600AA; Mon, 2 Jan 2017 17:07:57 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 3cW3xR4757yU; Mon, 2 Jan 2017 17:07:57 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 399FA1600AB; Mon, 2 Jan 2017 17:07:57 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id TU65LTJMtorw; Mon, 2 Jan 2017 17:07:57 -0800 (PST) Received: from [192.168.1.9] (unknown [47.153.178.162]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 1E55A1600AA; Mon, 2 Jan 2017 17:07:57 -0800 (PST) Subject: Re: bug#25342: GNU coreutils: race condition in "ln -f source dest" To: Mirsad Goran Todorovac <mtodorov3_69@HIDDEN>, 25342 <at> debbugs.gnu.org References: <727818896.5504359.1483394315468.ref@HIDDEN> <727818896.5504359.1483394315468@HIDDEN> From: Paul Eggert <eggert@HIDDEN> Organization: UCLA Computer Science Department Message-ID: <f0b8dd92-16d5-7037-def7-764bba990ce3@HIDDEN> Date: Mon, 2 Jan 2017 17:07:56 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <727818896.5504359.1483394315468@HIDDEN> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.2 (---) X-Debbugs-Envelope-To: 25342 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.2 (---) Although I like the idea of changing "ln -f A B" to do the equivalent of = "ln -f=20 A B.tmp; mv B.tmp B" when B already exists, I'm not sure I'd want to have= a new=20 option to restore the old behavior, as that would add complexity for litt= le real=20 benefit. Also, this behavior shouldn't be limited to ln; it should also be done by= cp -l.
bug-coreutils@HIDDEN
:bug#25342
; Package coreutils
.
Full text available.Received: (at submit) by debbugs.gnu.org; 2 Jan 2017 23:11:56 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 02 18:11:56 2017 Received: from localhost ([127.0.0.1]:39812 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1cOBlj-0005MA-Je for submit <at> debbugs.gnu.org; Mon, 02 Jan 2017 18:11:56 -0500 Received: from eggs.gnu.org ([208.118.235.92]:59188) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <mtodorov3_69@HIDDEN>) id 1cOAd1-0001yh-AK for submit <at> debbugs.gnu.org; Mon, 02 Jan 2017 16:58:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <mtodorov3_69@HIDDEN>) id 1cOAcu-0008BE-7L for submit <at> debbugs.gnu.org; Mon, 02 Jan 2017 16:58:46 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: ** X-Spam-Status: No, score=2.9 required=5.0 tests=BAYES_50,FORGED_YAHOO_RCVD, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,FREEMAIL_REPLYTO_END_DIGIT, HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:50430) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <mtodorov3_69@HIDDEN>) id 1cOAcu-0008B7-3p for submit <at> debbugs.gnu.org; Mon, 02 Jan 2017 16:58:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50153) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <mtodorov3_69@HIDDEN>) id 1cOAcr-0005q6-VQ for bug-coreutils@HIDDEN; Mon, 02 Jan 2017 16:58:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <mtodorov3_69@HIDDEN>) id 1cOAco-00089y-0K for bug-coreutils@HIDDEN; Mon, 02 Jan 2017 16:58:42 -0500 Received: from nm3-vm0.bullet.mail.bf1.yahoo.com ([98.139.212.154]:34743) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from <mtodorov3_69@HIDDEN>) id 1cOAcn-00089q-Pz for bug-coreutils@HIDDEN; Mon, 02 Jan 2017 16:58:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1483394316; bh=GNEvbhuv14DP7vTCw9A5ClF6N9eJQJ11xqnnF8lkKIg=; h=Date:From:Reply-To:To:Subject:References:From:Subject; b=JviNHF/kCkAGPtlLnvs1B5K/r30fUv22rSh7Sw16hauV27CMoLWnWU/0OfKWyoCpYrIYbAUDQuMfT6uAxK+LKPITI3xQzKAnAIwxSfjozbEbwk2nKgDsUQEAkROZTO1jt7wkVdHnN996guqfBGYErHGTAEOMK83GNz5ITrXfofrVqzeajhS7dKS5XOUUsaGMIe7kePA18F6zR7J1xvkL+JqaxlYS9/9mMajBywmcx06HVOdcrb221n1O0BsPRvYqQUxmqN6vIUbGovoHC3qMSDONZsGh8lVd1EcbQpc+HxQOELLRvZPvqdmXsLvpqjWkuMZDvUEaU+qD/WczptRGeg== Received: from [98.139.215.143] by nm3.bullet.mail.bf1.yahoo.com with NNFMP; 02 Jan 2017 21:58:36 -0000 Received: from [98.139.212.209] by tm14.bullet.mail.bf1.yahoo.com with NNFMP; 02 Jan 2017 21:58:36 -0000 Received: from [127.0.0.1] by omp1018.mail.bf1.yahoo.com with NNFMP; 02 Jan 2017 21:58:36 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 42116.34904.bm@HIDDEN X-YMail-OSG: WkHj7mEVM1mL2QZXCLeD7KDPEZryHhkrG9pbTD.KiokKlVyLqexPX3jjV6lNrqJ iPCOYmHCRSsOaZT33RBCu7GJr8COx.d_8qrr3uL3lvN1Hs41LDDb8qSjJqvh2U2jxC_gs6QA.S.Q WqAPk4YJom8lw_IXKvurXeDQ7Z4T2Ipcyh5WMNWuBh_wYAZcW.IxjEUX3wLpI1hy5mItyBUgISxC b47GfG9e645L4e7QziP3GxXBtA0Jv4084xmEGsza12vtRXEjntGNVNcUTEeAKu2FKXs896SLEpJL l1fR__zrxU_9t60kWVQfOKuzEnNbi6S3KA1kf_H9s2Gb1VC5rvFCu5C9_Fxk7GMql.5o1res1di7 Vmm_OlmwO8gy0rabxQdMVC0QRC2BL1hmIxzOGMG8rqrMfUg0eMRuMENuhkUYOuJHirnImjAmDWwr xO5eoCEeeNgXsAtmpIx1Cv0LS.aOepUxFM4Yrc.lUTZBtg25Xzu0vN08dHa3B0av8GMKWHpqH6km Q_zLyoclbce9ws.4NaDXLrs4M Received: from jws400083.mail.bf2.yahoo.com by sendmailws113.mail.bf1.yahoo.com; Mon, 02 Jan 2017 21:58:35 +0000; 1483394315.676 Date: Mon, 2 Jan 2017 21:58:35 +0000 (UTC) From: Mirsad Goran Todorovac <mtodorov3_69@HIDDEN> To: "bug-coreutils@HIDDEN" <bug-coreutils@HIDDEN> Message-ID: <727818896.5504359.1483394315468@HIDDEN> Subject: GNU coreutils: race condition in "ln -f source dest" MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_5504358_510736469.1483394315466" References: <727818896.5504359.1483394315468.ref@HIDDEN> Content-Length: 20248 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -2.8 (--) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 02 Jan 2017 18:11:53 -0500 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Reply-To: Mirsad Goran Todorovac <mtodorov3_69@HIDDEN> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.8 (--) ------=_Part_5504358_510736469.1483394315466 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable When "dest" is existing, ln -f source dest does an attempt of linkat(AT_FCW= DFD, source, AT_FCWDFD, dest), which fails with EEXIST if dest exists, and = then attempts an unlink(dest), followed by repeated linkat(). Between unlink() and second linkat() process maybe preempted, leaving no sy= stem file. An option -o (--force-overwrite) is proposed, so existing scripts would wor= k w/o breaking, and linkat() can be made atomic. By rights, there oughta be= an option for linkat() to do it, but right now it was done by spurious ide= a (Thanking the grace of Lord Merciful and Longsuffering). Patch follows. All the best,Mirsad X. Todorovac ___________________________________________________________________________= _______________________ marvin@marvin-desktop:~$ diff -r -U 3 coreutils-8.26 coreutils-8.26p1 diff -r -U 3 coreutils-8.26/src/ln.c coreutils-8.26p1/src/ln.c --- coreutils-8.26/src/ln.c=C2=A0=C2=A0=C2=A0 2016-11-14 13:05:20.000000000= +0100 +++ coreutils-8.26p1/src/ln.c=C2=A0=C2=A0=C2=A0 2017-01-02 22:23:53.6081943= 38 +0100 @@ -59,6 +59,9 @@ =C2=A0/* If true, remove existing files unconditionally.=C2=A0 */ =C2=A0static bool remove_existing_files; =C2=A0 +/* If true, remove existing files unconditionally, even if losing data.=C2= =A0 */ +static bool force_remove_existing_files; + =C2=A0/* If true, list each file as it is moved. */ =C2=A0static bool verbose; =C2=A0 @@ -90,6 +93,7 @@ =C2=A0=C2=A0 {"no-dereference", no_argument, NULL, 'n'}, =C2=A0=C2=A0 {"no-target-directory", no_argument, NULL, 'T'}, =C2=A0=C2=A0 {"force", no_argument, NULL, 'f'}, +=C2=A0 {"force-overwrite", no_argument, NULL, 'o'}, =C2=A0=C2=A0 {"interactive", no_argument, NULL, 'i'}, =C2=A0=C2=A0 {"suffix", required_argument, NULL, 'S'}, =C2=A0=C2=A0 {"target-directory", required_argument, NULL, 't'}, @@ -283,7 +287,8 @@ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (backup_type !=3D no_backups) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 dest_backup = =3D find_backup_file_name (dest, backup_type); -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (rename (dest, d= est_backup) !=3D 0) +=C2=A0=C2=A0=C2=A0 =C2=A0 if (logical && rename (dest, dest_backup) !=3D 0= || +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 !logical && link (dest, dest_backup) !=3D 0) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 int rename_errno =3D errno; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 free (dest_backup); @@ -301,10 +306,31 @@ =C2=A0=C2=A0 if (relative) =C2=A0=C2=A0=C2=A0=C2=A0 source =3D rel_source =3D convert_abs_rel (source,= dest); =C2=A0 -=C2=A0 ok =3D ((symbolic_link ? symlink (source, dest) +=C2=A0 if (logical || !force_remove_existing_files) +=C2=A0=C2=A0=C2=A0 ok =3D ((symbolic_link ? symlink (source, dest) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : linkat (AT_FDCWD, = source, AT_FDCWD, dest, =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 logical ? AT_SYMLINK_FOLLOW : 0)) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D=3D 0); +=C2=A0 else { +=C2=A0=C2=A0=C2=A0 char *tmpname =3D NULL; + +=C2=A0=C2=A0=C2=A0 if (force_remove_existing_files && +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 asprintf (&tmpname, "%s.%06d.ba= k", source, (int)getpid()) < strlen(source) + 1 + 6 + 4) { +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int asprintf_errno =3D errno; +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (tmpname) +=C2=A0=C2=A0=C2=A0 free (tmpname); +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 free (dest_backup); +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 free (rel_source); +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 error (0, asprintf_errno, _("cannot backup = %s: cannot allocate temp string"), +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 q= uoteaf (dest)); +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return false; +=C2=A0=C2=A0=C2=A0 } +=C2=A0=C2=A0=C2=A0=20 +=C2=A0=C2=A0=C2=A0 ok =3D ((symbolic_link ? symlink (source, dest) +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 : linkat (AT_FDCWD, sourc= e, AT_FDCWD, tmpname, 0) =3D=3D 0 +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 && renameat (= AT_FDCWD, tmpname, AT_FDCWD, dest) =3D=3D 0)); +=C2=A0 } + =C2=A0 =C2=A0=C2=A0 /* If the attempt to create a link failed and we are removing = or =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 backing up destinations, unlink the destinat= ion and try again. @@ -417,6 +443,7 @@ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 directories (note: will probably= fail due to\n\ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 system restrictions, even for th= e superuser)\n\ =C2=A0=C2=A0 -f, --force=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 remove existing destination f= iles\n\ +=C2=A0 -o, --overwrite=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 force remove existing destination files\n\ =C2=A0"), stdout); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 fputs (_("\ =C2=A0=C2=A0 -i, --interactive=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 prompt whether to remove destinations\n\ @@ -467,10 +494,10 @@ =C2=A0 =C2=A0=C2=A0 atexit (close_stdin); =C2=A0 -=C2=A0 symbolic_link =3D remove_existing_files =3D interactive =3D verbose +=C2=A0 symbolic_link =3D force_remove_existing_files =3D remove_existing_f= iles =3D interactive =3D verbose =C2=A0=C2=A0=C2=A0=C2=A0 =3D hard_dir_link =3D false; =C2=A0 -=C2=A0 while ((c =3D getopt_long (argc, argv, "bdfinrst:vFLPS:T", long_opt= ions, NULL)) +=C2=A0 while ((c =3D getopt_long (argc, argv, "bdfinorst:vFLPS:T", long_op= tions, NULL)) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 !=3D -1) =C2=A0=C2=A0=C2=A0=C2=A0 { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 switch (c) @@ -484,6 +511,8 @@ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 case 'F': =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 hard_dir_link = =3D true; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 case 'o': +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 force_remove_existi= ng_files =3D true; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 case 'f': =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 remove_existin= g_files =3D true; =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 interactive = =3D false; marvin@marvin-desktop:~$=20 ------=_Part_5504358_510736469.1483394315466 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <html><head></head><body><div style=3D"color:#000; background-color:#fff; f= ont-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, = sans-serif;font-size:13px"><div id=3D"yui_3_16_0_ym19_1_1483374881422_21991= " dir=3D"ltr">When "dest" is existing, <b id=3D"yui_3_16_0_ym19_1_148337488= 1422_22050">ln -f source des</b>t does an attempt of linkat(AT_FCWDFD, sour= ce, AT_FCWDFD, dest), which fails with EEXIST if dest exists, and then atte= mpts an unlink(dest), followed by repeated linkat().</div><div dir=3D"ltr" = id=3D"yui_3_16_0_ym19_1_1483374881422_22055"><br></div><div dir=3D"ltr" id= =3D"yui_3_16_0_ym19_1_1483374881422_22056">Between unlink() and second link= at() process maybe preempted, leaving no system file.<br></div><div id=3D"y= ui_3_16_0_ym19_1_1483374881422_21990"><br></div><div id=3D"yui_3_16_0_ym19_= 1_1483374881422_22013">An option -o (--force-overwrite) is proposed, so exi= sting scripts would work w/o breaking, and linkat() can be made atomic. By = rights, there oughta be an option for linkat() to do it, but right now it w= as done by spurious idea (Thanking the grace of Lord Merciful and Longsuffe= ring).</div><div id=3D"yui_3_16_0_ym19_1_1483374881422_25709"><br></div><di= v id=3D"yui_3_16_0_ym19_1_1483374881422_25793">Patch follows.</div><div id= =3D"yui_3_16_0_ym19_1_1483374881422_25838"><br></div><div id=3D"yui_3_16_0_= ym19_1_1483374881422_25872">All the best,</div><div id=3D"yui_3_16_0_ym19_1= _1483374881422_25873">Mirsad X. Todorovac<br></div><div id=3D"yui_3_16_0_ym= 19_1_1483374881422_25792"><br></div><div id=3D"yui_3_16_0_ym19_1_1483374881= 422_25876">________________________________________________________________= __________________________________<br></div><div id=3D"yui_3_16_0_ym19_1_14= 83374881422_23810" dir=3D"ltr"><font id=3D"yui_3_16_0_ym19_1_1483374881422_= 25801" face=3D"Courier New, courier, monaco, monospace, sans-serif">marvin@= marvin-desktop:~$ <b>diff -r -U 3 coreutils-8.26 coreutils-8.26p1</b><br id= =3D"yui_3_16_0_ym19_1_1483374881422_25595">diff -r -U 3 coreutils-8.26/src/= ln.c coreutils-8.26p1/src/ln.c<br id=3D"yui_3_16_0_ym19_1_1483374881422_255= 96">--- coreutils-8.26/src/ln.c 2016-11-14 13:05:20.00000= 0000 +0100<br id=3D"yui_3_16_0_ym19_1_1483374881422_25597">+++ coreutils-8.= 26p1/src/ln.c 2017-01-02 22:23:53.608194338 +0100<br id= =3D"yui_3_16_0_ym19_1_1483374881422_25598">@@ -59,6 +59,9 @@<br id=3D"yui_3= _16_0_ym19_1_1483374881422_25599"> /* If true, remove existing files u= nconditionally. */<br id=3D"yui_3_16_0_ym19_1_1483374881422_25600">&n= bsp;static bool remove_existing_files;<br id=3D"yui_3_16_0_ym19_1_148337488= 1422_25601"> <br id=3D"yui_3_16_0_ym19_1_1483374881422_25602">+/* If t= rue, remove existing files unconditionally, even if losing data. */<b= r id=3D"yui_3_16_0_ym19_1_1483374881422_25603">+static bool force_remove_ex= isting_files;<br id=3D"yui_3_16_0_ym19_1_1483374881422_25604">+<br id=3D"yu= i_3_16_0_ym19_1_1483374881422_25605"> /* If true, list each file as it= is moved. */<br id=3D"yui_3_16_0_ym19_1_1483374881422_25606"> static = bool verbose;<br id=3D"yui_3_16_0_ym19_1_1483374881422_25607"> <br id= =3D"yui_3_16_0_ym19_1_1483374881422_25608">@@ -90,6 +93,7 @@<br id=3D"yui_3= _16_0_ym19_1_1483374881422_25609"> {"no-dereference", no_argume= nt, NULL, 'n'},<br id=3D"yui_3_16_0_ym19_1_1483374881422_25610">  = ; {"no-target-directory", no_argument, NULL, 'T'},<br id=3D"yui_3_16_0_ym19= _1_1483374881422_25611"> {"force", no_argument, NULL, 'f'},<br = id=3D"yui_3_16_0_ym19_1_1483374881422_25612">+ {"force-overwrite", no= _argument, NULL, 'o'},<br id=3D"yui_3_16_0_ym19_1_1483374881422_25613">&nbs= p; {"interactive", no_argument, NULL, 'i'},<br id=3D"yui_3_16_0_ym19_= 1_1483374881422_25614"> {"suffix", required_argument, NULL, 'S'= },<br id=3D"yui_3_16_0_ym19_1_1483374881422_25615"> {"target-di= rectory", required_argument, NULL, 't'},<br id=3D"yui_3_16_0_ym19_1_1483374= 881422_25616">@@ -283,7 +287,8 @@<br id=3D"yui_3_16_0_ym19_1_1483374881422_= 25617"> if (backup_type !=3D no_backups= )<br id=3D"yui_3_16_0_ym19_1_1483374881422_25618"> &= nbsp; {<br id=3D"yui_3_16_0_ym19_1_1483374881422_25619">&= nbsp; dest_backup =3D= find_backup_file_name (dest, backup_type);<br id=3D"yui_3_16_0_ym19_1_1483= 374881422_25620">- if= (rename (dest, dest_backup) !=3D 0)<br id=3D"yui_3_16_0_ym19_1_14833748814= 22_25621">+ if (logical && rename (dest, d= est_backup) !=3D 0 ||<br id=3D"yui_3_16_0_ym19_1_1483374881422_25622">+&nbs= p; = !logical && link (dest, dest_backup) !=3D 0)<br id=3D"yui_3_16_0_ym= 19_1_1483374881422_25623"> &= nbsp; {<br id=3D"yui_3_16_0_ym19_1_1483374881422_25624">&= nbsp; &nbs= p; int rename_errno =3D errno;<br id=3D"yui_3_16_0_ym19_1_14833748814= 22_25625">  = ; free (dest_backup);<br id=3D"yui_3_16_0_ym19_1_14833748= 81422_25626">@@ -301,10 +306,31 @@<br id=3D"yui_3_16_0_ym19_1_1483374881422= _25627"> if (relative)<br id=3D"yui_3_16_0_ym19_1_1483374881422= _25628"> source =3D rel_source =3D convert_abs_rel = (source, dest);<br id=3D"yui_3_16_0_ym19_1_1483374881422_25629"> <br i= d=3D"yui_3_16_0_ym19_1_1483374881422_25630">- ok =3D ((symbolic_link = ? symlink (source, dest)<br id=3D"yui_3_16_0_ym19_1_1483374881422_25631">+&= nbsp; if (logical || !force_remove_existing_files)<br id=3D"yui_3_16_0_ym19= _1_1483374881422_25632">+ ok =3D ((symbolic_link ? symlin= k (source, dest)<br id=3D"yui_3_16_0_ym19_1_1483374881422_25633"> &nbs= p; : linkat (AT_FDCWD, source, AT= _FDCWD, dest,<br id=3D"yui_3_16_0_ym19_1_1483374881422_25634"> &= nbsp; &nbs= p; logical ? AT_SYMLINK_FOLLOW : 0))<br id=3D"yui_3= _16_0_ym19_1_1483374881422_25635">  = ; =3D=3D 0);<br id=3D"yui_3_16_0_ym19_1_1483374881422_25636">+ = else {<br id=3D"yui_3_16_0_ym19_1_1483374881422_25637">+ = char *tmpname =3D NULL;<br id=3D"yui_3_16_0_ym19_1_1483374881422_25638">+<b= r id=3D"yui_3_16_0_ym19_1_1483374881422_25639">+ if (forc= e_remove_existing_files &&<br id=3D"yui_3_16_0_ym19_1_1483374881422= _25640">+ asprintf (&tmpname,= "%s.%06d.bak", source, (int)getpid()) < strlen(source) + 1 + 6 + 4) {<b= r id=3D"yui_3_16_0_ym19_1_1483374881422_25641">+ &nb= sp; int asprintf_errno =3D errno;<br id=3D"yui_3_16_0_ym19_1_1483374881422_= 25642">+ if (tmpname)<br id=3D"yui_3_16_0_ym1= 9_1_1483374881422_25643">+ free (tmpname);<br id=3D"yui_3= _16_0_ym19_1_1483374881422_25644">+ free (des= t_backup);<br id=3D"yui_3_16_0_ym19_1_1483374881422_25645">+ &nb= sp; free (rel_source);<br id=3D"yui_3_16_0_ym19_1_1483374881422= _25646">+ error (0, asprintf_errno, _("cannot= backup %s: cannot allocate temp string"),<br id=3D"yui_3_16_0_ym19_1_14833= 74881422_25647">+ &nbs= p; quoteaf (dest));<br id=3D"yui_3_16_0_ym19_1_1483374881422_25= 648">+ return false;<br id=3D"yui_3_16_0_ym19= _1_1483374881422_25649">+ }<br id=3D"yui_3_16_0_ym19_1_14= 83374881422_25650">+ <br id=3D"yui_3_16_0_ym19_1_14833748= 81422_25651">+ ok =3D ((symbolic_link ? symlink (source, = dest)<br id=3D"yui_3_16_0_ym19_1_1483374881422_25652">+ &n= bsp; : linkat (AT_FDCWD, source, AT_FDCWD, tmpname,= 0) =3D=3D 0<br id=3D"yui_3_16_0_ym19_1_1483374881422_25653">+ &= nbsp; && renameat (AT_FDC= WD, tmpname, AT_FDCWD, dest) =3D=3D 0));<br id=3D"yui_3_16_0_ym19_1_1483374= 881422_25654">+ }<br id=3D"yui_3_16_0_ym19_1_1483374881422_25655">+<b= r id=3D"yui_3_16_0_ym19_1_1483374881422_25656"> <br id=3D"yui_3_16_0_y= m19_1_1483374881422_25657"> /* If the attempt to create a link = failed and we are removing or<br id=3D"yui_3_16_0_ym19_1_1483374881422_2565= 8"> backing up destinations, unlink the desti= nation and try again.<br id=3D"yui_3_16_0_ym19_1_1483374881422_25659">@@ -4= 17,6 +443,7 @@<br id=3D"yui_3_16_0_ym19_1_1483374881422_25660"> = &nb= sp; = directories (note: will probably fail due to= \n\<br id=3D"yui_3_16_0_ym19_1_1483374881422_25661">  = ; &n= bsp;  = ; system restrictions, even for the superuser)\n\<br id= =3D"yui_3_16_0_ym19_1_1483374881422_25662"> -f, --force &n= bsp;  = ; remove existing destination files\n\<br id=3D"yui_3_16_0_ym19= _1_1483374881422_25663">+ -o, --overwrite &nbs= p; force remove existing destinat= ion files\n\<br id=3D"yui_3_16_0_ym19_1_1483374881422_25664"> "), stdo= ut);<br id=3D"yui_3_16_0_ym19_1_1483374881422_25665"> &nbs= p; fputs (_("\<br id=3D"yui_3_16_0_ym19_1_1483374881422_25666">= -i, --interactive &nb= sp; prompt whether to remove destinations\n\<br id=3D"yui_3_16_= 0_ym19_1_1483374881422_25667">@@ -467,10 +494,10 @@<br id=3D"yui_3_16_0_ym1= 9_1_1483374881422_25668"> <br id=3D"yui_3_16_0_ym19_1_1483374881422_25= 669"> atexit (close_stdin);<br id=3D"yui_3_16_0_ym19_1_14833748= 81422_25670"> <br id=3D"yui_3_16_0_ym19_1_1483374881422_25671">- = symbolic_link =3D remove_existing_files =3D interactive =3D verbose<br id= =3D"yui_3_16_0_ym19_1_1483374881422_25672">+ symbolic_link =3D force_= remove_existing_files =3D remove_existing_files =3D interactive =3D verbose= <br id=3D"yui_3_16_0_ym19_1_1483374881422_25673"> = =3D hard_dir_link =3D false;<br id=3D"yui_3_16_0_ym19_1_1483374881422_25674= "> <br id=3D"yui_3_16_0_ym19_1_1483374881422_25675">- while ((c = =3D getopt_long (argc, argv, "bdfinrst:vFLPS:T", long_options, NULL))<br id= =3D"yui_3_16_0_ym19_1_1483374881422_25676">+ while ((c =3D getopt_lon= g (argc, argv, "bdfinorst:vFLPS:T", long_options, NULL))<br id=3D"yui_3_16_= 0_ym19_1_1483374881422_25677"> &nb= sp; !=3D -1)<br id=3D"yui_3_16_0_ym19_1_1483374881422_25678"> &n= bsp; {<br id=3D"yui_3_16_0_ym19_1_1483374881422_25679"> &n= bsp; switch (c)<br id=3D"yui_3_16_0_ym19_1_14833748= 81422_25680">@@ -484,6 +511,8 @@<br id=3D"yui_3_16_0_ym19_1_1483374881422_2= 5681"> case 'F':<br id=3D"y= ui_3_16_0_ym19_1_1483374881422_25682"> &= nbsp; hard_dir_link =3D true;<br id=3D"yui_3_16_0_ym19_1_= 1483374881422_25683"> = break;<br id=3D"yui_3_16_0_ym19_1_1483374881422_25684">+ = case 'o':<br id=3D"yui_3_16_0_ym19_1_1483374= 881422_25685">+ force= _remove_existing_files =3D true;<br id=3D"yui_3_16_0_ym19_1_1483374881422_2= 5686"> case 'f':<br id=3D"y= ui_3_16_0_ym19_1_1483374881422_25687"> &= nbsp; remove_existing_files =3D true;<br id=3D"yui_3_16_0= _ym19_1_1483374881422_25688"> &nbs= p; interactive =3D false;<br id=3D"yui_3_16_0_ym19_1_1483374881= 422_25689">marvin@marvin-desktop:~$ <br id=3D"yui_3_16_0_ym19_1_14833748814= 22_25690"><br></font></div><div id=3D"yui_3_16_0_ym19_1_1483374881422_25402= "><br></div></div></body></html> ------=_Part_5504358_510736469.1483394315466--
Mirsad Goran Todorovac <mtodorov3_69@HIDDEN>
:bug-coreutils@HIDDEN
.
Full text available.bug-coreutils@HIDDEN
:bug#25342
; Package coreutils
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.