http://bugs.winehq.org/show_bug.cgi?id=10957
--- Comment #16 from Robert Millan rmh@aybabtu.com 2007-12-31 03:32:08 --- (In reply to comment #15)
You can't delete a file and hope something else pick it up. For everything it's gone. So I doubt your "solution" is a a good one. Just don't remove the image file. Of course you are welcome to send your patch to wine-patches and see what happens.
The underlying loopback interface is based on i-nodes, not files. A file is just a way to refer it to the i-node that corresponds to your data. For this reason after the file has been renamed (and not necessarily "deleted" as such), you may still access its content via /dev/loop0.
You may argue that this is in fact a bug and /etc/mtab should be updated automatically, but solving that is impossible because the design of this scheme relies on subsequent invocations of mount for any update of that file. Of course this wouldn't happen if /etc/mtab was a symlink to /proc/mounts, but then we wouldn't have to worry about loopbacks at all.
You may also argue that users who rename images after setting loopbacks on them actually deserve this result because they made a mistake. I disagree. I think programs should be smarter than users and try to respond reasonably to their mistakes whenever this makes sense and doesn't compromise other areas. Programs are there to serve the user, not the other way around.