[HAL] mount result differs if invoked by HAL

Hi,

motivation
I am currently working on a wrapper for mount_msdosfs, because the normal binary has Problems if I mount a device with msdos filesystem that has files/folders with chinese/japanese names in it, especially if those were created by windows. I am not quiet sure, but I think it is the fact that windows is using UTF-16 as default.

If i mount an msdos device which has those by windows created names/files then in nautilus for example they will be displayed with this ending to the file/folder "(invalid encoding)"

Idea
Now I am using sysutils/fusefs-fusexmp_fh to loopback the mounted filesystem to a 2nd mount with charset conversion.

The commands are as follows:
Code:
root> mount_msdosfs -L zh_CN.GBK /dev/msdosfs/CW-P7EOS-X /mnt/tmp
root> fusexmp_fh -oallow_other,modules=iconv:subdir,from_code=GBK,subdir=/mnt/tmp /media/CW-P7EOS-X

So now I have renamed the mount_msdosfs and instead created a wrapper with the originally name, which does the 2 above listed commands automatically.

So whenever I now want to mount a msdos device I do:
Code:
root> mount_msdosfs /dev/msdosfs/CW-P7EOS-X /media/CW-P7EOS-X
And my wrapper does the work for me. This works without any problems.

Problem
I have named the wrapper mount_msdosfs, so that hal can use it in order to automount my devices.
The problem is, when HAL invokes the command, everything gets mounted, but the 2nd fuse mount will not display any folders/files with chinese/japanese names in it, not even with the suffix "(invalid encoding)".

From my debug output of the wrapper I see, that the wrapper does exactly the same when invoked by HAL, as it does when I invoke it manually with the root user.

So why is here are difference? Why are those files/folders not displayed when HAL invokes my wrapper? Is there any location I can check for errors on this?
Could it be a rights problem with HAL?
 
Any one a little clue?

I already asked the mailing lists for fuse and hal, but neither gave me a reply :(
 
Code:
#!/bin/sh
# Wrapper script for FreeBSD  which takes calls from HAL
# for running mount_ntfs, and performs it with a given FUSE helper.
###################################################################

## Modify this next variable to point to the correct FUSE helper.
FUSE_HELPER="ntfs-3g"
## DO NOT modify anything below this.

FUSEDB="/tmp"
if [ -n "${TMPDIR}" ]
then
   FUSEDB=${TMPDIR}
fi

FUSEDB="${FUSEDB}/.fuse-mnts"
MNTSTRING=""
OPTIONS=""
FOUNDOPT="0"
FOUNDU="0"
FOUNDG="0"
FOUNDBADARG="0"
HWDEV=""
FOUNDDEV="0"

for i in $@
do
    if [ "$FOUNDOPT" = "1" ]
    then
        OPTIONS="${OPTIONS} -o ${i}"
    elif [ "${FOUNDU}" = "1" ]
    then
        OPTIONS="${OPTIONS} -o uid=${i}"
    elif [ "${FOUNDG}" = "1" ]
    then
        OPTIONS="${OPTIONS} -o gid=${i}"
    elif [ "${FOUNDBADARG}" = "1" ]
    then
        # We have an invalid argument flag, so ignore it and following argument
        FOUNDBADARG="0"
    else

       if [ "${FOUNDDEV}" = "1" ]
       then
         # Save the mount-point, will be used later
         MNTPOINT="${i}"
         FOUNDDEV="2"
       fi

        echo ${i}| grep -q "/dev" 2>/dev/null
        if [ "$?" = "0" -a "${FOUNDDEV}" = "0" ]
        then
            FOUNDDEV="1"
            # Lets check if we were given a fuse[] device
            # or a real device name
            echo "${i}" | grep -q "fuse" 2>/dev/null
            if [ "$?" = "0" ]
            then
             # Lets save the old fuse device name we had saved
             OLDFUSE="${i}"

             # Lets get the *real* device name for FUSE helper
             REALHWDEV="`cat ${FUSEDB} | grep ${i} | cut -d '=' -f 2`"

             # Now lets change the string we will be saving
             i="${REALHWDEV}"
            else
             # We are doing a first time mount of this device

             # Set the real device name for mounting
             REALHWDEV="${i}"
            fi
        fi

        # Add the value to our mount string if it isn't any invalid flag
        if [ "${i}" != "-o" -a "${i}" != "-u" -a "${i}" != "-C" -a "${i}" != "-g" -a "${i}" != "-m" -a "${i}" != "-a" -a "${i}" != "-i" -a "${i}" -a "-W" ]
        then
          MNTSTRING="${MNTSTRING} ${i}"
        fi

    fi

    # Check if we are on a -u user id flag now
    if [ "${i}" = "-u" ]
    then
       FOUNDU="1"
    else
       FOUNDU="0"
    fi

    # Check if we are on a -g group id flag now
    if [ "${i}" = "-g" ]
    then
       FOUNDG="1"
    else
       FOUNDG="0"
    fi

    # Check if we are on a -o option
    if [ "${i}" = "-o" ]
    then
       FOUNDOPT="1"
    else
       FOUNDOPT="0"
    fi

    # Check if we are on some other invalid flag
    if [ "${i}" = "-C" -o "${i}" = "-m" -o "${i}" = "-W" ]
    then
       FOUNDBADARG="1"
    else
       FOUNDBADARG="0"
    fi
done

# Save our final string which our FUSE helper will use
FINALSTRING="${MNTSTRING} ${OPTIONS}"

# Check that fuse.ko is loaded
kldstat | grep -q fuse 2>/dev/null
if [ "$?" != "0" ]
then
  kldload /usr/local/modules/fuse.ko
fi

# Run the FUSE helper command now, with the options in the right order
${FUSE_HELPER} ${FINALSTRING}

# If we have an OLDFUSE variable, lets clear it from the list
if [ ! -z "${OLDFUSE}" -a -e ${FUSEDB} ]
then
   cat ${FUSEDB} | grep -v "${OLDFUSE}=" > /tmp/.newfuse
   mv /tmp/.newfuse ${FUSEDB}
fi

# Now lets figure out which fuse device was used and save it to DB
NEWFUSE="`mount | tr -s ' ' |  grep \" ${MNTPOINT} \" | cut -d ' ' -f 1`"

# Make sure we don't already have this fuse device listed
if [ -e ${FUSEDB} ]
then
   cat ${FUSEDB} | grep -v "${NEWFUSE}=" > /tmp/.newfuse
   mv /tmp/.newfuse ${FUSEDB}
else
   touch ${FUSEDB}
fi

# Save the fuse device to our DB
echo "${NEWFUSE}=${REALHWDEV}" >> ${FUSEDB}


# Finished!
exit 0

The above wrapper is more useful. Name the file as mount-fuse and add to this location: /usr/local/share/hal/
 
Back
Top