Commit 9f36c953 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Drop Init from raw interface. Move doInit to opcode.go.

parent b094739d
......@@ -6,10 +6,6 @@ import (
var _ = log.Println
func (me *DefaultRawFileSystem) Init(h *InHeader, input *InitIn) (*InitOut, Status) {
return new(InitOut), OK
}
func (me *DefaultRawFileSystem) Destroy(h *InHeader, input *InitIn) {
}
......
......@@ -233,7 +233,7 @@ func (me *MountState) chopMessage(req *request) *operationHandler {
handler := getHandler(req.inHeader.Opcode)
if handler == nil || handler.Func == nil {
log.Printf("Unknown opcode %d (input)", req.inHeader.Opcode)
log.Printf("Unknown opcode %v", req.inHeader.Opcode)
req.status = ENOSYS
return handler
}
......@@ -322,28 +322,3 @@ func serialize(req *request, handler *operationHandler, debug bool) {
operationName(req.inHeader.Opcode), req.status, val, msg)
}
}
func (me *MountState) init(h *InHeader, input *InitIn) (unsafe.Pointer, Status) {
out, initStatus := me.fileSystem.Init(h, input)
if initStatus != OK {
return nil, initStatus
}
if input.Major != FUSE_KERNEL_VERSION {
fmt.Printf("Major versions does not match. Given %d, want %d\n", input.Major, FUSE_KERNEL_VERSION)
return nil, EIO
}
if input.Minor < FUSE_KERNEL_MINOR_VERSION {
fmt.Printf("Minor version is less than we support. Given %d, want at least %d\n", input.Minor, FUSE_KERNEL_MINOR_VERSION)
return nil, EIO
}
out.Major = FUSE_KERNEL_VERSION
out.Minor = FUSE_KERNEL_MINOR_VERSION
out.MaxReadAhead = input.MaxReadAhead
out.Flags = FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_BIG_WRITES
out.MaxWrite = maxRead
return unsafe.Pointer(out), OK
}
......@@ -170,12 +170,6 @@ func NewLockingRawFileSystem(rfs RawFileSystem) *LockingRawFileSystem {
return l
}
func (me *LockingRawFileSystem) Init(h *InHeader, input *InitIn) (*InitOut, Status) {
me.lock.Lock()
defer me.lock.Unlock()
return me.Original.Init(h, input)
}
func (me *LockingRawFileSystem) Destroy(h *InHeader, input *InitIn) {
me.lock.Lock()
defer me.lock.Unlock()
......
......@@ -20,6 +20,33 @@ func replyString(opcode Opcode, ptr unsafe.Pointer) string {
////////////////////////////////////////////////////////////////
func doInit(state *MountState, req *request) {
input := (*InitIn)(req.inData)
if input.Major != FUSE_KERNEL_VERSION {
fmt.Printf("Major versions does not match. Given %d, want %d\n", input.Major, FUSE_KERNEL_VERSION)
req.status = EIO
return
}
if input.Minor < FUSE_KERNEL_MINOR_VERSION {
fmt.Printf("Minor version is less than we support. Given %d, want at least %d\n", input.Minor, FUSE_KERNEL_MINOR_VERSION)
req.status = EIO
return
}
out := &InitOut{
Major: FUSE_KERNEL_VERSION,
Minor: FUSE_KERNEL_MINOR_VERSION,
MaxReadAhead: input.MaxReadAhead,
Flags: FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_BIG_WRITES,
MaxWrite: maxRead,
}
req.outData = unsafe.Pointer(out)
req.status = OK
}
func doOpen(state *MountState, req *request) {
flags, handle, status := state.fileSystem.Open(req.inHeader, (*OpenIn)(req.inData))
req.status = status
......@@ -129,9 +156,7 @@ func doForget(state *MountState, req *request) {
func doReadlink(state *MountState, req *request) {
req.flatData, req.status = state.fileSystem.Readlink(req.inHeader)
}
func doInit(state *MountState, req *request) {
req.outData, req.status = state.init(req.inHeader, (*InitIn)(req.inData))
}
func doDestroy(state *MountState, req *request) {
state.fileSystem.Destroy(req.inHeader, (*InitIn)(req.inData))
}
......
......@@ -23,11 +23,6 @@ func (me *FileSystemConnector) SetOptions(opts FileSystemConnectorOptions) {
me.options = opts
}
func (me *FileSystemConnector) Init(h *InHeader, input *InitIn) (*InitOut, Status) {
// TODO ?
return &InitOut{}, OK
}
func (me *FileSystemConnector) Destroy(h *InHeader, input *InitIn) {
// TODO - umount all.
}
......
......@@ -31,11 +31,6 @@ func (me *TimingRawFileSystem) Latencies() map[string]float64 {
return me.LatencyMap.Latencies(1e-3)
}
func (me *TimingRawFileSystem) Init(h *InHeader, input *InitIn) (*InitOut, Status) {
defer me.startTimer("Init")()
return me.Original.Init(h, input)
}
func (me *TimingRawFileSystem) Destroy(h *InHeader, input *InitIn) {
defer me.startTimer("Destroy")()
me.Original.Destroy(h, input)
......
......@@ -504,7 +504,6 @@ type NotifyInvalEntryOut struct {
// the details of getting interactions with open files, renames, and
// threading right etc. are somewhat tricky and not very interesting.
type RawFileSystem interface {
Init(h *InHeader, input *InitIn) (out *InitOut, code Status)
Destroy(h *InHeader, input *InitIn)
Lookup(header *InHeader, name string) (out *EntryOut, status Status)
......
......@@ -105,10 +105,6 @@ type WrappingRawFileSystem struct {
Original RawFileSystem
}
func (me *WrappingRawFileSystem) Init(h *InHeader, input *InitIn) (*InitOut, Status) {
return me.Original.Init(h, input)
}
func (me *WrappingRawFileSystem) Destroy(h *InHeader, input *InitIn) {
me.Original.Destroy(h, input)
}
......
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