Made everything an op.
parent
2dfd8be146
commit
aba4e37d40
187
fuseops/ops.go
187
fuseops/ops.go
|
@ -63,6 +63,8 @@ func (o *InitOp) Respond(err error) {
|
||||||
// Look up a child by name within a parent directory. The kernel sends this
|
// Look up a child by name within a parent directory. The kernel sends this
|
||||||
// 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
|
||||||
|
|
||||||
// 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
|
||||||
|
|
||||||
|
@ -81,11 +83,22 @@ type LookUpInodeOp struct {
|
||||||
Entry ChildInodeEntry
|
Entry ChildInodeEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *LookUpInodeOp) Respond(err error) {
|
||||||
|
if err != nil {
|
||||||
|
o.commonOp.respondErr(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
||||||
// Refresh the attributes for an inode whose ID was previously returned in a
|
// Refresh the attributes for an inode whose ID was previously returned in a
|
||||||
// LookUpInodeOp. The kernel sends this when the FUSE VFS layer's cache of
|
// LookUpInodeOp. The kernel sends this when the FUSE VFS layer's cache of
|
||||||
// inode attributes is stale. This is controlled by the AttributesExpiration
|
// inode attributes is stale. This is controlled by the AttributesExpiration
|
||||||
// field of ChildInodeEntry, etc.
|
// field of ChildInodeEntry, etc.
|
||||||
type GetInodeAttributesOp struct {
|
type GetInodeAttributesOp struct {
|
||||||
|
commonOp
|
||||||
|
|
||||||
// The inode of interest.
|
// The inode of interest.
|
||||||
Inode InodeID
|
Inode InodeID
|
||||||
|
|
||||||
|
@ -96,11 +109,22 @@ type GetInodeAttributesOp struct {
|
||||||
AttributesExpiration time.Time
|
AttributesExpiration time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *GetInodeAttributesOp) Respond(err error) {
|
||||||
|
if err != nil {
|
||||||
|
o.commonOp.respondErr(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
||||||
// Change attributes for an inode.
|
// Change attributes for an inode.
|
||||||
//
|
//
|
||||||
// The kernel sends this for obvious cases like chmod(2), and for less obvious
|
// The kernel sends this for obvious cases like chmod(2), and for less obvious
|
||||||
// cases like ftrunctate(2).
|
// cases like ftrunctate(2).
|
||||||
type SetInodeAttributesOp struct {
|
type SetInodeAttributesOp struct {
|
||||||
|
commonOp
|
||||||
|
|
||||||
// The inode of interest.
|
// The inode of interest.
|
||||||
Inode InodeID
|
Inode InodeID
|
||||||
|
|
||||||
|
@ -117,15 +141,35 @@ type SetInodeAttributesOp struct {
|
||||||
AttributesExpiration time.Time
|
AttributesExpiration time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *SetInodeAttributesOp) Respond(err error) {
|
||||||
|
if err != nil {
|
||||||
|
o.commonOp.respondErr(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
||||||
// Forget an inode ID previously issued (e.g. by LookUpInode or MkDir). The
|
// Forget an inode ID previously issued (e.g. by LookUpInode or MkDir). The
|
||||||
// kernel sends this when removing an inode from its internal caches.
|
// kernel sends this when removing an inode from its internal caches.
|
||||||
type ForgetInodeOp struct {
|
type ForgetInodeOp struct {
|
||||||
|
commonOp
|
||||||
|
|
||||||
// The inode to be forgotten. The kernel guarantees that the node ID will not
|
// The inode to be forgotten. The kernel guarantees that the node ID will not
|
||||||
// be used in further calls to the file system (unless it is reissued by the
|
// be used in further calls to the file system (unless it is reissued by the
|
||||||
// file system).
|
// file system).
|
||||||
ID InodeID
|
ID InodeID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *ForgetInodeOp) Respond(err error) {
|
||||||
|
if err != nil {
|
||||||
|
o.commonOp.respondErr(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Inode creation
|
// Inode creation
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -138,6 +182,8 @@ type ForgetInodeOp struct {
|
||||||
// http://goo.gl/FZpLu5). But volatile file systems and paranoid non-volatile
|
// http://goo.gl/FZpLu5). But volatile file systems and paranoid non-volatile
|
||||||
// file systems should check for the reasons described below on CreateFile.
|
// file systems should check for the reasons described below on CreateFile.
|
||||||
type MkDirOp struct {
|
type MkDirOp struct {
|
||||||
|
commonOp
|
||||||
|
|
||||||
// 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
|
||||||
|
|
||||||
|
@ -149,6 +195,15 @@ type MkDirOp struct {
|
||||||
Entry ChildInodeEntry
|
Entry ChildInodeEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *MkDirOp) Respond(err error) {
|
||||||
|
if err != nil {
|
||||||
|
o.commonOp.respondErr(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
||||||
// Create a file inode and open it.
|
// Create a file inode and open it.
|
||||||
//
|
//
|
||||||
// The kernel sends this when the user asks to open a file with the O_CREAT
|
// The kernel sends this when the user asks to open a file with the O_CREAT
|
||||||
|
@ -163,6 +218,8 @@ type MkDirOp struct {
|
||||||
// course particularly applies to file systems that are volatile from the
|
// course particularly applies to file systems that are volatile from the
|
||||||
// kernel's point of view.
|
// kernel's point of view.
|
||||||
type CreateFileOp struct {
|
type CreateFileOp struct {
|
||||||
|
commonOp
|
||||||
|
|
||||||
// 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
|
||||||
|
|
||||||
|
@ -187,6 +244,15 @@ type CreateFileOp struct {
|
||||||
Handle HandleID
|
Handle HandleID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *CreateFileOp) Respond(err error) {
|
||||||
|
if err != nil {
|
||||||
|
o.commonOp.respondErr(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Unlinking
|
// Unlinking
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -199,24 +265,46 @@ type CreateFileOp struct {
|
||||||
//
|
//
|
||||||
// Sample implementation in ext2: ext2_rmdir (http://goo.gl/B9QmFf)
|
// Sample implementation in ext2: ext2_rmdir (http://goo.gl/B9QmFf)
|
||||||
type RmDirOp struct {
|
type RmDirOp struct {
|
||||||
|
commonOp
|
||||||
|
|
||||||
// The ID of parent directory inode, and the name of the directory being
|
// The ID of parent directory inode, and the name of the directory being
|
||||||
// removed within it.
|
// removed within it.
|
||||||
Parent InodeID
|
Parent InodeID
|
||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *RmDirOp) Respond(err error) {
|
||||||
|
if err != nil {
|
||||||
|
o.commonOp.respondErr(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
||||||
// Unlink a file from its parent. If this brings the inode's link count to
|
// Unlink a file from its parent. If this brings the inode's link count to
|
||||||
// zero, the inode should be deleted once the kernel sends ForgetInodeOp. It
|
// zero, the inode should be deleted once the kernel sends ForgetInodeOp. It
|
||||||
// may still be referenced before then if a user still has the file open.
|
// may still be referenced before then if a user still has the file open.
|
||||||
//
|
//
|
||||||
// Sample implementation in ext2: ext2_unlink (http://goo.gl/hY6r6C)
|
// Sample implementation in ext2: ext2_unlink (http://goo.gl/hY6r6C)
|
||||||
type UnlinkOp struct {
|
type UnlinkOp struct {
|
||||||
|
commonOp
|
||||||
|
|
||||||
// The ID of parent directory inode, and the name of the file being removed
|
// The ID of parent directory inode, and the name of the file being removed
|
||||||
// within it.
|
// within it.
|
||||||
Parent InodeID
|
Parent InodeID
|
||||||
Name string
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *UnlinkOp) Respond(err error) {
|
||||||
|
if err != nil {
|
||||||
|
o.commonOp.respondErr(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Directory handles
|
// Directory handles
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -228,6 +316,8 @@ type UnlinkOp struct {
|
||||||
// user-space process. On OS X it may not be sent for every open(2) (cf.
|
// user-space process. On OS X it may not be sent for every open(2) (cf.
|
||||||
// https://github.com/osxfuse/osxfuse/issues/199).
|
// https://github.com/osxfuse/osxfuse/issues/199).
|
||||||
type OpenDirOp struct {
|
type OpenDirOp struct {
|
||||||
|
commonOp
|
||||||
|
|
||||||
// The ID of the inode to be opened.
|
// The ID of the inode to be opened.
|
||||||
Inode InodeID
|
Inode InodeID
|
||||||
|
|
||||||
|
@ -245,8 +335,19 @@ type OpenDirOp struct {
|
||||||
Handle HandleID
|
Handle HandleID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *OpenDirOp) Respond(err error) {
|
||||||
|
if err != nil {
|
||||||
|
o.commonOp.respondErr(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
||||||
// Read entries from a directory previously opened with OpenDir.
|
// Read entries from a directory previously opened with OpenDir.
|
||||||
type ReadDirOp struct {
|
type ReadDirOp struct {
|
||||||
|
commonOp
|
||||||
|
|
||||||
// The directory inode that we are reading, and the handle previously
|
// The directory inode that we are reading, and the handle previously
|
||||||
// returned by OpenDir when opening that inode.
|
// returned by OpenDir when opening that inode.
|
||||||
Inode InodeID
|
Inode InodeID
|
||||||
|
@ -333,6 +434,15 @@ type ReadDirOp struct {
|
||||||
Data []byte
|
Data []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *ReadDirOp) Respond(err error) {
|
||||||
|
if err != nil {
|
||||||
|
o.commonOp.respondErr(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
||||||
// Release a previously-minted directory handle. The kernel sends this when
|
// Release a previously-minted directory handle. The kernel sends this when
|
||||||
// there are no more references to an open directory: all file descriptors are
|
// there are no more references to an open directory: all file descriptors are
|
||||||
// closed and all memory mappings are unmapped.
|
// closed and all memory mappings are unmapped.
|
||||||
|
@ -340,12 +450,23 @@ type ReadDirOp struct {
|
||||||
// The kernel guarantees that the handle ID will not be used in further ops
|
// The kernel guarantees that the handle ID will not be used in further ops
|
||||||
// sent to the file system (unless it is reissued by the file system).
|
// sent to the file system (unless it is reissued by the file system).
|
||||||
type ReleaseDirHandleOp struct {
|
type ReleaseDirHandleOp struct {
|
||||||
|
commonOp
|
||||||
|
|
||||||
// The handle ID to be released. The kernel guarantees that this ID will not
|
// 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
|
// be used in further calls to the file system (unless it is reissued by the
|
||||||
// file system).
|
// file system).
|
||||||
Handle HandleID
|
Handle HandleID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *ReleaseDirHandleOp) Respond(err error) {
|
||||||
|
if err != nil {
|
||||||
|
o.commonOp.respondErr(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// File handles
|
// File handles
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -357,6 +478,8 @@ type ReleaseDirHandleOp struct {
|
||||||
// process. On OS X it may not be sent for every open(2)
|
// process. On OS X it may not be sent for every open(2)
|
||||||
// (cf.https://github.com/osxfuse/osxfuse/issues/199).
|
// (cf.https://github.com/osxfuse/osxfuse/issues/199).
|
||||||
type OpenFileOp struct {
|
type OpenFileOp struct {
|
||||||
|
commonOp
|
||||||
|
|
||||||
// The ID of the inode to be opened.
|
// The ID of the inode to be opened.
|
||||||
Inode InodeID
|
Inode InodeID
|
||||||
|
|
||||||
|
@ -373,12 +496,23 @@ type OpenFileOp struct {
|
||||||
Handle HandleID
|
Handle HandleID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *OpenFileOp) Respond(err error) {
|
||||||
|
if err != nil {
|
||||||
|
o.commonOp.respondErr(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
||||||
// Read data from a file previously opened with CreateFile or OpenFile.
|
// Read data from a file previously opened with CreateFile or OpenFile.
|
||||||
//
|
//
|
||||||
// Note that this op is not sent for every call to read(2) by the end user;
|
// Note that this op is not sent for every call to read(2) by the end user;
|
||||||
// some reads may be served by the page cache. See notes on WriteFileOp for
|
// some reads may be served by the page cache. See notes on WriteFileOp for
|
||||||
// more.
|
// more.
|
||||||
type ReadFileOp struct {
|
type ReadFileOp struct {
|
||||||
|
commonOp
|
||||||
|
|
||||||
// The file inode that we are reading, and the handle previously returned by
|
// The file inode that we are reading, and the handle previously returned by
|
||||||
// CreateFile or OpenFile when opening that inode.
|
// CreateFile or OpenFile when opening that inode.
|
||||||
Inode InodeID
|
Inode InodeID
|
||||||
|
@ -400,6 +534,15 @@ type ReadFileOp struct {
|
||||||
Data []byte
|
Data []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *ReadFileOp) Respond(err error) {
|
||||||
|
if err != nil {
|
||||||
|
o.commonOp.respondErr(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
||||||
// Write data to a file previously opened with CreateFile or OpenFile.
|
// Write data to a file previously opened with CreateFile or OpenFile.
|
||||||
//
|
//
|
||||||
// When the user writes data using write(2), the write goes into the page
|
// When the user writes data using write(2), the write goes into the page
|
||||||
|
@ -429,6 +572,8 @@ type ReadFileOp struct {
|
||||||
// flush request.
|
// flush request.
|
||||||
//
|
//
|
||||||
type WriteFileOp struct {
|
type WriteFileOp struct {
|
||||||
|
commonOp
|
||||||
|
|
||||||
// The file inode that we are modifying, and the handle previously returned
|
// The file inode that we are modifying, and the handle previously returned
|
||||||
// by CreateFile or OpenFile when opening that inode.
|
// by CreateFile or OpenFile when opening that inode.
|
||||||
Inode InodeID
|
Inode InodeID
|
||||||
|
@ -465,6 +610,15 @@ type WriteFileOp struct {
|
||||||
Data []byte
|
Data []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *WriteFileOp) Respond(err error) {
|
||||||
|
if err != nil {
|
||||||
|
o.commonOp.respondErr(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
||||||
// Synchronize the current contents of an open file to storage.
|
// Synchronize the current contents of an open file to storage.
|
||||||
//
|
//
|
||||||
// vfs.txt documents this as being called for by the fsync(2) system call
|
// vfs.txt documents this as being called for by the fsync(2) system call
|
||||||
|
@ -482,11 +636,22 @@ type WriteFileOp struct {
|
||||||
// See also: FlushFileOp, which may perform a similar function when closing a
|
// See also: FlushFileOp, which may perform a similar function when closing a
|
||||||
// file (but which is not used in "real" file systems).
|
// file (but which is not used in "real" file systems).
|
||||||
type SyncFileOp struct {
|
type SyncFileOp struct {
|
||||||
|
commonOp
|
||||||
|
|
||||||
// The file and handle being sync'd.
|
// The file and handle being sync'd.
|
||||||
Inode InodeID
|
Inode InodeID
|
||||||
Handle HandleID
|
Handle HandleID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *SyncFileOp) Respond(err error) {
|
||||||
|
if err != nil {
|
||||||
|
o.commonOp.respondErr(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
||||||
// Flush the current state of an open file to storage upon closing a file
|
// Flush the current state of an open file to storage upon closing a file
|
||||||
// descriptor.
|
// descriptor.
|
||||||
//
|
//
|
||||||
|
@ -535,11 +700,22 @@ type SyncFileOp struct {
|
||||||
// to at least schedule a real flush, and maybe do it immediately in order to
|
// to at least schedule a real flush, and maybe do it immediately in order to
|
||||||
// return any errors that occur.
|
// return any errors that occur.
|
||||||
type FlushFileOp struct {
|
type FlushFileOp struct {
|
||||||
|
commonOp
|
||||||
|
|
||||||
// The file and handle being flushed.
|
// The file and handle being flushed.
|
||||||
Inode InodeID
|
Inode InodeID
|
||||||
Handle HandleID
|
Handle HandleID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *FlushFileOp) Respond(err error) {
|
||||||
|
if err != nil {
|
||||||
|
o.commonOp.respondErr(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
||||||
// Release a previously-minted file handle. The kernel calls this when there
|
// Release a previously-minted file handle. The kernel calls this when there
|
||||||
// are no more references to an open file: all file descriptors are closed
|
// are no more references to an open file: all file descriptors are closed
|
||||||
// and all memory mappings are unmapped.
|
// and all memory mappings are unmapped.
|
||||||
|
@ -547,8 +723,19 @@ type FlushFileOp struct {
|
||||||
// The kernel guarantees that the handle ID will not be used in further calls
|
// The kernel guarantees that the handle ID will not be used in further calls
|
||||||
// to the file system (unless it is reissued by the file system).
|
// to the file system (unless it is reissued by the file system).
|
||||||
type ReleaseFileHandleOp struct {
|
type ReleaseFileHandleOp struct {
|
||||||
|
commonOp
|
||||||
|
|
||||||
// The handle ID to be released. The kernel guarantees that this ID will not
|
// 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
|
// be used in further calls to the file system (unless it is reissued by the
|
||||||
// file system).
|
// file system).
|
||||||
Handle HandleID
|
Handle HandleID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *ReleaseFileHandleOp) Respond(err error) {
|
||||||
|
if err != nil {
|
||||||
|
o.commonOp.respondErr(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic("TODO")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue