aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-07-20 13:56:17 +0200
committerSven Gothel <[email protected]>2022-07-20 13:56:17 +0200
commit2a6e8d3130b993bc76a145337a5e4f1031882eeb (patch)
tree66fc09372312fb56e2a8c5c5f347dafb4e571e74
parentc88abd8359be48b19425dffe154b0eb469401bb9 (diff)
copy_options::ignore_symlink_errors: Also ignore symlinks if not supported by target filesystem if not using follow_symlinks (e.g.: vfat target)
-rw-r--r--include/jau/file_util.hpp7
-rw-r--r--java_jni/org/jau/fs/CopyOptions.java7
-rw-r--r--src/file_util.cpp9
3 files changed, 18 insertions, 5 deletions
diff --git a/include/jau/file_util.hpp b/include/jau/file_util.hpp
index 4b6f5d8..638327f 100644
--- a/include/jau/file_util.hpp
+++ b/include/jau/file_util.hpp
@@ -901,9 +901,12 @@ namespace jau {
follow_symlinks = 1 << 1,
/**
- * Ignore errors from erroneous symlinks, i.e. non-existing link-targets or recursive loop-errors.
+ * Ignore errors from erroneous symlinks, e.g. non-existing link-targets, recursive loop-errors.or unsupported symmlinks on target filesystem.
*
- * This flag is required to copy erroneous symlinks using follow_symlinks, otherwise not.
+ * This flag is required to
+ * - copy erroneous non-existing symlinks if using follow_symlinks
+ * - copy erroneous recursive loop-error symlinks if using follow_symlinks
+ * - ignore symlinks if not supported by target filesystem if not using follow_symlinks
*/
ignore_symlink_errors = 1 << 8,
diff --git a/java_jni/org/jau/fs/CopyOptions.java b/java_jni/org/jau/fs/CopyOptions.java
index cdc5161..a97d018 100644
--- a/java_jni/org/jau/fs/CopyOptions.java
+++ b/java_jni/org/jau/fs/CopyOptions.java
@@ -44,9 +44,12 @@ public class CopyOptions {
follow_symlinks ( (short)( 1 << 1 ) ),
/**
- * Ignore errors from erroneous symlinks, i.e. non-existing link-targets or recursive loop-errors.
+ * Ignore errors from erroneous symlinks, e.g. non-existing link-targets, recursive loop-errors.or unsupported symmlinks on target filesystem.
*
- * This flag is required to copy erroneous symlinks using follow_symlinks, otherwise not.
+ * This flag is required to
+ * - copy erroneous non-existing symlinks if using follow_symlinks
+ * - copy erroneous recursive loop-error symlinks if using follow_symlinks
+ * - ignore symlinks if not supported by target filesystem if not using follow_symlinks
*/
ignore_symlink_errors ( (short)( 1 << 8 ) ),
diff --git a/src/file_util.cpp b/src/file_util.cpp
index 6cc898a..3231d8f 100644
--- a/src/file_util.cpp
+++ b/src/file_util.cpp
@@ -1198,7 +1198,14 @@ static bool copy_file(const int src_dirfd, const file_stats& src_stats,
// symlink
const int res = ::symlinkat(link_target_path->c_str(), dst_dirfd, dst_basename.c_str());
if( 0 > res ) {
- ERR_PRINT("Creating symlink failed %s -> %s", dst_basename.c_str(), link_target_path->c_str());
+ if( EPERM == errno && is_set(copts, copy_options::ignore_symlink_errors ) ) {
+ if( is_set(copts, copy_options::verbose) ) {
+ jau::fprintf_td(stderr, "copy: Ignored: Failed to create symink %s -> %s, %s, errno %d, %s\n",
+ dst_basename.c_str(), link_target_path->c_str(), src_stats.to_string().c_str(), errno, ::strerror(errno));
+ }
+ return true;
+ }
+ ERR_PRINT("Creating symlink failed %s -> %s, %s", dst_basename.c_str(), link_target_path->c_str(), src_stats.to_string().c_str());
return false;
}
if( is_set(copts, copy_options::preserve_all) ) {