{"action":"created","issue":{"url":"https://api.github.com/repos/IgnorantGuru/spacefm/issues/634","repository_url":"https://api.github.com/repos/IgnorantGuru/spacefm","labels_url":"https://api.github.com/repos/IgnorantGuru/spacefm/issues/634/labels{/name}","comments_url":"https://api.github.com/repos/IgnorantGuru/spacefm/issues/634/comments","events_url":"https://api.github.com/repos/IgnorantGuru/spacefm/issues/634/events","html_url":"https://github.com/IgnorantGuru/spacefm/issues/634","id":145491761,"number":634,"title":"\"Destination directory <dir> is contained in source <dir>\" check misbehaves","user":{"login":"hasufell","id":1241845,"avatar_url":"https://avatars.githubusercontent.com/u/1241845?v=3","gravatar_id":"","url":"https://api.github.com/users/hasufell","html_url":"https://github.com/hasufell","followers_url":"https://api.github.com/users/hasufell/followers","following_url":"https://api.github.com/users/hasufell/following{/other_user}","gists_url":"https://api.github.com/users/hasufell/gists{/gist_id}","starred_url":"https://api.github.com/users/hasufell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hasufell/subscriptions","organizations_url":"https://api.github.com/users/hasufell/orgs","repos_url":"https://api.github.com/users/hasufell/repos","events_url":"https://api.github.com/users/hasufell/events{/privacy}","received_events_url":"https://api.github.com/users/hasufell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-03T12:54:08Z","updated_at":"2016-04-03T18:26:42Z","closed_at":null,"body":"This is a serious bug I encountered in my own filemanager too. I have a function [throwDestinationInSource](https://github.com/hasufell/hsfm/blob/8c95aa312a6ac8f84a01ff6a58397ac526fd2d5a/src/HSFM/FileSystem/Errors.hs#L113), which uses `realpath` to resolve symlinks etc, so we can reason about the filepaths.\r\n\r\nHowever, this still doesn't know anything about mountpoints. So if you did some `mount -o bind ...` stuff, you are able to start a copy operation that will never end. This is the case for spacefm too, possibly resulting in zero disk space and system crash.\r\n\r\nI guess one needs to do more low-level examination of the directories in order for this check to be reliable.\r\n\r\n----------\r\nEdit: I've fixed it by getting all parent directories of the _destination path_, getting device+file IDs of all those parent directories and checking if the device+file ID of the _source directory_ matches any of the parent directories of the destination path. Also [see](https://github.com/hasufell/hsfm/commit/ba4fbc200cdc4f8ac82641d97a20fe1e79f25609).\r\n\r\nHowever, I'm not sure if there are some gotchas there, will need some testing.\r\n"},"comment":{"url":"https://api.github.com/repos/IgnorantGuru/spacefm/issues/comments/205025381","html_url":"https://github.com/IgnorantGuru/spacefm/issues/634#issuecomment-205025381","issue_url":"https://api.github.com/repos/IgnorantGuru/spacefm/issues/634","id":205025381,"user":{"login":"IgnorantGuru","id":653952,"avatar_url":"https://avatars.githubusercontent.com/u/653952?v=3","gravatar_id":"","url":"https://api.github.com/users/IgnorantGuru","html_url":"https://github.com/IgnorantGuru","followers_url":"https://api.github.com/users/IgnorantGuru/followers","following_url":"https://api.github.com/users/IgnorantGuru/following{/other_user}","gists_url":"https://api.github.com/users/IgnorantGuru/gists{/gist_id}","starred_url":"https://api.github.com/users/IgnorantGuru/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IgnorantGuru/subscriptions","organizations_url":"https://api.github.com/users/IgnorantGuru/orgs","repos_url":"https://api.github.com/users/IgnorantGuru/repos","events_url":"https://api.github.com/users/IgnorantGuru/events{/privacy}","received_events_url":"https://api.github.com/users/IgnorantGuru/received_events","type":"User","site_admin":false},"created_at":"2016-04-03T18:26:42Z","updated_at":"2016-04-03T18:26:42Z","body":"Indeed that check is not infallible, more of a deterrent. SpaceFM does use realpath but maybe could do a similar check on IDs.\r\n"}}