Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
System Functions (k - m) link(2)
NAME
link - Creates an additional directory entry for an existing file on the current fileset
LIBRARY
G-series native OSS processes: system library
H-series and J-series OSS processes: implicit libraries
SYNOPSIS
#include <unistd.h>
int link(
const char *path1,
const char *path2);
PARAMETERS
path1 Points to the pathname of an existing file.
If any component of the path1 parameter refers to a symbolic link, the link is
traversed and pathname resolution continues.
path2 Points to the pathname for the directory entry to be created.
If any component of the path2 parameter refers to a symbolic link, the link is
traversed and pathname resolution continues.
If the final component of the path2 parameter refers to an existing entity, the call
fails and errno is set to [EEXIST].
DESCRIPTION
The link( ) function creates an additional hard link (directory entry) for an existing file. Both the
old and the new link share equal access rights to the underlying file. The link( ) function atomi-
cally creates a new link for the existing file and increments the link count of the file by 1.
The pathnames pointed to by both the path1 and path2 parameters must reside on the same
fileset. If this is not the case, errno is set to [EXDEV].
The path1 parameter must not name a directory; a hard link to a directory cannot be created.
Attempting to create a link to a directory fails. The value -1 is returned and errno is set to
[EPERM].
Attempting to create a link to /dev/tty or /dev/null or attempting to create a link in the root direc-
tory of an OSS fileset to a file named lost+found fails and causes errno to be set to [EPERM].
The calling process requires the following:
• Execute (search) permission on the directory containing the existing file.
• Execute (search) and write permission on the directory into which the link is being
added.
Upon successful completion, the link() function marks the st_ctime field of the file for update
and marks the st_ctime and st_mtime fields of the directory containing the new entry for update.
Accessing Files in Restricted-Access Filesets
When accessing a file in a restricted-access fileset, the super ID (255,255 in the Guardian
environment, 65535 in the OSS environment) is restricted by the same file permissions and
owner privileges as any other user ID: It has no special privileges unless the executable file
started by the super ID has the PRIVSETID file privilege. In this case, the process started by the
super ID can switch to another ID and then access files in restricted-access filesets as that ID.
Executable files that have the PRIVSOARFOPEN privilege and that are started by a member of
the Safeguard SECURITY-OSS-ADMINISTRATOR (SOA) group have the appropriate privilege
527186-023 Hewlett-Packard Company 4−15