Commit ff286a50 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

fuse: expose BackingFdMap

This prepares for extension to the passthrough support, in particular,
the ops_mask to be added to `struct fuse_backing_map`.

Change-Id: If4d7c321a5d09e9b2a3b804bd5e434aab394fe30
parent 17e27924
...@@ -14,29 +14,20 @@ const ( ...@@ -14,29 +14,20 @@ const (
_DEV_IOC_BACKING_CLOSE = 0x4004e502 _DEV_IOC_BACKING_CLOSE = 0x4004e502
) )
type backingMap struct {
Fd int32
Flags uint32
padding uint64
}
// RegisterBackingFd registers the given file descriptor in the // RegisterBackingFd registers the given file descriptor in the
// kernel, so the kernel can bypass FUSE and access the backing file // kernel, so the kernel can bypass FUSE and access the backing file
// directly for read and write calls. On success a backing ID is // directly for read and write calls. On success a backing ID is
// returned. The backing ID should unregistered using // returned. The backing ID should unregistered using
// UnregisterBackingFd() once the file is released. For now, the flags // UnregisterBackingFd() once the file is released. Within the
// argument is unused, and should be 0. // kernel, an inode can only have a single backing file, so multiple
func (ms *Server) RegisterBackingFd(fd int, flags uint32) (int32, syscall.Errno) { // Open/Create calls should coordinate to return a consistent backing
m := backingMap{ // ID.
Fd: int32(fd), func (ms *Server) RegisterBackingFd(m *BackingMap) (int32, syscall.Errno) {
Flags: flags,
}
ms.writeMu.Lock() ms.writeMu.Lock()
id, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(ms.mountFd), uintptr(_DEV_IOC_BACKING_OPEN), uintptr(unsafe.Pointer(&m))) id, _, errno := syscall.Syscall(syscall.SYS_IOCTL, uintptr(ms.mountFd), uintptr(_DEV_IOC_BACKING_OPEN), uintptr(unsafe.Pointer(m)))
ms.writeMu.Unlock() ms.writeMu.Unlock()
if ms.opts.Debug { if ms.opts.Debug {
ms.opts.Logger.Printf("ioctl: BACKING_OPEN %d (flags %x): id %d (%v)", fd, flags, id, errno) ms.opts.Logger.Printf("ioctl: BACKING_OPEN %v: id %d (%v)", m.string(), id, errno)
} }
return int32(id), errno return int32(id), errno
} }
......
...@@ -377,3 +377,7 @@ func (a *Attr) string() string { ...@@ -377,3 +377,7 @@ func (a *Attr) string() string {
a.Rdev, a.Ino, ft(a.Atime, a.Atimensec), ft(a.Mtime, a.Mtimensec), a.Rdev, a.Ino, ft(a.Atime, a.Atimensec), ft(a.Mtime, a.Mtimensec),
ft(a.Ctime, a.Ctimensec)) ft(a.Ctime, a.Ctimensec))
} }
func (m *BackingMap) string() string {
return fmt.Sprintf("{fd %d, flags 0x%x}", m.Fd, m.Flags)
}
...@@ -766,3 +766,10 @@ type WriteIn struct { ...@@ -766,3 +766,10 @@ type WriteIn struct {
Flags uint32 Flags uint32
Padding uint32 Padding uint32
} }
// Data for registering a file as backing an inode.
type BackingMap struct {
Fd int32
Flags uint32
padding uint64
}
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