Possible Solaris problem in 'checkout_entry()'
From: Linus Torvalds <torvalds@linux-foundation.org>
Date: 2016-06-15 22:44:23
I was looking at this due to the CE_UPDATE bug, and notice that we do
if (!lstat(path, &st)) {
... check if it's unchanged ..
unlink(path);
if (S_ISDIR(st.st_mode)) {
..
and it hit me that didn't we have issues with Solaris allowing an
"unlink()" to succeed on a directory when you are root, causing various
problems later with lost inodes during fsck?
We fixed that in commit fa2e71c9e794c43634670b62d1b4bf58d1ae7e60 back last
July, by avoiding to do the unlink() if it was already a directory in
create_directories(). But it *looks* like the same problem exists if you
use "git checkout -f" and have a directory where you expect a file.
I don't have any access to a Solaris box, nor do I want any, but this
test-script (as root, remember) should show if this is a problem:
mkdir repo
cd repo
git init
echo "Testfile" > a
git add a
git commit -m "Initial commit"
rm a
mkdir a
git checkout -f
where you probably need to then reboot and force a fsck to actually see if
it caused problems.
Solaris is just totally incredible crap here, but maybe we should move the
unlink to after that "if (S_ISDIR(..))" statement? And maybe somebody who
has a Solaris support contract can try to kick some Sun *ss to get them to
fix their crap?
Linus