Today i wanted to rename an upper case directories named e.g. 'A' to lower case on a CIFS mounted NAS. After doing e.g.
mv A a
the directory was gone and all its contents _lost_ (the effect is like issuing
rm -rf A/).
Somehow CIFS ignores the case insensitivity of VFAT and the mv results in attempting to move the directory into itself which is of course not possible.
The bad thing is that as result neither source nore target is existing any more.
In case 'A' is a regular file the mv command behaves like expected.
My fstab mount options for said device are
Note that because of
I need the noserverino option. I have no idea if this is in any way related to this bug.
If i add the option 'nolinux' (which is not documented in mount.cifs manual page) to my fstab entry then the mv command is rejected with an error message.
Hmmm...sounds like you might have gotten bitten by case insensitivity on the server. What kind of server is this?
We'll probably need to see a wire capture of this in order to make sense of what's happening. There are instructions on how to do this here:
...please run the capture while both mounting (so we can see what the server is advertising for capabilities) and while reproducing the issue.
Created attachment 5202 [details]
cifs logs and wireshark traces with two mount variants
> What kind of server is this?
It's an Iomega Home Network drive (NAS) with Linux inside.
This came to market in september 2007, the used samba server may be older.
The used device has an updated firmware (from manufacturer) which is advertised as 'improves mount.cifs with Linux clients'.
>...please run the capture while both mounting
I captured two cases (mount with and without 'nolinux' option) with wireshark and cifs debug output. You find the four files attached.
But while capturing I recognised, that by moving the command sequence to trigger the bug into a tiny shell script this changed the behaviour!
The script is
mount $1; cd $1
mkdir Y; touch Y/test; mv Y y; ls -l y; rmdir y
cd ..; umount $1
When running from the script, the mv command gives the error
Verschieben von „Y“ nach „y/Y“ nicht möglich: Eingabe-/Ausgabefehler
and the directory does _not_ disappear.
The subsequent ls in fact lists the contents as if the recursive mv has been successful:
-rwxrwxrwx 1 root root 0 17. Jan 22:20 test
drwxrwxrwx 1 root root 0 7. Jan 2008 Y
And in fact I really have a recursive directory entry: The result of
The zipfile is missing one of the captures (the "bad" one). It seems to have a directory in its place...
The "good.bug" capture is in there however and I think that shows at least part of what's going on. The issue seems pretty clearly tied up with case-sensitivity. The server is case insensitive and case preserving but the client doesn't seem to realize that.
Does this behave better if you mount with -o nocase?
Created attachment 5206 [details]
wireshark and cifs traces including 'nocase' mount
> The zipfile is missing one of the captures (the "bad" one)
Seems I mastered wireshark filters but not its file save dialog :)
Found the file on '/' and attached it.
> Does this behave better if you mount with -o nocase?
No, I could reproduce lost directory behaviour with 'nocase'.
Complete fstab entry is
//192.168.1.100/public /media/nocase cifs noauto,nocase,noserverino,user=admin,pass=admin,dirmode=0777,filemode=0777,rw,users 0 0
Two new logs attached.
Thanks so far
There was a problem fixed recently upstream relating to case sensitivity on cifs. The patch is here:
...do you have the ability to test recent upstream kernels? If so, could you test one with this patch?
>...do you have the ability to test recent upstream kernels?
Hmm, that would take some effort,
> If so, could you test one with this patch?
I applied the changes in readdir.c to cifs of my 22.214.171.124-0.1-default
and installed, inserted the resulting cifs.ko (had to use modprobe with "-f" because without I got "Invalid module format", don't known why).
Result: renaming single letter directories from lower to upper case (or vice versae) still makes them vanish (together with its contents):
$> mkdir a B
$> mkdir A b
mkdir: kann Verzeichnis „A“ nicht anlegen: Die Datei existiert bereit
mkdir: kann Verzeichnis „b“ nicht anlegen: Die Datei existiert bereit
$> mv a A; ls
$> mv b b; ls
$> mkdir d; mv C C
mv: Verschieben von „C“ in eigenes Unterverzeichnis („C/C“) nicht möglich
$> ls C
$> rm -rf C
rm: Entfernen von Verzeichnis „C/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c/c“ nicht möglich: Eingabe-/Ausgabefehler
Current fstab mount options: