vfs: Implement unlink (#9)
* vfs: Implement unlink Signed-off-by: Xuanwo <github@xuanwo.io> * Increase ttl Signed-off-by: Xuanwo <github@xuanwo.io>
This commit is contained in:
parent
55e69864a9
commit
2ce6125fbc
|
@ -166,7 +166,6 @@ func (fs *FS) Lookup(cancel <-chan struct{}, header *fuse.InHeader, name string,
|
|||
}
|
||||
|
||||
func (fs *FS) Forget(nodeid, nlookup uint64) {
|
||||
fs.fs.DeleteInode(nodeid)
|
||||
}
|
||||
|
||||
func (fs *FS) GetAttr(cancel <-chan struct{}, input *fuse.GetAttrIn, out *fuse.AttrOut) (code fuse.Status) {
|
||||
|
@ -237,7 +236,6 @@ func (fs *FS) Unlink(cancel <-chan struct{}, header *fuse.InHeader, name string)
|
|||
zap.Error(err))
|
||||
return fuse.EAGAIN
|
||||
}
|
||||
|
||||
return fuse.OK
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ func (dh *DirHandle) Next() (ino *Inode, err error) {
|
|||
}
|
||||
|
||||
ino = newInode(dh.ino.ID, o)
|
||||
err = dh.fs.SetInode(ino, time.Minute)
|
||||
err = dh.fs.SetInode(ino, time.Hour)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
22
vfs/fs.go
22
vfs/fs.go
|
@ -73,7 +73,19 @@ func NewFS(cfg *Config) (fs *FS, err error) {
|
|||
}
|
||||
|
||||
func (fs *FS) Delete(parent uint64, name string) (err error) {
|
||||
panic("implement me")
|
||||
ino, err := fs.GetEntry(parent, name)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = fs.s.Delete(ino.Path)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = fs.DeleteInode(ino)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (fs *FS) DeleteDir(path string) (err error) {
|
||||
|
@ -145,8 +157,12 @@ func (fs *FS) GetInode(id uint64) (ino *Inode, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (fs *FS) DeleteInode(id uint64) (err error) {
|
||||
err = fs.meta.Delete(meta.InodeKey(id))
|
||||
func (fs *FS) DeleteInode(ino *Inode) (err error) {
|
||||
err = fs.meta.Delete(meta.InodeKey(ino.ID))
|
||||
if err != nil {
|
||||
return fmt.Errorf("del inode: %w", err)
|
||||
}
|
||||
err = fs.meta.Delete(meta.EntryKey(ino.ParentID, ino.Name))
|
||||
if err != nil {
|
||||
return fmt.Errorf("del inode: %w", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue