mirror of
https://github.com/hanzoai/go-fuse.git
synced 2026-10-30 14:46:18 +00:00
The file type is not a bitmap, and looking at
S_IFBLK = 0x6000
S_IFCHR = 0x2000
S_IFDIR = 0x4000
S_IFIFO = 0x1000
S_IFLNK = 0xa000
S_IFREG = 0x8000
S_IFSOCK = 0xc000
and confirmed by the added test, we used to classify
block devices and sockets as directories:
--- FAIL: TestInodeIsDir (0.00s)
inode_test.go:25: wrong result for case struct { mode uint32; dir bool }{mode:0x6000, dir:false}
inode_test.go:25: wrong result for case struct { mode uint32; dir bool }{mode:0xc000, dir:false}
The check is fixed now and the test passes.
Change-Id: I6490992d1fecc8a6bea7c2c4b2f1bca765d03d4c
29 lines
480 B
Go
29 lines
480 B
Go
package fs
|
|
|
|
import (
|
|
"syscall"
|
|
"testing"
|
|
)
|
|
|
|
func TestInodeIsDir(t *testing.T) {
|
|
cases := []struct {
|
|
mode uint32
|
|
dir bool
|
|
}{
|
|
{syscall.S_IFBLK, false},
|
|
{syscall.S_IFCHR, false},
|
|
{syscall.S_IFDIR, true},
|
|
{syscall.S_IFIFO, false},
|
|
{syscall.S_IFLNK, false},
|
|
{syscall.S_IFREG, false},
|
|
{syscall.S_IFSOCK, false},
|
|
}
|
|
var i Inode
|
|
for _, c := range cases {
|
|
i.stableAttr.Mode = c.mode
|
|
if i.IsDir() != c.dir {
|
|
t.Errorf("wrong result for case %#v", c)
|
|
}
|
|
}
|
|
}
|