rename(3)

DESCRIPTION

Renames old_path to new_path within the same mounted filesystem. An existing target of the same type is replaced.

SYNOPSIS

#include <unistd.h>

int rename(const char *old_path, const char *new_path);

RETURN VALUE

  • Returns zero, or -1 and sets errno.

ERRORS

  • -EFAULT
    • Either pathname cannot be read.
  • -EINVAL
    • Path resolution fails or a directory is moved below itself.
  • -ENOENT
    • A path or parent directory does not exist.
  • -ENOTDIR
    • The source and target types are incompatible.
  • -EISDIR
    • The source and target types are incompatible.
  • -ENOTEMPTY
    • An existing target directory is not empty.
  • -EXDEV
    • The paths are on different mounted filesystems.

NOTES

The libc API exposes no rename flags.