diff options
author | Mark Whitley <markw@lineo.com> | 2001-04-30 18:17:00 +0000 |
---|---|---|
committer | Mark Whitley <markw@lineo.com> | 2001-04-30 18:17:00 +0000 |
commit | 8a633268ef478a31bd649d582ce07e9c26a4a03a (patch) | |
tree | a90a2bc3c3815f7f0e70f009b9b175736902a848 /libbb/copy_file.c | |
parent | 6f343944548c2e41fde4a376e805bf322a8e01c9 (diff) | |
download | busybox-w32-8a633268ef478a31bd649d582ce07e9c26a4a03a.tar.gz busybox-w32-8a633268ef478a31bd649d582ce07e9c26a4a03a.tar.bz2 busybox-w32-8a633268ef478a31bd649d582ce07e9c26a4a03a.zip |
Made new xreadlink function for libbb and changed applets to use it instead of
readlink(2).
Diffstat (limited to 'libbb/copy_file.c')
-rw-r--r-- | libbb/copy_file.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/libbb/copy_file.c b/libbb/copy_file.c index 2d18b6087..22684be74 100644 --- a/libbb/copy_file.c +++ b/libbb/copy_file.c | |||
@@ -196,19 +196,12 @@ int copy_file(const char *source, const char *dest, int flags) | |||
196 | return -1; | 196 | return -1; |
197 | } | 197 | } |
198 | } else if (S_ISLNK(source_stat.st_mode)) { | 198 | } else if (S_ISLNK(source_stat.st_mode)) { |
199 | int size; | 199 | char *lpath = xreadlink(source); |
200 | char buf[BUFSIZ + 1]; | 200 | if (symlink(lpath, dest) < 0) { |
201 | |||
202 | if ((size = readlink(source, buf, BUFSIZ)) < 0) { | ||
203 | perror_msg("cannot read `%s'", source); | ||
204 | return -1; | ||
205 | } | ||
206 | buf[size] = '\0'; | ||
207 | |||
208 | if (symlink(buf, dest) < 0) { | ||
209 | perror_msg("cannot create symlink `%s'", dest); | 201 | perror_msg("cannot create symlink `%s'", dest); |
210 | return -1; | 202 | return -1; |
211 | } | 203 | } |
204 | free(lpath); | ||
212 | 205 | ||
213 | #if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) | 206 | #if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) |
214 | if (flags & FILEUTILS_PRESERVE_STATUS) | 207 | if (flags & FILEUTILS_PRESERVE_STATUS) |