Fixed several issues that only showed up on Linux.

geesefs-0-30-9
Aaron Jacobs 2015-07-24 13:24:12 +10:00
commit 27eba3068c
4 changed files with 51 additions and 31 deletions

View File

@ -57,15 +57,17 @@ func Convert(
} }
to := &LookUpInodeOp{ to := &LookUpInodeOp{
Parent: InodeID(m.Hdr.Nodeid), protocol: protocol,
Name: string(buf[:n-1]), Parent: InodeID(m.Hdr.Nodeid),
Name: string(buf[:n-1]),
} }
io = to io = to
co = &to.commonOp co = &to.commonOp
case fusekernel.OpGetattr: case fusekernel.OpGetattr:
to := &GetInodeAttributesOp{ to := &GetInodeAttributesOp{
Inode: InodeID(m.Hdr.Nodeid), protocol: protocol,
Inode: InodeID(m.Hdr.Nodeid),
} }
io = to io = to
co = &to.commonOp co = &to.commonOp
@ -78,7 +80,8 @@ func Convert(
} }
to := &SetInodeAttributesOp{ to := &SetInodeAttributesOp{
Inode: InodeID(m.Hdr.Nodeid), protocol: protocol,
Inode: InodeID(m.Hdr.Nodeid),
} }
valid := fusekernel.SetattrValid(in.Valid) valid := fusekernel.SetattrValid(in.Valid)
@ -134,10 +137,19 @@ func Convert(
name = name[:i] name = name[:i]
to := &MkDirOp{ to := &MkDirOp{
Parent: InodeID(m.Hdr.Nodeid), protocol: protocol,
Name: string(name), Parent: InodeID(m.Hdr.Nodeid),
Mode: fuseshim.FileMode(in.Mode), Name: string(name),
// On Linux, vfs_mkdir calls through to the inode with at most
// permissions and sticky bits set (cf. https://goo.gl/WxgQXk), and fuse
// passes that on directly (cf. https://goo.gl/f31aMo). In other words,
// the fact that this is a directory is implicit in the fact that the
// opcode is mkdir. But we want the correct mode to go through, so ensure
// that os.ModeDir is set.
Mode: fuseshim.FileMode(in.Mode) | os.ModeDir,
} }
io = to io = to
co = &to.commonOp co = &to.commonOp
@ -157,9 +169,10 @@ func Convert(
name = name[:i] name = name[:i]
to := &CreateFileOp{ to := &CreateFileOp{
Parent: InodeID(m.Hdr.Nodeid), protocol: protocol,
Name: string(name), Parent: InodeID(m.Hdr.Nodeid),
Mode: fuseshim.FileMode(in.Mode), Name: string(name),
Mode: fuseshim.FileMode(in.Mode),
} }
io = to io = to
co = &to.commonOp co = &to.commonOp
@ -179,9 +192,10 @@ func Convert(
newName, target := names[0:i], names[i+1:len(names)-1] newName, target := names[0:i], names[i+1:len(names)-1]
to := &CreateSymlinkOp{ to := &CreateSymlinkOp{
Parent: InodeID(m.Hdr.Nodeid), protocol: protocol,
Name: string(newName), Parent: InodeID(m.Hdr.Nodeid),
Target: string(target), Name: string(newName),
Target: string(target),
} }
io = to io = to
co = &to.commonOp co = &to.commonOp

View File

@ -60,6 +60,7 @@ type Op interface {
// when resolving user paths to dentry structs, which are then cached. // when resolving user paths to dentry structs, which are then cached.
type LookUpInodeOp struct { type LookUpInodeOp struct {
commonOp commonOp
protocol fusekernel.Protocol
// The ID of the directory inode to which the child belongs. // The ID of the directory inode to which the child belongs.
Parent InodeID Parent InodeID
@ -88,7 +89,7 @@ func (o *LookUpInodeOp) ShortDesc() (desc string) {
} }
func (o *LookUpInodeOp) kernelResponse() (msg []byte) { func (o *LookUpInodeOp) kernelResponse() (msg []byte) {
size := fusekernel.EntryOutSize(fusekernel.Protocol{0, 0}) size := fusekernel.EntryOutSize(o.protocol)
buf := fuseshim.NewBuffer(size) buf := fuseshim.NewBuffer(size)
out := (*fusekernel.EntryOut)(buf.Alloc(size)) out := (*fusekernel.EntryOut)(buf.Alloc(size))
convertChildInodeEntry(&o.Entry, out) convertChildInodeEntry(&o.Entry, out)
@ -103,6 +104,7 @@ func (o *LookUpInodeOp) kernelResponse() (msg []byte) {
// field of ChildInodeEntry, etc. // field of ChildInodeEntry, etc.
type GetInodeAttributesOp struct { type GetInodeAttributesOp struct {
commonOp commonOp
protocol fusekernel.Protocol
// The inode of interest. // The inode of interest.
Inode InodeID Inode InodeID
@ -123,7 +125,7 @@ func (o *GetInodeAttributesOp) DebugString() string {
} }
func (o *GetInodeAttributesOp) kernelResponse() (msg []byte) { func (o *GetInodeAttributesOp) kernelResponse() (msg []byte) {
size := fusekernel.AttrOutSize(fusekernel.Protocol{0, 0}) size := fusekernel.AttrOutSize(o.protocol)
buf := fuseshim.NewBuffer(size) buf := fuseshim.NewBuffer(size)
out := (*fusekernel.AttrOut)(buf.Alloc(size)) out := (*fusekernel.AttrOut)(buf.Alloc(size))
out.AttrValid, out.AttrValidNsec = convertExpirationTime(o.AttributesExpiration) out.AttrValid, out.AttrValidNsec = convertExpirationTime(o.AttributesExpiration)
@ -139,6 +141,7 @@ func (o *GetInodeAttributesOp) kernelResponse() (msg []byte) {
// cases like ftrunctate(2). // cases like ftrunctate(2).
type SetInodeAttributesOp struct { type SetInodeAttributesOp struct {
commonOp commonOp
protocol fusekernel.Protocol
// The inode of interest. // The inode of interest.
Inode InodeID Inode InodeID
@ -157,7 +160,7 @@ type SetInodeAttributesOp struct {
} }
func (o *SetInodeAttributesOp) kernelResponse() (msg []byte) { func (o *SetInodeAttributesOp) kernelResponse() (msg []byte) {
size := fusekernel.AttrOutSize(fusekernel.Protocol{0, 0}) size := fusekernel.AttrOutSize(o.protocol)
buf := fuseshim.NewBuffer(size) buf := fuseshim.NewBuffer(size)
out := (*fusekernel.AttrOut)(buf.Alloc(size)) out := (*fusekernel.AttrOut)(buf.Alloc(size))
out.AttrValid, out.AttrValidNsec = convertExpirationTime(o.AttributesExpiration) out.AttrValid, out.AttrValidNsec = convertExpirationTime(o.AttributesExpiration)
@ -238,6 +241,7 @@ func (o *ForgetInodeOp) kernelResponse() (msg []byte) {
// Therefore the file system should return EEXIST if the name already exists. // Therefore the file system should return EEXIST if the name already exists.
type MkDirOp struct { type MkDirOp struct {
commonOp commonOp
protocol fusekernel.Protocol
// The ID of parent directory inode within which to create the child. // The ID of parent directory inode within which to create the child.
Parent InodeID Parent InodeID
@ -259,7 +263,7 @@ func (o *MkDirOp) ShortDesc() (desc string) {
} }
func (o *MkDirOp) kernelResponse() (msg []byte) { func (o *MkDirOp) kernelResponse() (msg []byte) {
size := fusekernel.EntryOutSize(fusekernel.Protocol{0, 0}) size := fusekernel.EntryOutSize(o.protocol)
buf := fuseshim.NewBuffer(size) buf := fuseshim.NewBuffer(size)
out := (*fusekernel.EntryOut)(buf.Alloc(size)) out := (*fusekernel.EntryOut)(buf.Alloc(size))
convertChildInodeEntry(&o.Entry, out) convertChildInodeEntry(&o.Entry, out)
@ -280,6 +284,7 @@ func (o *MkDirOp) kernelResponse() (msg []byte) {
// Therefore the file system should return EEXIST if the name already exists. // Therefore the file system should return EEXIST if the name already exists.
type CreateFileOp struct { type CreateFileOp struct {
commonOp commonOp
protocol fusekernel.Protocol
// The ID of parent directory inode within which to create the child file. // The ID of parent directory inode within which to create the child file.
Parent InodeID Parent InodeID
@ -311,7 +316,7 @@ func (o *CreateFileOp) ShortDesc() (desc string) {
} }
func (o *CreateFileOp) kernelResponse() (msg []byte) { func (o *CreateFileOp) kernelResponse() (msg []byte) {
eSize := fusekernel.EntryOutSize(fusekernel.Protocol{0, 0}) eSize := fusekernel.EntryOutSize(o.protocol)
buf := fuseshim.NewBuffer(eSize + unsafe.Sizeof(fusekernel.OpenOut{})) buf := fuseshim.NewBuffer(eSize + unsafe.Sizeof(fusekernel.OpenOut{}))
e := (*fusekernel.EntryOut)(buf.Alloc(eSize)) e := (*fusekernel.EntryOut)(buf.Alloc(eSize))
@ -328,6 +333,7 @@ func (o *CreateFileOp) kernelResponse() (msg []byte) {
// return EEXIST (cf. the notes on CreateFileOp and MkDirOp). // return EEXIST (cf. the notes on CreateFileOp and MkDirOp).
type CreateSymlinkOp struct { type CreateSymlinkOp struct {
commonOp commonOp
protocol fusekernel.Protocol
// The ID of parent directory inode within which to create the child symlink. // The ID of parent directory inode within which to create the child symlink.
Parent InodeID Parent InodeID
@ -357,7 +363,7 @@ func (o *CreateSymlinkOp) ShortDesc() (desc string) {
} }
func (o *CreateSymlinkOp) kernelResponse() (msg []byte) { func (o *CreateSymlinkOp) kernelResponse() (msg []byte) {
size := fusekernel.EntryOutSize(fusekernel.Protocol{0, 0}) size := fusekernel.EntryOutSize(o.protocol)
buf := fuseshim.NewBuffer(size) buf := fuseshim.NewBuffer(size)
out := (*fusekernel.EntryOut)(buf.Alloc(size)) out := (*fusekernel.EntryOut)(buf.Alloc(size))
convertChildInodeEntry(&o.Entry, out) convertChildInodeEntry(&o.Entry, out)

View File

@ -1,8 +1,8 @@
package fuseshim package fusekernel
import "time" import "time"
type attr struct { type Attr struct {
Ino uint64 Ino uint64
Size uint64 Size uint64
Blocks uint64 Blocks uint64
@ -21,31 +21,31 @@ type attr struct {
padding uint32 padding uint32
} }
func (a *attr) Crtime() time.Time { func (a *Attr) Crtime() time.Time {
return time.Time{} return time.Time{}
} }
func (a *attr) SetCrtime(s uint64, ns uint32) { func (a *Attr) SetCrtime(s uint64, ns uint32) {
// Ignored on Linux. // Ignored on Linux.
} }
func (a *attr) SetFlags(f uint32) { func (a *Attr) SetFlags(f uint32) {
// Ignored on Linux. // Ignored on Linux.
} }
type setattrIn struct { type SetattrIn struct {
setattrInCommon setattrInCommon
} }
func (in *setattrIn) BkupTime() time.Time { func (in *SetattrIn) BkupTime() time.Time {
return time.Time{} return time.Time{}
} }
func (in *setattrIn) Chgtime() time.Time { func (in *SetattrIn) Chgtime() time.Time {
return time.Time{} return time.Time{}
} }
func (in *setattrIn) Flags() uint32 { func (in *SetattrIn) Flags() uint32 {
return 0 return 0
} }
@ -61,10 +61,10 @@ func openFlags(flags uint32) OpenFlags {
return OpenFlags(flags) return OpenFlags(flags)
} }
type getxattrIn struct { type GetxattrIn struct {
getxattrInCommon getxattrInCommon
} }
type setxattrIn struct { type SetxattrIn struct {
setxattrInCommon setxattrInCommon
} }

View File

@ -1,4 +1,4 @@
package bazilfuse package fuseshim
import ( import (
"bytes" "bytes"