Because rename(2) is called by mv, is it safe to assume the following would be atomic?$ mv /home/me/someDir /tmp/toBeDeleted$ rm -rf /tmp/toBeDeleted
Atomic removal of directory
linux;rename;mv;concurrency
If the directories are on the same hardware partition mounted as a single filesystem, then moving something is actually just renaming it to a different path.  However, if they are not, then each file inside may need to be read in and copied out, so no part of the move would be atomic.  As Gilles points out, POSIX stipulates this is the case for discrete filesystems.Excepting that, a quick check with strace confirms mv does use the rename() system call (not to be confused with rename, the command line utility). That would make mving a directory atomic from a userspace perspective.  The rename() system call will throw an EBUSY error if:oldpath or newpath is a directory that is in use by some process (perhaps as current  working  directory, or as root directory, or because it was open for reading) or is in use by the system (for example as mount point), while the system considers this an error.  (Note that there is no requirement to return EBUSY in  such casesthere  is  nothing  wrong  with doing the rename anywaybut it is allowed to return EBUSY if the system cannot otherwise handle such situations.)From man 2 rename.  The connection to atomicity here is that you can't  interrupt another process working in the directory, and another process can't interrupt this -- it'll end up with an invalid path/not found type error if you beat it in the chase.