fuserfrontend: support truncate(2) by wrapping ftruncate(2)
Support truncate(2) by opening the file and calling ftruncate(2) While the glibc "truncate" wrapper seems to always use ftruncate, fsstress from xfstests uses this a lot by calling "truncate64" directly.
This commit is contained in:
parent
1de5ceed58
commit
38767ab527
@ -489,6 +489,8 @@ func (f *file) GetAttr(a *fuse.Attr) fuse.Status {
|
|||||||
var allocateWarnOnce sync.Once
|
var allocateWarnOnce sync.Once
|
||||||
|
|
||||||
// Allocate - FUSE call, fallocate(2)
|
// Allocate - FUSE call, fallocate(2)
|
||||||
|
// This is not implemented yet in gocryptfs, but it is neither in EncFS. This
|
||||||
|
// suggests that the user demand is low.
|
||||||
func (f *file) Allocate(off uint64, sz uint64, mode uint32) fuse.Status {
|
func (f *file) Allocate(off uint64, sz uint64, mode uint32) fuse.Status {
|
||||||
allocateWarnOnce.Do(func() {
|
allocateWarnOnce.Do(func() {
|
||||||
tlog.Warn.Printf("fallocate(2) is not supported, returning ENOSYS - see https://github.com/rfjakob/gocryptfs/issues/1")
|
tlog.Warn.Printf("fallocate(2) is not supported, returning ENOSYS - see https://github.com/rfjakob/gocryptfs/issues/1")
|
||||||
|
@ -207,14 +207,17 @@ 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only warn once
|
// Support truncate(2) by opening the file and calling ftruncate(2)
|
||||||
var truncateWarnOnce sync.Once
|
// While the glibc "truncate" wrapper seems to always use ftruncate, fsstress from
|
||||||
|
// xfstests uses this a lot by calling "truncate64" directly.
|
||||||
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) {
|
||||||
truncateWarnOnce.Do(func() {
|
file, code := fs.Open(path, uint32(os.O_RDWR), context)
|
||||||
tlog.Warn.Printf("truncate(2) is not supported, returning ENOSYS - use ftruncate(2)")
|
if code != fuse.OK {
|
||||||
})
|
return code
|
||||||
return fuse.ENOSYS
|
}
|
||||||
|
code = file.Truncate(offset)
|
||||||
|
file.Release()
|
||||||
|
return code
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *FS) Utimens(path string, Atime *time.Time, Mtime *time.Time, context *fuse.Context) (code fuse.Status) {
|
func (fs *FS) Utimens(path string, Atime *time.Time, Mtime *time.Time, context *fuse.Context) (code fuse.Status) {
|
||||||
|
Loading…
Reference in New Issue
Block a user