5
/* sanitize link() error returns
7
/* #include <sane_fsops.h>
9
/* int sane_link(from, to)
13
/* sane_link() implements the link(2) system call, and works
14
/* around some errors that are possible with NFS file systems.
18
/* The Secure Mailer license must be distributed with this software.
21
/* IBM T.J. Watson Research
23
/* Yorktown Heights, NY 10598, USA
33
/* Utility library. */
36
#include "sane_fsops.h"
38
/* sane_link - sanitize link() error returns */
40
int sane_link(const char *from, const char *to)
42
char *myname = "sane_link";
48
* Normal case: link() succeeds.
50
if (link(from, to) >= 0)
54
* Woops. Save errno, and see if the error is an NFS artefact. If it is,
55
* pretend the error never happened.
58
if (stat(from, &from_st) >= 0 && stat(to, &to_st) >= 0
59
&& from_st.st_dev == to_st.st_dev
60
&& from_st.st_ino == to_st.st_ino) {
61
msg_info("%s(%s,%s): worked around spurious NFS error",
67
* Nope, it didn't. Restore errno and report the error.