How do I get the path to a DMG (disk image) file given the mounted volume path?
A somewhat pedestrian way would be to retrieve the name of your DMG file from the output of hdiutil and then search for it, e.g., via

hdiutil info -plist | grep dmg | sed 's/&lt;string&gt;\([^&lt;]*\)&lt;\/string&gt;/\1/' | xargs basename | xargs mdfind -name


You may need to modify the grep dmg part to be smarter if you have several images mounted, or you loop through all DMG files reported by hdiutil, e.g.,

for F in `hdiutil info -plist | grep dmg | sed 's/&lt;string&gt;\([^&lt;]*\)&lt;\/string&gt;/\1/'`
  do basename $F | xargs mdfind -name
done


However, none of the above takes your mount path as input. To do that, you could add a sed command in the pipe that extracts the paragraph of interest, e.g.,

hdiutil info -plist | tail -r | sed -n '/\/Volumes\/MOUNTNAME/,/dmg/p' | grep dmg | sed 's/&lt;string&gt;\([^&lt;]*\)&lt;\/string&gt;/\1/' | xargs basename | xargs mdfind -name


Perhaps it is also easier to work on the direct output of hdiutil info, without the -plist flag.