diff --git a/src/woeusb b/src/woeusb index d7bd555..09dcf6d 100755 --- a/src/woeusb +++ b/src/woeusb @@ -236,7 +236,8 @@ init(){ "${install_mode}" \ "${target_media}" \ target_device \ - target_partition + target_partition \ + target_filesystem_type check_source_and_target_not_busy \ "${install_mode}" \ @@ -831,16 +832,46 @@ check_runtime_parameters(){ }; declare -fr check_runtime_parameters determine_target_parameters(){ - util_check_function_parameters_quantity 4 $# + util_check_function_parameters_quantity 5 $# local install_mode="${1}"; shift local target_media="${1}"; shift local -n target_device_ref="${1}"; shift local -n target_partition_ref="${1}"; shift + local -n target_filesystem_type_ref="${1}"; shift if [ "${install_mode}" = partition ]; then + local target_filesystem_type_libblkid + target_partition_ref="${target_media}" # BASHDOC: Basic Shell Features » Shell Expansions » Shell Parameter Expansion(`${PARAMETER/PATTERN/STRING}') target_device_ref="${target_media/%[0-9]/}" + + # Detect target filesystem + target_filesystem_type_libblkid="$( + lsblk \ + --noheadings \ + --output FSTYPE \ + "${target_partition_ref}" + )" + + case "${target_filesystem_type_libblkid}" in + vfat) + target_filesystem_type_ref=FS_FAT + ;; + ntfs) + target_filesystem_type_ref=FS_NTFS + ;; + *) + printf -- \ + '%s: Error: Unsupported target filesystem "%s", currently supported target filesystems: %s, %s' \ + "${FUNCNAME[0]}" \ + "${target_filesystem_type_libblkid}" \ + "${ENUM_SUPPORTED_FILESYSTEMS[FS_FAT]}" \ + "${ENUM_SUPPORTED_FILESYSTEMS[FS_NTFS]}" + return 1 + ;; + esac + unset target_filesystem_type_libblkid else # install_mode = device target_device_ref="${target_media}" target_partition_ref="${target_device}1" @@ -849,6 +880,9 @@ determine_target_parameters(){ if [ "${verbose}" = true ]; then echo "${FUNCNAME[0]}: Info: Target device is '${target_device_ref}'." echo "${FUNCNAME[0]}: Info: Target partition is '${target_partition_ref}'." + if [ "${install_mode}" = partition ]; then + echo "${FUNCNAME[0]}: Info: Target filesystem is '${ENUM_SUPPORTED_FILESYSTEMS[$target_filesystem_type]}'." + fi fi return 0 }; declare -fr determine_target_parameters