[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1029962: check-missing-firmware fails to find firmware file or package on partitioned removable media



And before I forget…

Pascal Hambourg <pascal@plouf.fr.eu.org> (2023-04-01):
> The current algorithm mounts only the first "suitable" disk or partition
> when searching for loose firmware files or packages.
> If it mounts the wrong devices, firmware files are not found.
> 
> This patch adds the following subcommands to mountmedia:
> mountmedia list [floppy]: list devices
> mountmedia mounted: test if /media is mounted
> mountmedia mount <device|dir>: mount device (ro) or directory on /media
> 
> The behaviour when no subcommand is passed is unchanged.
> 
> The "mount" subcommand loads the ext4 module to be able to mount media
> with ext* filesystems in addition to vfat. It may be useful in cases
> such as bug#1033498 when some loose firmware files are symlinks, which
> are not supported by vfat. However it may increase the search time if
> there are many ext* partitions.
> 
> Additionally, the "list" subcommand adds /hd-media to the device list
> if it exists for compatibility with the current behaviour.
> 
> These subcommands are intended to be used by check-missing-firmware
> from package hw-media in order to search firmware files or packages
> on all available media.

This should be hw-detect, rather than hw-media. :)

> ---
>  mountmedia | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 53 insertions(+), 2 deletions(-)
> 
> diff --git a/mountmedia b/mountmedia
> index 6013579..7181ac5 100755
> --- a/mountmedia
> +++ b/mountmedia
> @@ -1,6 +1,18 @@
>  #!/bin/sh
>  set -e
>  
> +# parse sub-commands
> +if [ "$1" = list ]; then
> +	CMD_LIST=1
> +	# shift to parse optional parameter "floppy"
> +	shift
> +elif [ "$1" = mounted ]; then
> +	CMD_MOUNTED=1
> +elif [ "$1" = mount ]; then
> +	CMD_MOUNT=1
> +	dev="$2"
> +fi
> +
>  if [ "$1" = driver ]; then
>  	WANTDRIVER=1
>  elif [ "$1" = floppy ]; then
> @@ -59,10 +71,49 @@ checkcontents() {
>  	fi
>  }
>  
> +# execute sub-commands
> +
> +if [ "$CMD_LIST" ]; then
> +	if [ -d /hd-media ]; then
> +		# for compatibility with default behaviour
> +		echo /hd-media
> +	fi
> +	devlist
> +	exit 0
> +fi
> +
> +if [ "$CMD_MOUNTED" ]; then
> +	media_mounted
> +	exit
> +fi
> +
> +if [ "$CMD_MOUNT" ]; then
> +	if [ -d "$dev" ]; then # directory -> bind mount
> +		mount --bind $dev $MNT
> +		exit
> +	elif [ -b "$dev" ]; then # block device -> normal mount
> +		modprobe -q vfat || true
> +		# allow to mount ext2/3/4 too, may be useful in some cases (see #1033498)
> +		modprobe -q ext4 || true
> +		if [ $dev = /dev/fd0 ]; then
> +			# for compatibility with default behaviour
> +			# useless if floppy support is dropped
> +			log-output -t mountmedia modprobe -q floppy || true
> +			log-output -t mountmedia modprobe -q ide-floppy || true
> +			update-dev --settle
> +		fi
> +		mount -r -t auto $dev $MNT
> +		exit
> +	fi
> +	exit 1
> +fi
> +
> +# default operation when no subcommand is passed
> +
>  if ! ( media_mounted && checkcontents $MNT ); then
>  	# Special case for an already mounted /hd-media.
>  	if [ -d /hd-media ] && checkcontents /hd-media; then
> -		mount --bind /hd-media /media
> +		mount --bind /hd-media $MNT

Since new subcommands are supposed to have run and exited before, I
would expect the default operation to require no changes at all, so the
/media → $MNT update seems weird.

>  		exit 0
>  	fi
>  
> @@ -79,7 +130,7 @@ if ! ( media_mounted && checkcontents $MNT ); then
>  			fi
>  		done
>  		
> -		if [ "$i" = 1 ]; then       
> +		if [ "$i" = 1 ]; then
>  			# Give USB time to settle, make sure all devices are
>  			# seen next time though.
>  			sleep 5

This part could have been dropped too, even if it's very minor compared
to the question above.


Cheers,
-- 
Cyril Brulebois (kibi@debian.org)            <https://debamax.com/>
D-I release manager -- Release team member -- Freelance Consultant

Attachment: signature.asc
Description: PGP signature


Reply to: