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 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 field of the file 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 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.
• The use of static memory by the process increases slightly.
These effects occur only when the first 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 file is not changed, and errno is set to indicate the error.
527186-004 Hewlett-Packard Company 9−7