Use package fuseshim in package fuseops.

geesefs-0-30-9
Aaron Jacobs 2015-07-23 16:21:14 +10:00
parent 81dee67b51
commit 4dc22ba2e7
4 changed files with 75 additions and 77 deletions

View File

@ -20,7 +20,7 @@ import (
"reflect"
"strings"
"github.com/jacobsa/bazilfuse"
"github.com/jacobsa/fuse/internal/fuseshim"
"github.com/jacobsa/reqtrace"
"golang.org/x/net/context"
)
@ -30,7 +30,7 @@ import (
type internalOp interface {
Op
// Respond to the underlying bazilfuse request, successfully.
// Respond to the underlying fuseshim request, successfully.
respond()
}
@ -42,8 +42,8 @@ type commonOp struct {
// The op in which this struct is embedded.
op internalOp
// The underlying bazilfuse request for this op.
bazilReq bazilfuse.Request
// The underlying fuseshim request for this op.
bazilReq fuseshim.Request
// A function that can be used to log debug information about the op. The
// first argument is a call depth.
@ -81,7 +81,7 @@ func (o *commonOp) ShortDesc() (desc string) {
func (o *commonOp) init(
ctx context.Context,
op internalOp,
bazilReq bazilfuse.Request,
bazilReq fuseshim.Request,
debugLog func(int, string, ...interface{}),
errorLogger *log.Logger,
finished func(error)) {
@ -122,7 +122,7 @@ func (o *commonOp) Respond(err error) {
// Report that the user is responding.
o.finished(err)
// If successful, we should respond to bazilfuse with the appropriate struct.
// If successful, we should respond to fuseshim with the appropriate struct.
if err == nil {
o.op.respond()
return

View File

@ -19,14 +19,12 @@ import (
"time"
"golang.org/x/net/context"
"github.com/jacobsa/bazilfuse"
)
// This function is an implementation detail of the fuse package, and must not
// be called by anyone else.
//
// Convert the supplied bazilfuse request struct to an Op. finished will be
// Convert the supplied fuseshim request struct to an Op. finished will be
// called with the error supplied to o.Respond when the user invokes that
// method, before a response is sent to the kernel.
//
@ -36,7 +34,7 @@ import (
// The debug logging function and error logger may be nil.
func Convert(
opCtx context.Context,
r bazilfuse.Request,
r fuseshim.Request,
debugLogForOp func(int, string, ...interface{}),
errorLogger *log.Logger,
finished func(error)) (o Op) {
@ -44,7 +42,7 @@ func Convert(
var io internalOp
switch typed := r.(type) {
case *bazilfuse.LookupRequest:
case *fuseshim.LookupRequest:
to := &LookUpInodeOp{
bfReq: typed,
Parent: InodeID(typed.Header.Node),
@ -53,7 +51,7 @@ func Convert(
io = to
co = &to.commonOp
case *bazilfuse.GetattrRequest:
case *fuseshim.GetattrRequest:
to := &GetInodeAttributesOp{
bfReq: typed,
Inode: InodeID(typed.Header.Node),
@ -61,32 +59,32 @@ func Convert(
io = to
co = &to.commonOp
case *bazilfuse.SetattrRequest:
case *fuseshim.SetattrRequest:
to := &SetInodeAttributesOp{
bfReq: typed,
Inode: InodeID(typed.Header.Node),
}
if typed.Valid&bazilfuse.SetattrSize != 0 {
if typed.Valid&fuseshim.SetattrSize != 0 {
to.Size = &typed.Size
}
if typed.Valid&bazilfuse.SetattrMode != 0 {
if typed.Valid&fuseshim.SetattrMode != 0 {
to.Mode = &typed.Mode
}
if typed.Valid&bazilfuse.SetattrAtime != 0 {
if typed.Valid&fuseshim.SetattrAtime != 0 {
to.Atime = &typed.Atime
}
if typed.Valid&bazilfuse.SetattrMtime != 0 {
if typed.Valid&fuseshim.SetattrMtime != 0 {
to.Mtime = &typed.Mtime
}
io = to
co = &to.commonOp
case *bazilfuse.ForgetRequest:
case *fuseshim.ForgetRequest:
to := &ForgetInodeOp{
bfReq: typed,
Inode: InodeID(typed.Header.Node),
@ -95,7 +93,7 @@ func Convert(
io = to
co = &to.commonOp
case *bazilfuse.MkdirRequest:
case *fuseshim.MkdirRequest:
to := &MkDirOp{
bfReq: typed,
Parent: InodeID(typed.Header.Node),
@ -105,7 +103,7 @@ func Convert(
io = to
co = &to.commonOp
case *bazilfuse.CreateRequest:
case *fuseshim.CreateRequest:
to := &CreateFileOp{
bfReq: typed,
Parent: InodeID(typed.Header.Node),
@ -116,7 +114,7 @@ func Convert(
io = to
co = &to.commonOp
case *bazilfuse.SymlinkRequest:
case *fuseshim.SymlinkRequest:
to := &CreateSymlinkOp{
bfReq: typed,
Parent: InodeID(typed.Header.Node),
@ -126,7 +124,7 @@ func Convert(
io = to
co = &to.commonOp
case *bazilfuse.RenameRequest:
case *fuseshim.RenameRequest:
to := &RenameOp{
bfReq: typed,
OldParent: InodeID(typed.Header.Node),
@ -137,7 +135,7 @@ func Convert(
io = to
co = &to.commonOp
case *bazilfuse.RemoveRequest:
case *fuseshim.RemoveRequest:
if typed.Dir {
to := &RmDirOp{
bfReq: typed,
@ -156,7 +154,7 @@ func Convert(
co = &to.commonOp
}
case *bazilfuse.OpenRequest:
case *fuseshim.OpenRequest:
if typed.Dir {
to := &OpenDirOp{
bfReq: typed,
@ -175,7 +173,7 @@ func Convert(
co = &to.commonOp
}
case *bazilfuse.ReadRequest:
case *fuseshim.ReadRequest:
if typed.Dir {
to := &ReadDirOp{
bfReq: typed,
@ -198,7 +196,7 @@ func Convert(
co = &to.commonOp
}
case *bazilfuse.ReleaseRequest:
case *fuseshim.ReleaseRequest:
if typed.Dir {
to := &ReleaseDirHandleOp{
bfReq: typed,
@ -215,7 +213,7 @@ func Convert(
co = &to.commonOp
}
case *bazilfuse.WriteRequest:
case *fuseshim.WriteRequest:
to := &WriteFileOp{
bfReq: typed,
Inode: InodeID(typed.Header.Node),
@ -226,7 +224,7 @@ func Convert(
io = to
co = &to.commonOp
case *bazilfuse.FsyncRequest:
case *fuseshim.FsyncRequest:
// We don't currently support this for directories.
if typed.Dir {
to := &unknownOp{}
@ -242,7 +240,7 @@ func Convert(
co = &to.commonOp
}
case *bazilfuse.FlushRequest:
case *fuseshim.FlushRequest:
to := &FlushFileOp{
bfReq: typed,
Inode: InodeID(typed.Header.Node),
@ -251,7 +249,7 @@ func Convert(
io = to
co = &to.commonOp
case *bazilfuse.ReadlinkRequest:
case *fuseshim.ReadlinkRequest:
to := &ReadSymlinkOp{
bfReq: typed,
Inode: InodeID(typed.Header.Node),
@ -280,8 +278,8 @@ func Convert(
func convertAttributes(
inode InodeID,
attr InodeAttributes,
expiration time.Time) bazilfuse.Attr {
return bazilfuse.Attr{
expiration time.Time) fuseshim.Attr {
return fuseshim.Attr{
Inode: uint64(inode),
Size: attr.Size,
Mode: attr.Mode,
@ -317,8 +315,8 @@ func convertExpirationTime(t time.Time) (d time.Duration) {
func convertChildInodeEntry(
in *ChildInodeEntry,
out *bazilfuse.LookupResponse) {
out.Node = bazilfuse.NodeID(in.Child)
out *fuseshim.LookupResponse) {
out.Node = fuseshim.NodeID(in.Child)
out.Generation = uint64(in.Generation)
out.Attr = convertAttributes(in.Child, in.Attributes, in.AttributesExpiration)
out.EntryValid = convertExpirationTime(in.EntryExpiration)

View File

@ -19,7 +19,7 @@ import (
"os"
"time"
"github.com/jacobsa/bazilfuse"
"github.com/jacobsa/fuse/internal/fuseshim"
"golang.org/x/net/context"
)
@ -55,7 +55,7 @@ type Op interface {
// when resolving user paths to dentry structs, which are then cached.
type LookUpInodeOp struct {
commonOp
bfReq *bazilfuse.LookupRequest
bfReq *fuseshim.LookupRequest
// The ID of the directory inode to which the child belongs.
Parent InodeID
@ -84,7 +84,7 @@ func (o *LookUpInodeOp) ShortDesc() (desc string) {
}
func (o *LookUpInodeOp) respond() {
resp := bazilfuse.LookupResponse{}
resp := fuseshim.LookupResponse{}
convertChildInodeEntry(&o.Entry, &resp)
o.bfReq.Respond(&resp)
@ -97,7 +97,7 @@ func (o *LookUpInodeOp) respond() {
// field of ChildInodeEntry, etc.
type GetInodeAttributesOp struct {
commonOp
bfReq *bazilfuse.GetattrRequest
bfReq *fuseshim.GetattrRequest
// The inode of interest.
Inode InodeID
@ -110,7 +110,7 @@ type GetInodeAttributesOp struct {
}
func (o *GetInodeAttributesOp) respond() {
resp := bazilfuse.GetattrResponse{
resp := fuseshim.GetattrResponse{
Attr: convertAttributes(o.Inode, o.Attributes, o.AttributesExpiration),
}
@ -124,7 +124,7 @@ func (o *GetInodeAttributesOp) respond() {
// cases like ftrunctate(2).
type SetInodeAttributesOp struct {
commonOp
bfReq *bazilfuse.SetattrRequest
bfReq *fuseshim.SetattrRequest
// The inode of interest.
Inode InodeID
@ -143,7 +143,7 @@ type SetInodeAttributesOp struct {
}
func (o *SetInodeAttributesOp) respond() {
resp := bazilfuse.SetattrResponse{
resp := fuseshim.SetattrResponse{
Attr: convertAttributes(o.Inode, o.Attributes, o.AttributesExpiration),
}
@ -192,7 +192,7 @@ func (o *SetInodeAttributesOp) respond() {
// implicitly decrementing all lookup counts to zero.
type ForgetInodeOp struct {
commonOp
bfReq *bazilfuse.ForgetRequest
bfReq *fuseshim.ForgetRequest
// The inode whose reference count should be decremented.
Inode InodeID
@ -223,7 +223,7 @@ func (o *ForgetInodeOp) respond() {
// Therefore the file system should return EEXIST if the name already exists.
type MkDirOp struct {
commonOp
bfReq *bazilfuse.MkdirRequest
bfReq *fuseshim.MkdirRequest
// The ID of parent directory inode within which to create the child.
Parent InodeID
@ -245,7 +245,7 @@ func (o *MkDirOp) ShortDesc() (desc string) {
}
func (o *MkDirOp) respond() {
resp := bazilfuse.MkdirResponse{}
resp := fuseshim.MkdirResponse{}
convertChildInodeEntry(&o.Entry, &resp.LookupResponse)
o.bfReq.Respond(&resp)
@ -264,7 +264,7 @@ func (o *MkDirOp) respond() {
// Therefore the file system should return EEXIST if the name already exists.
type CreateFileOp struct {
commonOp
bfReq *bazilfuse.CreateRequest
bfReq *fuseshim.CreateRequest
// The ID of parent directory inode within which to create the child file.
Parent InodeID
@ -274,7 +274,7 @@ type CreateFileOp struct {
Mode os.FileMode
// Flags for the open operation.
Flags bazilfuse.OpenFlags
Flags fuseshim.OpenFlags
// Set by the file system: information about the inode that was created.
//
@ -299,9 +299,9 @@ func (o *CreateFileOp) ShortDesc() (desc string) {
}
func (o *CreateFileOp) respond() {
resp := bazilfuse.CreateResponse{
OpenResponse: bazilfuse.OpenResponse{
Handle: bazilfuse.HandleID(o.Handle),
resp := fuseshim.CreateResponse{
OpenResponse: fuseshim.OpenResponse{
Handle: fuseshim.HandleID(o.Handle),
},
}
@ -315,7 +315,7 @@ func (o *CreateFileOp) respond() {
// return EEXIST (cf. the notes on CreateFileOp and MkDirOp).
type CreateSymlinkOp struct {
commonOp
bfReq *bazilfuse.SymlinkRequest
bfReq *fuseshim.SymlinkRequest
// The ID of parent directory inode within which to create the child symlink.
Parent InodeID
@ -345,7 +345,7 @@ func (o *CreateSymlinkOp) ShortDesc() (desc string) {
}
func (o *CreateSymlinkOp) respond() {
resp := bazilfuse.SymlinkResponse{}
resp := fuseshim.SymlinkResponse{}
convertChildInodeEntry(&o.Entry, &resp.LookupResponse)
o.bfReq.Respond(&resp)
@ -392,7 +392,7 @@ func (o *CreateSymlinkOp) respond() {
//
type RenameOp struct {
commonOp
bfReq *bazilfuse.RenameRequest
bfReq *fuseshim.RenameRequest
// The old parent directory, and the name of the entry within it to be
// relocated.
@ -419,7 +419,7 @@ func (o *RenameOp) respond() {
// Sample implementation in ext2: ext2_rmdir (http://goo.gl/B9QmFf)
type RmDirOp struct {
commonOp
bfReq *bazilfuse.RemoveRequest
bfReq *fuseshim.RemoveRequest
// The ID of parent directory inode, and the name of the directory being
// removed within it.
@ -440,7 +440,7 @@ func (o *RmDirOp) respond() {
// Sample implementation in ext2: ext2_unlink (http://goo.gl/hY6r6C)
type UnlinkOp struct {
commonOp
bfReq *bazilfuse.RemoveRequest
bfReq *fuseshim.RemoveRequest
// The ID of parent directory inode, and the name of the entry being removed
// within it.
@ -465,13 +465,13 @@ func (o *UnlinkOp) respond() {
// https://github.com/osxfuse/osxfuse/issues/199).
type OpenDirOp struct {
commonOp
bfReq *bazilfuse.OpenRequest
bfReq *fuseshim.OpenRequest
// The ID of the inode to be opened.
Inode InodeID
// Mode and options flags.
Flags bazilfuse.OpenFlags
Flags fuseshim.OpenFlags
// Set by the file system: an opaque ID that will be echoed in follow-up
// calls for this directory using the same struct file in the kernel. In
@ -485,8 +485,8 @@ type OpenDirOp struct {
}
func (o *OpenDirOp) respond() {
resp := bazilfuse.OpenResponse{
Handle: bazilfuse.HandleID(o.Handle),
resp := fuseshim.OpenResponse{
Handle: fuseshim.HandleID(o.Handle),
}
o.bfReq.Respond(&resp)
@ -496,7 +496,7 @@ func (o *OpenDirOp) respond() {
// Read entries from a directory previously opened with OpenDir.
type ReadDirOp struct {
commonOp
bfReq *bazilfuse.ReadRequest
bfReq *fuseshim.ReadRequest
// The directory inode that we are reading, and the handle previously
// returned by OpenDir when opening that inode.
@ -585,7 +585,7 @@ type ReadDirOp struct {
}
func (o *ReadDirOp) respond() {
resp := bazilfuse.ReadResponse{
resp := fuseshim.ReadResponse{
Data: o.Data,
}
@ -603,7 +603,7 @@ func (o *ReadDirOp) respond() {
// Errors from this op are ignored by the kernel (cf. http://goo.gl/RL38Do).
type ReleaseDirHandleOp struct {
commonOp
bfReq *bazilfuse.ReleaseRequest
bfReq *fuseshim.ReleaseRequest
// The handle ID to be released. The kernel guarantees that this ID will not
// be used in further calls to the file system (unless it is reissued by the
@ -628,13 +628,13 @@ func (o *ReleaseDirHandleOp) respond() {
// (cf.https://github.com/osxfuse/osxfuse/issues/199).
type OpenFileOp struct {
commonOp
bfReq *bazilfuse.OpenRequest
bfReq *fuseshim.OpenRequest
// The ID of the inode to be opened.
Inode InodeID
// Mode and options flags.
Flags bazilfuse.OpenFlags
Flags fuseshim.OpenFlags
// An opaque ID that will be echoed in follow-up calls for this file using
// the same struct file in the kernel. In practice this usually means
@ -647,8 +647,8 @@ type OpenFileOp struct {
}
func (o *OpenFileOp) respond() {
resp := bazilfuse.OpenResponse{
Handle: bazilfuse.HandleID(o.Handle),
resp := fuseshim.OpenResponse{
Handle: fuseshim.HandleID(o.Handle),
}
o.bfReq.Respond(&resp)
@ -662,7 +662,7 @@ func (o *OpenFileOp) respond() {
// more.
type ReadFileOp struct {
commonOp
bfReq *bazilfuse.ReadRequest
bfReq *fuseshim.ReadRequest
// The file inode that we are reading, and the handle previously returned by
// CreateFile or OpenFile when opening that inode.
@ -686,7 +686,7 @@ type ReadFileOp struct {
}
func (o *ReadFileOp) respond() {
resp := bazilfuse.ReadResponse{
resp := fuseshim.ReadResponse{
Data: o.Data,
}
@ -727,7 +727,7 @@ func (o *ReadFileOp) respond() {
// concurrent requests".)
type WriteFileOp struct {
commonOp
bfReq *bazilfuse.WriteRequest
bfReq *fuseshim.WriteRequest
// The file inode that we are modifying, and the handle previously returned
// by CreateFile or OpenFile when opening that inode.
@ -766,7 +766,7 @@ type WriteFileOp struct {
}
func (o *WriteFileOp) respond() {
resp := bazilfuse.WriteResponse{
resp := fuseshim.WriteResponse{
Size: len(o.Data),
}
@ -792,7 +792,7 @@ func (o *WriteFileOp) respond() {
// file (but which is not used in "real" file systems).
type SyncFileOp struct {
commonOp
bfReq *bazilfuse.FsyncRequest
bfReq *fuseshim.FsyncRequest
// The file and handle being sync'd.
Inode InodeID
@ -853,7 +853,7 @@ func (o *SyncFileOp) respond() {
// return any errors that occur.
type FlushFileOp struct {
commonOp
bfReq *bazilfuse.FlushRequest
bfReq *fuseshim.FlushRequest
// The file and handle being flushed.
Inode InodeID
@ -875,7 +875,7 @@ func (o *FlushFileOp) respond() {
// Errors from this op are ignored by the kernel (cf. http://goo.gl/RL38Do).
type ReleaseFileHandleOp struct {
commonOp
bfReq *bazilfuse.ReleaseRequest
bfReq *fuseshim.ReleaseRequest
// The handle ID to be released. The kernel guarantees that this ID will not
// be used in further calls to the file system (unless it is reissued by the
@ -910,7 +910,7 @@ func (o *unknownOp) respond() {
// Read the target of a symlink inode.
type ReadSymlinkOp struct {
commonOp
bfReq *bazilfuse.ReadlinkRequest
bfReq *fuseshim.ReadlinkRequest
// The symlink inode that we are reading.
Inode InodeID

View File

@ -19,7 +19,7 @@ import (
"os"
"time"
"github.com/jacobsa/bazilfuse"
"github.com/jacobsa/fuse/internal/fuseshim"
)
// A 64-bit number used to uniquely identify a file or directory in the file
@ -38,7 +38,7 @@ const RootInodeID = 1
func init() {
// Make sure the constant above is correct. We do this at runtime rather than
// defining the constant in terms of bazilfuse.RootID for two reasons:
// defining the constant in terms of fuseshim.RootID for two reasons:
//
// 1. Users can more clearly see that the root ID is low and can therefore
// be used as e.g. an array index, with space reserved up to the root.
@ -46,12 +46,12 @@ func init() {
// 2. The constant can be untyped and can therefore more easily be used as
// an array index.
//
if RootInodeID != bazilfuse.RootID {
if RootInodeID != fuseshim.RootID {
panic(
fmt.Sprintf(
"Oops, RootInodeID is wrong: %v vs. %v",
RootInodeID,
bazilfuse.RootID))
fuseshim.RootID))
}
}