EISDIR errors for rename(2)
by Skaperen from LinuxQuestions.org on (#5DJK3)
for non-directory objects with appropriate ownership and permission, rename(2) can replace the target object with the source object. but if the target object is an empty directory, rename(2) will give an EISDIR error, even if the ownership and permissions would allow rmdir(2) to remove it. this requires the calling code to rmdir(2) to replace it, opening a gap of time that another process could put an object there, perhaps a directory.
by letting rename(2) replace the target when the right conditions exist (permissions are appropriate and the directory is empty, it can do it atomically.
does anyone know why this is not allowed? it would seem to me that rename(2) calling rmdir(2) would be safe inside the kernel lock.


by letting rename(2) replace the target when the right conditions exist (permissions are appropriate and the directory is empty, it can do it atomically.
does anyone know why this is not allowed? it would seem to me that rename(2) calling rmdir(2) would be safe inside the kernel lock.