func (t *IntegrationTest) SetUp(ti *TestInfo) { t.ctx = ti.Ctx t.bucket = gcsfake.NewFakeBucket(&t.clock, "some_bucket") // Set up a fixed, non-zero time. t.clock.SetTime(time.Date(2012, 8, 15, 22, 56, 0, 0, time.Local)) // Set up the syncer. const appendThreshold = 0 const tmpObjectPrefix = ".gcsfuse_tmp/" t.syncer = gcsx.NewSyncer( appendThreshold, tmpObjectPrefix, t.bucket) }
func (t *FileTest) createInode() { if t.in != nil { t.in.Unlock() } t.in = inode.NewFileInode( fileInodeID, t.backingObj, fuseops.InodeAttributes{ Uid: uid, Gid: gid, Mode: fileMode, }, t.bucket, gcsx.NewSyncer( 1, // Append threshold ".gcsfuse_tmp/", t.bucket), "", &t.clock) t.in.Lock() }
// Create a fuse file system server according to the supplied configuration. func NewServer(cfg *ServerConfig) (server fuse.Server, err error) { // Check permissions bits. if cfg.FilePerms&^os.ModePerm != 0 { err = fmt.Errorf("Illegal file perms: %v", cfg.FilePerms) return } if cfg.DirPerms&^os.ModePerm != 0 { err = fmt.Errorf("Illegal dir perms: %v", cfg.FilePerms) return } // Create the object syncer. if cfg.TmpObjectPrefix == "" { err = errors.New("You must set TmpObjectPrefix.") return } syncer := gcsx.NewSyncer( cfg.AppendThreshold, cfg.TmpObjectPrefix, cfg.Bucket) // Set up the basic struct. fs := &fileSystem{ mtimeClock: timeutil.RealClock(), cacheClock: cfg.CacheClock, bucket: cfg.Bucket, syncer: syncer, tempDir: cfg.TempDir, implicitDirs: cfg.ImplicitDirectories, inodeAttributeCacheTTL: cfg.InodeAttributeCacheTTL, dirTypeCacheTTL: cfg.DirTypeCacheTTL, uid: cfg.Uid, gid: cfg.Gid, fileMode: cfg.FilePerms, dirMode: cfg.DirPerms | os.ModeDir, inodes: make(map[fuseops.InodeID]inode.Inode), nextInodeID: fuseops.RootInodeID + 1, generationBackedInodes: make(map[string]inode.GenerationBackedInode), implicitDirInodes: make(map[string]inode.DirInode), handles: make(map[fuseops.HandleID]interface{}), } // Set up the root inode. root := inode.NewDirInode( fuseops.RootInodeID, "", // name fuseops.InodeAttributes{ Uid: fs.uid, Gid: fs.gid, Mode: fs.dirMode, }, fs.implicitDirs, fs.dirTypeCacheTTL, cfg.Bucket, fs.mtimeClock, fs.cacheClock) root.Lock() root.IncrementLookupCount() fs.inodes[fuseops.RootInodeID] = root fs.implicitDirInodes[root.Name()] = root root.Unlock() // Set up invariant checking. fs.mu = syncutil.NewInvariantMutex(fs.checkInvariants) // Periodically garbage collect temporary objects. var gcCtx context.Context gcCtx, fs.stopGarbageCollecting = context.WithCancel(context.Background()) go garbageCollect(gcCtx, cfg.TmpObjectPrefix, fs.bucket) server = fuseutil.NewFileSystemServer(fs) return }