#!/bin/sh # # Wrapper script around /usr/sbin/hald-subfs-mount to fix some of the mentally # deficient aspects of that program. Mainly, to change mount options. # https://bugzilla.novell.com/show_bug.cgi?id=141544 # This is not a solution, just a workaround. # A solution would be to actually read the volume.policy.mount.option.* # hal settings, but all that hal stuff is annoyingly complex (and badly # documented). Perhaps a better solution would be to read /etc/fstab, # like everyone expects since the beginning of time. # # How to install: # 1) mv /usr/sbin/hald-subfs-mount /usr/sbin/hald-subfs-mount.orig # 2) Copy this script to /usr/sbin/hald-subfs-mount # 3) chmod 755 /usr/sbin/hald-subfs-mount # 4) Review the mount options you want to use # 5) If you want to change anything, or see what's going on, # uncomment (or set) the DEBUG and ERROR variables. # 6) This script supersedes the method given in the SUSE 10.0 release notes # for turning off the "sync" mount option! # (which is https://bugzilla.novell.com/show_bug.cgi?id=105871) # # Latest version: # http://volker.dnsalias.net/soft/rpm/suse10.0/other/hald-subfs-mount # # Copyright (C) by Volker Kuhlmann # Released under the terms of the GNU General Public License (GPL) Version 2. # See http://www.gnu.org/ for details. # # Volker Kuhlmann # 4, 5, 24 Jan 2006 # VERSION="1.1, 24 Jan 2006" AUTHOR="Volker Kuhlmann " COPYRIGHT="Copyright (C) 2006" # Mount options to use for these filesystems MOUNTOPTS_VFAT=rw,nosuid,nodev,noexec,fs=floppyfss,procuid,utf8=true,fmask=137 MOUNTOPTS_ISO9660=ro,nosuid,nodev,noexec,fs=cdfss MOUNTOPTS_EXT2=rw,nosuid,nodev,noexec,noatime,fs=ext2 MOUNTOPTS_REISERFS=rw,nosuid,nodev,noexec,noatime,fs=reiserfs # Mount point (without path) for your optical drive # (E.g. for /media/dvdrecorder, set this to dvdrecorder) MOUNTPOINT_DVD=dvdrecorder # Write debugging output to this directory (will be created if non-existant). DEBUG= #DEBUG=/tmp/root/hal # Errors are logged here (this may start with /dev/) ERROR= ERROR=$DEBUG # To what the original binary has been renamed hald_subfs_mount=/usr/sbin/hald-subfs-mount.orig ## Handle these mount/unmount events specially ## MODIFY MOUNT OPTIONS HERE! handle_mount_umount_event() { ## vfat filesystems on memory sticks etc if [ "$HAL_PROP_VOLUME_FSTYPE" = vfat \ ]; then case "$HALD_ACTION" in add) MOUNT \ $MOUNTOPTS_VFAT \ "$HAL_PROP_BLOCK_DEVICE" \ "$HAL_PROP_VOLUME_POLICY_DESIRED_MOUNT_POINT" ;; remove) UMOUNT \ "$HAL_PROP_VOLUME_MOUNT_POINT" ;; esac ## CD, DVD, ISO9660 #/dev/hdX on /media/... type subfs (ro,nosuid,nodev,fs=cdfss,procuid,iocharset=utf8) elif [ "$HAL_PROP_VOLUME_FSTYPE" = iso9660 \ ]; then case "$HALD_ACTION" in add) MOUNT \ $MOUNTOPTS_ISO9660 \ "$HAL_PROP_BLOCK_DEVICE" \ "$MOUNTPOINT_DVD" \ "$HAL_PROP_VOLUME_POLICY_DESIRED_MOUNT_POINT" ;; remove) UMOUNT \ "$HAL_PROP_VOLUME_MOUNT_POINT" \ "$HAL_PROP_VOLUME_POLICY_DESIRED_MOUNT_POINT" ;; esac ## CD, DVD, ext2 #/dev/hdX on /media/vollabel type subfs (rw,nosuid,nodev,sync,fs=ext2) elif [ "$HAL_PROP_VOLUME_FSTYPE" = ext2 \ ]; then case "$HALD_ACTION" in add) MOUNT \ $MOUNTOPTS_EXT2 \ "$HAL_PROP_BLOCK_DEVICE" \ "$MOUNTPOINT_DVD" \ "$HAL_PROP_VOLUME_POLICY_DESIRED_MOUNT_POINT" ;; remove) UMOUNT \ "$HAL_PROP_VOLUME_MOUNT_POINT" \ "$HAL_PROP_VOLUME_POLICY_DESIRED_MOUNT_POINT" ;; esac ## CD, DVD, reiserfs #/dev/hdX on /media/idedisk type subfs (rw,nosuid,nodev,sync,fs=reiserfs) elif [ "$HAL_PROP_VOLUME_FSTYPE" = reiserfs \ ]; then case "$HALD_ACTION" in add) MOUNT \ $MOUNTOPTS_REISERFS \ "$HAL_PROP_BLOCK_DEVICE" \ "$MOUNTPOINT_DVD" ;; # there's no volume label info available for reiserfs remove) UMOUNT \ "$HAL_PROP_VOLUME_MOUNT_POINT" ;; esac fi } # Create dir, mount, and create symlink if given MOUNT() { local mountpoint="/media/$3" if [ ! -e "$mountpoint" ]; then mkdir -p "$mountpoint" elif [ ! -d "$mountpoint" ]; then echo 1>&2 "Error: $0: mount point '$mountpoint' exists and is not a directory" exit 1 fi set -x /bin/mount -t subfs -o "$1" "$2" "$mountpoint" if [ "$4" -a "$4" != "$3" -a ! -e "/media/$4" ]; then /bin/ln -s "$3" "/media/$4" fi exit $? } # Unmount, remove dir, and remove symlink if necessary UMOUNT() { local mountpoint="$1" set -x if [ -n "$1" ]; then # something already unmounts this, but making sure doesn't hurt /bin/umount -t subfs "$mountpoint" rmdir "$mountpoint" fi if [ "$2" -a -L "/media/$2" ]; then rm "/media/$2" fi exit $? } # Open error logfile open_error_log() { if [ "$ERROR" ]; then if [ "${ERROR#/dev/}" = "$ERROR" ]; then mkdir -p $ERROR exec 2>$ERROR/hald-subfs.$$.err else exec 2>$ERROR fi fi } # Log environment (+ arguments) log_env() { if [ "$DEBUG" ]; then mkdir -p $DEBUG test -x /usr/bin/showargs \ && /usr/bin/showargs "$@" >$DEBUG/hald-subfs.$$.args /usr/bin/env | /usr/bin/sort >$DEBUG/hald-subfs.$$.env fi } # Call the original hald-subfs-mount binary hald_subfs_mount() { if [ "$DEBUG" ]; then mkdir -p $DEBUG /usr/bin/strace -f -o $DEBUG/hald-subfs.$$.strace $hald_subfs_mount "$@" else exec -a hald-subfs-mount $hald_subfs_mount "$@" fi } ### MAIN log_env ## Intercept any mounts we want to handle specially ourselves if [ "$HAL_PROP_BLOCK_IS_VOLUME" = true \ -a "$HAL_PROP_INFO_CATEGORY" = volume \ -a "$HAL_PROP_VOLUME_FSUSAGE" = filesystem ]; then open_error_log handle_mount_umount_event "$@" fi hald_subfs_mount "$@"