Files
oldlinux-files/Linux-0.98/Yggdrasil-0.98.3/usr/man/man2/link.2
2024-02-19 00:21:16 -05:00

85 lines
1.8 KiB
Groff

.TH LINK 2
.UC 4
.SH NAME
link, rmdir, symlink, unlink \- create, remove, rename hard and soft links
.SH SYNOPSIS
.nf
.B #include <unistd.h>
.B int link(const char oldname, const char newname);
.B int rename(const char oldname, const char newname);
.B int rmdir (const char name);
.B int symlink(const char oldname, const char newname);
.B int unlink(const char name);
.fi
.SH DESCRIPTION
.B link()
and
.B symlink()
create hard and soft links named
.I newname
pointing to the file named
.I oldname.
respecively.
.PP
.B rename()
works like link(), only the link named by
.I oldname
ceases to exist.
.PP
.B unlink()
removes the link
.I name.
If reference count for the inode associated with
.I name
reaches 0, the actual file is removed.
Note that reference count counts only hard links.
If
.B unlink()
is performed on a softlink, only the softlink is removed.
.PP
.B rmdir()
works like a specialized unlink which only removes directories.
.PP
0 is returned on success, a negative value for an error condition.
.SH ERRORS
.B -EACCESS
is returned if there is no execute permission in the directory.
.B -ENOENT
is returned if
.I oldname
does not exist, or any portion of the paths do not exist.
.PP
.B -ENOTDIR
returned if
.B rmdir()
is called on a non-directory.
.PP
.B -EPERM
is returned if permissions do not allow the link to be operated on,
or if a zero length name
results from parsing the new name during creation, or if the
action is not supported by the particular filesystem.
.PP
.B -EXDEV
is returned by
.B link
if
.I oldname
and
.I newname
are on different logical devices.
.PP
.B
.SH FILES
linux/fs/namei.c
.br
/usr/include/linux/sys.h
.br
/usr/include/unistd.h
.SH BUGS
.B link()
creates hard links, which may not span filesystems. Use
.B symlink
in these situations.