diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2008-11-03 14:03:21 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2008-11-03 14:03:21 +0000 |
commit | 55246d6c1cc70e10c6f80b4880bd2cced68aa1dd (patch) | |
tree | 2f3a10adcb6b523e9ba51855ec3760803c4dbb2a /CCache/util.c | |
parent | 05ec950cc2cb76b5f8dd8c53c6ba9c4ca8b70431 (diff) | |
download | swig-55246d6c1cc70e10c6f80b4880bd2cced68aa1dd.tar.gz |
apply debian/patches/05_nfs_fix.diff
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10906 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'CCache/util.c')
-rw-r--r-- | CCache/util.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/CCache/util.c b/CCache/util.c index a6b88997c..70d7ea7d4 100644 --- a/CCache/util.c +++ b/CCache/util.c @@ -58,9 +58,26 @@ void copy_fd(int fd_in, int fd_out) } } +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 |