Background
I have a folder named akorg✽
. That Unicode character causes headaches for me when software makes incorrect assumptions about the text encoding of my file paths, so I'd like to remove it from the name.
The problem
You'd think this would be easy:
$ mv akorg✽ akorg
mv: cannot move ‘akorg✽’ to a subdirectory of itself, ‘akorg/akorg✽’
but—that's strange—it thinks a folder called akorg
already exists. I'm pretty sure there isn't one:
$ ls -la
total 699K
drwxr-xr-x 15 ak ak 15 Jun 12 17:34 .
drwxr-xr-x 57 ak ak 4.0K Jun 12 17:35 ..
drwxr-xr-x 11 ak ak 21 Jun 12 16:58 akorg✽
drwxr-xr-x 2 ak ak 2 May 28 20:47 Desktop
...
Still, stat
says otherwise:
$ stat akorg
File: ‘akorg’
Size: 21 Blocks: 33 IO Block: 1536 directory
Device: 15h/21d Inode: 292128 Links: 11
...
So apparently there is an invisible folder in the way. Whatever, I'll just remove it:
$ rmdir akorg
rmdir: failed to remove ‘akorg’: No such file or directory
Right, then. What in the world is this thing?
What I know so far
- I'm using the stable release of ZFS on Linux. Here's the zpool status and zfs properties.
-
stat
returns the same inode for bothakorg
andakorg✽
. Searching by that inode returns onlyakorg✽
:$ find . -maxdepth 1 -inum 292128 ./akorg✽
-
More things that don't work on the "invisible" folder:
$ rm akorg rm: cannot remove ‘akorg’: Is a directory $ unlink akorg unlink: cannot unlink ‘akorg’: Is a directory $ mv akorg akorg_temp mv: cannot move ‘akorg’ to ‘akorg_temp’: No such file or directory
- I get the same results in both Bash 4.2.45 and zsh 5.0.0. In both, tab-completion of
ak
returns onlyakorg✽/
. - The strace of my initial renaming attempt confirms that I'm typing the names correctly and that the attempt is thwarted by the preexistence of a folder named
akorg
. -
This response to a more explicit renaming attempt is puzzling and scary:
$ mv --verbose --no-target-directory --no-clobber akorg✽ akorg removed ‘akorg✽’
I don't understand why it claims to have removed
akorg✽
, or why it would try. Fortunately,ls
andstat akorg akorg✽
reveal that nothing is actually gone. Here's the strace. -
To rule out encoding quirks as the cause of this, I've temporarily given
akorg✽
an intermediate name:$ mv --verbose --no-target-directory --no-clobber akorg✽ bananas ‘akorg✽’ -> ‘bananas’
That worked as expected,
$ ls -la total 715K drwxr-xr-x 16 ak ak 16 Jun 13 15:11 . drwxr-xr-x 57 ak ak 4.0K Jun 13 14:03 .. drwxr-xr-x 11 ak ak 21 Jun 12 16:58 bananas drwxr-xr-x 2 ak ak 2 May 28 20:47 Desktop ...
but the "invisible" folder is still present:
$ stat bananas akorg File: ‘bananas’ Size: 21 Blocks: 33 IO Block: 1536 directory Device: 15h/21d Inode: 292128 Links: 11 ... File: ‘akorg’ Size: 21 Blocks: 33 IO Block: 1536 directory Device: 15h/21d Inode: 292128 Links: 11 ...
and
mv
still behaves strangely when I try to use the nameakorg
:$ mv --verbose --no-target-directory --no-clobber bananas akorg removed ‘bananas’
Best Answer
This is weird. (And this "answer" started as a comment ;), became a bit long for it.)
Looking at the
strace
it looks like there are no hidden characters or the like, else I suspect you would have seen it in e.g. (which should have resulted in-1 ENOENT
and not0
if everything was OK):as you do in:
Came across a mail exchange where one person has the opposite problem.
ls
list the files, butstat
giveENOENT
– though that was on FreeBSD.I do not know much about
zfs
, but could it be that some sync, snapshot or the like has failed and left a corrupted file table? Did you create/have a directory namedakorg
that you deleted before you tried themv
?Do not know if you can get some error descriptions by:
One thing to try is check the reverse inode lookup (optionally add yet another
d
) and checkpath
:On a folder named
baz
:On a directory named
foo
holding several subdirectories including one namedakorg✽
:The settings you have on
zfs get all storage/home-ak-annex
for various name mod also looks sane (as far as I can tell) as well as the other properties by reading ZFS Properties:If you build
zfs
yourself you can enable debug by./configure --enable-debug
and play with the above including-vvvv
,-bbbb
etc.Lastly you could open a new Issue on the git.