mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
When calling dasdfmt on device node symlinks like /dev/disk/by-id/ccw-0X9300, dasdfmt fails with "dasdfmt: the ioctl to get the blocksize of the device failed (Bad file descriptor)" This is because before the actual formatting process starts, the disk will be disabled calling the BIODASDDISABLE ioctl, resulting in the removal of the symlink. Trying to open this file later in the process to retrieve e.g. blocksize information results in the mentioned error, as the file doesn't exist any longer. This incorrect behaviour was introduced with commit8826028bdc("dasdfmt: Use libdasd provided ioctl functions") at which the use of a globally available file descriptor was omitted. Instead, the ioctl library functions require a device node to be passed as a function parameter and will open a file descriptor themselves. So, before that change, the global file descriptor was always valid even when the file was removed. In order to fix this without modifying the behaviour of libdasd, introduce the two global variables dev_node and dev_path. dev_path is the original device path entered by the user. dev_node on the other hand is the reliable device node under /dev/block/ using the major and minor numbers and is determined in get_device_name(). The dev_path is used for message output only and the dev_node variable is used for the actual disk operations. As these two variables are global, the device parameters for several functions are removed to make the code a bit cleaner. Fixes:8826028bdc("dasdfmt: Use libdasd provided ioctl functions") Reviewed-by: Stefan Haberland <sth@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>