My response to this problem is the result of cobbling together answers taken from several other posts (many thanks) and my own experience.
The background: I have an external hard drive with an NTFS file system. I want to plug it in occasionally. Previously the volume would mount 'read only'. Once I got that fixed, the files on the volume were in an unusable state. in order to get the volume mounted correctly and have the files accessible, I had to do the following:
FYI: I'm a kornshell user. Adjust these commands to your preferred shell.
$ sudo ksh
<password>
$ mv /sbin/mount_ntfs /sbin/mount_ntfs.orig
$ vi /sbin/mount_ntfs
Then paste the content below:
#!/bin/ksh
# --- direct all script stdout to a temp file for examination
exec > /tmp/ntfs
# --- connect all stderr to stdout
exec 2>&1
# --- get the last argument on the command line - this is the mount point
eval echo \$$# |
read MOUNT_PT
echo "\${MOUNT_PT} = \"${MOUNT_PT}\""
echo
echo "Mounting $@"
# --- call the original ntfs mounter with the arguments handed in
/sbin/mount_ntfs.orig -o rw "$@"
echo "Mounted $@"
# --- show the result of the mounting operation
mount
# --- fix files at the newly mounted MOUNT_PT that are in the 'brok' state
find "${MOUNT_PT}" -type f |
while read FILE; do
# ---
# --- use 'SetFile' to modify the file status
# ---
# --- this command line assumes the 'SetFile' command has been installed
# --- and is available in your PATH
# ---
SetFile -c "" -t "" "${FILE}"
done
Then:
$ chmod a+x /sbin/mount_ntfs
$ chown root:wheel /sbin/mount_ntfs
Now, any time I plug in the disk, it is mounted 'read/write' and the files on the disk have their 'brok' status reset. This script works well for me. Your mileage may vary.
Enjoy --