diff options
author | Brendan Cully <brendan@kublai.com> | 2007-04-06 12:54:46 -0700 |
---|---|---|
committer | Brendan Cully <brendan@kublai.com> | 2007-04-06 12:54:46 -0700 |
commit | d086df8820f3f70333b42a66027458fb5e286712 (patch) | |
tree | bc741c6bdc2dfd880e685a5601499ececc012c77 /lib.c | |
parent | f5372058942d63b0432255dbdeaf0c808f3f431f (diff) |
Make safe_open with O_EXCL friendlier for NFS.
Per #2707, when an open file is moved into a different directory over
NFS, it may leave a .nfsXXX hardlink behind. This causes the rmdir in
safe_open to fail, leaving tempdir droppings around. This patch works
around the problem by closing the file after creating it and reopening
it after rename.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 15 |
1 files changed, 6 insertions, 9 deletions
@@ -575,18 +575,15 @@ int safe_open (const char *path, int flags) rmdir (safe_dir); return fd; } - + + /* NFS and I believe cygwin do not handle movement of open files well */ + close (fd); if (mutt_put_file_in_place (path, safe_file, safe_dir) == -1) - { - close (fd); return -1; - } - } - else - { - if ((fd = open (path, flags, 0600)) < 0) - return fd; } + + if ((fd = open (path, flags & ~O_EXCL, 0600)) < 0) + return fd; /* make sure the file is not symlink */ if (lstat (path, &osb) < 0 || fstat (fd, &nsb) < 0 || |