The unlink service removes a directory entry. A directory entry can be identified by a pathname to a file, a link name to a file, or a symbolic link.
If a link to a file is removed, and the link count becomes zero, and no other process has the file open, the file itself is deleted.
Operation | Environment |
---|---|
Authorization: | Supervisor or problem state, any PSW key |
Dispatchable unit mode: | Task |
Cross memory mode: | PASN = HASN |
AMODE (BPX1UNL): | 31-bit |
AMODE (BPX4UNL): | 64-bit |
ASC mode: | Primary mode |
Interrupt status: | Enabled for interrupts |
Locks: | Unlocked |
Control parameters: | All parameters must be addressable by the caller and in the primary address space. |
|
AMODE 64 callers use BPX4UNL with the same parameters.
The name of a fullword that contains the length of Name.
The name of a field, of length Name_length, that contains the name of the directory entry that is to be removed. Name can be a pathname to a file, a link name to a file, or a symbolic link name. The pathname was specified when the file was created (see open (BPX1OPN, BPX4OPN) — Open a file). The link name was specified when a link to the file was created (see link (BPX1LNK, BPX4LNK) — Create a link to a file), or when the symbolic link was created (see symlink (BPX1SYM, BPX4SYM) — Create a symbolic link to a path name).
The name of a fullword in which the unlink service returns 0 if the request is successful, or -1 if it is not successful.
Return_code | Explanation |
---|---|
EACCES | One of the following conditions occurred:
|
EBUSY | The file cannot be unlinked because it is being used by the system or the file is open by a remote NFS client with a share reservation that conflicts with the requested operation. |
EINVAL | The Name parameter is incorrect. It contains a null character. |
ELOOP | A loop exists in symbolic links that were encountered during resolution of the Name argument. This error is issued if more than 24 symbolic links are detected in the resolution of Name. |
ENAMETOOLONG | Name is longer than 1023 characters, or some component of the pathname is longer than 255 characters. Name truncation is not supported. |
ENOENT | Name was not found, or no name was specified. The following reason code can accompany the return code: JRUnlNoEnt. |
ENOTDIR | Some component of the pathname prefix is not a directory. |
EPERM | Name refers to a directory. Directories cannot be removed using unlink. The following reason code can accompany the return code: JRUnlDir. |
EROFS | The link that is to be removed is on a read-only file system. The following reason code can accompany the return code: JRUnlMountRO. |
The name of a fullword in which the unlink service stores the reason code. The unlink service returns Reason_code only if Return_value is -1. Reason_code further qualifies the Return_code value. For the reason codes, see z/OS UNIX System Services Messages and Codes.
There are no restrictions on the use of the unlink service.
For an example using this callable service, see BPX1UNL (unlink) example.