POSIX: ensure file and directory inodes are different

this is just an in memory representation.

POSIX wants different inode numbers for the same named file or directory.
This commit is contained in:
chrislu
2022-01-11 23:44:48 -08:00
parent 5bb37d5905
commit 2dcb8cb93b
7 changed files with 43 additions and 34 deletions

View File

@@ -41,8 +41,14 @@ func (fp FullPath) Child(name string) FullPath {
return FullPath(dir + "/" + noPrefix)
}
func (fp FullPath) AsInode() uint64 {
return uint64(HashStringToLong(string(fp)))
func (fp FullPath) AsInode(isDirectory bool) uint64 {
inode := uint64(HashStringToLong(string(fp)))
if isDirectory {
inode = inode - inode%2 // even
} else {
inode = inode - inode%2 + 1 // odd
}
return inode
}
// split, but skipping the root