

unlink()               COHERENT System Call              unlink()




Remove a file

iinntt uunnlliinnkk(_n_a_m_e) cchhaarr *_n_a_m_e;

unlink removes the directory entry for the given file name, which
in effect erases name from  the disk.  name cannot be opened once
it has been unlinked.  If name is the last link, unlink frees the
i-node and  data blocks.  Deallocation is delayed  if the file is
open.  Other links to the file remain intact.

***** Example *****

This example removes the files named on the command line.


main(argc, argv)
int argc; char *argv[];
{
        int i;



        for (i = 1; i < argc; i++) {
                if (unlink(argv[i]) == -1) {
                        printf("Cannot unlink \"%s\"\n", argv[i]);
                        exit(1);
                }
        }
        exit(0);
}


***** See Also *****

COHERENT system calls, link(), ln, rm, rmdir

***** Diagnostics *****

uunnlliinnkk returns zero when  successful.  It returns -1 if file does
not exist, if the user  does not have write and search permission
in the  directory containing file, or if file  is a directory and
the invoker is not the superuser.














COHERENT Lexicon                                           Page 1


