In article <17572.992771844@???>,
Sheldon Hearn <sheldonh@???> wrote:
>The issue that you can't get
>around regardless of your implementation is the window during which the
>file is updated. Since there's no POSIX "forced link" [1], you can't
>guarantee atomic updates without some "hitching post" or lock.
>
>[1] Naive users are fooled into believing that a file update may be made
> atomic using ln -f, but this is actually an unlink() + link()
> operation, at least in BSD UNIX.
NAME
rename - change the name or location of a file
SYNOPSIS
#include <stdio.h>
int rename(const char *oldpath, const char *newpath);
DESCRIPTION
rename renames a file, moving it between directories if
required.
Any other hard links to the file (as created using
link(2)) are unaffected.
If newpath already exists it will be atomically replaced
(subject to a few conditions - see ERRORS below), so that
there is no point at which another process attempting to
access newpath will find it missing.
If newpath exists but the operation fails for some reason
rename guarantees to leave an instance of newpath in
place.
CONFORMING TO
POSIX, 4.3BSD, ANSI C
Mike.