Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ symlink(2) — AIX PS/2 1.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chdir

link

readlink

unlink, rmslink, remove

ln



SYMLINK(2,L)                AIX Technical Reference                SYMLINK(2,L)



-------------------------------------------------------------------------------
symlink



PURPOSE

Creates a symbolic link to a file or directory.

LIBRARY

Standard C Library (libc.a)

SYNTAX

int symlink (path1, path2)
char *path1, *path2;

DESCRIPTION

The symlink system call creates a symbolic link to a file or directory by
creating a file that contains the name of the destination file to which it is
being linked.  The symbolic link functions as a pointer to the destination file
or directory.  The path1 parameter specifies the destination file.  If path1 is
not a full path name (does not begin with /), it is evaluated in the context of
path2, not the current working directory (see "chdir.") No checks are made to
determine if path1 is a valid path name.

The path2 parameter specifies the name of the symbolic link.  Both path names
are null-terminated character strings.  If Network File System is installed on
your system, these paths can cross outside your cluster into another node.  A
symbolic link can cross file system boundaries.

Use the readlink command to read the contents of the symbolic link.

If the destination file pointed to by the symbolic link is renamed or removed,
the symbolic link points to a non-existent file.  If the symbolic link itself
is deleted, the destination file is not affected.

If path1 begins with the path prefix <LOCAL>/, a process's local string set by
the setlocal call will be substituted for this prefix when this symbolic link
is later used.  This allows a symbolic link to point to different files on
different machines.

A symbolic link made in a system-level, replicated file system (refer to the
description of replicated file systems in Managing the AIX Operating System)
cannot be removed with a normal unlink call.  The rmslink call must be used
instead.

Symbolic links cannot be created in hidden directories.





Processed November 7, 1990       SYMLINK(2,L)                                 1





SYMLINK(2,L)                AIX Technical Reference                SYMLINK(2,L)



Note:  Indiscriminate use of symbolic links can confuse naive programs and
       users.  Care should be used to avoid creating symbolic link loops.

RETURN VALUE

Upon successful completion, 0 is returned.  Otherwise, a -1 is returned and
errno is set to indicate the error.

ERROR CONDITIONS

The symlink system call fails if one or more of the following are true:

ENOTDIR   A component of path2 prefix is not a directory.

ENOENT    A component of path2 does not exist.

EACCES    The requested link requires writing in a directory with a mode that
          denies write permission.

ENOENT    A symbolic link was named, but the file to which it refers does not
          exist.

EEXIST    The link named by path2 already exists.

ENOENT    The path2 parameter points to a NULL path name.

EACCES    Search permission is denied on a component of the path prefix of
          path2.

EROFS     The requested link requires writing in a directory on a read-only
          file system.

EFAULT    The path1 or path2 parameter points to a location outside of the
          process's allocated address space.

ELOOP     Too many symbolic links were encountered in translating path2.

ENFILE    The system inode table is out of space.

ENOSPC    The new symbolic link cannot be created because there is no space or
          no inodes left on the file system designated to contain the link.

EACCES    An attempt was made to create a symbolic link inside a hidden
          directory.

EDQUOT    The directory in which the entry for the new link is being placed
          cannot be extended, because the user's quota of disk blocks on the
          file system containing the directory has been exhausted.

If the Transparent Computing Facility is installed on your system, symlink can
also fail if one or more of the following are true:




Processed November 7, 1990       SYMLINK(2,L)                                 2





SYMLINK(2,L)                AIX Technical Reference                SYMLINK(2,L)



ESITEDN1  path2 cannot be accessed because a site went down.

ESITEDN2  The operation was terminated because a site failed.

ENOSTORE  path is a name relative to the working directory, but no site which
          stores this directory is currently up.

ENOSTORE  A component of path2 is replicated but is not stored on any site
          which is currently up.

EROFS     The requested link requires writing in a replicated file system in
          which the primary copy is unavailable.

EINTR     A signal was caught during the system call.

If Network File System is installed on your system, symlink can also fail if
the following is true:

ESTALE    The process's root or current directory is located in an NFS virtual
          file system that has been unmounted.

ETIMEDOUT The connection timed out.

RELATED INFORMATION

In this book:  "chdir," "link," "readlink," and "unlink, rmslink, remove."

The symbolic link section in Using the AIX Operating System.

The ln command  in AIX Operating System Commands Reference.

























Processed November 7, 1990       SYMLINK(2,L)                                 3



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026