Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!ogicse!unicorn!phil From: phil@unicorn.cc.wwu.edu (Phil Nelson) Newsgroups: comp.os.minix Subject: fs "bug" (rename) and "fix" Keywords: fs rename Message-ID: <1990Nov28.001925.24250@unicorn.cc.wwu.edu> Date: 28 Nov 90 00:19:25 GMT Organization: Western Washington University, Bellingham WA. Lines: 42 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 it is a prefix, then the rename is denied. This means many rename calls will fail when it is safe to do the rename. I don't have the POSIX definition, but I presume that is not a POSIX requirement. After looking at the fs code, I decided that the "correct" test was to see if the old file name is a DIRECTORY prefix in the new name. If it is, then the rename is trying to move a directory into a subdirectory of itself. This is something that should not work. I changed the code to test for the directory prefix problem. The uuencoded, compressed cdiff follows. --Phil Nelson (phil@cs.wwu.edu, Western Washington University, Bellingham, WA) --------- table !"#$%&'()*+,-./0123456789:;<=>? @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ begin 644 link.cdiff.Z M'YV-*@*"8)/&S1H78UR\D9/F3 (J=C(&#A0P9-4#T5 "y M!-.F(%ZH )'$#(@T=*[. ?%F#0L08]"4&;,&A)F%(,* L!.&81DZ>;A:A?-Fx MSIPT8MA(+"-'SL(Y+I2^>-HTC544YPQ1U8Q6#*"0R#0&%:v MCILQ;>"@>,/YBYLP;>?KHDF;!H%:M<3 :+G0VV!-!7=8<<@I9Y]ST$D'@@@NB)#"t M8C" P >RBU,%111]D 0HLMP =5s M5%-5=556:6S5U5=AC57668FIQ99;<-%&EUUXZ04"7W[) 9A@A%UUV'F,.0:9r M9,!=1M]F]X&67VFGI0;":FF!0$8:KXU!QT)QN0:;;+39QE]NNY4QX&25"8<"q M<708ER"''CI(G1S6B9E=H-L1^ET9X2G&6'E\)G"C"28,=VBBH6VA71G<+?AHp M"EU("L()+YP0Z8DILN>>C95YJ9E]GHDY&IG\F8DF@(D)2&6!?FJHH'<-@B@Bo 4A19B**RCQ3XHH(04FJ<8BNJY^AY]n m end