LINK(2)

NAME
link, rmdir, symlink, unlink - create, remove, rename hard and soft links

SYNOPSIS
#include <unistd.h>
int link(const char oldname, const char newname);
int rename(const char oldname, const char newname);
int rmdir (const char name);
int symlink(const char oldname, const char newname);
int unlink(const char name);

DESCRIPTION
link() and symlink() create hard and soft links named newname pointing to the file named oldname. respecively.

rename() works like link(), only the link named by oldname ceases to exist.

unlink() removes the link name. If reference count for the inode associated with name reaches 0, the actual file is removed. Note that reference count counts only hard links. If unlink() is performed on a softlink, only the softlink is removed.

rmdir() works like a specialized unlink which only removes directories.

0 is returned on success, a negative value for an error condition.

ERRORS
-EACCESS is returned if there is no execute permission in the directory. -ENOENT is returned if oldname does not exist, or any portion of the paths do not exist.

-ENOTDIR returned if rmdir() is called on a non-directory.

-EPERM is returned if permissions do not allow the link to be operated on, or if a zero length name results from parsing the new name during creation, or if the action is not supported by the particular filesystem.

-EXDEV is returned by link if oldname and newname are on different logical devices.

FILES
linux/fs/namei.c
/usr/include/linux/sys.h
/usr/include/unistd.h

BUGS
link() creates hard links, which may not span filesystems. Use symlink in these situations.