PageRenderTime 31ms CodeModel.GetById 24ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/CCache/debian/patches/05_nfs_fix.diff

#
Unknown | 45 lines | 43 code | 2 blank | 0 comment | 0 complexity | 4c722c465f522ddab3a91813caa869fb MD5 | raw file
 1--- ccache.1.orig	2007-05-20 17:30:57.000000000 +1200
 2+++ ccache.1	2007-05-20 17:31:27.000000000 +1200
 3@@ -367,12 +367,6 @@
 4 .IP o 
 5 ccache avoids a double call to cpp on a cache miss
 6 .PP 
 7-.SH "BUGS" 
 8-.PP 
 9-When the cache is stored on an NFS filesystem, the filesystem must be
10-exported with the \fBno_subtree_check\fP option to make renames between
11-directories reliable\&.
12-.PP 
13 .SH "CREDITS" 
14 .PP 
15 Thanks to the following people for their contributions to ccache
16--- util.c.patched	2007-05-20 18:19:11.000000000 +1200
17+++ util.c	2007-05-20 18:20:55.000000000 +1200
18@@ -58,9 +58,26 @@
19 	}
20 }
21 
22+static int safe_rename(const char* oldpath, const char* newpath)
23+{
24+    /* safe_rename is for creating entries in the cache.
25+
26+       Works like rename(), but it never overwrites an existing
27+       cache entry. This avoids corruption on NFS. */
28+    int status = link( oldpath, newpath );
29+    if( status == 0 || errno == EEXIST )
30+    {
31+	return unlink( oldpath );
32+    }
33+    else
34+    {
35+	return -1;
36+    }
37+}
38+ 
39 /* move a file using rename */
40 int move_file(const char *src, const char *dest) {
41-	return rename(src, dest);
42+	return safe_rename(src, dest);
43 }
44 
45 /* copy a file - used when hard links don't work