func (fs *MyFileSystem) Getattr(path string, context *fuse.Context) (*fuse.Attr, fuse.Status) { // Check if the file exists in your file system if !fs.fileExists(path) { return nil, fuse.ENOENT } // Create an attribute structure and set the size attribute attr := fuse.Attr{} attr.Size = uint64(fs.getFileSize(path)) // Return the attribute structure and success status return &attr, fuse.OK }
func (fs *MyFileSystem) Truncate(path string, size uint64, context *fuse.Context) (code fuse.Status) { // Check if the file exists in your file system if !fs.fileExists(path) { return fuse.ENOENT } // Get the file and set the size attribute file := fs.getFile(path) file.Size = int64(size) // Update the file in your file system fs.updateFile(path, file) // Return the success status return fuse.OK }