code: func (fm *filesManager) openFile(file *file) error {
  	fm.Lock()
  	if fm.isClosed {
  		fm.Unlock()
  		return fmt.Errorf("unable to open file %q, store is being closed", file.name)
  	}
  	curState := atomic.LoadInt32(&file.state)
  	if curState == fileRemoved {
  		fm.Unlock()
  		return fmt.Errorf("unable to open file %q, it has been removed", file.name)
  	}
  	if curState != fileClosed || file.handle != nil {
  		fm.Unlock()
  		panic(fmt.Errorf("request to open file %q but invalid state: handle=%v - state=%v", file.name, file.handle, file.state))
  	}
  	var err error
  	if fm.limit > 0 && fm.openedFDs >= fm.limit {
  		fm.closeUnusedFiles(file.id)
  	}
  	file.handle, err = openFileWithFlags(file.name, file.flags)
  	if err == nil {
  		atomic.StoreInt32(&file.state, fileInUse)
  		fm.openedFDs++
  	}
  	fm.Unlock()
  	return err
  }
docs: // openFile opens the given file and sets its state to `fileInUse`.
  // If the file manager has been closed or the file removed, this call
  // returns an error.
  // Otherwise, if the file's state is not `fileClosed` this call will panic.
  // This call will possibly cause opened but unused files to be closed if the
  // number of open file requests is above the set limit.