Commit 1abfc5d4 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Drop Type field from inode.

parent 1ff48a1a
...@@ -22,7 +22,7 @@ type mountData struct { ...@@ -22,7 +22,7 @@ type mountData struct {
// * eventual consistency is OK here // * eventual consistency is OK here
// //
// * the kernel controls when to ask for updates, // * the kernel controls when to ask for updates,
// so we can't make entries directly anyway. // so we can't make entries disappear directly anyway.
unmountPending bool unmountPending bool
} }
...@@ -41,7 +41,6 @@ type inode struct { ...@@ -41,7 +41,6 @@ type inode struct {
Name string Name string
LookupCount int LookupCount int
OpenCount int OpenCount int
Type uint32 // dirent type, used to check if mounts are valid.
mount *mountData mount *mountData
} }
...@@ -66,6 +65,10 @@ func (me *inode) totalMountCount() int { ...@@ -66,6 +65,10 @@ func (me *inode) totalMountCount() int {
return o return o
} }
func (me *inode) IsDir() bool {
return me.Children != nil
}
const initDirSize = 20 const initDirSize = 20
func (me *inode) verify() { func (me *inode) verify() {
...@@ -256,7 +259,7 @@ func (me *FileSystemConnector) verify() { ...@@ -256,7 +259,7 @@ func (me *FileSystemConnector) verify() {
} }
} }
func (me *FileSystemConnector) newInode(root bool) *inode { func (me *FileSystemConnector) newInode(root bool, isDir bool) *inode {
data := new(inode) data := new(inode)
if root { if root {
data.NodeId = FUSE_ROOT_ID data.NodeId = FUSE_ROOT_ID
...@@ -265,7 +268,10 @@ func (me *FileSystemConnector) newInode(root bool) *inode { ...@@ -265,7 +268,10 @@ func (me *FileSystemConnector) newInode(root bool) *inode {
data.NodeId = uint64(uintptr(unsafe.Pointer(data))) data.NodeId = uint64(uintptr(unsafe.Pointer(data)))
} }
me.inodeMap[data.NodeId] = data me.inodeMap[data.NodeId] = data
if isDir {
data.Children = make(map[string]*inode, initDirSize)
}
return data return data
} }
...@@ -277,12 +283,9 @@ func (me *FileSystemConnector) lookupUpdate(parent *inode, name string, isDir bo ...@@ -277,12 +283,9 @@ func (me *FileSystemConnector) lookupUpdate(parent *inode, name string, isDir bo
data, ok := parent.Children[name] data, ok := parent.Children[name]
if !ok { if !ok {
data = me.newInode(false) data = me.newInode(false, isDir)
data.Name = name data.Name = name
data.setParent(parent) data.setParent(parent)
if isDir {
data.Children = make(map[string]*inode, initDirSize)
}
} }
return data return data
...@@ -376,8 +379,7 @@ func EmptyFileSystemConnector() (out *FileSystemConnector) { ...@@ -376,8 +379,7 @@ func EmptyFileSystemConnector() (out *FileSystemConnector) {
out.inodeMap = make(map[uint64]*inode) out.inodeMap = make(map[uint64]*inode)
out.openFiles = make(map[uint64]*interfaceBridge) out.openFiles = make(map[uint64]*interfaceBridge)
rootData := out.newInode(true) rootData := out.newInode(true, true)
rootData.Type = ModeToType(S_IFDIR)
rootData.Children = make(map[string]*inode, initDirSize) rootData.Children = make(map[string]*inode, initDirSize)
out.options.NegativeTimeout = 0.0 out.options.NegativeTimeout = 0.0
...@@ -413,7 +415,7 @@ func (me *FileSystemConnector) Mount(mountPoint string, fs FileSystem) Status { ...@@ -413,7 +415,7 @@ func (me *FileSystemConnector) Mount(mountPoint string, fs FileSystem) Status {
} }
node = me.findInode(mountPoint) node = me.findInode(mountPoint)
if node.Type&ModeToType(S_IFDIR) == 0 { if !node.IsDir() {
return EINVAL return EINVAL
} }
...@@ -534,7 +536,6 @@ func (me *FileSystemConnector) internalLookupWithNode(parent *inode, name string ...@@ -534,7 +536,6 @@ func (me *FileSystemConnector) internalLookupWithNode(parent *inode, name string
data := me.lookupUpdate(parent, name, attr.Mode&S_IFDIR != 0) data := me.lookupUpdate(parent, name, attr.Mode&S_IFDIR != 0)
data.LookupCount += lookupCount data.LookupCount += lookupCount
data.Type = ModeToType(attr.Mode)
out = &EntryOut{ out = &EntryOut{
NodeId: data.NodeId, NodeId: data.NodeId,
......
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