diff options
| author | chrislu <chris.lu@gmail.com> | 2022-01-11 23:44:48 -0800 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-01-11 23:44:48 -0800 |
| commit | 2dcb8cb93b951bd8457cdb670edf2146b068a836 (patch) | |
| tree | dfbe0e451b3c0f32204cd52e8ea3a617a8ca201f /weed/util/fullpath.go | |
| parent | 5bb37d5905bbc2b091540ff96e0b1389e1016029 (diff) | |
| download | seaweedfs-2dcb8cb93b951bd8457cdb670edf2146b068a836.tar.xz seaweedfs-2dcb8cb93b951bd8457cdb670edf2146b068a836.zip | |
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.
Diffstat (limited to 'weed/util/fullpath.go')
| -rw-r--r-- | weed/util/fullpath.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/weed/util/fullpath.go b/weed/util/fullpath.go index 85028b052..404187e8b 100644 --- a/weed/util/fullpath.go +++ b/weed/util/fullpath.go @@ -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 |
