ya-mouse / fatresize

Resize FAT partitions using libparted
GNU General Public License v3.0
14 stars 21 forks source link

fatresize should force user confirmation before performing irreversible and unwanted changes #13

Closed fragglet closed 4 years ago

fragglet commented 4 years ago

In the following case I wished to resize a 512MiB FAT16 filesystem to a 4GiB one but forgot about the 2GiB limit. This is a log:

# fatresize -s 3700Mi -i /dev/sda1
fatresize 1.0.2 (06/16/18)
FAT: fat16
Size: 512451072
Min size: 489846784
Max size: 4000317440

# fatresize -s 3700Mi /dev/sda1
fatresize 1.0.2 (06/16/18)
Warning: The file system can only be resized to this size by converting to FAT32. 
If you convert to FAT32, and MS Windows is installed on this partition, then you
must re-install the MS Windows boot loader.  If you want to do this, you should
consult the Parted manual (or your distribution's manual).  Also, converting to
FAT32 will make the file system unreadable by MS DOS, MS Windows 95a, and
MS Windows NT.

# fatresize -i /dev/sda1
fatresize 1.0.2 (06/16/18)
FAT: fat32
Size: 3879977472
Min size: 536870912
Max size: 4000317440

fatresize provided a warning but did not ask me to confirm that I wanted to proceed before converting the filesystem to FAT32, which (1) is surprising behavior, (2) is not something I asked the tool to do, (3) left the filesystem in a useless state since this was being used for a DOS machine.

My suggestion is to implement one of the following:

  1. Prompt the user to type the word "yes" to confirm that filesystem conversion is wanted.
  2. Change the warning to an error and force the user to supply a command line argument like "--allow-filesystem-conversion".
ya-mouse commented 4 years ago

Ok, I will add the flag. Thanks!

ya-mouse commented 4 years ago

The change will be made in the next v1.1.0 release. The flag will be: -f, --force to not ask questions. Default behavior is to prompt for the choice.

fragglet commented 4 years ago

Thank you!