Playing with e2fsprogs debugfs
, by change/accident, a file named filen/ame
was created. Obviously the forward slash character /
serves as the special separator character in pathnames.
Still using debugfs
I wanted to remove the file named filen/ame
, but I had little success, since the /
character is not interpreted as part of the filename?
Does debugfs provide a way to remove this file containing the slash? If so how?
I used:
cd /tmp
echo "content" > contentfile
dd if=/dev/zero of=/tmp/ext4fs bs=1M count=50
mkfs.ext4 /tmp/ext4fs
debugfs -w -R "write /tmp/contentfile filen/ame" /tmp/ext4fs
debugfs -w -R "ls" /tmp/ext4fs
which outputs:
debugfs 1.43.4 (31-Jan-2017)
2 (12) . 2 (12) .. 11 (20) lost+found 12 (980) filen/ame
I tried the following to remove the filen/ame
file:
debugfs -w -R "rm filen/ame" /tmp/ext4fs
but this did not work and only produced:
debugfs 1.43.4 (31-Jan-2017)
rm: File not found by ext2_lookup while trying to resolve filename
Apart from changing the content of the directory node manually, is there a way to remove the file using debugfs
?
Best Answer
If you want a fix and are not just trying out
debugfs
, you can have fsck do the work for you. Mark the filesystem as dirty and runfsck -y
to get the filename changed: