Skip to content

Commit

Permalink
Added check for files bigger than 4GB (#186)
Browse files Browse the repository at this point in the history
Reviewed-by: 林博仁(Buo-ren, Lin) <[email protected]>
Signed-off-by: 林博仁(Buo-ren, Lin) <[email protected]>
  • Loading branch information
WaxyMocha authored and brlin-tw committed May 2, 2018
1 parent a3af891 commit 29d74ee
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/woeusb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"\
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 29d74ee

Please sign in to comment.