Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

System Functions (s and S) symlink(2)
NAME
symlink - Creates a symbolic link to a file
LIBRARY
G-series native Guardian processes: system library
G-series native OSS processes: system library
H-series native Guardian processes: implicit libraries
H-series OSS processes: implicit libraries
SYNOPSIS
#include <unistd.h>
int symlink(
const char *path1,
const char *path2);
PARAMETERS
path1 Specifies the file for which the symbolic link must be created. The file named by
the path1 parameter does not need to exist when the link is created. The path1
parameter can refer to a symbolic link.
path2 Names the symbolic link to be created. An error is returned if the symbolic link
named by the path2 parameter already exists.
DESCRIPTION
The symlink() function creates a symbolic link with the name specified by the path2 parameter,
which refers to the file named by the path1 parameter.
Like a hard link (described in the link(2) reference page), a symbolic link allows a file to have
multiple names. The presence of a hard link guarantees the existence of a file, even after the ori-
ginal name has been removed; a symbolic link provides no such guarantee. Unlike hard links, a
symbolic link can cross fileset boundaries.
When a component of a pathname refers to a symbolic link rather than a directory, the pathname
contained in the symbolic link is resolved. If the pathname in the symbolic link starts with a
slash (/) character, the symbolic link pathname is resolved relative to the root directory of the
process. If the pathname in the symbolic link does not start with a slash (/) character, the sym-
bolic link pathname is resolved relative to the directory that contains the symbolic link.
If the symbolic link is not the last component of the original pathname, the remaining com-
ponents of the original pathname are appended to the contents of the link and pathname resolu-
tion continues.
The symbolic link pathname may or may not be traversed, depending on which function is being
performed. Most functions traverse the link.
The functions that refer only to the symbolic link itself, rather than to the object to which the link
refers, are as follows:
link() An error is returned if a symbolic link is named by the path2 parameter.
lstat() If the file specified is a symbolic link, the status of the link itself is returned.
mknod( ) An error is returned if a symbolic link is named as the path parameter.
open() An error is returned when O_CREAT and O_EXCL are both specified and the
path parameter specifies an existing symbolic link.
527186-023 Hewlett-Packard Company 7533