From b7338d33ed92e76a4e5ec5a5c496e9bf33961264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=8D=9A=E4=BB=81=28Buo-ren=2C=20Lin=29?= Date: Mon, 24 Dec 2018 16:24:20 +0800 Subject: [PATCH] Fix missing file system detection in --partition preparation mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since commit 29d74ee(v3.1.5) a detection is implemented to prematurely detect for files over 4GiB in the source image (the FAT32 single file size limit), however it depends on the `target_filesystem_type` variable to determine whether the check should be run, which isn't set according to the existing target partition's file system in --partition preparation mode, and thus the check will be run when the user's target file system is NTFS and chooses to use the --partition creation mode because the `target_filesystem_type` variable is set to FS_FAT by default and isn't changed accordingly. This patch implements the missing detection in determine_target_parameters. Fixes #226. Signed-off-by: 林博仁(Buo-ren, Lin) --- src/woeusb | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) 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