sys_link  [fs/namei.c]


Creates a new link (also known as a hard link) to an existing file.
This system call is identical to sys_linkat with ecx and esi set to AT_FDCWD.

Arguments

eax 9
ebx Pointer to a null-terminated string specifying the pathname of an existing file.
ecx Pointer to a null-terminated string specifying the pathname of the new link. If it is already exists it will not be overwritten.

Return values

If the system call succeeds the return value is 0.
If the system call fails the return value is one of the following errno values:

-EXDEV Existing file and new link pathnames are not on the same filesystem.
-EPERM The filesystem containing existing file and new link does not support the creation of hard links.
-EFAULT ebx or ecx points outside your accessible address space.
-EACCES Write access to the directory containing new link is not allowed for the process's effective UID, or one of the directories in Existing file path or new link path did not allow search (execute) permission.
-ENAMETOOLONG Existing file or new link pathname was too long.
-ENOENT A directory component in existing file or new link pathname does not exist or is a dangling symbolic link.
-ENOTDIR A component used as a directory in existing file or new link pathname is not, in fact, a directory.
-ENOMEM Insufficient kernel memory was available.
-EROFS The file is on a read-only filesystem.
-EEXIST Path pointed by ecx already exists.
-EMLINK The file referred to by ebx already has the maximum number of links to it.
-ELOOP Too many symbolic links were encountered in resolving existing file or new link pathname.
-ENOSPC The device containing the file has no room for the new directory entry.
-EPERM Path pointed by ebx is a directory.
-EIO An I/O error occurred.

Remarks

Hard links, as created by sys_link, cannot span filesystems. Use sys_symlink if this is required.
On NFS file systems, the return code may be wrong in case the NFS server performs the link creation and dies before it can say so. Use sys_stat to find out if the link got created.

Compatibility

n/a