## symlink

#### OS/161 Reference Manual

### Name

symlink - create symbolic link

### Library

Standard C Library (libc, -lc)

### Synopsis

`#include <unistd.h>`
`int`
`symlink(const char *`oldname`, const char *`linkname`);`

### Description

`symlink` creates a symbolic link. The symlink itself is named linkname, and it points to oldname.

oldname need not exist or be on the same filesystem.

The call (like all system calls) must be atomic; that is, the symlink should either be created or not created, and no other process should see an intermediate state (such as, for example, a blank symlink whose name hasn't been written out yet...) For recoverable file systems, this includes after crash recovery.

### Return Values

On success, `symlink` returns 0. On error, -1 is returned, and errno is set according to the error encountered.

### Errors

The following error codes should be returned under the conditions given. Other error codes may be returned for other cases not mentioned here.

| ENODEV | The device prefix of filename did not exist.
ENOTDIR | A non-final component of linkname was not a directory.
ENOENT | A non-final component of linkname did not exist.
EEXIST | linkname already exists.
ENOSPC | The filesystem that was to hold the link is full.
EIO | A hard I/O error occurred.
EFAULT | linkname or oldname was an invalid pointer.