Issues removing files with certain characters in their names.

Harald Becker ralda at gmx.de
Fri May 30 18:06:24 UTC 2014


Hi Joshua !

On 29-05-2014 18:41 Joshua Judson Rosen <jrosen at harvestai.com>
wrote:

>But why is ls able to match the files when rm is not able to
>remove them?

The problem happens on the opposite direction you expect. It is
not the create/open/unlink which modify the file name it is the
directory scan. ls doesn't really match the filename. It just
scans the directory, filters with given file name masks, then
display what it got. But on some unusual file names the directory
scan gives names which does not exactly match the name stored on
file system. They can be displayed, but used for an remove or
move operation the stat/unlink fails. This usually happens
when the names contain control or unprintable characters
(e.g. a byte with all zero) which get removed by the
kernel/file system driver.

>Is it perhaps because ls is not actually doing any operations on
>the files themselves (not even a stat?), and just reporting the
>dirent->d_name strings that it got from readdir()? In which case
>"ls -l *" would fail on the same files even when "ls *" doesn't?

Correct.

>Or is there something deeper whereby stat() succeeds but
>unlink() fails?

No. Never got this.

--
Harald


More information about the busybox mailing list