Commit 1ab130b4 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

nodefs: test Mknod

parent 41672d15
...@@ -50,7 +50,9 @@ Decisions ...@@ -50,7 +50,9 @@ Decisions
reading) are handled automatically. No support for directory reading) are handled automatically. No support for directory
seeks. seeks.
To decide To do/To decide
========= =========
* implement remaining file types (exercise Mknod) * decide on a final package name
* handle less open/create.
...@@ -100,7 +100,13 @@ func (b *rawBridge) newInode(ctx context.Context, ops Operations, id NodeAttr, p ...@@ -100,7 +100,13 @@ func (b *rawBridge) newInode(ctx context.Context, ops Operations, id NodeAttr, p
_ = ops.(SymlinkOperations) _ = ops.(SymlinkOperations)
case fuse.S_IFREG: case fuse.S_IFREG:
_ = ops.(FileOperations) _ = ops.(FileOperations)
case fuse.S_IFIFO, syscall.S_IFSOCK:
// no type check necessary: FIFO and SOCK don't go
// through FUSE for open/read etc.
break
default: default:
// Remaining types are char and block devices. Not
// sure how those would work in FUSE
log.Panicf("filetype %o unimplemented", id.Mode) log.Panicf("filetype %o unimplemented", id.Mode)
} }
......
...@@ -555,4 +555,37 @@ func TestGetAttrParallel(t *testing.T) { ...@@ -555,4 +555,37 @@ func TestGetAttrParallel(t *testing.T) {
wg.Wait() wg.Wait()
} }
// XXX test mknod. func TestMknod(t *testing.T) {
tc := newTestCase(t, false, false)
defer tc.Clean()
modes := map[string]uint32{
"regular": syscall.S_IFREG,
"socket": syscall.S_IFSOCK,
"fifo": syscall.S_IFIFO,
}
for nm, mode := range modes {
t.Run(nm, func(t *testing.T) {
p := filepath.Join(tc.mntDir, nm)
err := syscall.Mknod(p, mode|0755, (8<<8)|0)
if err != nil {
t.Fatalf("mknod(%s): %v", nm, err)
}
var st syscall.Stat_t
if err := syscall.Stat(p, &st); err != nil {
got := st.Mode &^ 07777
if want := mode; got != want {
t.Fatalf("stat(%s): got %o want %o", nm, got, want)
}
}
// We could test if the files can be
// read/written but: The kernel handles FIFOs
// without talking to FUSE at all. Presumably,
// this also holds for sockets. Regular files
// are tested extensively elsewhere.
})
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment