Symbolic Links

Symbolic links solve the thorny problem of providing a link to a file on another file system. They represent a file system "re-director" of sorts. In order to allow programs to work with symbolic links, the UNIX kernel provides a few system calls specific to symbolic links.

The symlink(2) Function

The symlink(2) function permits the caller to create a symbolic link, as opposed to a hard link that is created by link(2). The synopsis for symlink(2) is as follows:

#include <unistd.h>

int symlink(const char *path, const char *symlnk);

The symbolic link named by the argument symlnk is created to point to the pathname provided by the argument path. The function returns 0 if successful; otherwise -1 and a value for errno are returned. ...

Get Advanced UNIX Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.