Only warn once for unsupported fallocate(2) and truncate(2)
Also, print the inode number in Ftruncate warnings.
This commit is contained in:
parent
8fb32aab68
commit
4259c8f7eb
@ -336,7 +336,7 @@ func (f *file) Truncate(newSize uint64) fuse.Status {
|
|||||||
err := syscall.Ftruncate(int(f.fd.Fd()), 0)
|
err := syscall.Ftruncate(int(f.fd.Fd()), 0)
|
||||||
f.fdLock.Unlock()
|
f.fdLock.Unlock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cryptfs.Warn.Printf("Ftruncate(fd, 0) returned error: %v", err)
|
cryptfs.Warn.Printf("ino%d: Ftruncate(fd, 0) returned error: %v", f.ino, err)
|
||||||
return fuse.ToStatus(err)
|
return fuse.ToStatus(err)
|
||||||
}
|
}
|
||||||
// Truncate to zero kills the file header
|
// Truncate to zero kills the file header
|
||||||
@ -348,7 +348,7 @@ func (f *file) Truncate(newSize uint64) fuse.Status {
|
|||||||
// the file
|
// the file
|
||||||
fi, err := f.fd.Stat()
|
fi, err := f.fd.Stat()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cryptfs.Warn.Printf("Truncate: Fstat failed: %v", err)
|
cryptfs.Warn.Printf("ino%d: Truncate: Fstat failed: %v", f.ino, err)
|
||||||
return fuse.ToStatus(err)
|
return fuse.ToStatus(err)
|
||||||
}
|
}
|
||||||
oldSize := f.cfs.CipherSizeToPlainSize(uint64(fi.Size()))
|
oldSize := f.cfs.CipherSizeToPlainSize(uint64(fi.Size()))
|
||||||
@ -455,8 +455,14 @@ func (f *file) GetAttr(a *fuse.Attr) fuse.Status {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Allocate - FUSE call, fallocate(2)
|
// Allocate - FUSE call, fallocate(2)
|
||||||
|
var allocateWarned bool
|
||||||
|
|
||||||
func (f *file) Allocate(off uint64, sz uint64, mode uint32) fuse.Status {
|
func (f *file) Allocate(off uint64, sz uint64, mode uint32) fuse.Status {
|
||||||
cryptfs.Warn.Printf("Fallocate is not supported, returning ENOSYS - see https://github.com/rfjakob/gocryptfs/issues/1")
|
// Only warn once
|
||||||
|
if !allocateWarned {
|
||||||
|
cryptfs.Warn.Printf("fallocate(2) is not supported, returning ENOSYS - see https://github.com/rfjakob/gocryptfs/issues/1")
|
||||||
|
allocateWarned = true
|
||||||
|
}
|
||||||
return fuse.ENOSYS
|
return fuse.ENOSYS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,8 +198,14 @@ func (fs *FS) Mknod(path string, mode uint32, dev uint32, context *fuse.Context)
|
|||||||
return fs.FileSystem.Mknod(cPath, mode, dev, context)
|
return fs.FileSystem.Mknod(cPath, mode, dev, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var truncateWarned bool
|
||||||
|
|
||||||
func (fs *FS) Truncate(path string, offset uint64, context *fuse.Context) (code fuse.Status) {
|
func (fs *FS) Truncate(path string, offset uint64, context *fuse.Context) (code fuse.Status) {
|
||||||
cryptfs.Warn.Printf("Truncate of a closed file is not supported, returning ENOSYS")
|
// Only warn once
|
||||||
|
if !truncateWarned {
|
||||||
|
cryptfs.Warn.Printf("truncate(2) is not supported, returning ENOSYS - use ftruncate(2)")
|
||||||
|
truncateWarned = true
|
||||||
|
}
|
||||||
return fuse.ENOSYS
|
return fuse.ENOSYS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user