diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-07-11 17:35:32 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-07-11 17:35:32 +0000 |
commit | 195fa15caf7d79a5447d7476c113777cb3bebbd8 (patch) | |
tree | df66cd937cdf8e066ff06ba0c3b241d848bba071 | |
parent | 61dc0571832b88097192a8c0eab190a44c577371 (diff) | |
download | busybox-w32-195fa15caf7d79a5447d7476c113777cb3bebbd8.tar.gz busybox-w32-195fa15caf7d79a5447d7476c113777cb3bebbd8.tar.bz2 busybox-w32-195fa15caf7d79a5447d7476c113777cb3bebbd8.zip |
Another patch from Matt Kraai <kraai@alumni.carnegiemellon.edu>:
>
> The following patch allows ln -n to function like GNU. It also fixes a
> typo with my previous patch to add support for ln FILE DIRECTORY. And
> it removes some code that checks the maximum length of the filenames. I
> can't figure out why that code is necessary. Anyone know?
>
> Matt
-rw-r--r-- | coreutils/ln.c | 29 | ||||
-rw-r--r-- | ln.c | 29 |
2 files changed, 4 insertions, 54 deletions
diff --git a/coreutils/ln.c b/coreutils/ln.c index 3c45dee33..71d84f066 100644 --- a/coreutils/ln.c +++ b/coreutils/ln.c | |||
@@ -92,13 +92,7 @@ extern int ln_main(int argc, char **argv) | |||
92 | 92 | ||
93 | linkName = argv[argc - 1]; | 93 | linkName = argv[argc - 1]; |
94 | 94 | ||
95 | if (strlen(linkName) > BUFSIZ) { | 95 | linkIntoDirFlag = isDirectory(linkName, followLinks, NULL); |
96 | fprintf(stderr, name_too_long, "ln"); | ||
97 | exit FALSE; | ||
98 | } | ||
99 | |||
100 | linkIntoDirFlag = isDirectory(linkName, TRUE, NULL); | ||
101 | |||
102 | if ((argc >= 3) && linkIntoDirFlag == FALSE) { | 96 | if ((argc >= 3) && linkIntoDirFlag == FALSE) { |
103 | fprintf(stderr, not_a_directory, "ln", linkName); | 97 | fprintf(stderr, not_a_directory, "ln", linkName); |
104 | exit FALSE; | 98 | exit FALSE; |
@@ -108,27 +102,8 @@ extern int ln_main(int argc, char **argv) | |||
108 | dirName = linkName; | 102 | dirName = linkName; |
109 | 103 | ||
110 | while (argc-- >= 2) { | 104 | while (argc-- >= 2) { |
111 | #if 0 | ||
112 | char srcName[BUFSIZ + 1]; | ||
113 | int nChars; | ||
114 | #endif | ||
115 | int status; | 105 | int status; |
116 | 106 | ||
117 | if (strlen(*argv) > BUFSIZ) { | ||
118 | fprintf(stderr, name_too_long, "ln"); | ||
119 | exit FALSE; | ||
120 | } | ||
121 | |||
122 | #if 0 | ||
123 | if (followLinks == FALSE) { | ||
124 | strcpy(srcName, *argv); | ||
125 | } else { | ||
126 | /* Warning! This can silently truncate if > BUFSIZ, but | ||
127 | I don't think that there can be one > BUFSIZ anyway. */ | ||
128 | nChars = readlink(*argv, srcName, BUFSIZ); | ||
129 | srcName[nChars] = '\0'; | ||
130 | } | ||
131 | #endif | ||
132 | if (linkIntoDirFlag == TRUE) { | 107 | if (linkIntoDirFlag == TRUE) { |
133 | char *baseName = get_last_path_component(*argv); | 108 | char *baseName = get_last_path_component(*argv); |
134 | linkName = (char *)malloc(strlen(dirName)+strlen(baseName)+2); | 109 | linkName = (char *)malloc(strlen(dirName)+strlen(baseName)+2); |
@@ -155,7 +130,7 @@ extern int ln_main(int argc, char **argv) | |||
155 | exit FALSE; | 130 | exit FALSE; |
156 | } | 131 | } |
157 | 132 | ||
158 | if (linkIntoDirFlag) | 133 | if (linkIntoDirFlag == TRUE) |
159 | free(linkName); | 134 | free(linkName); |
160 | 135 | ||
161 | argv++; | 136 | argv++; |
@@ -92,13 +92,7 @@ extern int ln_main(int argc, char **argv) | |||
92 | 92 | ||
93 | linkName = argv[argc - 1]; | 93 | linkName = argv[argc - 1]; |
94 | 94 | ||
95 | if (strlen(linkName) > BUFSIZ) { | 95 | linkIntoDirFlag = isDirectory(linkName, followLinks, NULL); |
96 | fprintf(stderr, name_too_long, "ln"); | ||
97 | exit FALSE; | ||
98 | } | ||
99 | |||
100 | linkIntoDirFlag = isDirectory(linkName, TRUE, NULL); | ||
101 | |||
102 | if ((argc >= 3) && linkIntoDirFlag == FALSE) { | 96 | if ((argc >= 3) && linkIntoDirFlag == FALSE) { |
103 | fprintf(stderr, not_a_directory, "ln", linkName); | 97 | fprintf(stderr, not_a_directory, "ln", linkName); |
104 | exit FALSE; | 98 | exit FALSE; |
@@ -108,27 +102,8 @@ extern int ln_main(int argc, char **argv) | |||
108 | dirName = linkName; | 102 | dirName = linkName; |
109 | 103 | ||
110 | while (argc-- >= 2) { | 104 | while (argc-- >= 2) { |
111 | #if 0 | ||
112 | char srcName[BUFSIZ + 1]; | ||
113 | int nChars; | ||
114 | #endif | ||
115 | int status; | 105 | int status; |
116 | 106 | ||
117 | if (strlen(*argv) > BUFSIZ) { | ||
118 | fprintf(stderr, name_too_long, "ln"); | ||
119 | exit FALSE; | ||
120 | } | ||
121 | |||
122 | #if 0 | ||
123 | if (followLinks == FALSE) { | ||
124 | strcpy(srcName, *argv); | ||
125 | } else { | ||
126 | /* Warning! This can silently truncate if > BUFSIZ, but | ||
127 | I don't think that there can be one > BUFSIZ anyway. */ | ||
128 | nChars = readlink(*argv, srcName, BUFSIZ); | ||
129 | srcName[nChars] = '\0'; | ||
130 | } | ||
131 | #endif | ||
132 | if (linkIntoDirFlag == TRUE) { | 107 | if (linkIntoDirFlag == TRUE) { |
133 | char *baseName = get_last_path_component(*argv); | 108 | char *baseName = get_last_path_component(*argv); |
134 | linkName = (char *)malloc(strlen(dirName)+strlen(baseName)+2); | 109 | linkName = (char *)malloc(strlen(dirName)+strlen(baseName)+2); |
@@ -155,7 +130,7 @@ extern int ln_main(int argc, char **argv) | |||
155 | exit FALSE; | 130 | exit FALSE; |
156 | } | 131 | } |
157 | 132 | ||
158 | if (linkIntoDirFlag) | 133 | if (linkIntoDirFlag == TRUE) |
159 | free(linkName); | 134 | free(linkName); |
160 | 135 | ||
161 | argv++; | 136 | argv++; |