The Samba-Bugzilla – Bug 7907
unlink of illegal name should not return EINVAL
Last modified: 2011-01-11 15:27:52 UTC
It appears that unlink()ing a filename with illegal characters (such as "*") returns EINVAL. This is odd, because it could have just returned ENOENT (just like deleting any other nonexistant file), or, if you follow the next POSIX standard, EILSEQ.
The manifistation of this issue is that if you do
rm -f "*"
with the current coreutils, rm -f doesn't ignore this error, because it only ignores ENOENT, not EINVAL. I noticed this when a Linux kernel makefile broke (with the files on a Windows machine mounted with cifs), because "rm -f .tmp-versions/*" failed when the directory was empty, and the failure was not ignored.
This will be fixed in the next version of rm (it will ignore both EINVAL and EILSEQ), but it anyway brings up a question why smbfs/cifsfs needs to return EINVAL at all. EINVAL is nowhere to be mentioned in the unlink(2) documentation, by the way.
For clarification - here's the wording that will be in the next POSIX revision that adds the requirement for EILSEQ on unsupported file names: