/* link.c 1.0.1 (4 Jan 1998) */ /* Adam M. Costello */ /* link */ /* */ /* Tries to create the file as a hard link to */ /* . Returns 0 on success, 1 if */ /* already exists, 2 for other failures. The only */ /* output is an error message on stderr if the exit */ /* status is 2 (not 1). */ #include #include int main(int argc, char **argv) { int r; if (argc != 3) return 2; r = link(argv[1], argv[2]); if (r != -1) return 0; if (errno == EEXIST) return 1; perror(argv[0]); return 2; }