Skip to content
BSD syscall#10

svc · unix #10

unlink

Removes a directory entry, releasing the associated inode when its link count reaches zero.

Prototype

int unlink(user_addr_t path);

Returns: int

Arguments

NameTypeDirDescription
pathuser_addr_t-

Version history

XNU tagmacOS#
xnu-1456.1.26macOS 10.6 Snow Leopard10
xnu-1486.2.1110
xnu-1504.15.310
xnu-1504.3.1210
xnu-1504.7.410
xnu-1504.9.1710
xnu-1504.9.2610
xnu-1504.9.3710

Notes

If processes still hold the file open the storage is reclaimed only after the last close. On macOS unlink on a file with the schg or uchg flag returns EPERM unless the flag is first cleared via chflags. SIP protects certain paths even from root.

Detection

ES emits ES_EVENT_TYPE_NOTIFY_UNLINK with the parent and removed vnode.

Related APIs

unlinkatrmdirrenameopenchflags