7 /* sanitize rename() error returns
9 /* #include <sane_fsops.h>
11 /* int sane_rename(old, new)
15 /* sane_rename() implements the rename(2) system call, and works
16 /* around some errors that are possible with NFS file systems.
20 /* The Secure Mailer license must be distributed with this software.
23 /* IBM T.J. Watson Research
25 /* Yorktown Heights, NY 10598, USA
33 #include <stdio.h> /* rename(2) syscall in stdio.h? */
35 /* Utility library. */
38 #include "sane_fsops.h"
40 /* sane_rename - sanitize rename() error returns */
42 int sane_rename(const char *from
, const char *to
)
44 const char *myname
= "sane_rename";
49 * Normal case: rename() succeeds.
51 if (rename(from
, to
) >= 0)
55 * Woops. Save errno, and see if the error is an NFS artefact. If it is,
56 * pretend the error never happened.
59 if (stat(from
, &st
) < 0 && stat(to
, &st
) >= 0) {
60 msg_info("%s(%s,%s): worked around spurious NFS error",
66 * Nope, it didn't. Restore errno and report the error.