link

Creates a new link to an existing file.

Library:LibC
Classification:POSIX
Service:General C Services

Syntax

  #include <unistd.h> 
   
  int link (
     const char   *path1,
     const char   *path2);
  

Parameters

path 1

(IN) Points to the path and filename of an existing file.

path2

(IN) Points to the path and filename of the entry to create.

Return Values

If successful, returns 0. Otherwise returns -1 and sets errno.

Decimal

Constant

Description

1

ENOENT

A path component in path1 or path2 does not exist.

5

ENOMEM

Insufficient memory to perform the task.

6

EACCES

Permission is denied to a component of path1 or path2.

7

EEXIST

The link specified by path2 already exists.

65

ENAMETOOLONG

The name of a component in path1 or path2 exceeds system limits.

66

ENOSYS

Not supported because the NLM is not using POSIX semantics.

67

ENOTDIR

A path component in path1 or path2 is not a directory.

79

ENOTSUP

Not supported because either the volume is not an NSS volume or if an NSS volume, the volume does not support the sLink function.

105

ENOCONTEXT

The calling thread has no library context.

Remarks

The link function only works with NLMs that are using POSIX semantics, on NSS volumes that support the sLink function, and for hard links. Soft links are not currently supported.

See Also