Previous | Table of Contents | Next

Page 866

EFAULT buf or path points to an invalid address.
EIO An I/O error occurred while reading from or writing to the filesystem.
For fstatfs:
EBADF fd is not a valid open file descriptor.
EFAULT buf points to an invalid address.
EIO An I/O error occurred while reading from or writing to the filesystem.

SEE ALSO

stat(2)

Linux 0.99.11, 24 July 1993

stime

stime—Set time

SYPNOSIS

#include <time.h>
int stime(time_t *t);

DESCRIPTION

stime sets the system's idea of the time and date. time, pointed to by t, is measured in seconds from 00:00:00 GMT January 1, 1970. stime() may only be executed by the superuser.

RETURN VALUE

On success, 0 is returned. On error, _1 is returned, and errno is set appropriately.

ERRORS

EPERM The caller is not the superuser.

CONFORMS TO

SVID, AT&T, X/OPEN

SEE ALSO

date(1)

Linux 0.99.11, 24 July 1993

swapon, swapoff

swapon, swapoff—Start/stop swapping to file/device

SYPNOSIS

#include <unistd.h>
#include <linux/swap.h>
int swapon(const char *path, int swapflags);
int swapoff(const char *path);

Page 867

DESCRIPTION

swapon sets the swap area to the file or block device specified by path. swapoff stops swapping to the file or block device specified by path.

swapon takes a swapflags argument. If swapflags has the SWAP_FLAG_PREFER bit turned on, the new swap area will have a higher priority than default. The priority is encoded as (prio << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK. These functions may only be used by the superuser.

Priority

Each swap area has a priority, either high or low. The default priority is low. Within the low-priority areas, newer areas are of even lower priority than older areas.

All priorities set with swapflags are high priority, higher than the default. They may have any non-negative value chosen by the caller. Higher numbers mean higher priority.

Swap pages are allocated from areas in priority order, highest priority first. For areas with different priorities, a higher-priority area is exhausted before using a lower-priority area. If two or more areas have the same priority, and that is the highest priority available, pages are allocated on a round-robin basis between them.

As of Linux 1.3.6, the kernel usually follows these rules, but there are exceptions.

RETURN VALUE

On success, 0 is returned. On error, _1 is returned, and errno is set appropriately.

ERRORS

Many other errors besides the following can occur if path is not valid:
EPERM The user is not the superuser, or more than MAX_SWAPFILES (defined to be 8 in Linux 1.3.6) are in use.
EINVAL Returned if path exists, but is neither a regular path nor a block device.
ENOENT Returned if path does not exist.
ENOMEM Returned if there is insufficient memory to start swapping.

CONFORMS TO

These functions are Linux specific.

NOTES

The partition or path must be prepared with mkswap(8).

HISTORY

The second (swapflags) argument was introduced in Linux 1.3.2.

SEE ALSO

mkswap(8), swapon(8), swapoff(8)

Linux 1.3.6, 22 July 1995

symlink

symlink—Makes a new name for a file

Page 868

SYPNOSIS

#include <unistd.h>
int symlink(const char *oldpath, const char *newpath);

DESCRIPTION

symlink creates a symbolic link named oldpath that contains newpath.

Symbolic links are interpreted at runtime, as if the contents of the link were substituted into the path being followed to find a file or directory.

Symbolic links may contain .. path components that (if used at the start of the link) refer to the parent directories of the one in which the link resides.

A symbolic link (also known as a soft link) can point to an existing file or to a nonexistent one; the latter case is known as a dangling link.

The permissions of a symbolic link are irrelevant; the ownership is ignored when following the link, but is checked when removal or renaming of the link is requested and the link is in a directory with the sticky bit set.

If newpath exists, it will not be overwritten.

RETURN VALUE

On success, 0 is returned. On error, _1 is returned, and errno is set appropriately.

ERRORS

EPERM The filesystem containing pathname does not support the creation of symbolic links.
EFAULT oldpath or newpath points outside your accessible address space.
EACCES Write access to the directory containing newpath is not allowed for the process's effective UID, or one of the directories in newpath did not allow search (execute) permission.
ENAMETOOLONG oldpath or newpath was too long.
ENOENT A directory component in newpath does not exist or is a dangling symbolic link, or oldpath is the empty string.
ENOTDIR A component used as a directory in newpath is not, in fact, a directory.
ENOMEM Insufficient kernel memory was available.
EROFS The file is on a read-only filesystem.
EEXIST newpath already exists.
ELOOP newpath contains a reference to a circular symbolic link—that is, a symbolic link whose expansion contains a reference to itself.
ENOSPC The device containing the file has no room for the new directory entry.

NOTES

No checking of oldpath is done.

Deleting the name referred to by a symlink will actually delete the file (unless it also has other hard links). If this behavior is not desired, use link.

CONFORMS TO

SVID, AT&T, POSIX, BSD 4.3

BUGS

See open(2) regarding multiple files with the same name, and NFS.

Previous | Table of Contents | Next

1