GNOME Bugzilla – Bug 509606
Auto busy on unmount
Last modified: 2011-06-07 12:38:33 UTC
When there are open files on a mount we should automatically fail unmount requests with G_IO_ERROR_BUSY (unless G_MOUNT_UNMOUNT_FORCE is specified).
Created attachment 107788 [details] [review] Patch This patch includes: - A g_vfs_backend_is_busy function that returns TRUE if the daemon has gvfschannels active - Unmount flags parameter is retrieved from the DBus message when creating the unmount job - When trying to unmount, if the backend is busy and Force flag is not present a G_IO_ERROR_BUSY error is returned. - A -f command line option to gvfs-mount to be able to force unmount. I still have some doubts about the current behaviour and possible improvements: - g_vfs_backend_is_busy could be g_vfs_backend_get_n_channels instead so that the error message would include the number of open files instead of just "File system is busy" - The Force flag is only checked in the try method, assuming that unmount will only be called if try didn't succeed. So, the question is, should we pass the force flag to the backends? or is right to assume that if unmount is called is because the backend is not busy or the force flag is present? - Should the unmount job close the active channels when force flag is present?
I dunno if getting a number of open files is better than is-busy. However, if we could get the filename of the open file (at least in the case there is only one open) that may be nice... I think we should pass in the force flag. Some backend may need to do something special with it. I think we should close active channels on force flag. Its similar to a force shutdown from the backend itself, which should also do this.
Oh, and btw, lets wait with this one to post-branch.
Created attachment 108661 [details] [review] Updated patch New version of the patch.
We have branched now. Looks like g_vfs_backend_close_active_channels leaks the channels list.
Created attachment 109358 [details] [review] Another update Here is a new version against current trunk and with the leak fixed.
Patch looks good to me. Alex, should we get this in this cycle ?
Fixed on git master. Updating 08c4a19..100ea69 Fast-forward daemon/gvfsbackend.c | 29 +++++++++++++ daemon/gvfsbackend.h | 3 + daemon/gvfschannel.c | 45 ++++++++++++++++++++ daemon/gvfschannel.h | 2 +- daemon/gvfsdaemon.c | 16 +++++++ daemon/gvfsdaemon.h | 3 + daemon/gvfsjobunmount.c | 106 +++++++++++++++++++++++++++++++++++++++------- 7 files changed, 187 insertions(+), 17 deletions(-)