From 29d74ee5092213439176ae60daa5560486c7b79b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Szyma=C5=84ski?= Date: Wed, 2 May 2018 14:16:29 +0200 Subject: [PATCH] Added check for files bigger than 4GB (#186) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: 林博仁(Buo-ren, Lin) Signed-off-by: 林博仁(Buo-ren, Lin) --- src/woeusb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/woeusb b/src/woeusb index 307ddc4..926a509 100755 --- a/src/woeusb +++ b/src/woeusb @@ -272,6 +272,13 @@ init(){ exit 1 fi + if [ "${target_filesystem_type}" == 'FAT' ]; then + if ! check_for_big_files\ + "${source_fs_mountpoint}"; then + exit 1 + fi + fi + if ! mount_target_filesystem\ "${target_partition}"\ "${target_fs_mountpoint}"\ @@ -2004,6 +2011,25 @@ util_check_function_parameters_quantity(){ return 0 }; declare -fr util_check_function_parameters_quantity +## Check every file in source directory for files bigger than max fat32 file size (~4GB) +check_for_big_files(){ + local -r source_fs_mountpoint="${1}" + local IFS_backup=$IFS + + IFS=$'\n' + for file in ` find "${source_fs_mountpoint}" -type f `; do + if (( $(stat -c "%s" $file) > 4294967295 )); then # Max fat32 file size is 2^32 - 1 bytes + echo_with_color red "Error: File $file is larger than that supported by the fat32 filesystem. Use NTFS (--target-filesystem NTFS)." + IFS=$IFS_backup + unset IFS_backup + return 1 + fi + done + IFS=$IFS_backup + unset IFS_backup + return 0 +}; declare -fr check_for_big_files + trap trap_exit EXIT trap trap_errexit ERR trap trap_interrupt INT