mirror of
https://github.com/xiaoqidun/symfs.git
synced 2026-02-02 16:13:54 +08:00
feat(优化代码): 优化代码
This commit is contained in:
@@ -41,8 +41,8 @@ func errno(err error) int {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
if errno, ok := err.(syscall.Errno); ok {
|
if sysErr, ok := err.(syscall.Errno); ok {
|
||||||
return -int(errno)
|
return -int(sysErr)
|
||||||
}
|
}
|
||||||
return -int(fuse.ENOENT)
|
return -int(fuse.ENOENT)
|
||||||
}
|
}
|
||||||
@@ -164,11 +164,13 @@ func (s *SymFS) Chown(path string, uid uint32, gid uint32) int {
|
|||||||
// 入参: path 路径, tmsp 时间戳数组
|
// 入参: path 路径, tmsp 时间戳数组
|
||||||
// 返回: int 错误码
|
// 返回: int 错误码
|
||||||
func (s *SymFS) Utimens(path string, tmsp []fuse.Timespec) int {
|
func (s *SymFS) Utimens(path string, tmsp []fuse.Timespec) int {
|
||||||
|
if len(tmsp) < 2 {
|
||||||
|
return -int(fuse.EINVAL)
|
||||||
|
}
|
||||||
path = s.realPath(path)
|
path = s.realPath(path)
|
||||||
atime := time.Unix(tmsp[0].Sec, tmsp[0].Nsec)
|
atime := time.Unix(tmsp[0].Sec, tmsp[0].Nsec)
|
||||||
mtime := time.Unix(tmsp[1].Sec, tmsp[1].Nsec)
|
mtime := time.Unix(tmsp[1].Sec, tmsp[1].Nsec)
|
||||||
err := os.Chtimes(path, atime, mtime)
|
return errno(os.Chtimes(path, atime, mtime))
|
||||||
return errno(err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Access 检查文件访问权限
|
// Access 检查文件访问权限
|
||||||
|
|||||||
Reference in New Issue
Block a user