That's definitely a problem. We also might have issues with rmdir of /
too, and maybe other stuff. Other things include anything that would
want to change a link when that link is a directory (I grab the parent
since that is where the link info is stored), and maybe also if the
process has a different / directory (say a chroot, which no one can set
up on Akaros but the nd stuff is built to handle).
As far as fixing it goes, just swapping those probably won't work,
since do_lookup() expects to start from an nd that was filled in by a
path_lookup(). o/w, nd->dentry is 0, etc.
I think we'd need a path_lookup(), maybe with nd->intent = LOOKUP_OPEN,
just to check for existence. If so, then we abort with EEXIST. Then
we do the existing parent path_lookup, etc. We can also remove the
later do_lookup / EEXIST check. Btw, the whole VFS stack is racy as
hell.
For rmdir, we ought to do some sort of "root directory detection",
probably before the parent's path_lookup (for similar reasons), and
return EBUSY. I have a TODO in there for that (L 1712). Though I'm
less concerned about rmdir. You'll fail, just for the wrong reason.
And if you don't fail, then oh well. Shouldn't have removed /. =)
I slapped a patch together that seems to do the trick:
/ $ mkdir -p /foobar
/ $ ls -a /foobar
. ..
/ $ mkdir /
mkdir: can't create directory '/': File exists
It's on origin/mkdir:
763c4ba24078 ("Fix do_mkdir on root directories")
Barret
—
Reply to this email directly or view it on GitHub.![]()