Przeglądaj źródła

Finally understood the Unix files problem in VirtualBox: Files in a shared folder cannot be removed before they are closed (unlike native Linux files, which can be unlinked before they are closed)

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6949 8c9fc860-2736-0410-a75d-ab315db34111
felixf 8 lat temu
rodzic
commit
ec325ed0e8
1 zmienionych plików z 3 dodań i 5 usunięć
  1. 3 5
      source/Generic.Unix.UnixFiles.Mod

+ 3 - 5
source/Generic.Unix.UnixFiles.Mod

@@ -401,12 +401,10 @@ TYPE
 						IF (r >= 0) & ((ostat.dev # nstat.dev) OR (ostat.ino # nstat.ino)) THEN
 							 r := Unix.unlink( ADDRESSOF( new ) )  (* work around stale nfs handles *);
 						END;
-						
-						
 						r := Unix.rename( ADDRESSOF( old ), ADDRESSOF( new ) );
 						IF r < 0 THEN
 							res := Unix.errno( );
-							IF (res = Unix.EXDEV) OR (res = Unix.ETXTBSY) THEN  (* cross device link, move the file *)
+							IF (res = Unix.EXDEV) OR (res = Unix.ETXTBSY) THEN  (* cross device link, move the file / file busy frequently happens in VirtualBox *)
 
 								fdold := Unix.open( ADDRESSOF( old ), Unix.rdonly, {} );
 								IF fdold < 0 THEN    
@@ -430,9 +428,9 @@ TYPE
 									END;
 									n := Unix.read( fdold, ADDRESSOF( buf ), Bufsize )
 								END;
-								r := Unix.close( fdold );
-
 								r := Unix.unlink( ADDRESSOF( old ) );  								
+								r := Unix.close( fdold );
+								r := Unix.unlink( ADDRESSOF( old ) );  (* for virtual box to work *)
 								r := Unix.close( fdnew );  
 								res := Files.Ok
 							ELSE