ls shows file, but when trying to read it is says it doesn't exist

5

I have a CIFS mount on my PC and the ls command shows me a certain file is there:

[bf@localhost dirX]$ ls -la
total 4096
drwxr-xr-x. 2 bf bf      0 20 okt 09:12 .
drwxr-xr-x. 2 bf bf      0  5 sep 11:05 ..
-rwxr-xr-x. 1 bf bf    880 19 okt 17:44 WeirdFile
-rwxr-xr-x. 1 bf bf    880 19 okt 17:44 GoodFile

However, when trying to read from it (or save to it), it says the file doesn't exist:

[bf@localhost dirX]$ cat WeirdFile
cat: WeirdFile: No such file or directory

Trying to cat GoodFile does work.

I am having trouble with CIFS anyway since moving to Fedora 26 and having to force to version 2.1 in fstab. Main problem is bad performance (slow!), but this is just plain weird.

Update when remounting the share, the file is gone.

Bart Friederichs

Posted 2017-10-20T07:26:00.933

Reputation: 1 000

Have you tried: more *WeirdFile* ? – chingNotCHing – 2017-10-20T08:25:07.833

Answers

2

A possible reason that that Weirdfile isn't really using ASCII characters in the name. If this is the case, if you type the file name it doesn't work, but if you use copy/paste it does (it can also work with command completion, depending on where the non-Ascii character is).

There are two possibilities for non-ASCII characters: * the non-ASCII character has a glyph which is identical to one in the latin alphabet (Cyrillic 'a', 'o', 'e' are typical) * the non-ASCII character is not visible (+U200B, non-breaking-zero-width-space, for instance).

Besides the copy/paste v.s. retype difference:

  • if you do ls suspisciousfile | wc -c, with all-ASCII the wc output will be just one more byte than you can count characters in the file name (due to final linefeed), if there are non-ASCII characters it will be longer.
  • with hexdump: ls suspisciousfile | hexdump -C will make any non-ASCII characters very obvious.

Example with a specially crafted filе (where the final е is actually a Cyrillic character:

enter image description here

xenoid

Posted 2017-10-20T07:26:00.933

Reputation: 7 552

1I typed the filename using tab completion. And tried hexdump, nothing weird there. – Bart Friederichs – 2017-10-20T08:38:00.953