[PATCH xauth/iceauth] auth_finalize: Attempt to rename() if link() fails

Jeremy Huddleston jeremyhu at apple.com
Sun May 8 16:08:29 PDT 2011


On some file systems (like AFP), hard links are not supported. If
link fails, try rename() before giving up.

Reported-by: Jamie Kennea <jamie at pompey.org>
Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
---
 process.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/process.c b/process.c
index 04abc33..a4021c7 100644
--- a/process.c
+++ b/process.c
@@ -888,7 +888,8 @@ auth_finalize(void)
 #if defined(WIN32) || defined(__UNIXOS2__)
 		if (rename(temp_name, xauth_filename) == -1)
 #else
-		if (link (temp_name, xauth_filename) == -1)
+		/* Attempt to rename() if link() fails, since this may be on a FS that does not support hard links */
+		if (link (temp_name, xauth_filename) == -1 && rename(temp_name, xauth_filename) == -1)
 #endif
 		{
 		    fprintf (stderr,
-- 
1.7.4.4




More information about the xorg-devel mailing list