Skip to content
Permalink
Browse files

Make the delay configurable.

  • Loading branch information...
jacobsa committed Sep 17, 2015
1 parent 4ce5f1d commit 9b69a2ca015b863aa364d180610a07685d5829ee
Showing with 12 additions and 6 deletions.
  1. +11 −5 slowfs/fs.go
  2. +1 −1 slowfs/main.go
@@ -1,6 +1,7 @@
package main

import (
"flag"
"fmt"
"os"
"sync"
@@ -13,9 +14,12 @@ import (
"github.com/jacobsa/fuse/fuseutil"
)

var fDelay = flag.Duration(
"delay", time.Second, "How long to delay file creation.")

func mount(mountPoint string) (mfs *fuse.MountedFileSystem, err error) {
// Create the file system.
fs, err := newFileSystem()
fs, err := newFileSystem(*fDelay)
if err != nil {
err = fmt.Errorf("newFileSystem: %v", err)
return
@@ -47,21 +51,23 @@ func mount(mountPoint string) (mfs *fuse.MountedFileSystem, err error) {
type fileSystem struct {
fuseutil.NotImplementedFileSystem

uid uint32
gid uint32
delay time.Duration
uid uint32
gid uint32

mu sync.Mutex
nextInodeID fuseops.InodeID
}

func newFileSystem() (fs *fileSystem, err error) {
func newFileSystem(delay time.Duration) (fs *fileSystem, err error) {
uid, gid, err := myUserAndGroup()
if err != nil {
err = fmt.Errorf("myUserAndGroup: %v", err)
return
}

fs = &fileSystem{
delay: delay,
uid: uid,
gid: gid,
nextInodeID: fuseops.RootInodeID + 1,
@@ -78,7 +84,7 @@ func (fs *fileSystem) StatFS(
func (fs *fileSystem) CreateFile(
ctx context.Context,
op *fuseops.CreateFileOp) (err error) {
time.Sleep(time.Second)
time.Sleep(fs.delay)

// Allocate an inode ID.
fs.mu.Lock()
@@ -1,4 +1,4 @@
// slowfs is a fuse file system that contains nw files and supports creating
// slowfs is a fuse file system that contains no files and supports creating
// new ones (that disappear into the void), with a delay while creating in
// order to reproduce a Go issue involving EINTR errors on Darwin.
package main

0 comments on commit 9b69a2c

Please sign in to comment.
You can’t perform that action at this time.