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

System Functions (u) unlink(2)
NAME
unlink - Removes a directory entry from the OSS environment
LIBRARY
G-series native OSS processes: system library
H-series and J-series OSS processes: implicit libraries
SYNOPSIS
#include <unistd.h>
int unlink(
const char *path);
PARAMETERS
path Specifies the directory entry to be removed.
DESCRIPTION
The unlink( ) function removes the directory entry specified by the path parameter and decre-
ments the link count of the file referenced by the link.
When all links to a file are removed and no process has the file open, all resources associated
with the file are reclaimed and the file is no longer accessible. If one or more processes have the
file open when the last link is removed, the link is removed before the unlink( ) function returns
but the removal of the file contents is postponed until all open references to the file are removed.
If the path parameter names a symbolic link, the symbolic link itself is removed.
The path parameter must not name a directory.
The calling process requires both execute (search) and write access permission for the directory
containing the file being unlinked. Write permission for an OSS file is not required.
Upon successful completion, the unlink() function marks for update the st_ctime and st_mtime
fields of the directory that contained the entry that was removed. If the file’s link count is not 0
(zero) or if the file is open, the st_ctime eld of the file is also marked for update.
Accessing Files in Restricted-Access Filesets
When accessing a file in a restricted-access leset, 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 les in restricted-access lesets 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
to use this function on any file in a restricted-access leset. However, Network File System
(NFS) clients are not granted SOA group privileges, even if these clients are accessing the sys-
tem with a user ID that is a member of the SOA security group.
For more information about restricted-access lesets and file privileges, see the Open System Ser-
vices Management and Operations Guide.
Use From the Guardian Environment
The unlink( ) function belongs to a set of functions that have the following effects when the first
of them is called from the Guardian environment:
Two Guardian file system file numbers (not necessarily the next two available) are allo-
cated for the root directory and the current working directory. These file numbers cannot
be closed by calling the Guardian FILE_CLOSE_ procedure.
The current working directory is assigned from the VOLUME attribute of the Guardian
environment =_DEFAULTS DEFINE.
527186-023 Hewlett-Packard Company 97