File: 05_nfs_fix.diff

package info (click to toggle)
renderdoc 1.2%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 79,584 kB
  • sloc: cpp: 491,671; ansic: 285,823; python: 12,617; java: 11,345; cs: 7,181; makefile: 6,703; yacc: 5,682; ruby: 4,648; perl: 3,461; php: 2,119; sh: 2,068; lisp: 1,835; tcl: 1,068; ml: 747; xml: 137
file content (45 lines) | stat: -rw-r--r-- 1,223 bytes parent folder | download | duplicates (15)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
--- ccache.1.orig	2007-05-20 17:30:57.000000000 +1200
+++ ccache.1	2007-05-20 17:31:27.000000000 +1200
@@ -367,12 +367,6 @@
 .IP o 
 ccache avoids a double call to cpp on a cache miss
 .PP 
-.SH "BUGS" 
-.PP 
-When the cache is stored on an NFS filesystem, the filesystem must be
-exported with the \fBno_subtree_check\fP option to make renames between
-directories reliable\&.
-.PP 
 .SH "CREDITS" 
 .PP 
 Thanks to the following people for their contributions to ccache
--- util.c.patched	2007-05-20 18:19:11.000000000 +1200
+++ util.c	2007-05-20 18:20:55.000000000 +1200
@@ -58,9 +58,26 @@
 	}
 }
 
+static int safe_rename(const char* oldpath, const char* newpath)
+{
+    /* safe_rename is for creating entries in the cache.
+
+       Works like rename(), but it never overwrites an existing
+       cache entry. This avoids corruption on NFS. */
+    int status = link( oldpath, newpath );
+    if( status == 0 || errno == EEXIST )
+    {
+	return unlink( oldpath );
+    }
+    else
+    {
+	return -1;
+    }
+}
+ 
 /* move a file using rename */
 int move_file(const char *src, const char *dest) {
-	return rename(src, dest);
+	return safe_rename(src, dest);
 }
 
 /* copy a file - used when hard links don't work