diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-11-06 06:07:27 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-11-06 06:07:27 +0000 |
commit | 29d2e362dedf42d60ffebf6756144fb5449e753a (patch) | |
tree | 57ba26bdcf5dae8deb91a3d1a9b47bcc140689a0 /coreutils/ln.c | |
parent | bc3419069494fac078b316ce3a2f6a232c763c3e (diff) |
Fixed ln, df, and removed redundant stuff from mtab.
Diffstat (limited to 'coreutils/ln.c')
-rw-r--r-- | coreutils/ln.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/coreutils/ln.c b/coreutils/ln.c index 1e30e2b29..62496fba0 100644 --- a/coreutils/ln.c +++ b/coreutils/ln.c @@ -27,23 +27,21 @@ #include <errno.h> -static const char ln_usage[] = "ln [-s] [-f] original-name additional-name\n" -"\n" -"\tAdd a new name that refers to the same file as \"original-name\"\n" -"\n" -"\t-s:\tUse a \"symbolic\" link, instead of a \"hard\" link.\n" -"\t-f:\tRemove existing destination files.\n"; +static const char ln_usage[] = "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n" +"Create a link named LINK_NAME or DIRECTORY to the specified TARGET\n" +"\nOptions:\n" +"\t-s\tmake symbolic links instead of hard links\n" +"\t-f\tremove existing destination files\n"; static int symlinkFlag = FALSE; static int removeoldFlag = FALSE; -static const char *destName; extern int ln_main(int argc, char **argv) { int status; - char newdestName[NAME_MAX]; + static char* linkName; if (argc < 3) { usage (ln_usage); @@ -69,30 +67,27 @@ extern int ln_main(int argc, char **argv) } - destName = argv[argc - 1]; + linkName = argv[argc - 1]; - if ((argc > 3) && !(isDirectory(destName))) { - fprintf(stderr, "%s: not a directory\n", destName); + if ((argc > 3) && !(isDirectory(linkName))) { + fprintf(stderr, "%s: not a directory\n", linkName); exit (FALSE); } while (argc-- >= 2) { - strcpy(newdestName, destName); - strcat(newdestName, (*argv)+(strlen(*(++argv)))); - if (removeoldFlag==TRUE ) { - status = ( unlink(newdestName) && errno != ENOENT ); + status = ( unlink(linkName) && errno != ENOENT ); if ( status != 0 ) { - perror(newdestName); + perror(linkName); exit( FALSE); } } if ( symlinkFlag==TRUE) - status = symlink(*argv, newdestName); + status = symlink(*argv, linkName); else - status = link(*argv, newdestName); + status = link(*argv, linkName); if ( status != 0 ) { - perror(newdestName); + perror(linkName); exit( FALSE); } } |