aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--weed/mount/filehandle.go3
-rw-r--r--weed/mount/inode_to_path.go7
-rw-r--r--weed/mount/weedfs.go5
-rw-r--r--weed/mount/weedfs_attr.go6
-rw-r--r--weed/mount/weedfs_dir_lookup.go5
-rw-r--r--weed/mount/weedfs_dir_mkrm.go10
-rw-r--r--weed/mount/weedfs_dir_read.go5
-rw-r--r--weed/mount/weedfs_file_io.go1
-rw-r--r--weed/mount/weedfs_file_mkrm.go26
-rw-r--r--weed/mount/weedfs_file_sync.go2
-rw-r--r--weed/mount/weedfs_link.go10
-rw-r--r--weed/mount/weedfs_rename.go10
-rw-r--r--weed/mount/weedfs_symlink.go12
-rw-r--r--weed/s3api/filer_multipart.go4
14 files changed, 76 insertions, 30 deletions
diff --git a/weed/mount/filehandle.go b/weed/mount/filehandle.go
index f2a2ec69c..770e89a10 100644
--- a/weed/mount/filehandle.go
+++ b/weed/mount/filehandle.go
@@ -49,7 +49,8 @@ func newFileHandle(wfs *WFS, handleId FileHandleId, inode uint64, entry *filer_p
}
func (fh *FileHandle) FullPath() util.FullPath {
- return fh.wfs.inodeToPath.GetPath(fh.inode)
+ fp, _ := fh.wfs.inodeToPath.GetPath(fh.inode)
+ return fp
}
func (fh *FileHandle) addChunks(chunks []*filer_pb.FileChunk) {
diff --git a/weed/mount/inode_to_path.go b/weed/mount/inode_to_path.go
index edea91a5d..ae95730e1 100644
--- a/weed/mount/inode_to_path.go
+++ b/weed/mount/inode_to_path.go
@@ -3,6 +3,7 @@ package mount
import (
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/util"
+ "github.com/hanwen/go-fuse/v2/fuse"
"sync"
)
@@ -65,14 +66,14 @@ func (i *InodeToPath) GetInode(path util.FullPath) uint64 {
return inode
}
-func (i *InodeToPath) GetPath(inode uint64) util.FullPath {
+func (i *InodeToPath) GetPath(inode uint64) (util.FullPath, fuse.Status) {
i.RLock()
defer i.RUnlock()
path, found := i.inode2path[inode]
if !found {
- glog.Fatalf("not found inode %d", inode)
+ return "", fuse.ENOENT
}
- return path.FullPath
+ return path.FullPath, fuse.OK
}
func (i *InodeToPath) HasPath(path util.FullPath) bool {
diff --git a/weed/mount/weedfs.go b/weed/mount/weedfs.go
index b070fdd6c..1e6d1a856 100644
--- a/weed/mount/weedfs.go
+++ b/weed/mount/weedfs.go
@@ -110,7 +110,10 @@ func (wfs *WFS) String() string {
}
func (wfs *WFS) maybeReadEntry(inode uint64) (path util.FullPath, fh *FileHandle, entry *filer_pb.Entry, status fuse.Status) {
- path = wfs.inodeToPath.GetPath(inode)
+ path, status = wfs.inodeToPath.GetPath(inode)
+ if status != fuse.OK {
+ return
+ }
var found bool
if fh, found = wfs.fhmap.FindFileHandle(inode); found {
return path, fh, fh.entry, fuse.OK
diff --git a/weed/mount/weedfs_attr.go b/weed/mount/weedfs_attr.go
index 4042ce8f1..9f995608c 100644
--- a/weed/mount/weedfs_attr.go
+++ b/weed/mount/weedfs_attr.go
@@ -66,7 +66,7 @@ func (wfs *WFS) SetAttr(cancel <-chan struct{}, input *fuse.SetAttrIn, out *fuse
}
if mode, ok := input.GetMode(); ok {
- entry.Attributes.FileMode = uint32(mode)
+ entry.Attributes.FileMode = mode & 07777
}
if uid, ok := input.GetUID(); ok {
@@ -81,6 +81,10 @@ func (wfs *WFS) SetAttr(cancel <-chan struct{}, input *fuse.SetAttrIn, out *fuse
entry.Attributes.Mtime = mtime.Unix()
}
+ if atime, ok := input.GetATime(); ok {
+ entry.Attributes.Mtime = atime.Unix()
+ }
+
entry.Attributes.Mtime = time.Now().Unix()
out.AttrValid = 1
wfs.setAttrByPbEntry(&out.Attr, input.NodeId, entry)
diff --git a/weed/mount/weedfs_dir_lookup.go b/weed/mount/weedfs_dir_lookup.go
index 852e08444..4eceb5ce4 100644
--- a/weed/mount/weedfs_dir_lookup.go
+++ b/weed/mount/weedfs_dir_lookup.go
@@ -20,7 +20,10 @@ func (wfs *WFS) Lookup(cancel <-chan struct{}, header *fuse.InHeader, name strin
return s
}
- dirPath := wfs.inodeToPath.GetPath(header.NodeId)
+ dirPath, code := wfs.inodeToPath.GetPath(header.NodeId)
+ if code != fuse.OK {
+ return
+ }
fullFilePath := dirPath.Child(name)
diff --git a/weed/mount/weedfs_dir_mkrm.go b/weed/mount/weedfs_dir_mkrm.go
index 17b70cacd..a73bb3c2a 100644
--- a/weed/mount/weedfs_dir_mkrm.go
+++ b/weed/mount/weedfs_dir_mkrm.go
@@ -37,7 +37,10 @@ func (wfs *WFS) Mkdir(cancel <-chan struct{}, in *fuse.MkdirIn, name string, out
},
}
- dirFullPath := wfs.inodeToPath.GetPath(in.NodeId)
+ dirFullPath, code := wfs.inodeToPath.GetPath(in.NodeId)
+ if code != fuse.OK {
+ return
+ }
entryFullPath := dirFullPath.Child(name)
@@ -89,7 +92,10 @@ func (wfs *WFS) Rmdir(cancel <-chan struct{}, header *fuse.InHeader, name string
return fuse.Status(syscall.ENOTEMPTY)
}
- dirFullPath := wfs.inodeToPath.GetPath(header.NodeId)
+ dirFullPath, code := wfs.inodeToPath.GetPath(header.NodeId)
+ if code != fuse.OK {
+ return
+ }
entryFullPath := dirFullPath.Child(name)
glog.V(3).Infof("remove directory: %v", entryFullPath)
diff --git a/weed/mount/weedfs_dir_read.go b/weed/mount/weedfs_dir_read.go
index a14f4d960..9e8587995 100644
--- a/weed/mount/weedfs_dir_read.go
+++ b/weed/mount/weedfs_dir_read.go
@@ -142,7 +142,10 @@ func (wfs *WFS) doReadDirectory(input *fuse.ReadIn, out *fuse.DirEntryList, isPl
}
isEarlyTerminated := false
- dirPath := wfs.inodeToPath.GetPath(input.NodeId)
+ dirPath, code := wfs.inodeToPath.GetPath(input.NodeId)
+ if code != fuse.OK {
+ return code
+ }
var dirEntry fuse.DirEntry
if input.Offset == 0 {
diff --git a/weed/mount/weedfs_file_io.go b/weed/mount/weedfs_file_io.go
index 7c8d1babc..8ecf5039f 100644
--- a/weed/mount/weedfs_file_io.go
+++ b/weed/mount/weedfs_file_io.go
@@ -64,6 +64,7 @@ func (wfs *WFS) Open(cancel <-chan struct{}, in *fuse.OpenIn, out *fuse.OpenOut)
fileHandle, code := wfs.AcquireHandle(in.NodeId, in.Uid, in.Gid)
if code == fuse.OK {
out.Fh = uint64(fileHandle.fh)
+ // TODO https://github.com/libfuse/libfuse/blob/master/include/fuse_common.h#L64
}
return code
}
diff --git a/weed/mount/weedfs_file_mkrm.go b/weed/mount/weedfs_file_mkrm.go
index 032008a85..243696dba 100644
--- a/weed/mount/weedfs_file_mkrm.go
+++ b/weed/mount/weedfs_file_mkrm.go
@@ -45,7 +45,7 @@ func (wfs *WFS) Mknod(cancel <-chan struct{}, in *fuse.MknodIn, name string, out
Attributes: &filer_pb.FuseAttributes{
Mtime: time.Now().Unix(),
Crtime: time.Now().Unix(),
- FileMode: uint32(toFileMode(in.Mode) &^ wfs.option.Umask),
+ FileMode: uint32(toFileMode(in.Mode)),
Uid: in.Uid,
Gid: in.Gid,
Collection: wfs.option.Collection,
@@ -54,7 +54,10 @@ func (wfs *WFS) Mknod(cancel <-chan struct{}, in *fuse.MknodIn, name string, out
},
}
- dirFullPath := wfs.inodeToPath.GetPath(in.NodeId)
+ dirFullPath, code := wfs.inodeToPath.GetPath(in.NodeId)
+ if code != fuse.OK {
+ return
+ }
entryFullPath := dirFullPath.Child(name)
@@ -99,12 +102,21 @@ func (wfs *WFS) Mknod(cancel <-chan struct{}, in *fuse.MknodIn, name string, out
/** Remove a file */
func (wfs *WFS) Unlink(cancel <-chan struct{}, header *fuse.InHeader, name string) (code fuse.Status) {
- dirFullPath := wfs.inodeToPath.GetPath(header.NodeId)
+ dirFullPath, code := wfs.inodeToPath.GetPath(header.NodeId)
+ if code != fuse.OK {
+ if code == fuse.ENOENT {
+ return fuse.OK
+ }
+ return code
+ }
entryFullPath := dirFullPath.Child(name)
- entry, status := wfs.maybeLoadEntry(entryFullPath)
- if status != fuse.OK {
- return status
+ entry, code := wfs.maybeLoadEntry(entryFullPath)
+ if code != fuse.OK {
+ if code == fuse.ENOENT {
+ return fuse.OK
+ }
+ return code
}
// first, ensure the filer store can correctly delete
@@ -113,7 +125,7 @@ func (wfs *WFS) Unlink(cancel <-chan struct{}, header *fuse.InHeader, name strin
err := filer_pb.Remove(wfs, string(dirFullPath), name, isDeleteData, false, false, false, []int32{wfs.signature})
if err != nil {
glog.V(0).Infof("remove %s: %v", entryFullPath, err)
- return fuse.ENOENT
+ return fuse.OK
}
// then, delete meta cache
diff --git a/weed/mount/weedfs_file_sync.go b/weed/mount/weedfs_file_sync.go
index 29a13690b..8fb7c73b4 100644
--- a/weed/mount/weedfs_file_sync.go
+++ b/weed/mount/weedfs_file_sync.go
@@ -7,7 +7,6 @@ import (
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/hanwen/go-fuse/v2/fuse"
- "os"
"time"
)
@@ -129,7 +128,6 @@ func (wfs *WFS) doFlush(fh *FileHandle, uid, gid uint32) fuse.Status {
entry.Attributes.Crtime = time.Now().Unix()
}
entry.Attributes.Mtime = time.Now().Unix()
- entry.Attributes.FileMode = uint32(os.FileMode(entry.Attributes.FileMode) &^ wfs.option.Umask)
entry.Attributes.Collection, entry.Attributes.Replication = fh.dirtyPages.GetStorageOptions()
}
diff --git a/weed/mount/weedfs_link.go b/weed/mount/weedfs_link.go
index 7cc98b3e6..4e8559e72 100644
--- a/weed/mount/weedfs_link.go
+++ b/weed/mount/weedfs_link.go
@@ -21,8 +21,14 @@ func (wfs *WFS) Link(cancel <-chan struct{}, in *fuse.LinkIn, name string, out *
return s
}
- newParentPath := wfs.inodeToPath.GetPath(in.NodeId)
- oldEntryPath := wfs.inodeToPath.GetPath(in.Oldnodeid)
+ newParentPath, code := wfs.inodeToPath.GetPath(in.NodeId)
+ if code != fuse.OK {
+ return
+ }
+ oldEntryPath, code := wfs.inodeToPath.GetPath(in.Oldnodeid)
+ if code != fuse.OK {
+ return
+ }
oldParentPath, _ := oldEntryPath.DirAndName()
oldEntry, status := wfs.maybeLoadEntry(oldEntryPath)
diff --git a/weed/mount/weedfs_rename.go b/weed/mount/weedfs_rename.go
index 9e461abce..9c83a4b94 100644
--- a/weed/mount/weedfs_rename.go
+++ b/weed/mount/weedfs_rename.go
@@ -145,9 +145,15 @@ func (wfs *WFS) Rename(cancel <-chan struct{}, in *fuse.RenameIn, oldName string
return fuse.EINVAL
}
- oldDir := wfs.inodeToPath.GetPath(in.NodeId)
+ oldDir, code := wfs.inodeToPath.GetPath(in.NodeId)
+ if code != fuse.OK {
+ return
+ }
oldPath := oldDir.Child(oldName)
- newDir := wfs.inodeToPath.GetPath(in.Newdir)
+ newDir, code := wfs.inodeToPath.GetPath(in.Newdir)
+ if code != fuse.OK {
+ return
+ }
newPath := newDir.Child(newName)
glog.V(4).Infof("dir Rename %s => %s", oldPath, newPath)
diff --git a/weed/mount/weedfs_symlink.go b/weed/mount/weedfs_symlink.go
index 66d956a91..eb8169d70 100644
--- a/weed/mount/weedfs_symlink.go
+++ b/weed/mount/weedfs_symlink.go
@@ -18,7 +18,10 @@ func (wfs *WFS) Symlink(cancel <-chan struct{}, header *fuse.InHeader, target st
return s
}
- dirPath := wfs.inodeToPath.GetPath(header.NodeId)
+ dirPath, code := wfs.inodeToPath.GetPath(header.NodeId)
+ if code != fuse.OK {
+ return
+ }
entryFullPath := dirPath.Child(name)
request := &filer_pb.CreateEntryRequest{
@@ -29,7 +32,7 @@ func (wfs *WFS) Symlink(cancel <-chan struct{}, header *fuse.InHeader, target st
Attributes: &filer_pb.FuseAttributes{
Mtime: time.Now().Unix(),
Crtime: time.Now().Unix(),
- FileMode: uint32((os.FileMode(0777) | os.ModeSymlink) &^ wfs.option.Umask),
+ FileMode: uint32(os.FileMode(0777) | os.ModeSymlink),
Uid: header.Uid,
Gid: header.Gid,
SymlinkTarget: target,
@@ -64,7 +67,10 @@ func (wfs *WFS) Symlink(cancel <-chan struct{}, header *fuse.InHeader, target st
}
func (wfs *WFS) Readlink(cancel <-chan struct{}, header *fuse.InHeader) (out []byte, code fuse.Status) {
- entryFullPath := wfs.inodeToPath.GetPath(header.NodeId)
+ entryFullPath, code := wfs.inodeToPath.GetPath(header.NodeId)
+ if code != fuse.OK {
+ return
+ }
entry, status := wfs.maybeLoadEntry(entryFullPath)
if status != fuse.OK {
diff --git a/weed/s3api/filer_multipart.go b/weed/s3api/filer_multipart.go
index e687fba10..1795ade93 100644
--- a/weed/s3api/filer_multipart.go
+++ b/weed/s3api/filer_multipart.go
@@ -270,10 +270,6 @@ func (s3a *S3ApiServer) listObjectParts(input *s3.ListPartsInput) (output *ListP
glog.Errorf("listObjectParts %s %s error: %v", *input.Bucket, *input.UploadId, err)
return nil, s3err.ErrNoSuchUpload
}
- if len(entries) == 0 {
- glog.Errorf("listObjectParts %s %s not found", *input.Bucket, *input.UploadId)
- return nil, s3err.ErrNoSuchUpload
- }
output.IsTruncated = aws.Bool(!isLast)