Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!bruce!cechew From: cechew@bruce.cs.monash.OZ.AU (Earl Chew) Newsgroups: comp.os.minix Subject: Re: fs "bug" (rename) and "fix" Keywords: fs rename Message-ID: <3404@bruce.cs.monash.OZ.AU> Date: 28 Nov 90 01:57:42 GMT References: <1990Nov28.001925.24250@unicorn.cc.wwu.edu> Organization: Monash Uni. Computer Science, Australia Lines: 50 In <1990Nov28.001925.24250@unicorn.cc.wwu.edu> phil@unicorn.cc.wwu.edu (Phil Nelson) writes: >Recently, I was working with a program that used the rename system call >to make backup files. It used calls like rename("file","file~"). This >call failed every time. After tracking down what was happening, I >discovered that fs (the code for rename) checks to make sure that the >old file name (file) is not a prefix of the new file name (file~). If Actually, there is a problem with both the original and the proposed patch. Assume that the cwd is /a and that there is a directory named /a/b. Consider: rename("b","b~"); /* failed original */ rename("b","/a/b/c"); /* fails proposed patch */ It may get worse once symbolic links are introduced. Enclosed is a copy of a patch that Bruce sent me that appears to cure the problem. Earl ------------------------------------------------------------------------------- table !"#$%&'()*+,-./0123456789:;<=>? @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ begin 644 link.c.cdif.Z M'YV0*@*"8)/&S1H78UR\D9/F3 (J:.J F%(&#@@0-D# R*&CA@T=,6J B)$Cz M!PP%+5(.+'APS,.($RM>S+BQX\>0(TN>#,BSIT\5"GB"D!$#!PL9,D3V5'"1y MZ440+U2 2&(&1!HZ5N> >+.&!8@Q:,J,60/"S$(084#8"<.P#)T\6ZO">3-Gx M3AHQ;,J *"-'SL(Y+D"H>.'T8IJJ*.2 Z-$#Q),E*4#L41 "1(*H("#J?<.&w M# @X8>B@ =&FSARL;MY@%:,W+1PY9"@X$SFBYLP;>^^EU,)011U%PPT@N-@"s M?$]!)1555F&5AE9<>0666&29I5A::[7U5FUSU7577GOU]=> A5F%V'F-/1;9r M9)7)EUE8]7E6T!MDZ*4?:JJ!P!I:&M8!!U]DI ';&'0L!-<;5=W&GVX#A;%?q MG')0V>6!PS68!APM^)#&%VV0J9<)4WU!1190%#%>8TE\04024A0Q!!5/2)'%p MEL ED$!Q==!I56IE"I;;'5_,X2:<G)IBJCZSJI4)N>-#AG&ZQSBH'o MH+8"5VH"9+CYQ9AEHO!JL6\>6RN*TR*;PJV6)7 '&FE B0(54E1AJ63+&HC8n MM+)6B^QBC1D*!ZFXFGI>BNJQYUZZ"8@!6QAK<&MJ GVD"ZRP[!K[;F-AD+'6m M<65(2VR[M,H!!X0"3BBPJ7#4(2RT$2?L;JW;IGO@P$F/%>;B281V @!%%7'='9!N8=?]$AJ-<)W*NBj MOAN;2K/-Z1:,:Q^6+=OQQ[U*#//(%I?<91\)X&@99O0Q=Y]HI)F&IG\@ *B8i C@((1&!QB&R;7H8/2F3UAA1=F6#J#WGV8NHBKEW@B>OFRJ !Hh g end ------------------------------------------------------------------------------- -- Earl Chew, Dept of Computer Science, Monash University, Australia 3168 EMAIL: cechew@bruce.cs.monash.edu.au PHONE: 03 5655447 FAX: 03 5655146 ----------------------------------------------------------------------