2 * Mini ln implementation for busybox
5 * Copyright (C) 1999 by Lineo, inc.
6 * Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 static const char ln_usage[] = "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n\n"
31 "Create a link named LINK_NAME or DIRECTORY to the specified TARGET\n\n"
33 "\t-s\tmake symbolic links instead of hard links\n"
34 "\t-f\tremove existing destination files\n";
37 static int symlinkFlag = FALSE;
38 static int removeoldFlag = FALSE;
41 extern int ln_main(int argc, char **argv)
44 static char* linkName;
52 /* Parse any options */
53 while (**argv == '-') {
70 linkName = argv[argc - 1];
72 if ((argc > 3) && !(isDirectory(linkName))) {
73 fprintf(stderr, "%s: not a directory\n", linkName);
78 if (removeoldFlag==TRUE ) {
79 status = ( unlink(linkName) && errno != ENOENT );
85 if ( symlinkFlag==TRUE)
86 status = symlink(*argv, linkName);
88 status = link(*argv, linkName);