- }
- argc--;
- argv++;
- }
-
- linkName = argv[argc - 1];
-
- if (strlen(linkName) > BUFSIZ) {
- fprintf(stderr, name_too_long, "ln");
- exit FALSE;
- }
-
- linkIntoDirFlag = isDirectory(linkName, TRUE, NULL);
-
- if ((argc > 3) && !linkIntoDirFlag) {
- fprintf(stderr, not_a_directory, "ln", linkName);
- exit FALSE;
- }
-
- while (argc-- >= 2) {
- char srcName[BUFSIZ + 1];
- int nChars, status;
-
- if (strlen(*argv) > BUFSIZ) {
- fprintf(stderr, name_too_long, "ln");
- exit FALSE;
- }
-
- if (followLinks == FALSE) {
- strcpy(srcName, *argv);
- } else {
- /* Warning! This can silently truncate if > BUFSIZ, but
- I don't think that there can be one > BUFSIZ anyway. */
- nChars = readlink(*argv, srcName, BUFSIZ);
- srcName[nChars] = '\0';
- }
-
- if (removeoldFlag == TRUE) {
- status = (unlink(linkName) && errno != ENOENT);
- if (status != 0) {
- perror(linkName);
- exit FALSE;
- }
- }
-
- if (symlinkFlag == TRUE)
- status = symlink(*argv, linkName);
- else
- status = link(*argv, linkName);
- if (status != 0) {
- perror(linkName);
- exit FALSE;