code: func newStorage(root string, maxFileSize int64, indexConf jsonconfig.Obj) (s *storage, err error) {
  	fi, err := os.Stat(root)
  	if os.IsNotExist(err) {
  		return nil, fmt.Errorf("storage root %q doesn't exist", root)
  	}
  	if err != nil {
  		return nil, fmt.Errorf("Failed to stat directory %q: %v", root, err)
  	}
  	if !fi.IsDir() {
  		return nil, fmt.Errorf("storage root %q exists but is not a directory", root)
  	}
  	index, err := newIndex(root, indexConf)
  	if err != nil {
  		return nil, err
  	}
  	defer func() {
  		if err != nil {
  			index.Close()
  		}
  	}()
  	if maxFileSize <= 0 {
  		maxFileSize = defaultMaxFileSize
  	}
  	// Be consistent with trailing slashes.  Makes expvar stats for total
  	// reads/writes consistent across diskpacked targets, regardless of what
  	// people put in their low level config.
  	root = strings.TrimRight(root, `\/`)
  	s = &storage{
  		root:         root,
  		index:        index,
  		maxFileSize:  maxFileSize,
  		Generationer: local.NewGenerationer(root),
  	}
  	if err := s.openAllPacks(); err != nil {
  		s.Close()
  		return nil, err
  	}
  	s.mu.Lock()
  	defer s.mu.Unlock()
  	if _, _, err := s.StorageGeneration(); err != nil {
  		return nil, fmt.Errorf("Error initialization generation for %q: %v", root, err)
  	}
  	return s, nil
  }
docs: // newStorage returns a new storage in path root with the given maxFileSize,
  // or defaultMaxFileSize (512MB) if <= 0