RTEMS Logo

RTEMS 4.6.1 On-Line Library


Files and Directories Manager rename - Renames a file

PREV UP NEXT Bookshelf RTEMS POSIX API User's Guide

4.4.20: rename - Renames a file

CALLING SEQUENCE:

#include <unistd.h>

int rename(
  const char *old,
  const char *new
);

STATUS CODES:

EACCES
Search permission is denied for a directory in a file's path prefix.
EBUSY
The directory is in use.
EEXIST
The named file already exists.
EINVAL
Invalid argument.
EISDIR
Attempt to open a directory for writing or to rename a file to be a directory.
EMLINK
The number of links would exceed LINK_MAX.
ENAMETOOLONG
Length of a filename string exceeds PATH_MAX and _POSIX_NO_TRUNC is in effect.
ENOENT
A file or directory does no exist.
ENOSPC
No space left on disk.
ENOTDIR
A component of the specified pathname was not a directory when a directory was expected.
ENOTEMPTY
Attempt to delete or rename a non-empty directory.
EROFS
Read-only file system
EXDEV
Attempt to link a file to another file system.

DESCRIPTION:

The rename() function causes the file known bo old to now be known as new.

Ordinary files may be renamed to ordinary files, and directories may be renamed to directories; however, files cannot be converted using rename(). The new pathname may not contain a path prefix of old.

NOTES:

If a file already exists by the name new, it is removed. The rename() function is atomic. If the rename() detects an error, no files are removed. This guarantees that the rename("x", "x") does not remove x.

You may not rename dot or dot-dot.

The routine is implemented in Cygnus newlib using link() and unlink().


PREV UP NEXT Bookshelf RTEMS POSIX API User's Guide

Copyright © 1988-2004 OAR Corporation