Changeset 3027
- Timestamp:
- 12/02/08 07:20:11 (16 months ago)
- Location:
- pcbsd
- Files:
-
- 2 modified
-
branches/7.0/system-overlay/sbin/mount_ntfs (modified) (8 diffs)
-
trunk/system-overlay/sbin/mount_ntfs (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pcbsd/branches/7.0/system-overlay/sbin/mount_ntfs
r2911 r3027 1 1 #!/bin/sh 2 # Wrapper script for PC-BSD, which takes calls from HAL3 # for running mount_ntfs, and performs it with ntfs-3g4 ####################################################### 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 ################################################################### 5 5 6 FUSEDB="/tmp/.fuse-mnts" 6 ## Modify this next variable to point to the correct FUSE helper. 7 FUSE_HELPER="ntfs-3g" 8 ## DO NOT modify anything below this. 9 10 FUSEDB="/tmp" 11 if [ -n "${TMPDIR}" ] 12 then 13 FUSEDB=${TMPDIR} 14 fi 15 16 FUSEDB="${FUSEDB}/.fuse-mnts" 7 17 MNTSTRING="" 8 18 OPTIONS="" 9 19 FOUNDOPT="0" 10 FOUNDU="0"11 20 HWDEV="" 12 21 FOUNDDEV="0" … … 17 26 then 18 27 OPTIONS="${OPTIONS} -o ${i}" 19 elif [ "${FOUNDU}" = "1" ]20 then21 OPTIONS="${OPTIONS} -o uid=${i}"22 28 else 23 29 24 30 if [ "${FOUNDDEV}" = "1" ] 25 31 then … … 28 34 FOUNDDEV="2" 29 35 fi 30 31 echo $ i | grep "/dev" >/dev/null2>/dev/null36 37 echo ${i}| grep -q "/dev" 2>/dev/null 32 38 if [ "$?" = "0" -a "${FOUNDDEV}" = "0" ] 33 39 then … … 35 41 # Lets check if we were given a fuse[] device 36 42 # or a real device name 37 echo "${i}" | grep "fuse" >/dev/null2>/dev/null43 echo "${i}" | grep -q "fuse" 2>/dev/null 38 44 if [ "$?" = "0" ] 39 45 then 40 41 # We are trying to re-mount a dev which HAL already has marked as fuse42 43 46 # Lets save the old fuse device name we had saved 44 47 OLDFUSE="${i}" 45 48 46 # Lets get the *real* device name for ntfs-3g49 # Lets get the *real* device name for FUSE helper 47 50 REALHWDEV="`cat ${FUSEDB} | grep ${i} | cut -d '=' -f 2`" 48 49 # Get the udi of this HAL device50 HALID="`hal-find-by-property --key block.device --string ${OLDFUSE}`"51 51 52 52 # Now lets change the string we will be saving 53 53 i="${REALHWDEV}" 54 55 54 else 56 57 55 # We are doing a first time mount of this device 58 56 59 57 # Set the real device name for mounting 60 58 REALHWDEV="${i}" 59 fi 60 fi 61 61 62 # Get the udi of this HAL device63 HALID="`hal-find-by-property --key block.device --string ${REALHWDEV}`"64 fi65 66 fi67 68 62 # Add the value to our mount string 69 if [ "$ i" != "-o" -a ${i} != "-u" ]63 if [ "${i}" != "-o" ] 70 64 then 71 65 MNTSTRING="${MNTSTRING} ${i}" … … 74 68 fi 75 69 76 # Check if we have been given a -o flag77 70 if [ "${i}" = "-o" ] 78 71 then … … 81 74 FOUNDOPT="0" 82 75 fi 83 84 # Check if we have been given a -u flag85 if [ "${i}" = "-u" ]86 then87 FOUNDU="1"88 else89 FOUNDU="0"90 fi91 76 done 92 77 93 # Save our final string which ntfs-3gwill use78 # Save our final string which our FUSE helper will use 94 79 FINALSTRING="${MNTSTRING} ${OPTIONS}" 95 80 96 81 97 82 # Check that fuse.ko is loaded 98 kldstat | grep fuse >/dev/null2>/dev/null83 kldstat | grep -q fuse 2>/dev/null 99 84 if [ "$?" != "0" ] 100 85 then … … 102 87 fi 103 88 104 # Run the ntfs-3gcommand now, with the options in the right order105 ntfs-3g ${FINALSTRING} 89 # Run the FUSE helper command now, with the options in the right order 90 ${FUSE_HELPER} ${FINALSTRING} 106 91 107 92 # If we have an OLDFUSE variable, lets clear it from the list 108 if [ ! -z "${OLDFUSE}" ]93 if [ ! -z "${OLDFUSE}" -a -e ${FUSEDB} ] 109 94 then 110 95 cat ${FUSEDB} | grep -v "${OLDFUSE}=" > /tmp/.newfuse … … 116 101 117 102 # 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~" ] 103 if [ -e ${FUSEDB} ] 127 104 then 128 cp "/media/.hal-mtab~" /tmp/orig-hal 105 cat ${FUSEDB} | grep -v "${NEWFUSE}=" > /tmp/.newfuse 106 mv /tmp/.newfuse ${FUSEDB} 129 107 else 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} 147 109 fi 148 110 -
pcbsd/trunk/system-overlay/sbin/mount_ntfs
r2911 r3027 1 1 #!/bin/sh 2 # Wrapper script for PC-BSD, which takes calls from HAL3 # for running mount_ntfs, and performs it with ntfs-3g4 ####################################################### 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 ################################################################### 5 5 6 FUSEDB="/tmp/.fuse-mnts" 6 ## Modify this next variable to point to the correct FUSE helper. 7 FUSE_HELPER="ntfs-3g" 8 ## DO NOT modify anything below this. 9 10 FUSEDB="/tmp" 11 if [ -n "${TMPDIR}" ] 12 then 13 FUSEDB=${TMPDIR} 14 fi 15 16 FUSEDB="${FUSEDB}/.fuse-mnts" 7 17 MNTSTRING="" 8 18 OPTIONS="" 9 19 FOUNDOPT="0" 10 FOUNDU="0"11 20 HWDEV="" 12 21 FOUNDDEV="0" … … 17 26 then 18 27 OPTIONS="${OPTIONS} -o ${i}" 19 elif [ "${FOUNDU}" = "1" ]20 then21 OPTIONS="${OPTIONS} -o uid=${i}"22 28 else 23 29 24 30 if [ "${FOUNDDEV}" = "1" ] 25 31 then … … 28 34 FOUNDDEV="2" 29 35 fi 30 31 echo $ i | grep "/dev" >/dev/null2>/dev/null36 37 echo ${i}| grep -q "/dev" 2>/dev/null 32 38 if [ "$?" = "0" -a "${FOUNDDEV}" = "0" ] 33 39 then … … 35 41 # Lets check if we were given a fuse[] device 36 42 # or a real device name 37 echo "${i}" | grep "fuse" >/dev/null2>/dev/null43 echo "${i}" | grep -q "fuse" 2>/dev/null 38 44 if [ "$?" = "0" ] 39 45 then 40 41 # We are trying to re-mount a dev which HAL already has marked as fuse42 43 46 # Lets save the old fuse device name we had saved 44 47 OLDFUSE="${i}" 45 48 46 # Lets get the *real* device name for ntfs-3g49 # Lets get the *real* device name for FUSE helper 47 50 REALHWDEV="`cat ${FUSEDB} | grep ${i} | cut -d '=' -f 2`" 48 49 # Get the udi of this HAL device50 HALID="`hal-find-by-property --key block.device --string ${OLDFUSE}`"51 51 52 52 # Now lets change the string we will be saving 53 53 i="${REALHWDEV}" 54 55 54 else 56 57 55 # We are doing a first time mount of this device 58 56 59 57 # Set the real device name for mounting 60 58 REALHWDEV="${i}" 59 fi 60 fi 61 61 62 # Get the udi of this HAL device63 HALID="`hal-find-by-property --key block.device --string ${REALHWDEV}`"64 fi65 66 fi67 68 62 # Add the value to our mount string 69 if [ "$ i" != "-o" -a ${i} != "-u" ]63 if [ "${i}" != "-o" ] 70 64 then 71 65 MNTSTRING="${MNTSTRING} ${i}" … … 74 68 fi 75 69 76 # Check if we have been given a -o flag77 70 if [ "${i}" = "-o" ] 78 71 then … … 81 74 FOUNDOPT="0" 82 75 fi 83 84 # Check if we have been given a -u flag85 if [ "${i}" = "-u" ]86 then87 FOUNDU="1"88 else89 FOUNDU="0"90 fi91 76 done 92 77 93 # Save our final string which ntfs-3gwill use78 # Save our final string which our FUSE helper will use 94 79 FINALSTRING="${MNTSTRING} ${OPTIONS}" 95 80 96 81 97 82 # Check that fuse.ko is loaded 98 kldstat | grep fuse >/dev/null2>/dev/null83 kldstat | grep -q fuse 2>/dev/null 99 84 if [ "$?" != "0" ] 100 85 then … … 102 87 fi 103 88 104 # Run the ntfs-3gcommand now, with the options in the right order105 ntfs-3g ${FINALSTRING} 89 # Run the FUSE helper command now, with the options in the right order 90 ${FUSE_HELPER} ${FINALSTRING} 106 91 107 92 # If we have an OLDFUSE variable, lets clear it from the list 108 if [ ! -z "${OLDFUSE}" ]93 if [ ! -z "${OLDFUSE}" -a -e ${FUSEDB} ] 109 94 then 110 95 cat ${FUSEDB} | grep -v "${OLDFUSE}=" > /tmp/.newfuse … … 116 101 117 102 # 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~" ] 103 if [ -e ${FUSEDB} ] 127 104 then 128 cp "/media/.hal-mtab~" /tmp/orig-hal 105 cat ${FUSEDB} | grep -v "${NEWFUSE}=" > /tmp/.newfuse 106 mv /tmp/.newfuse ${FUSEDB} 129 107 else 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} 147 109 fi 148 110
