|
|
coherent
link() COHERENT System Call link()
Create a link
lliinnkk(_o_l_d, _n_e_w)
cchhaarr *_o_l_d, *_n_e_w;
A link to a file is another name for the file. All attributes of
the file appear identical among all links.
link creates a link called new to an existing file named old.
For administrative reasons, it is an error for users other than
the superuser to create a link to a directory. Such links can
make the file system no longer tree structured unless carefully
controlled, posing problems for commands such as find.
***** Example *****
This example, called lock.c, demonstrates how link can be used to
perform intertask locking. With this technique, a program can
start a process in the background and stop any other user from
starting the identical process.
main()
{
if(link("lock.c", "lockfile") == -1) {
printf("Cannot link\n");
exit(1);
}
sleep(50); /* do nothing for 50 seconds */
unlink("lockfile");
printf("done\n");
exit(0);
}
***** See Also *****
COHERENT system calls, find, ln, unlink()
***** Diagnostics *****
link returns zero when successful. It returns -1 on errors,
e.g., old does not exist, new already exists, attempt to link
across file systems, or no permission to create new in the target
directory.
***** Notes *****
Because each mounted file system is a self-contained entity,
links between different mounted file systems fail.
COHERENT Lexicon Page 1
link() COHERENT System Call link()
COHERENT Lexicon Page 2
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.