Commit 5e70a522 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

ioctl wip.

parent 3585c6cf
......@@ -74,6 +74,7 @@ type File interface {
Chmod(perms uint32) Status
Utimens(atimeNs uint64, mtimeNs uint64) Status
Truncate(size uint64) Status
Ioctl(input *IoctlIn) (output *IoctlOut, data []byte, code Status)
}
// MountOptions contains time out options for a FileSystem. The
......@@ -142,6 +143,9 @@ type RawFileSystem interface {
ReadDir(header *InHeader, input *ReadIn) (*DirEntryList, Status)
ReleaseDir(header *InHeader, input *ReleaseIn)
FsyncDir(header *InHeader, input *FsyncIn) (code Status)
//
Ioctl(header *InHeader, input *IoctlIn) (output *IoctlOut, data []byte, code Status)
}
// DefaultRawFileSystem returns ENOSYS for every operation.
......
......@@ -91,10 +91,6 @@ func (me *DefaultRawFileSystem) Bmap(header *InHeader, input *BmapIn) (out *Bmap
return nil, ENOSYS
}
func (me *DefaultRawFileSystem) Ioctl(header *InHeader, input *IoctlIn) (out *IoctlOut, code Status) {
return nil, ENOSYS
}
func (me *DefaultRawFileSystem) Poll(header *InHeader, input *PollIn) (out *PollOut, code Status) {
return nil, ENOSYS
}
......@@ -133,6 +129,10 @@ func (me *DefaultRawFileSystem) FsyncDir(header *InHeader, input *FsyncIn) (code
return ENOSYS
}
func (me *DefaultRawFileSystem) Ioctl(header *InHeader, input *IoctlIn) (output *IoctlOut, data []byte, code Status) {
return nil, nil, ENOSYS
}
////////////////////////////////////////////////////////////////
// DefaultFile
......@@ -176,6 +176,10 @@ func (me *DefaultFile) Chmod(perms uint32) Status {
return ENOSYS
}
func (me *DefaultFile) Ioctl(input *IoctlIn) (output *IoctlOut, data []byte, code Status) {
return nil, nil, ENOSYS
}
////////////////////////////////////////////////////////////////
// DefaultFileSystem
......
......@@ -601,6 +601,20 @@ func TestReadOnly(t *testing.T) {
ts.testReaddir()
}
func TestIoctl(t *testing.T) {
ts := new(testCase)
ts.Setup(t)
defer ts.Cleanup()
f, err := os.OpenFile(filepath.Join(ts.mountPoint, "hello.txt"),
os.O_WRONLY|os.O_CREATE, 0777)
defer f.Close()
CheckSuccess(err)
v, e := ioctl(f.Fd(), 0x5401, 42)
fmt.Println("ioctl", v, e)
}
func TestRecursiveMount(t *testing.T) {
ts := new(testCase)
ts.Setup(t)
......@@ -650,3 +664,4 @@ func TestRecursiveMount(t *testing.T) {
ts.Cleanup()
}
......@@ -158,3 +158,11 @@ func asSlice(ptr unsafe.Pointer, byteCount int) []byte {
h := &reflect.SliceHeader{uintptr(ptr), byteCount, byteCount}
return *(*[]byte)(unsafe.Pointer(h))
}
func ioctl(fd int, cmd int, arg uintptr) (int, int) {
r0, _, e1 := syscall.Syscall(
syscall.SYS_IOCTL, uintptr(fd), uintptr(cmd), uintptr(arg))
val := int(r0)
errno := int(e1)
return val, errno
}
......@@ -283,6 +283,13 @@ func doRename(state *MountState, req *request) {
req.status = state.fileSystem.Rename(req.inHeader, (*RenameIn)(req.inData), req.filenames[0], req.filenames[1])
}
func doIoctl(state *MountState, req *request) {
out, data, stat := state.fileSystem.Ioctl(req.inHeader, (*IoctlIn)(req.inData))
req.outData = unsafe.Pointer(out)
req.flatData = data
req.status = stat
}
////////////////////////////////////////////////////////////////
type operationFunc func(*MountState, *request)
......
......@@ -464,3 +464,9 @@ func (me *FileSystemConnector) Read(input *ReadIn, bp *BufferPool) ([]byte, Stat
f, _ := me.getFile(input.Fh)
return f.Read(input, bp)
}
func (me *FileSystemConnector) Ioctl(header *InHeader, input *IoctlIn) (out *IoctlOut, data []byte, code Status) {
f, _ := me.getFile(input.Fh)
return f.Ioctl(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