symlink -- creates symbolic link to a file


cc ... -lc

int symlink(path, newpath)
char *path, *newpath;


The symlink function creates a symbolic link. The argument path is the name and location of the object to which the symbolic link points. The argument newpath is the name and location of the symbolic link being created.

The object, path, that the symbolic link, newpath, points to, must be specified either as an absolute path, or as a relative path leading from the directory containing the symbolic link to the object path. path and newpath need not be on the same file systems. The object path need not exist for the symbolic link to be created. Neither path nor newpath can be a null string.

Symbolic links are used only to find objects, therefore they can point to any object supported by the filesystem, including, but not limited to, regular files, directories, block, character and FIFO special files and other symbolic links.

A call to stat(S) with the symbolic link newpath returns information about the file, path, as if stat(S) had been called on path directly. A call to lstat(S) returns information about the symbolic link, newpath. Both of these routines are described on the stat(S) manual page.

Calls to symlink(S) or lstat(S) made on a kernel on which these calls are not supported, such as SCO UNIX System V Release 3.2 Version 2.0, produce the signal SIGSYS. Programs can be made to operate correctly on kernels that do and do not support these routines by first calling lstat(S) and then calling stat(S) if SIGSYS is produced by the first call.

readlink(S) can be used to read the contents of a symbolic link.

An error is returned if any of the following is true:

Search permission denied for a component of the path prefix of newpath.

The file specified in newpath already exists.

path or newpath points outside the process's allocated address space.


  1. The filesystem on which newpath is created does not support symbolic links

  2. The path argument is a null string

Too many symbolic links were encountered in translating the newpath file argument. The maximum number of symbolic links, that can be found in a pathname, is defined by _POSIX_SYMLOOP in the <sys/unistd.h> header file. This value is compiled into the kernel so changing this value does not affect the limit unless the kernel is recompiled.


  1. The length of a component of newpath exceeds the allowable length of a pathname component on the filesystem on which it is to be created, for example, 255 characters on EAFS and ES51K filesystems.

  2. The length of either path or newpath exceeds 1024 characters.

A component of the path prefix of the newpath file argument does not exist.


  1. The directory in which the entry for the new symbolic link is being placed cannot be extended because no space is left on the filesystem containing the directory.

  2. The new symbolic link cannot be created because no space is left on the filesystem containing the link.

  3. No free inodes are available on the filesystem containing the link.

A component of the path prefix of the newpath file argument is not a directory.

The file specified in newpath would reside on a read-only filesystem.

Return value

Upon successful completion, zero (0) is returned. If an error occurs, an error is returned in errno and -1 is returned to the calling routine.

See also

link(S), ln(C), lstat(S), readlink(S), stat(S), unlink(S)

Standards conformance

symlink is not part of any currently supported standard; it is an extension of AT&T System V developed by the Santa Cruz Operation and maintained by The SCO Group. .
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003