aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-01-17 13:51:34 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2009-01-17 13:51:34 +0000
commit9f9b81c9ea45280689ebed795c578d0b58b829ed (patch)
tree8700a9f9a297729e3ff346cb14058e3e30c9bf84 /src
parentd73f1295df0870cf4ead7aa3f6d56326cd68b449 (diff)
downloadwydawca-9f9b81c9ea45280689ebed795c578d0b58b829ed.tar.gz
wydawca-9f9b81c9ea45280689ebed795c578d0b58b829ed.tar.bz2
Fix handling of the symlink directive.
* src/diskio.c (symlink_file): Silently remove existing symlink target. * NEWS: Update. git-svn-id: file:///svnroot/wydawca/trunk@331 6bb4bd81-ecc2-4fd4-a2d4-9571d19c0d33
Diffstat (limited to 'src')
-rw-r--r--src/diskio.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/src/diskio.c b/src/diskio.c
index 43191bb..85389cb 100644
--- a/src/diskio.c
+++ b/src/diskio.c
@@ -585,11 +585,41 @@ symlink_file (struct file_triplet *trp, struct directory_pair *dpair,
dst_dir, strerror (errno));
else
{
- rc = symlink (src, dst);
- if (rc)
- logmsg (LOG_ERR,
- "symlinking %s to %s in directory %s failed: %s",
- src, dst, dst_dir, strerror (errno));
+ struct stat st;
+
+ if (lstat (dst, &st) == 0)
+ {
+ if (!S_ISLNK (st.st_mode))
+ {
+ logmsg (LOG_ERR,
+ "file %s exists and is not a symbolic link",
+ dst, strerror (errno));
+ rc = 1;
+ }
+ else if (unlink (dst))
+ {
+ logmsg (LOG_ERR,
+ "Cannot unlink %s: %s",
+ dst, strerror (errno));
+ rc = 1;
+ }
+ }
+ else if (errno != ENOENT)
+ {
+ logmsg (LOG_ERR,
+ "cannot stat file %s: %s",
+ dst, strerror (errno));
+ rc = 1;
+ }
+
+ if (rc == 0)
+ {
+ rc = symlink (src, dst);
+ if (rc)
+ logmsg (LOG_ERR,
+ "symlinking %s to %s in directory %s failed: %s",
+ src, dst, dst_dir, strerror (errno));
+ }
}
}
}

Return to:

Send suggestions and report system problems to the System administrator.