Changeset 3027

Show
Ignore:
Timestamp:
12/02/08 07:20:11 (16 months ago)
Author:
kris
Message:

Updated mount_ntfs to corrispond with the HAL update we are including in 7.0.2,
which fixes a lot of NTFS R/W mounting, and fixes issues ejecting cd/dvd's in KDE4

Location:
pcbsd
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pcbsd/branches/7.0/system-overlay/sbin/mount_ntfs

    r2911 r3027  
    11#!/bin/sh 
    2 # Wrapper script for PC-BSD, which takes calls from HAL 
    3 # for running mount_ntfs, and performs it with ntfs-3g 
    4 ####################################################### 
     2# Wrapper script for FreeBSD and PC-BSD, which takes calls from HAL 
     3# for running mount_ntfs, and performs it with a given FUSE helper. 
     4################################################################### 
    55 
    6 FUSEDB="/tmp/.fuse-mnts" 
     6## Modify this next variable to point to the correct FUSE helper. 
     7FUSE_HELPER="ntfs-3g" 
     8## DO NOT modify anything below this. 
     9 
     10FUSEDB="/tmp" 
     11if [ -n "${TMPDIR}" ] 
     12then 
     13   FUSEDB=${TMPDIR} 
     14fi 
     15 
     16FUSEDB="${FUSEDB}/.fuse-mnts" 
    717MNTSTRING="" 
    818OPTIONS="" 
    919FOUNDOPT="0" 
    10 FOUNDU="0" 
    1120HWDEV="" 
    1221FOUNDDEV="0" 
     
    1726    then 
    1827        OPTIONS="${OPTIONS} -o ${i}" 
    19     elif [ "${FOUNDU}" = "1" ] 
    20     then 
    21         OPTIONS="${OPTIONS} -o uid=${i}" 
    2228    else 
    23             
     29 
    2430       if [ "${FOUNDDEV}" = "1" ] 
    2531       then 
     
    2834         FOUNDDEV="2" 
    2935       fi 
    30   
    31         echo $i | grep "/dev" >/dev/null 2>/dev/null 
     36 
     37        echo ${i}| grep -q "/dev" 2>/dev/null 
    3238        if [ "$?" = "0" -a "${FOUNDDEV}" = "0" ] 
    3339        then 
     
    3541            # Lets check if we were given a fuse[] device 
    3642            # or a real device name 
    37             echo "${i}" | grep "fuse" >/dev/null 2>/dev/null 
     43            echo "${i}" | grep -q "fuse" 2>/dev/null 
    3844            if [ "$?" = "0" ] 
    3945            then 
    40                
    41              # We are trying to re-mount a dev which HAL already has marked as fuse 
    42  
    4346             # Lets save the old fuse device name we had saved 
    4447             OLDFUSE="${i}" 
    4548 
    46              # Lets get the *real* device name for ntfs-3g 
     49             # Lets get the *real* device name for FUSE helper 
    4750             REALHWDEV="`cat ${FUSEDB} | grep ${i} | cut -d '=' -f 2`" 
    48  
    49              # Get the udi of this HAL device 
    50              HALID="`hal-find-by-property --key block.device --string ${OLDFUSE}`" 
    5151 
    5252             # Now lets change the string we will be saving 
    5353             i="${REALHWDEV}" 
    54   
    5554            else 
    56   
    5755             # We are doing a first time mount of this device 
    58               
     56 
    5957             # Set the real device name for mounting 
    6058             REALHWDEV="${i}" 
     59            fi 
     60        fi 
    6161 
    62              # Get the udi of this HAL device 
    63              HALID="`hal-find-by-property --key block.device --string ${REALHWDEV}`" 
    64             fi 
    65  
    66         fi 
    67          
    6862        # Add the value to our mount string 
    69         if [ "$i" != "-o" -a ${i} != "-u" ] 
     63        if [ "${i}" != "-o" ] 
    7064        then 
    7165          MNTSTRING="${MNTSTRING} ${i}" 
     
    7468    fi 
    7569 
    76     # Check if we have been given a -o flag 
    7770    if [ "${i}" = "-o" ] 
    7871    then 
     
    8174       FOUNDOPT="0" 
    8275    fi 
    83  
    84     # Check if we have been given a -u flag 
    85     if [ "${i}" = "-u" ] 
    86     then 
    87        FOUNDU="1" 
    88     else 
    89        FOUNDU="0" 
    90     fi 
    9176done 
    9277 
    93 # Save our final string which ntfs-3g will use 
     78# Save our final string which our FUSE helper will use 
    9479FINALSTRING="${MNTSTRING} ${OPTIONS}" 
    9580 
    9681 
    9782# Check that fuse.ko is loaded 
    98 kldstat | grep fuse >/dev/null 2>/dev/null 
     83kldstat | grep -q fuse 2>/dev/null 
    9984if [ "$?" != "0" ] 
    10085then 
     
    10287fi 
    10388 
    104 # Run the ntfs-3g command now, with the options in the right order 
    105 ntfs-3g ${FINALSTRING}  
     89# Run the FUSE helper command now, with the options in the right order 
     90${FUSE_HELPER} ${FINALSTRING} 
    10691 
    10792# If we have an OLDFUSE variable, lets clear it from the list 
    108 if [ ! -z "${OLDFUSE}" ] 
     93if [ ! -z "${OLDFUSE}" -a -e ${FUSEDB} ] 
    10994then 
    11095   cat ${FUSEDB} | grep -v "${OLDFUSE}=" > /tmp/.newfuse 
     
    116101 
    117102# Make sure we don't already have this fuse device listed 
    118 cat ${FUSEDB} | grep -v "${NEWFUSE}=" > /tmp/.newfuse 
    119 mv /tmp/.newfuse ${FUSEDB} 
    120  
    121 # Now, lets have HAL be notifed of the mount taking place 
    122 hal-set-property --udi ${HALID} --key block.device --string ${NEWFUSE} 
    123  
    124 # Make sure to set /media/.hal-mtab with the new device so we can umount 
    125 echo '#!/bin/sh 
    126 if [ -e "/media/.hal-mtab~" ] 
     103if [ -e ${FUSEDB} ] 
    127104then 
    128   cp "/media/.hal-mtab~" /tmp/orig-hal 
     105   cat ${FUSEDB} | grep -v "${NEWFUSE}=" > /tmp/.newfuse 
     106   mv /tmp/.newfuse ${FUSEDB} 
    129107else 
    130   cp /media/.hal-mtab /tmp/orig-hal 
    131 fi 
    132 rm /media/.hal-mtab-lock 
    133 ID=`cat /tmp/orig-hal | tr "\t" " " | tr -s " " | grep "${1} " | cut -d " " -f 2` 
    134 cat /tmp/orig-hal | grep -v "${1}" > /tmp/.hal-mtab 
    135 echo "${2}      ${ID}   0       ntfs    nosuid  ${3}" >> /tmp/.hal-mtab 
    136 cp /tmp/.hal-mtab /media/.hal-mtab 
    137 cp /tmp/.hal-mtab "/media/.hal-mtab~" 
    138 #touch /media/.hal-mtab-lock 
    139 ' > /tmp/.fixmtab 
    140 chmod 755 /tmp/.fixmtab 
    141  
    142 if [ -z "${OLDFUSE}" ] 
    143 then 
    144    (sleep 5; /tmp/.fixmtab ${REALHWDEV} ${NEWFUSE} ${MNTPOINT})& 
    145 else 
    146    (sleep 5; /tmp/.fixmtab ${OLDFUSE} ${NEWFUSE} ${MNTPOINT})& 
     108   touch ${FUSEDB} 
    147109fi 
    148110 
  • pcbsd/trunk/system-overlay/sbin/mount_ntfs

    r2911 r3027  
    11#!/bin/sh 
    2 # Wrapper script for PC-BSD, which takes calls from HAL 
    3 # for running mount_ntfs, and performs it with ntfs-3g 
    4 ####################################################### 
     2# Wrapper script for FreeBSD and PC-BSD, which takes calls from HAL 
     3# for running mount_ntfs, and performs it with a given FUSE helper. 
     4################################################################### 
    55 
    6 FUSEDB="/tmp/.fuse-mnts" 
     6## Modify this next variable to point to the correct FUSE helper. 
     7FUSE_HELPER="ntfs-3g" 
     8## DO NOT modify anything below this. 
     9 
     10FUSEDB="/tmp" 
     11if [ -n "${TMPDIR}" ] 
     12then 
     13   FUSEDB=${TMPDIR} 
     14fi 
     15 
     16FUSEDB="${FUSEDB}/.fuse-mnts" 
    717MNTSTRING="" 
    818OPTIONS="" 
    919FOUNDOPT="0" 
    10 FOUNDU="0" 
    1120HWDEV="" 
    1221FOUNDDEV="0" 
     
    1726    then 
    1827        OPTIONS="${OPTIONS} -o ${i}" 
    19     elif [ "${FOUNDU}" = "1" ] 
    20     then 
    21         OPTIONS="${OPTIONS} -o uid=${i}" 
    2228    else 
    23             
     29 
    2430       if [ "${FOUNDDEV}" = "1" ] 
    2531       then 
     
    2834         FOUNDDEV="2" 
    2935       fi 
    30   
    31         echo $i | grep "/dev" >/dev/null 2>/dev/null 
     36 
     37        echo ${i}| grep -q "/dev" 2>/dev/null 
    3238        if [ "$?" = "0" -a "${FOUNDDEV}" = "0" ] 
    3339        then 
     
    3541            # Lets check if we were given a fuse[] device 
    3642            # or a real device name 
    37             echo "${i}" | grep "fuse" >/dev/null 2>/dev/null 
     43            echo "${i}" | grep -q "fuse" 2>/dev/null 
    3844            if [ "$?" = "0" ] 
    3945            then 
    40                
    41              # We are trying to re-mount a dev which HAL already has marked as fuse 
    42  
    4346             # Lets save the old fuse device name we had saved 
    4447             OLDFUSE="${i}" 
    4548 
    46              # Lets get the *real* device name for ntfs-3g 
     49             # Lets get the *real* device name for FUSE helper 
    4750             REALHWDEV="`cat ${FUSEDB} | grep ${i} | cut -d '=' -f 2`" 
    48  
    49              # Get the udi of this HAL device 
    50              HALID="`hal-find-by-property --key block.device --string ${OLDFUSE}`" 
    5151 
    5252             # Now lets change the string we will be saving 
    5353             i="${REALHWDEV}" 
    54   
    5554            else 
    56   
    5755             # We are doing a first time mount of this device 
    58               
     56 
    5957             # Set the real device name for mounting 
    6058             REALHWDEV="${i}" 
     59            fi 
     60        fi 
    6161 
    62              # Get the udi of this HAL device 
    63              HALID="`hal-find-by-property --key block.device --string ${REALHWDEV}`" 
    64             fi 
    65  
    66         fi 
    67          
    6862        # Add the value to our mount string 
    69         if [ "$i" != "-o" -a ${i} != "-u" ] 
     63        if [ "${i}" != "-o" ] 
    7064        then 
    7165          MNTSTRING="${MNTSTRING} ${i}" 
     
    7468    fi 
    7569 
    76     # Check if we have been given a -o flag 
    7770    if [ "${i}" = "-o" ] 
    7871    then 
     
    8174       FOUNDOPT="0" 
    8275    fi 
    83  
    84     # Check if we have been given a -u flag 
    85     if [ "${i}" = "-u" ] 
    86     then 
    87        FOUNDU="1" 
    88     else 
    89        FOUNDU="0" 
    90     fi 
    9176done 
    9277 
    93 # Save our final string which ntfs-3g will use 
     78# Save our final string which our FUSE helper will use 
    9479FINALSTRING="${MNTSTRING} ${OPTIONS}" 
    9580 
    9681 
    9782# Check that fuse.ko is loaded 
    98 kldstat | grep fuse >/dev/null 2>/dev/null 
     83kldstat | grep -q fuse 2>/dev/null 
    9984if [ "$?" != "0" ] 
    10085then 
     
    10287fi 
    10388 
    104 # Run the ntfs-3g command now, with the options in the right order 
    105 ntfs-3g ${FINALSTRING}  
     89# Run the FUSE helper command now, with the options in the right order 
     90${FUSE_HELPER} ${FINALSTRING} 
    10691 
    10792# If we have an OLDFUSE variable, lets clear it from the list 
    108 if [ ! -z "${OLDFUSE}" ] 
     93if [ ! -z "${OLDFUSE}" -a -e ${FUSEDB} ] 
    10994then 
    11095   cat ${FUSEDB} | grep -v "${OLDFUSE}=" > /tmp/.newfuse 
     
    116101 
    117102# Make sure we don't already have this fuse device listed 
    118 cat ${FUSEDB} | grep -v "${NEWFUSE}=" > /tmp/.newfuse 
    119 mv /tmp/.newfuse ${FUSEDB} 
    120  
    121 # Now, lets have HAL be notifed of the mount taking place 
    122 hal-set-property --udi ${HALID} --key block.device --string ${NEWFUSE} 
    123  
    124 # Make sure to set /media/.hal-mtab with the new device so we can umount 
    125 echo '#!/bin/sh 
    126 if [ -e "/media/.hal-mtab~" ] 
     103if [ -e ${FUSEDB} ] 
    127104then 
    128   cp "/media/.hal-mtab~" /tmp/orig-hal 
     105   cat ${FUSEDB} | grep -v "${NEWFUSE}=" > /tmp/.newfuse 
     106   mv /tmp/.newfuse ${FUSEDB} 
    129107else 
    130   cp /media/.hal-mtab /tmp/orig-hal 
    131 fi 
    132 rm /media/.hal-mtab-lock 
    133 ID=`cat /tmp/orig-hal | tr "\t" " " | tr -s " " | grep "${1} " | cut -d " " -f 2` 
    134 cat /tmp/orig-hal | grep -v "${1}" > /tmp/.hal-mtab 
    135 echo "${2}      ${ID}   0       ntfs    nosuid  ${3}" >> /tmp/.hal-mtab 
    136 cp /tmp/.hal-mtab /media/.hal-mtab 
    137 cp /tmp/.hal-mtab "/media/.hal-mtab~" 
    138 #touch /media/.hal-mtab-lock 
    139 ' > /tmp/.fixmtab 
    140 chmod 755 /tmp/.fixmtab 
    141  
    142 if [ -z "${OLDFUSE}" ] 
    143 then 
    144    (sleep 5; /tmp/.fixmtab ${REALHWDEV} ${NEWFUSE} ${MNTPOINT})& 
    145 else 
    146    (sleep 5; /tmp/.fixmtab ${OLDFUSE} ${NEWFUSE} ${MNTPOINT})& 
     108   touch ${FUSEDB} 
    147109fi 
    148110