aboutsummaryrefslogtreecommitdiff
path: root/weed/util/fullpath.go
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-01-12 11:51:13 -0800
committerchrislu <chris.lu@gmail.com>2022-01-12 11:51:13 -0800
commitfec8428fd80feb1ac7bfa34f5775a442f4627433 (patch)
treee6533e6bfe43e0ca768986341645d01021ec09dd /weed/util/fullpath.go
parente82ad60122a22ab72659fc86368e42f91c0e9e34 (diff)
downloadseaweedfs-fec8428fd80feb1ac7bfa34f5775a442f4627433.tar.xz
seaweedfs-fec8428fd80feb1ac7bfa34f5775a442f4627433.zip
POSIX: different inode for same named different file types
Diffstat (limited to 'weed/util/fullpath.go')
-rw-r--r--weed/util/fullpath.go24
1 files changed, 19 insertions, 5 deletions
diff --git a/weed/util/fullpath.go b/weed/util/fullpath.go
index 404187e8b..d2fb017a1 100644
--- a/weed/util/fullpath.go
+++ b/weed/util/fullpath.go
@@ -1,6 +1,7 @@
package util
import (
+ "os"
"path/filepath"
"strings"
)
@@ -41,12 +42,25 @@ func (fp FullPath) Child(name string) FullPath {
return FullPath(dir + "/" + noPrefix)
}
-func (fp FullPath) AsInode(isDirectory bool) uint64 {
+// AsInode an in-memory only inode representation
+func (fp FullPath) AsInode(fileMode os.FileMode) uint64 {
inode := uint64(HashStringToLong(string(fp)))
- if isDirectory {
- inode = inode - inode%2 // even
- } else {
- inode = inode - inode%2 + 1 // odd
+ inode = inode - inode%16
+ if fileMode == 0 {
+ } else if fileMode&os.ModeDir > 0 {
+ inode += 1
+ } else if fileMode&os.ModeSymlink > 0 {
+ inode += 2
+ } else if fileMode&os.ModeDevice > 0 {
+ inode += 3
+ } else if fileMode&os.ModeNamedPipe > 0 {
+ inode += 4
+ } else if fileMode&os.ModeSocket > 0 {
+ inode += 5
+ } else if fileMode&os.ModeCharDevice > 0 {
+ inode += 6
+ } else if fileMode&os.ModeIrregular > 0 {
+ inode += 7
}
return inode
}