Open System Services System Calls Reference Manual (G06.27+, H06.04+)

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 OSS processes: implicit libraries
SYNOPSIS
#include <unistd.h>
int unlink(
const char *path);
PARAMETERS
path Species the directory entry to be removed.
DESCRIPTION
The unlink() function removes the directory entry specied by the path parameter and decre-
ments the link count of the le referenced by the link.
When all links to a le are removed and no process has the le open, all resources associated
with the le are reclaimed and the le is no longer accessible. If one or more processes have the
le open when the last link is removed, the link is removed before the unlink( ) function returns
but the removal of the le contents is postponed until all open references to the le 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 le being unlinked. Write permission for an OSS le is not required.
Upon successful completion, the unlink() function marks for update the st_ctime and st_mtime
elds of the directory that contained the entry that was removed. If the les link count is not 0
(zero) or if the le is open, the st_ctime eld of the le is also marked for update.
Use From the Guardian Environment
The unlink() function belongs to a set of functions that have the following effects when the rst
of them is called from the Guardian environment:
Two Guardian le system le numbers (not necessarily the next two available) are allo-
cated for the root directory and the current working directory. These le 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.
The use of static memory by the process increases slightly.
These effects occur only when the rst of the set of functions is called. The effects are not cumu-
lative.
RETURN VALUES
Upon successful completion, the value 0 (zero) is returned. Otherwise, the value -1 is returned,
the named le is not changed, and errno is set to indicate the error.
527186-004 Hewlett-Packard Company 97