code: func (f *FileStore) CreateSnapshot() (string, error) {
  	f.traceLogger.Info("Creating snapshot", zap.String("dir", f.dir))
  
  	f.mu.Lock()
  	// create a copy of the files slice and ensure they aren't closed out from
  	// under us, nor the slice mutated.
  	files := make([]TSMFile, len(f.files))
  	copy(files, f.files)
  
  	for _, tsmf := range files {
  		tsmf.Ref()
  		defer tsmf.Unref()
  	}
  
  	// increment and keep track of the current temp dir for when we drop the lock.
  	// this ensures we are the only writer to the directory.
  	f.currentTempDirID += 1
  	tmpPath := fmt.Sprintf("%d.%s", f.currentTempDirID, TmpTSMFileExtension)
  	tmpPath = filepath.Join(f.dir, tmpPath)
  	f.mu.Unlock()
  
  	// create the tmp directory and add the hard links. there is no longer any shared
  	// mutable state.
  	err := os.Mkdir(tmpPath, 0777)
  	if err != nil {
  		return "", err
  	}
  	for _, tsmf := range files {
  		newpath := filepath.Join(tmpPath, filepath.Base(tsmf.Path()))
  		if err := os.Link(tsmf.Path(), newpath); err != nil {
  			return "", fmt.Errorf("error creating tsm hard link: %q", err)
  		}
  		for _, tf := range tsmf.TombstoneFiles() {
  			newpath := filepath.Join(tmpPath, filepath.Base(tf.Path))
  			if err := os.Link(tf.Path, newpath); err != nil {
  				return "", fmt.Errorf("error creating tombstone hard link: %q", err)
  			}
  		}
  	}
  
  	return tmpPath, nil
  }
docs: // CreateSnapshot creates hardlinks for all tsm and tombstone files
  // in the path provided.