Unique volname for DMGs
After a lot of searching and much cursing, I think that this is really a problem that practically nobody is aware of or concerned about.  Still, I was able to find a solution, it's not great, but it should work.  The idea is to mount the DMG in a known directory with some random name -- this name (the last element in the -mountpoint path) will be the name property of the disk.  So using this I walk over all of the disks and look for ones with a matching name -- complain if I find none or more than one, otherwise, I have the needed object ready to work with.

mnt="some-random-name-$$"
hdiutil attach -readwrite -noverify -noautoopen \
               -mountpoint "/tmp/$mnt" "/tmp/out.dmg"
/usr/bin/osascript &lt;&lt;-EOF
      tell application "Finder"
        set myDisks to every disk of desktop
        set theDMGDisk to ""
        repeat with d in myDisks
          if name of d = "$mnt"
            if theDMGDisk = ""
              set theDMGDisk to d
            else
              error "Too many attached DMGs found!"
            end if
          end if
        end repeat
        if theDMGDisk = "" then error "Attached DMG not found!"
        -- found a single matching disk, continue
        tell theDMGDisk
... etc ...