From 921a99bb9bcfb70312440e899d8f1a15fd177c49 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Tue, 23 Mar 2021 15:22:52 +0100 Subject: [PATCH] tool/run: option to copy tftp served files (x86) Fixes #4153 --- tool/run/load/tftp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/tool/run/load/tftp b/tool/run/load/tftp index 5e18cb2013..6bce565cdb 100644 --- a/tool/run/load/tftp +++ b/tool/run/load/tftp @@ -56,24 +56,29 @@ proc generate_tftp_config { } { if {[string length $tftp_base_dir] > 0 && [string length $tftp_offset_dir] > 0} { - # if the link target exists as directory this leads to bad behavior - if {[file exists $tftp_base_dir$tftp_offset_dir] && - [string compare [file type $tftp_base_dir$tftp_offset_dir] "directory"] == 0} { - - puts stderr "Error: TFTP symlink target $tftp_base_dir$tftp_offset_dir is a directory" - exit -1 - } - exec ln -nfs "[pwd]" "$tftp_base_dir$tftp_offset_dir" - set tftp_base "" if {[load_tftp_use_absolute]} { set tftp_base $tftp_base_dir } - set fh [open "$tftp_base_dir$tftp_offset_dir/config-00-00-00-00-00-00" "WRONLY CREAT TRUNC"] - puts $fh " root $tftp_base$tftp_offset_dir/[run_dir]" - puts $fh " config config-52-54-00-12-34-56" - close $fh + if {[load_tftp_copy_files]} { + exec cp -r --dereference "[pwd]/[run_dir]/." $tftp_base_dir$tftp_offset_dir/. + } else { + # if the link target exists as directory this leads to bad behavior + if {[file exists $tftp_base_dir$tftp_offset_dir] && + [string compare [file type $tftp_base_dir$tftp_offset_dir] "directory"] == 0} { + + puts stderr "Error: TFTP symlink target $tftp_base_dir$tftp_offset_dir is a directory" + exit -1 + } + + exec ln -nfs "[pwd]" "$tftp_base_dir$tftp_offset_dir" + + set fh [open "$tftp_base_dir$tftp_offset_dir/config-00-00-00-00-00-00" "WRONLY CREAT TRUNC"] + puts $fh " root $tftp_base$tftp_offset_dir/[run_dir]" + puts $fh " config config-52-54-00-12-34-56" + close $fh + } } else { puts "Warning, TFTP base directory or TFTP offset directory not set." }