|
@@ -6,6 +6,7 @@ import (
|
|
"os"
|
|
"os"
|
|
"os/user"
|
|
"os/user"
|
|
"strconv"
|
|
"strconv"
|
|
|
|
+ "syscall"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
"dev.hexasoftware.com/hxs/prettylog"
|
|
"dev.hexasoftware.com/hxs/prettylog"
|
|
@@ -457,10 +458,9 @@ func (fs *GDriveFS) CreateFile(ctx context.Context, op *fuseops.CreateFileOp) (e
|
|
err = fuse.ENOENT
|
|
err = fuse.ENOENT
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- // Only write on My Drive for now
|
|
|
|
|
|
+ // Only write on child folders
|
|
if parentFile.Inode == fuseops.RootInodeID {
|
|
if parentFile.Inode == fuseops.RootInodeID {
|
|
- err = fuse.ENOATTR
|
|
|
|
- return
|
|
|
|
|
|
+ return syscall.EPERM
|
|
}
|
|
}
|
|
|
|
|
|
// Generate ID
|
|
// Generate ID
|
|
@@ -554,6 +554,10 @@ func (fs *GDriveFS) Unlink(ctx context.Context, op *fuseops.UnlinkOp) (err error
|
|
if parentEntry == nil {
|
|
if parentEntry == nil {
|
|
return fuse.ENOENT
|
|
return fuse.ENOENT
|
|
}
|
|
}
|
|
|
|
+ if parentEntry.Inode == fuseops.RootInodeID {
|
|
|
|
+ return syscall.EPERM
|
|
|
|
+ }
|
|
|
|
+
|
|
fileEntry := parentEntry.findByName(op.Name, false)
|
|
fileEntry := parentEntry.findByName(op.Name, false)
|
|
if fileEntry == nil {
|
|
if fileEntry == nil {
|
|
return fuse.ENOATTR
|
|
return fuse.ENOATTR
|
|
@@ -581,7 +585,7 @@ func (fs *GDriveFS) MkDir(ctx context.Context, op *fuseops.MkDirOp) (err error)
|
|
return fuse.ENOENT
|
|
return fuse.ENOENT
|
|
}
|
|
}
|
|
if parentFile.Inode == fuseops.RootInodeID {
|
|
if parentFile.Inode == fuseops.RootInodeID {
|
|
- return fuse.ENOATTR
|
|
|
|
|
|
+ return syscall.EPERM
|
|
}
|
|
}
|
|
|
|
|
|
// Should check existent first too
|
|
// Should check existent first too
|
|
@@ -614,6 +618,9 @@ func (fs *GDriveFS) RmDir(ctx context.Context, op *fuseops.RmDirOp) (err error)
|
|
if parentFile == nil {
|
|
if parentFile == nil {
|
|
return fuse.ENOENT
|
|
return fuse.ENOENT
|
|
}
|
|
}
|
|
|
|
+ if parentFile.Inode == fuseops.RootInodeID {
|
|
|
|
+ return syscall.EPERM
|
|
|
|
+ }
|
|
|
|
|
|
theFile := parentFile.findByName(op.Name, false)
|
|
theFile := parentFile.findByName(op.Name, false)
|
|
|
|
|
|
@@ -639,6 +646,10 @@ func (fs *GDriveFS) Rename(ctx context.Context, op *fuseops.RenameOp) (err error
|
|
return fuse.ENOENT
|
|
return fuse.ENOENT
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if oldParentFile.Inode == fuseops.RootInodeID || newParentFile.Inode == fuseops.RootInodeID {
|
|
|
|
+ return syscall.EPERM
|
|
|
|
+ }
|
|
|
|
+
|
|
oldFile := oldParentFile.findByName(op.OldName, false)
|
|
oldFile := oldParentFile.findByName(op.OldName, false)
|
|
|
|
|
|
ngFile := &drive.File{
|
|
ngFile := &drive.File{
|