[PC-BSD Commits] r3027 - in pcbsd: branches/7.0/system-overlay/sbin trunk/system-overlay/sbin

svn at pcbsd.org svn at pcbsd.org
Tue Dec 2 07:20:11 PST 2008


Author: kris
Date: 2008-12-02 07:20:11 -0800 (Tue, 02 Dec 2008)
New Revision: 3027

Modified:
   pcbsd/branches/7.0/system-overlay/sbin/mount_ntfs
   pcbsd/trunk/system-overlay/sbin/mount_ntfs
Log:

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



Modified: pcbsd/branches/7.0/system-overlay/sbin/mount_ntfs
===================================================================
--- pcbsd/branches/7.0/system-overlay/sbin/mount_ntfs	2008-12-02 13:15:02 UTC (rev 3026)
+++ pcbsd/branches/7.0/system-overlay/sbin/mount_ntfs	2008-12-02 15:20:11 UTC (rev 3027)
@@ -1,13 +1,22 @@
 #!/bin/sh
-# Wrapper script for PC-BSD, which takes calls from HAL
-# for running mount_ntfs, and performs it with ntfs-3g
-#######################################################
+# Wrapper script for FreeBSD and PC-BSD, which takes calls from HAL
+# for running mount_ntfs, and performs it with a given FUSE helper.
+###################################################################
 
-FUSEDB="/tmp/.fuse-mnts"
+## 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"
 HWDEV=""
 FOUNDDEV="0"
 
@@ -16,96 +25,72 @@
     if [ "$FOUNDOPT" = "1" ]
     then
         OPTIONS="${OPTIONS} -o ${i}"
-    elif [ "${FOUNDU}" = "1" ]
-    then
-        OPTIONS="${OPTIONS} -o uid=${i}"
     else
-           
+
        if [ "${FOUNDDEV}" = "1" ]
        then
          # Save the mount-point, will be used later
          MNTPOINT="${i}"
          FOUNDDEV="2"
        fi
- 
-        echo $i | grep "/dev" >/dev/null 2>/dev/null
+
+        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 "fuse" >/dev/null 2>/dev/null
+            echo "${i}" | grep -q "fuse" 2>/dev/null
             if [ "$?" = "0" ]
             then
-              
-             # We are trying to re-mount a dev which HAL already has marked as fuse
-
              # Lets save the old fuse device name we had saved
              OLDFUSE="${i}"
 
-             # Lets get the *real* device name for ntfs-3g
+             # Lets get the *real* device name for FUSE helper
              REALHWDEV="`cat ${FUSEDB} | grep ${i} | cut -d '=' -f 2`"
 
-             # Get the udi of this HAL device
-             HALID="`hal-find-by-property --key block.device --string ${OLDFUSE}`"
-
              # 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}"
-
-             # Get the udi of this HAL device
-             HALID="`hal-find-by-property --key block.device --string ${REALHWDEV}`"
             fi
-
         fi
-        
+
         # Add the value to our mount string
-        if [ "$i" != "-o" -a ${i} != "-u" ]
+        if [ "${i}" != "-o" ]
         then
           MNTSTRING="${MNTSTRING} ${i}"
         fi
 
     fi
 
-    # Check if we have been given a -o flag
     if [ "${i}" = "-o" ]
     then
        FOUNDOPT="1"
     else
        FOUNDOPT="0"
     fi
-
-    # Check if we have been given a -u flag
-    if [ "${i}" = "-u" ]
-    then
-       FOUNDU="1"
-    else
-       FOUNDU="0"
-    fi
 done
 
-# Save our final string which ntfs-3g will use
+# Save our final string which our FUSE helper will use
 FINALSTRING="${MNTSTRING} ${OPTIONS}"
 
 
 # Check that fuse.ko is loaded
-kldstat | grep fuse >/dev/null 2>/dev/null
+kldstat | grep -q fuse 2>/dev/null
 if [ "$?" != "0" ]
 then
   kldload /usr/local/modules/fuse.ko
 fi
 
-# Run the ntfs-3g command now, with the options in the right order
-ntfs-3g ${FINALSTRING} 
+# 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}" ]
+if [ ! -z "${OLDFUSE}" -a -e ${FUSEDB} ]
 then
    cat ${FUSEDB} | grep -v "${OLDFUSE}=" > /tmp/.newfuse
    mv /tmp/.newfuse ${FUSEDB}
@@ -115,37 +100,14 @@
 NEWFUSE="`mount | tr -s ' ' |  grep \" ${MNTPOINT} \" | cut -d ' ' -f 1`"
 
 # Make sure we don't already have this fuse device listed
-cat ${FUSEDB} | grep -v "${NEWFUSE}=" > /tmp/.newfuse
-mv /tmp/.newfuse ${FUSEDB}
-
-# Now, lets have HAL be notifed of the mount taking place
-hal-set-property --udi ${HALID} --key block.device --string ${NEWFUSE}
-
-# Make sure to set /media/.hal-mtab with the new device so we can umount
-echo '#!/bin/sh
-if [ -e "/media/.hal-mtab~" ]
+if [ -e ${FUSEDB} ]
 then
-  cp "/media/.hal-mtab~" /tmp/orig-hal
+   cat ${FUSEDB} | grep -v "${NEWFUSE}=" > /tmp/.newfuse
+   mv /tmp/.newfuse ${FUSEDB}
 else
-  cp /media/.hal-mtab /tmp/orig-hal
+   touch ${FUSEDB}
 fi
-rm /media/.hal-mtab-lock
-ID=`cat /tmp/orig-hal | tr "\t" " " | tr -s " " | grep "${1} " | cut -d " " -f 2`
-cat /tmp/orig-hal | grep -v "${1}" > /tmp/.hal-mtab
-echo "${2}	${ID}	0	ntfs	nosuid	${3}" >> /tmp/.hal-mtab
-cp /tmp/.hal-mtab /media/.hal-mtab
-cp /tmp/.hal-mtab "/media/.hal-mtab~"
-#touch /media/.hal-mtab-lock
-' > /tmp/.fixmtab
-chmod 755 /tmp/.fixmtab
 
-if [ -z "${OLDFUSE}" ]
-then
-   (sleep 5; /tmp/.fixmtab ${REALHWDEV} ${NEWFUSE} ${MNTPOINT})&
-else
-   (sleep 5; /tmp/.fixmtab ${OLDFUSE} ${NEWFUSE} ${MNTPOINT})&
-fi
-
 # Save the fuse device to our DB
 echo "${NEWFUSE}=${REALHWDEV}" >> ${FUSEDB}
 

Modified: pcbsd/trunk/system-overlay/sbin/mount_ntfs
===================================================================
--- pcbsd/trunk/system-overlay/sbin/mount_ntfs	2008-12-02 13:15:02 UTC (rev 3026)
+++ pcbsd/trunk/system-overlay/sbin/mount_ntfs	2008-12-02 15:20:11 UTC (rev 3027)
@@ -1,13 +1,22 @@
 #!/bin/sh
-# Wrapper script for PC-BSD, which takes calls from HAL
-# for running mount_ntfs, and performs it with ntfs-3g
-#######################################################
+# Wrapper script for FreeBSD and PC-BSD, which takes calls from HAL
+# for running mount_ntfs, and performs it with a given FUSE helper.
+###################################################################
 
-FUSEDB="/tmp/.fuse-mnts"
+## 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"
 HWDEV=""
 FOUNDDEV="0"
 
@@ -16,96 +25,72 @@
     if [ "$FOUNDOPT" = "1" ]
     then
         OPTIONS="${OPTIONS} -o ${i}"
-    elif [ "${FOUNDU}" = "1" ]
-    then
-        OPTIONS="${OPTIONS} -o uid=${i}"
     else
-           
+
        if [ "${FOUNDDEV}" = "1" ]
        then
          # Save the mount-point, will be used later
          MNTPOINT="${i}"
          FOUNDDEV="2"
        fi
- 
-        echo $i | grep "/dev" >/dev/null 2>/dev/null
+
+        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 "fuse" >/dev/null 2>/dev/null
+            echo "${i}" | grep -q "fuse" 2>/dev/null
             if [ "$?" = "0" ]
             then
-              
-             # We are trying to re-mount a dev which HAL already has marked as fuse
-
              # Lets save the old fuse device name we had saved
              OLDFUSE="${i}"
 
-             # Lets get the *real* device name for ntfs-3g
+             # Lets get the *real* device name for FUSE helper
              REALHWDEV="`cat ${FUSEDB} | grep ${i} | cut -d '=' -f 2`"
 
-             # Get the udi of this HAL device
-             HALID="`hal-find-by-property --key block.device --string ${OLDFUSE}`"
-
              # 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}"
-
-             # Get the udi of this HAL device
-             HALID="`hal-find-by-property --key block.device --string ${REALHWDEV}`"
             fi
-
         fi
-        
+
         # Add the value to our mount string
-        if [ "$i" != "-o" -a ${i} != "-u" ]
+        if [ "${i}" != "-o" ]
         then
           MNTSTRING="${MNTSTRING} ${i}"
         fi
 
     fi
 
-    # Check if we have been given a -o flag
     if [ "${i}" = "-o" ]
     then
        FOUNDOPT="1"
     else
        FOUNDOPT="0"
     fi
-
-    # Check if we have been given a -u flag
-    if [ "${i}" = "-u" ]
-    then
-       FOUNDU="1"
-    else
-       FOUNDU="0"
-    fi
 done
 
-# Save our final string which ntfs-3g will use
+# Save our final string which our FUSE helper will use
 FINALSTRING="${MNTSTRING} ${OPTIONS}"
 
 
 # Check that fuse.ko is loaded
-kldstat | grep fuse >/dev/null 2>/dev/null
+kldstat | grep -q fuse 2>/dev/null
 if [ "$?" != "0" ]
 then
   kldload /usr/local/modules/fuse.ko
 fi
 
-# Run the ntfs-3g command now, with the options in the right order
-ntfs-3g ${FINALSTRING} 
+# 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}" ]
+if [ ! -z "${OLDFUSE}" -a -e ${FUSEDB} ]
 then
    cat ${FUSEDB} | grep -v "${OLDFUSE}=" > /tmp/.newfuse
    mv /tmp/.newfuse ${FUSEDB}
@@ -115,37 +100,14 @@
 NEWFUSE="`mount | tr -s ' ' |  grep \" ${MNTPOINT} \" | cut -d ' ' -f 1`"
 
 # Make sure we don't already have this fuse device listed
-cat ${FUSEDB} | grep -v "${NEWFUSE}=" > /tmp/.newfuse
-mv /tmp/.newfuse ${FUSEDB}
-
-# Now, lets have HAL be notifed of the mount taking place
-hal-set-property --udi ${HALID} --key block.device --string ${NEWFUSE}
-
-# Make sure to set /media/.hal-mtab with the new device so we can umount
-echo '#!/bin/sh
-if [ -e "/media/.hal-mtab~" ]
+if [ -e ${FUSEDB} ]
 then
-  cp "/media/.hal-mtab~" /tmp/orig-hal
+   cat ${FUSEDB} | grep -v "${NEWFUSE}=" > /tmp/.newfuse
+   mv /tmp/.newfuse ${FUSEDB}
 else
-  cp /media/.hal-mtab /tmp/orig-hal
+   touch ${FUSEDB}
 fi
-rm /media/.hal-mtab-lock
-ID=`cat /tmp/orig-hal | tr "\t" " " | tr -s " " | grep "${1} " | cut -d " " -f 2`
-cat /tmp/orig-hal | grep -v "${1}" > /tmp/.hal-mtab
-echo "${2}	${ID}	0	ntfs	nosuid	${3}" >> /tmp/.hal-mtab
-cp /tmp/.hal-mtab /media/.hal-mtab
-cp /tmp/.hal-mtab "/media/.hal-mtab~"
-#touch /media/.hal-mtab-lock
-' > /tmp/.fixmtab
-chmod 755 /tmp/.fixmtab
 
-if [ -z "${OLDFUSE}" ]
-then
-   (sleep 5; /tmp/.fixmtab ${REALHWDEV} ${NEWFUSE} ${MNTPOINT})&
-else
-   (sleep 5; /tmp/.fixmtab ${OLDFUSE} ${NEWFUSE} ${MNTPOINT})&
-fi
-
 # Save the fuse device to our DB
 echo "${NEWFUSE}=${REALHWDEV}" >> ${FUSEDB}
 



More information about the Commits mailing list