ENOTDIR for nonexistent path components
matt at mattmccutchen.net
Thu Sep 23 20:26:17 MDT 2010
On Thu, 2010-09-23 at 09:20 -0400, Jeff Fellin wrote:
> I've been porting rsync-3.0.7 to run on UWIN, an AT&T Labs open source
> project, supporting a Unix environment on Windows. The code configured
> easily and compiled without any modifications or ifdef's added to the
> The backup test was failing because it didn't create a subdirectory.
> In tracing the code I realized the problem was in robust_move() in
> backup.c. UWIN returns ENOTDIR, when the rename(2) is called when a
> directory component is not in the new pathname. According to the Open
> Group website this is a valid errno value.
Ugh. The standard says:
A component of either path prefix is not a directory; ...
I always interpreted this to mean, "is a file that is not a directory",
and assumed that a nonexistent component would be reported as ENOENT.
This behavior better separates the meanings of the error codes and
corresponds to the most natural way to implement walking of a non-final
path component in the OS: first call a generic function that looks up
the dentry and returns ENOENT if it isn't there, and then check whether
the inode is a directory and return ENOTDIR if it isn't. Linux does
this, and rsync assumes it in many more places than the two you cited.
It might be worth seeking official clarification. If your
interpretation is correct, it becomes Wayne's decision whether working
on all POSIX-compliant systems is important enough to merit adding extra
code throughout rsync.
More information about the rsync