link

OS/161 Reference Manual

Name

link - create hard link to a file

Library

Standard C Library (libc, -lc)

Synopsis

#include <unistd.h>

int
link(const char *oldname, const char *newname);

Description

link creates a new name, newname, for the file referred to by oldname. Henceforth, both names are equally valid ways to refer to the same file. The file is only deleted when all names are removed. This is a "hard link".

The creation of the new name is atomic. The two names must be on the same filesystem. Directories may not be hard-linked.

Return Values

On success, link returns 0. On error, -1 is returned, and errno is set according to the error encountered.

Errors

The following error codes should be returned under the conditions given. Other error codes may be returned for other errors not mentioned here.
  
ENODEV The device prefix of one of the names did not exist.
ENOTDIR A non-final component of one of the names was not a directory.
ENOENT A non-final component of newname did not exist.
ENOENT oldname does not exist.
EEXIST newname already exists.
EISDIR oldname is a directory.
EXDEV The two names are on different filesystems.
ENOSPC The filesystem involved is full.
EIO A hard I/O error occurred.
EFAULT One of the arguments was an invalid pointer.